Skip to content

Commit fd55e60

Browse files
committed
feat(payment_terms): PDF and e-invoice updates
1 parent d46dc76 commit fd55e60

81 files changed

Lines changed: 206 additions & 107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/models/payment_term.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ def net_payment_term_alias
5757
end
5858
end
5959

60+
# Localized sentence for the term in the current I18n locale.
61+
def label
62+
if term_type == "day_of_month"
63+
I18n.t("invoice.payment_terms.day_of_month.#{month_offset_variant}", day: day_of_month, months: month_offset)
64+
else
65+
I18n.t("invoice.payment_terms.#{term_type}", days:)
66+
end
67+
end
68+
6069
def due_date_for(issuing_date)
6170
issuing_date = issuing_date.to_date
6271

@@ -77,6 +86,14 @@ def carries?(field)
7786
FIELDS_BY_TERM_TYPE.fetch(term_type, []).include?(field)
7887
end
7988

89+
def month_offset_variant
90+
case month_offset
91+
when 0 then "same_month"
92+
when 1 then "following_month"
93+
else "months_after"
94+
end
95+
end
96+
8097
# Only day_of_month terms carry a month_offset.
8198
# If absent - next month (1) by default.
8299
def normalized_month_offset(month_offset)

app/serializers/e_invoices/invoices/common.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def credits_and_payments(&block)
4444
end
4545

4646
def payment_terms_description
47-
"#{I18n.t("invoice.payment_term")} #{I18n.t("invoice.payment_term_days", net_payment_term: invoice.net_payment_term)}"
47+
invoice.snapshotted_payment_term.label
4848
end
4949

5050
def allowances

app/views/payment_request_mailer/requested.slim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ div style="margin-bottom: 32px;font-style: normal;font-weight: 400;font-size: 16
44
= I18n.t("email.payment_request.requested.reminder_overdue_balance", billing_entity_name: @billing_entity.name)
55
div style="margin-bottom: 32px;font-style: normal;font-weight: 400;font-size: 16px;line-height: 24px;color: #19212E;"
66
= I18n.t("email.payment_request.requested.total_amount_due", amount: MoneyHelper.format(@payment_request.amount))
7-
div style="margin-bottom: 32px;font-style: normal;font-weight: 400;font-size: 16px;line-height: 24px;color: #19212E;"
8-
= I18n.t("email.payment_request.requested.payment_terms", count: @customer.applicable_net_payment_term)
97
div style="margin-bottom: 32px;font-style: normal;font-weight: 400;font-size: 16px;line-height: 24px;color: #19212E;"
108
= I18n.t("email.payment_request.requested.already_paid")
119
div style="margin-bottom: 32px;font-style: normal;font-weight: 400;font-size: 16px;line-height: 24px;color: #19212E;"

app/views/templates/invoices/v3.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ html
357357
td.body-2 = I18n.l(issuing_date, format: :default)
358358
tr
359359
td.body-1 = I18n.t('invoice.payment_term')
360-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
360+
td.body-2 = snapshotted_payment_term.label
361361
.invoice-information-column
362362
table.invoice-information-table
363363
- if customer.metadata.displayable.any?

app/views/templates/invoices/v3/charge.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ html
351351
td.body-2 = I18n.l(issuing_date, format: :default)
352352
tr
353353
td.body-1 = I18n.t('invoice.payment_term')
354-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
354+
td.body-2 = snapshotted_payment_term.label
355355
.invoice-information-column
356356
table.invoice-information-table
357357
- if customer.metadata.displayable.any?

app/views/templates/invoices/v3/one_off.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ html
352352
td.body-2 = I18n.l(issuing_date, format: :default)
353353
tr
354354
td.body-1 = I18n.t('invoice.payment_term')
355-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
355+
td.body-2 = snapshotted_payment_term.label
356356
.invoice-information-column
357357
table.invoice-information-table
358358
- if customer.metadata.displayable.any?

app/views/templates/invoices/v4.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ html
440440
td.body-2 = I18n.l(issuing_date, format: :default)
441441
tr
442442
td.body-1 = I18n.t('invoice.payment_term')
443-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
443+
td.body-2 = snapshotted_payment_term.label
444444
.invoice-information-column
445445
table.invoice-information-table
446446
- if customer.metadata.displayable.any?

app/views/templates/invoices/v4/charge.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ html
437437
td.body-2 = I18n.l(issuing_date, format: :default)
438438
tr
439439
td.body-1 = I18n.t('invoice.payment_term')
440-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
440+
td.body-2 = snapshotted_payment_term.label
441441
.invoice-information-column
442442
table.invoice-information-table
443443
- if customer.metadata.displayable.any?

app/views/templates/invoices/v4/fixed_charge.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ html
430430
td.body-2 = I18n.l(issuing_date, format: :default)
431431
tr
432432
td.body-1 = I18n.t('invoice.payment_term')
433-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
433+
td.body-2 = snapshotted_payment_term.label
434434
.invoice-information-column
435435
table.invoice-information-table
436436
- if customer.metadata.displayable.any?

app/views/templates/invoices/v4/one_off.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ html
378378
td.body-2 = I18n.l(issuing_date, format: :default)
379379
tr
380380
td.body-1 = I18n.t('invoice.payment_term')
381-
td.body-2 = I18n.t('invoice.payment_term_days', net_payment_term:)
381+
td.body-2 = snapshotted_payment_term.label
382382
.invoice-information-column
383383
table.invoice-information-table
384384
- if customer.metadata.displayable.any?

0 commit comments

Comments
 (0)