Skip to content

Commit

Permalink
feat(PrgoressiveBilling): Update locales
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet committed Aug 26, 2024
1 parent e0b01b7 commit 44f84d0
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions app/services/invoices/progressive_billing_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def call
Credits::AppliedCouponsService.call(invoice:)
Invoices::ComputeAmountsFromFees.call(invoice:)

create_credit_note_credit
create_applied_prepaid_credit

invoice.payment_status = invoice.total_amount_cents.positive? ? :pending : :succeeded
Expand Down Expand Up @@ -121,6 +122,12 @@ def should_deliver_email?
License.premium? && subscription.organization.email_settings.include?('invoice.finalized')
end

def create_credit_note_credit
credit_result = Credits::CreditNoteService.call(invoice:).raise_if_error!

invoice.total_amount_cents -= credit_result.credits.sum(&:amount_cents) if credit_result.credits
end

def create_applied_prepaid_credit
wallet = subscription.customer.wallets.active.first
return unless wallet&.active?
Expand Down
2 changes: 1 addition & 1 deletion app/views/templates/invoices/v4.slim
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ html
- if progressive_billing?
p.body-3.mb-24
- applied_usage_threshold = applied_usage_thresholds.order(created_at: :asc).last
= I18n.t('invoice.reached_usage_threshold', usage_amount: MoneyHelper. applied_usage_threshold.lifetime_usage_amount, threshold_amount: MoneyHelper.format(applied_usage_threshold.threshold.amount_cents)
= I18n.t('invoice.reached_usage_threshold', usage_amount: MoneyHelper. applied_usage_threshold.lifetime_usage_amount, threshold_amount: MoneyHelper.format(applied_usage_threshold.threshold.amount_cents))

p.body-3.mb-24 = LineBreakHelper.break_lines(organization.invoice_footer)

Expand Down
1 change: 1 addition & 0 deletions config/locales/de/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ de:
progressive_billing_credit: Nutzung bereits abgerechnet
quarter: quartal
quarterly: Vierteljährlich
reached_usage_threshold: Diese progressive Rechnung wird erstellt, da Ihre kumulierte Nutzung %{usage_amount} erreicht hat und den Schwellenwert von %{threshold_amount} überschritten hat.
see_breakdown: Siehe Aufschlüsselung für Gesamtübersicht
sub_total: Zwischensumme
sub_total_with_tax: Zwischensumme (inkl. Steuern)
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ en:
progressive_billing_credit: Usage already billed
quarter: quarter
quarterly: Quarterly
reached_usage_threshold: This progressive billing invoice is generated because your lifetime usage has reached %{usage_amount}, exceeding the ${threshold_amount} threshold.
reached_usage_threshold: This progressive billing is generated because your cumulative usage has reached %{usage_amount}, exceeding the %{threshold_amount} threshold.
see_breakdown: See breakdown for total unit
sub_total: Subtotal
sub_total_with_tax: Subtotal (incl. tax)
Expand Down
1 change: 1 addition & 0 deletions config/locales/es/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ es:
progressive_billing_credit: Uso ya facturado
quarter: trimestre
quarterly: Trimestral
reached_usage_threshold: Esta facturación progresiva se genera porque su uso acumulado ha alcanzado los %{usage_amount}, superando el umbral de %{threshold_amount}.
see_breakdown: Consulte el desglose a continuación
sub_total: Subtotal
sub_total_with_tax: Subtotal (impuestos incl.)
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fr:
progressive_billing_credit: Usage déjà facturé
quarter: trimestre
quarterly: trimestriellement
reached_usage_threshold: Cette facturation progressive est générée car votre usage cumulé a atteint %{usage_amount}, dépassant le seuil de %{threshold_amount}.
see_breakdown: Consultez le détail ci-après
sub_total: Sous total
sub_total_with_tax: Sous total (TTC)
Expand Down
3 changes: 2 additions & 1 deletion config/locales/it/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ it:
prepaid_credit_invoice: Fattura anticipata
prepaid_credits: Crediti prepagati
prepaid_credits_with_value: Crediti prepagati - %{wallet_name}
progressive_billing_credit: Utilizzo già fatturato
progressive_billing_credit: Uso già fatturato
quarter: trimestre
quarterly: Trimestrale
reached_usage_threshold: Questa fatturazione progressiva è generata poiché il tuo utilizzo cumulato ha raggiunto %{usage_amount}, superando la soglia di %{threshold_amount}.
see_breakdown: Vedere la ripartizione per l'unità totale
sub_total: Subtotale
sub_total_with_tax: Subtotale (incl. tasse)
Expand Down
1 change: 1 addition & 0 deletions config/locales/nb/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ nb:
progressive_billing_credit: Bruk allerede fakturert
quarter: kvartal
quarterly: Kvartalsvis
reached_usage_threshold: Denne progressive faktureringen er generert fordi din akkumulerte bruk har nådd %{usage_amount}, og overskredet terskelen på %{threshold_amount}.
see_breakdown: Se oversikt for antall enheter
sub_total: Sub total
sub_total_with_tax: Sub total (inkl. MVA)
Expand Down
3 changes: 2 additions & 1 deletion config/locales/sv/invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ sv:
prepaid_credit_invoice: Förskottsfaktura
prepaid_credits: Förbetald kontobalans
prepaid_credits_with_value: Förbetald kontobalans - %{wallet_name}
progressive_billing_credit: Användning redan fakturerad
progressive_billing_credit: Redan fakturerad användning
quarter: kvartal
quarterly: Kvartalsvis
reached_usage_threshold: Denna progressiva fakturering skapas eftersom din ackumulerade användning har nått %{usage_amount} och överstiger %{threshold_amount} tröskeln.
see_breakdown: Se uppdelning nedan
sub_total: Delsumma
sub_total_with_tax: Delsumma (inkl. moms)
Expand Down

0 comments on commit 44f84d0

Please sign in to comment.