diff --git a/modules/account_payment_sepa/template/pain.001.001.03.xml b/modules/account_payment_sepa/template/pain.001.001.03.xml index ef689518b0..52c8213550 100644 --- a/modules/account_payment_sepa/template/pain.001.001.03.xml +++ b/modules/account_payment_sepa/template/pain.001.001.03.xml @@ -32,7 +32,7 @@ this repository contains the full copyright notices and license terms. --> ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} @@ -45,7 +45,7 @@ this repository contains the full copyright notices and license terms. --> TRF ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} @@ -77,7 +77,7 @@ this repository contains the full copyright notices and license terms. --> - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa/template/pain.001.001.05.xml b/modules/account_payment_sepa/template/pain.001.001.05.xml index cd029cba1b..bfe1893941 100644 --- a/modules/account_payment_sepa/template/pain.001.001.05.xml +++ b/modules/account_payment_sepa/template/pain.001.001.05.xml @@ -13,7 +13,7 @@ this repository contains the full copyright notices and license terms. --> ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} @@ -26,7 +26,7 @@ this repository contains the full copyright notices and license terms. --> TRF ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} @@ -59,7 +59,7 @@ this repository contains the full copyright notices and license terms. --> - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa/template/pain.001.003.03.xml b/modules/account_payment_sepa/template/pain.001.003.03.xml index aac2eac7a5..04e9adced7 100644 --- a/modules/account_payment_sepa/template/pain.001.003.03.xml +++ b/modules/account_payment_sepa/template/pain.001.003.03.xml @@ -15,7 +15,7 @@ this repository contains the full copyright notices and license terms. --> ${group.sepa_message_id[:35]} ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} ${PartyIdentification(group.sepa_initiating_party, id=group.journal.sepa_payable_initiator_id, with_address=False)} @@ -25,7 +25,7 @@ this repository contains the full copyright notices and license terms. --> TRF ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} @@ -52,7 +52,7 @@ this repository contains the full copyright notices and license terms. --> - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa/template/pain.008.001.02.xml b/modules/account_payment_sepa/template/pain.008.001.02.xml index 2dd3195542..4b9a43c1ac 100644 --- a/modules/account_payment_sepa/template/pain.008.001.02.xml +++ b/modules/account_payment_sepa/template/pain.008.001.02.xml @@ -32,7 +32,7 @@ this repository contains the full copyright notices and license terms. --> ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} @@ -45,7 +45,7 @@ this repository contains the full copyright notices and license terms. --> DD ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} @@ -83,7 +83,7 @@ this repository contains the full copyright notices and license terms. --> ${payment.sepa_end_to_end_id} - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa/template/pain.008.001.04.xml b/modules/account_payment_sepa/template/pain.008.001.04.xml index f43a861e84..a597142303 100644 --- a/modules/account_payment_sepa/template/pain.008.001.04.xml +++ b/modules/account_payment_sepa/template/pain.008.001.04.xml @@ -13,7 +13,7 @@ this repository contains the full copyright notices and license terms. --> ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${len(group.payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} @@ -26,7 +26,7 @@ this repository contains the full copyright notices and license terms. --> DD ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} @@ -64,7 +64,7 @@ this repository contains the full copyright notices and license terms. --> ${payment.sepa_end_to_end_id} - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa/template/pain.008.003.02.xml b/modules/account_payment_sepa/template/pain.008.003.02.xml index ff22e76336..a167344082 100644 --- a/modules/account_payment_sepa/template/pain.008.003.02.xml +++ b/modules/account_payment_sepa/template/pain.008.003.02.xml @@ -15,7 +15,7 @@ this repository contains the full copyright notices and license terms. --> ${group.sepa_message_id[:35]} ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} ${PartyIdentification(group.sepa_initiating_party, id=group.journal.sepa_receivable_initiator_id, with_address=False)} @@ -25,7 +25,7 @@ this repository contains the full copyright notices and license terms. --> DD ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} SEPA @@ -56,7 +56,7 @@ this repository contains the full copyright notices and license terms. --> ${payment.sepa_instruction_id} ${payment.sepa_end_to_end_id} - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa_cfonb/template/pain.001.001.03-cfonb.xml b/modules/account_payment_sepa_cfonb/template/pain.001.001.03-cfonb.xml index 38c1f490ad..cf9b578bd1 100644 --- a/modules/account_payment_sepa_cfonb/template/pain.001.001.03-cfonb.xml +++ b/modules/account_payment_sepa_cfonb/template/pain.001.001.03-cfonb.xml @@ -26,7 +26,7 @@ this repository contains the full copyright notices and license terms. --> ${group.sepa_message_id[:35]} ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} ${PartyIdentification(group.sepa_initiating_party)} @@ -36,7 +36,7 @@ this repository contains the full copyright notices and license terms. --> TRF ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} @@ -62,7 +62,7 @@ this repository contains the full copyright notices and license terms. --> ${payment.sepa_end_to_end_id} - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} diff --git a/modules/account_payment_sepa_cfonb/template/pain.008.001.02-cfonb.xml b/modules/account_payment_sepa_cfonb/template/pain.008.001.02-cfonb.xml index b06be38d84..7bda4d37a5 100644 --- a/modules/account_payment_sepa_cfonb/template/pain.008.001.02-cfonb.xml +++ b/modules/account_payment_sepa_cfonb/template/pain.008.001.02-cfonb.xml @@ -32,7 +32,7 @@ this repository contains the full copyright notices and license terms. --> ${group.sepa_message_id[:35]} ${datetime.datetime.now().replace(microsecond=0).isoformat()} ${sum(len(payments) for _, payments in group.sepa_payments)} - ${sum(p.amount for p in group.payments)} + ${format(sum(p.amount for p in group.payments).normalize(), 'f')} ${PartyIdentification(group.sepa_initiating_party)} @@ -42,7 +42,7 @@ this repository contains the full copyright notices and license terms. --> DD ${'true' if group.journal.sepa_batch_booking else 'false'} ${len(payments)} - ${sum(p.amount for p in payments)} + ${format(sum(p.amount for p in payments).normalize(), 'f')} SEPA @@ -73,7 +73,7 @@ this repository contains the full copyright notices and license terms. --> ${payment.sepa_instruction_id} ${payment.sepa_end_to_end_id} - ${payment.amount} + ${format(payment.amount.normalize(), 'f')} ${mandate.identification} diff --git a/modules/edocument_ubl/edocument.py b/modules/edocument_ubl/edocument.py index d7cd90d923..ddd3f190a9 100644 --- a/modules/edocument_ubl/edocument.py +++ b/modules/edocument_ubl/edocument.py @@ -279,7 +279,7 @@ class Invoice(Model): elif self.invoice.currency == self.invoice.company.currency: return line.debit - line.credit else: - return 0 + return Decimal(0) return sum(map(balance, self.invoice.lines_to_pay)) @classmethod diff --git a/modules/edocument_ubl/template/2/CreditNote.xml b/modules/edocument_ubl/template/2/CreditNote.xml index 2179db01a9..f9fdd61bee 100644 --- a/modules/edocument_ubl/template/2/CreditNote.xml +++ b/modules/edocument_ubl/template/2/CreditNote.xml @@ -90,7 +90,7 @@ this repository contains the full copyright notices and license terms. --> ${this.invoice.payment_term.description} - ${line.amount} + ${format(line.amount.normalize(), 'f')} ${line.maturity_date} @@ -101,16 +101,16 @@ this repository contains the full copyright notices and license terms. --> ${reason_code} ${allowance_charge.product.name} - ${abs(allowance_charge.amount)} + ${format(abs(allowance_charge.amount).normalize(), 'f')} ${TaxCategory(tax_line.tax)} - ${-amount} + ${format((-amount).normalize(), 'f')} - ${-line.base} - ${-line.amount} + ${format((-line.base).normalize(), 'f')} + ${format((-line.amount).normalize(), 'f')} ${format((line.tax.rate * 100).normalize(), 'f')} ${TaxCategory(line.tax)} @@ -118,19 +118,19 @@ this repository contains the full copyright notices and license terms. --> - ${-this.invoice.untaxed_amount} - ${-this.invoice.untaxed_amount} - ${-(this.invoice.untaxed_amount + this.invoice.tax_amount)} + ${format((-this.invoice.untaxed_amount).normalize(), 'f')} + ${format((-this.invoice.untaxed_amount).normalize(), 'f')} + ${format((-(this.invoice.untaxed_amount + this.invoice.tax_amount)).normalize(), 'f')} - ${-(this.invoice.total_amount - this.invoice.untaxed_amount - this.invoice.tax_amount)} + ${format((-(this.invoice.total_amount - this.invoice.untaxed_amount - this.invoice.tax_amount)).normalize(), 'f')} - ${-this.prepaid_amount} - ${-this.invoice.total_amount + this.prepaid_amount} + ${format((-this.prepaid_amount).normalize(), 'f')} + ${format((-this.invoice.total_amount + this.prepaid_amount).normalize(), 'f')} ${line_id} ${format(-Decimal(str(line.quantity)), 'f')} - ${-line.amount} + ${format((-line.amount).normalize(), 'f')} ${line.description} ${line.product.name if line.product else line.summary} @@ -152,7 +152,7 @@ this repository contains the full copyright notices and license terms. --> - ${line.unit_price} + ${format(line.unit_price.normalize(), 'f')} diff --git a/modules/edocument_ubl/template/2/Invoice.xml b/modules/edocument_ubl/template/2/Invoice.xml index 56de7a1431..a66d06cc3f 100644 --- a/modules/edocument_ubl/template/2/Invoice.xml +++ b/modules/edocument_ubl/template/2/Invoice.xml @@ -90,7 +90,7 @@ this repository contains the full copyright notices and license terms. --> ${this.invoice.payment_term.description} - ${line.amount} + ${format(line.amount.normalize(), 'f')} ${line.maturity_date} @@ -101,16 +101,16 @@ this repository contains the full copyright notices and license terms. --> ${reason_code} ${allowance_charge.product.name} - ${abs(allowance_charge.amount)} + ${format(abs(allowance_charge.amount).normalize(), 'f')} ${TaxCategory(tax_line.tax)} - ${amount} + ${format(amount.normalize(), 'f')} - ${line.base} - ${line.amount} + ${format(line.base.normalize(), 'f')} + ${format(line.amount.normalize(), 'f')} ${format((line.tax.rate * 100).normalize(), 'f')} ${TaxCategory(line.tax)} @@ -118,19 +118,19 @@ this repository contains the full copyright notices and license terms. --> - ${this.invoice.untaxed_amount} - ${this.invoice.untaxed_amount} - ${this.invoice.untaxed_amount + this.invoice.tax_amount} + ${format(this.invoice.untaxed_amount.normalize(), 'f')} + ${format(this.invoice.untaxed_amount.normalize(), 'f')} + ${format((this.invoice.untaxed_amount + this.invoice.tax_amount).normalize(), 'f')} - ${this.invoice.total_amount - this.invoice.untaxed_amount - this.invoice.tax_amount} + ${format((this.invoice.total_amount - this.invoice.untaxed_amount - this.invoice.tax_amount).normalize(), 'f')} - ${this.prepaid_amount} - ${this.invoice.total_amount - this.prepaid_amount} + ${format(this.prepaid_amount.normalize(), 'f')} + ${format((this.invoice.total_amount - this.prepaid_amount).normalize(), 'f')} ${line_id} ${format(Decimal(str(line.quantity)), 'f')} - ${line.amount} + ${format(line.amount.normalize(), 'f')} ${line.description} ${line.product.name if line.product else line.summary} @@ -152,7 +152,7 @@ this repository contains the full copyright notices and license terms. --> - ${line.unit_price} + ${format(line.unit_price.normalize(), 'f')} diff --git a/modules/edocument_uncefact/template/16B-CII/CrossIndustryInvoice.xml b/modules/edocument_uncefact/template/16B-CII/CrossIndustryInvoice.xml index 25ba81b3f5..a4aa3d5567 100644 --- a/modules/edocument_uncefact/template/16B-CII/CrossIndustryInvoice.xml +++ b/modules/edocument_uncefact/template/16B-CII/CrossIndustryInvoice.xml @@ -43,11 +43,11 @@ this repository contains the full copyright notices and license terms. --> - ${amount * this.type_sign} + ${format((amount * this.type_sign).normalize(), 'f')} ${tax.unece_code} ${tax.vatex_code} ${tax.legal_notice} - ${base * this.type_sign} + ${format((base * this.type_sign).normalize(), 'f')} ${tax.unece_category_code} ${format((tax.rate * 100).normalize(), 'f')} @@ -73,7 +73,7 @@ this repository contains the full copyright notices and license terms. --> - ${this.invoice.currency.round(line.unit_price)} + ${format(this.invoice.currency.round(line.unit_price).normalize(), 'f')} @@ -84,7 +84,7 @@ this repository contains the full copyright notices and license terms. --> ${TradeTax(tax.tax)} - ${line.amount} + ${format(line.amount.normalize(), 'f')} @@ -157,14 +157,14 @@ this repository contains the full copyright notices and license terms. --> ${DateTime(line.maturity_date)} - ${(line.amount_second_currency or (line.debit - line.credit)) * this.type_sign} + ${format(((line.amount_second_currency or (line.debit - line.credit)) * this.type_sign).normalize(), 'f')} - ${this.invoice.untaxed_amount * this.type_sign} - ${this.invoice.untaxed_amount * this.type_sign} - ${this.invoice.tax_amount * this.type_sign} - ${this.invoice.total_amount * this.type_sign} - ${this.invoice.amount_to_pay * this.type_sign} + ${format((this.invoice.untaxed_amount * this.type_sign).normalize(), 'f')} + ${format((this.invoice.untaxed_amount * this.type_sign).normalize(), 'f')} + ${format((this.invoice.tax_amount * this.type_sign).normalize(), 'f')} + ${format((this.invoice.total_amount * this.type_sign).normalize(), 'f')} + ${format((this.invoice.amount_to_pay * this.type_sign).normalize(), 'f')}