Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove zero units fees from PDF template #1664

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/fee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Fee < ApplicationRecord
scope :subscription_kind, -> { where(fee_type: :subscription) }
scope :charge_kind, -> { where(fee_type: :charge) }

scope :positive_units, -> { where('units > ?', 0) }

# NOTE: pay_in_advance fees are not be linked to any invoice, but add_on fees does not have any subscriptions
# so we need a bit of logic to find the fee in the right organization scope
scope :from_organization,
Expand Down
6 changes: 3 additions & 3 deletions app/views/templates/invoices/v4/_subscription_details.slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/ Charges payed in advance on payed in advance plan
- if subscription.plan.charges.where(pay_in_advance: true).any? && subscription.plan.pay_in_advance?
/ Loop over all top level fees
- subscription_fees(subscription.id).charge_kind.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees|
- subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees|
- fee = fees.first
- next unless fee.charge.pay_in_advance?

Expand Down Expand Up @@ -58,7 +58,7 @@
td.body-2 = I18n.t('invoice.amount')

/ Loop over all top level fees
- subscription_fees(subscription.id).charge_kind.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees|
- subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees|
- fee = fees.first
- next if fee.charge.pay_in_advance?

Expand Down Expand Up @@ -91,7 +91,7 @@
td.body-2 = I18n.t('invoice.amount')

/ Loop over all top level fees
- subscription_fees(subscription.id).charge_kind.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees|
- subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees|
- fee = fees.first
- next unless fee.charge.pay_in_advance?

Expand Down
Loading