Skip to content

Commit

Permalink
feat(manual-payments): Add total paid and total due to pdf templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ivannovosad committed Jan 9, 2025
1 parent e82f8d3 commit 52a1a24
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 6 deletions.
6 changes: 6 additions & 0 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ class Invoice < ApplicationRecord
:sub_total_excluding_taxes_amount_cents,
:sub_total_including_taxes_amount_cents,
:total_amount_cents,
:total_paid_amount_cents,
:taxes_amount_cents,
with_model_currency: :currency

# NOTE: Readonly fields
monetize :charge_amount_cents,
:subscription_amount_cents,
:total_due_amount_cents,
disable_validation: true,
allow_nil: true,
with_model_currency: :currency
Expand Down Expand Up @@ -254,6 +256,10 @@ def charge_pay_in_advance_proration_range(fee, timestamp)
}
end

def total_due_amount_cents
total_amount_cents - total_paid_amount_cents
end

# amount cents onto which we can issue a credit note
def available_to_credit_amount_cents
return 0 if version_number < CREDIT_NOTES_MIN_VERSION || draft?
Expand Down
12 changes: 11 additions & 1 deletion app/views/templates/invoices/v3/_subscription_details.slim
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@
td.body-2 = '-' + MoneyHelper.format(prepaid_credit_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due')
td.body-1 = I18n.t('invoice.total')
td.body-1
= MoneyHelper.format(total_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_paid_amount')
td.body-1
= MoneyHelper.format(total_paid_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due_amount')
td.body-1
= MoneyHelper.format(total_due_amount)
- else
tr
td.body-2
Expand Down
10 changes: 9 additions & 1 deletion app/views/templates/invoices/v3/_subscriptions_summary.slim
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,13 @@ table.total-table width="100%"
td.body-2 = '-' + MoneyHelper.format(prepaid_credit_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due')
td.body-1 = I18n.t('invoice.total')
td.body-1 = MoneyHelper.format(total_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_paid_amount')
td.body-1 = MoneyHelper.format(total_paid_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due_amount')
td.body-1 = MoneyHelper.format(total_due_amount)
12 changes: 11 additions & 1 deletion app/views/templates/invoices/v4/_subscription_details.slim
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,19 @@
td.body-2 = '-' + MoneyHelper.format(prepaid_credit_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due')
td.body-1 = I18n.t('invoice.total')
td.body-1
= MoneyHelper.format(total_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_paid_amount')
td.body-1
= MoneyHelper.format(total_paid_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due_amount')
td.body-1
= MoneyHelper.format(total_due_amount)
- else
- if progressive_billing_credit_amount_cents.positive?
- credits = progressice_billing_credits(invoice_subscription.subscription).all
Expand Down
10 changes: 9 additions & 1 deletion app/views/templates/invoices/v4/_subscriptions_summary.slim
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,13 @@ table.total-table width="100%"
td.body-2 = '-' + MoneyHelper.format(prepaid_credit_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due')
td.body-1 = I18n.t('invoice.total')
td.body-1 = MoneyHelper.format(total_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_paid_amount')
td.body-1 = MoneyHelper.format(total_paid_amount)
tr
td.body-2
td.body-1 = I18n.t('invoice.total_due_amount')
td.body-1 = MoneyHelper.format(total_due_amount)
2 changes: 2 additions & 0 deletions config/locales/de/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ de:
total_credits: Gesamtguthaben
total_credits_with_value: 'Gesamtguthaben: %{credit_amount} Credits'
total_due: Insgesamt fällig
total_due_amount: Betrag fällig
total_events: 'Ereignisse insgesamt: %{count}'
total_paid_amount: Betrag bezahlt
total_unit: 'Gesamte Einheiten: %{units}'
total_unit_interval: 'Gesamte Einheiten: %{events_count} Ereignisse für %{units}'
true_up_details: Mindestausgabe von %{min_amount} anteilig an den Nutzungstagen
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ en:
total_credits: Total credits
total_credits_with_value: 'Total credits: %{credit_amount} credits'
total_due: Total due
total_due_amount: Amount due
total_events: 'Total events: %{count}'
total_paid_amount: Amount paid
total_unit: 'Total unit: %{units}'
total_unit_interval: 'Total unit: %{events_count} events for %{units}'
true_up_details: Minimum spend of %{min_amount} prorated on days of usage
Expand Down
4 changes: 3 additions & 1 deletion config/locales/es/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ es:
total: Total
total_credits_with_value: 'Total de créditos con valor: %{credit_amount} créditos'
total_due: Total debido
total_event: Eventos totales
total_due_amount: Monto debido
total_events: 'Eventos totales: %{count}'
total_paid_amount: Monto pagado
total_unit: 'Total de unidades: %{units}'
total_unit_interval: 'Total de unidades: %{events_count} evento(s) para %{units}'
true_up_details: Gasto mínimo de %{min_amount} prorrateado en días de uso
Expand Down
2 changes: 2 additions & 0 deletions config/locales/fr/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ fr:
total_credits: Total crédits
total_credits_with_value: 'Nombre total de crédits: %{credit_amount} crédits'
total_due: Total dû
total_due_amount: Montant dû
total_events: 'Nombre total d''événements: %{count}'
total_paid_amount: Montant payé
total_unit: 'Nombre total d''unités: %{units}'
total_unit_interval: 'Nombre total d''unités: %{events_count} événement(s) pour %{units}'
true_up_details: Dépense minimale de %{min_amount} au prorata des jours d'utilisation
Expand Down
2 changes: 2 additions & 0 deletions config/locales/it/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ it:
total_credits: Crediti totali
total_credits_with_value: 'Crediti totali: %{credit_amount} crediti'
total_due: Totale dovuto
total_due_amount: Importo dovuto
total_events: 'Eventi totali: %{count}'
total_paid_amount: Importo pagato
total_unit: 'Unità totale: %{units}'
total_unit_interval: 'Unità totale: %{events_count} eventi per %{units}'
true_up_details: Spesa minima di %{min_amount} proporzionata sui giorni di utilizzo
Expand Down
2 changes: 2 additions & 0 deletions config/locales/nb/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ nb:
total_credits: Antall kreditter
total_credits_with_value: 'Antall kreditter: %{credit_amount} kreditter'
total_due: Å betale
total_due_amount: Skyldig beløp
total_events: 'Totalt antall hendelser: %{count}'
total_paid_amount: Betalt beløp
total_unit: 'Antall enheter: %{units}'
total_unit_interval: 'Antall enheter: %{events_count} hendelser for %{units}'
true_up_details: Minimumsutgift på %{min_amount} beregnet etter antall brukte dager
Expand Down
4 changes: 3 additions & 1 deletion config/locales/sv/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ sv:
total: Total
total_credits_with_value: 'Totalt antal krediter med värde: %{credit_amount} krediter'
total_due: Att betala
total_event: Totala händelser
total_due_amount: Att betala belopp
total_events: 'Totala händelser: %{count}'
total_paid_amount: Betalt belopp
total_unit: 'Totalt antal enheter: %{units}'
total_unit_interval: 'Totalt antal enheter: %{events_count} händelse(r) för %{units}'
true_up_details: Minsta utgift på %{min_amount} fördelat på användningsdagar
Expand Down

0 comments on commit 52a1a24

Please sign in to comment.