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

feat(ProgressiveBilling): Add invocing reason on the progressive billing invoice template #2472

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
feat(PrgoressiveBilling): Update locales
  • Loading branch information
vincent-pochet committed Aug 26, 2024
commit 44f84d053d27197c317bdf7175eae9559b8e7892
7 changes: 7 additions & 0 deletions app/services/invoices/progressive_billing_service.rb
Original file line number Diff line number Diff line change
@@ -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
@@ -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?
2 changes: 1 addition & 1 deletion app/views/templates/invoices/v4.slim
Original file line number Diff line number Diff line change
@@ -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)

1 change: 1 addition & 0 deletions config/locales/de/invoice.yml
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion config/locales/en/invoice.yml
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions config/locales/es/invoice.yml
Original file line number Diff line number Diff line change
@@ -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.)
1 change: 1 addition & 0 deletions config/locales/fr/invoice.yml
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion config/locales/it/invoice.yml
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions config/locales/nb/invoice.yml
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion config/locales/sv/invoice.yml
Original file line number Diff line number Diff line change
@@ -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)