From 98cce5003f4bcc32cbdd792631c4de432dd4029c Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 13 Feb 2024 18:18:48 +0100 Subject: [PATCH 1/2] FIX l10n_it_reverse_charge in multi currency: use the supplier invoice date Steps: - Configure reverse charge - Configure 2 different rate for USD: for 19/12/2023 and for 31/01/2024 - Create a USD supplier invoice with invoice date 19/12/2023 and accounting date 31/01/2024 - Validate Observed: the currency rate of self invoice is 31/01/2024 Desired: the currency rate of self invoice is 19/12/2023 --- l10n_it_reverse_charge/models/account_move.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/l10n_it_reverse_charge/models/account_move.py b/l10n_it_reverse_charge/models/account_move.py index b5208036d78d..3eb7d884f729 100644 --- a/l10n_it_reverse_charge/models/account_move.py +++ b/l10n_it_reverse_charge/models/account_move.py @@ -36,6 +36,14 @@ def _compute_rc_flag(self): line.rc = is_rc rc = fields.Boolean("RC", compute="_compute_rc_flag", store=True, readonly=False) + rc_source_line_id = fields.Many2one("account.move.line", readonly=True) + + def _compute_currency_rate(self): + res = super()._compute_currency_rate() + for line in self: + if line.currency_id and line.rc_source_line_id: + line.currency_rate = line.rc_source_line_id.currency_rate + return res class AccountMove(models.Model): @@ -81,6 +89,7 @@ def rc_inv_line_vals(self, line): "price_unit": line.price_unit, "quantity": line.quantity, "discount": line.discount, + "rc_source_line_id": line.id, } def rc_inv_vals(self, partner, rc_type, lines, currency): @@ -462,6 +471,7 @@ def generate_supplier_self_invoice(self): invoice_line_vals = [] for inv_line in self.invoice_line_ids: line_vals = inv_line.copy_data()[0] + line_vals["rc_source_line_id"] = inv_line.id line_vals["move_id"] = supplier_invoice.id line_tax_ids = inv_line.tax_ids mapped_taxes = rc_type.map_tax( From 758728dc9836197832749123a14c8127d4f71f11 Mon Sep 17 00:00:00 2001 From: eLBati Date: Wed, 31 Jan 2024 16:59:37 +0100 Subject: [PATCH 2/2] FIX l10n_it_fatturapa_out and l10n_it_fatturapa_out_rc avoiding to convert to EUR tax_base_amount as it is already in company currency (currency_field='company_currency_id') Note: tests are not using tax_base_amount to compute ImponibileImporto (they use line.price_subtotal) because it is empty, while it sould not Steps: - Configure reverse charge for extra UE suppliers - Create an USD invoice, with 1 line, with fiscal position for extra UE suppliers - Confirm - Generate XML from self invocie Observed: "Totale imponibile" is different from "Prezzo unitario" FIX l10n_it_fatturapa_out_rc in multi currency: use the supplier invoice date REF fpa_to_eur using move line currency_rate when available --- .../data/invoice_it_template.xml | 29 +++---------------- l10n_it_fatturapa_out/wizard/efattura.py | 20 ++++++++----- .../wizard/wizard_export_fatturapa.py | 23 +++++++++++---- .../data/invoice_it_template.xml | 2 +- .../views/invoice_it_template.xml | 4 +-- 5 files changed, 36 insertions(+), 42 deletions(-) diff --git a/l10n_it_fatturapa_out/data/invoice_it_template.xml b/l10n_it_fatturapa_out/data/invoice_it_template.xml index 1ef2d45bee6d..dd3e7f0a8849 100644 --- a/l10n_it_fatturapa_out/data/invoice_it_template.xml +++ b/l10n_it_fatturapa_out/data/invoice_it_template.xml @@ -170,7 +170,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati) t-call="l10n_it_fatturapa_out.account_invoice_line_it_sconto_maggiorazione" /> -