Skip to content

Commit

Permalink
Add more translation variables
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Aug 20, 2024
1 parent 19b6f24 commit 0f69868
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/bill/operations/delete_credit_note.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Bill::DeleteCreditNote # CreditNote::DeleteOperation
status.add_error Rex.t(
:"operation.error.credit_note_finalized",
id: credit_note.id,
reference: credit_note.reference,
status: credit_note.status.to_s
)
end
Expand Down
1 change: 1 addition & 0 deletions src/bill/operations/delete_transaction.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Bill::DeleteTransaction # Transaction::DeleteOperation
status.add_error Rex.t(
:"operation.error.transaction_finalized",
id: transaction.id,
reference: transaction.reference,
status: transaction.status.to_s
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Bill::CreateFinalizedCreditNoteTransaction

description = credit_note.description || Rex.t(
:"operation.misc.credit_note_description",
credit_note_id: credit_note.id,
reference: credit_note.reference
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Bill::CreateFinalizedInvoiceTransaction

description = invoice.description || Rex.t(
:"operation.misc.invoice_description",
invoice_id: invoice.id,
reference: invoice.reference
)

Expand Down
6 changes: 5 additions & 1 deletion src/bill/operations/mixins/validate_credit_note_item.cr
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ module Bill::ValidateCreditNoteItem
id.add_error Rex.t(
:"operation.error.credit_exceeds_invoice",
amount: current_item_amount,
amount_fmt: FractionalMoney.new(current_item_amount).to_s,
amount_mu: FractionalMoney.new(current_item_amount).amount_mu,
balance: balance,
balance_mu: FractionalMoney.new(balance).amount_mu
balance_fmt: FractionalMoney.new(balance).to_s,
balance_mu: FractionalMoney.new(balance).amount_mu,
currency_code: Bill.settings.currency.code,
currency_sign: Bill.settings.currency.sign
)
end
end
Expand Down
6 changes: 5 additions & 1 deletion src/bill/operations/mixins/validate_receipt.cr
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ module Bill::ValidateReceipt

amount.add_error Rex.t(
:"operation.error.amount_lte_zero",
amount: value
amount: value,
amount_fmt: FractionalMoney.new(value).to_s,
amount_mu: FractionalMoney.new(value).amount_mu,
currency_code: Bill.settings.currency.code,
currency_sign: Bill.settings.currency.sign
)
end
end
Expand Down
10 changes: 9 additions & 1 deletion src/bill/operations/mixins/validate_transaction.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ module Bill::ValidateTransaction
private def validate_amount_not_zero
amount.value.try do |value|
return unless value.zero?
amount.add_error Rex.t(:"operation.error.amount_zero", amount: value)

amount.add_error Rex.t(
:"operation.error.amount_zero",
amount: value,
amount_fmt: FractionalMoney.new(value).to_s,
amount_mu: FractionalMoney.new(value).amount_mu,
currency_code: Bill.settings.currency.code,
currency_sign: Bill.settings.currency.sign
)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions src/bill/operations/refund_payment.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ module Bill::RefundPayment # Transaction::SaveOperation
amount.add_error Rex.t(
:"operation.error.refund_exceeds_receipt",
amount: value,
amount_fmt: FractionalMoney.new(value).to_s,
amount_mu: FractionalMoney.new(value).amount_mu,
currency_code: Bill.settings.currency.code,
currency_sign: Bill.settings.currency.sign,
receipt_amount: receipt.amount,
receipt_amount_fmt: receipt.amount_fm.to_s,
receipt_amount_mu: receipt.amount_fm.amount_mu
)
end
Expand Down
1 change: 1 addition & 0 deletions src/bill/operations/update_credit_note.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Bill::UpdateCreditNote # CreditNote::SaveOperation
status.add_error Rex.t(
:"operation.error.credit_note_finalized",
id: credit_note.id,
reference: credit_note.reference,
status: credit_note.status.to_s
)
end
Expand Down
1 change: 1 addition & 0 deletions src/bill/operations/update_invoice.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Bill::UpdateInvoice # Invoice::SaveOperation
status.add_error Rex.t(
:"operation.error.invoice_finalized",
id: invoice.id,
reference: invoice.reference,
status: invoice.status.to_s
)
end
Expand Down
1 change: 1 addition & 0 deletions src/bill/operations/update_receipt.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Bill::UpdateReceipt # Receipt::SaveOperation
status.add_error Rex.t(
:"operation.error.receipt_finalized",
id: receipt.id,
reference: receipt.reference,
status: receipt.status.to_s
)
end
Expand Down
1 change: 1 addition & 0 deletions src/bill/operations/update_transaction.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Bill::UpdateTransaction # Transaction::SaveOperation
status.add_error Rex.t(
:"operation.error.transaction_finalized",
id: transaction.id,
reference: transaction.reference,
status: transaction.status.to_s
)
end
Expand Down

0 comments on commit 0f69868

Please sign in to comment.