From cb2a111a6d2b8488d454bfc5276d4ac7dcebb7e3 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Tue, 9 Feb 2021 15:55:15 +0100 Subject: [PATCH] [FIX] l10n_it_fatturapa_in: fattura con arrotondamento importata con dettaglio minimo Risolve #2093. Quando viene importata con dettaglio minimo la fattura non ha righe, la max() fallisce su recordset vuoto. --- .../tests/data/IT05979361218_016.xml | 94 +++++++++++++++++++ .../tests/test_import_fatturapa_xml.py | 9 ++ .../wizard/wizard_import_fatturapa.py | 3 +- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 l10n_it_fatturapa_in/tests/data/IT05979361218_016.xml diff --git a/l10n_it_fatturapa_in/tests/data/IT05979361218_016.xml b/l10n_it_fatturapa_in/tests/data/IT05979361218_016.xml new file mode 100644 index 000000000000..2d290043be62 --- /dev/null +++ b/l10n_it_fatturapa_in/tests/data/IT05979361218_016.xml @@ -0,0 +1,94 @@ + + + + + + IT + 05979361218 + + 006 + FPA12 + UFPQ1O + + + + + IT + 05979361218 + + + SOCIETA' ALPHA BETA SRL + + RF02 + + + VIALE ROMA 543B + 07100 + SASSARI + SS + IT + + + + + 80213330584 + + AMMINISTRAZIONE BETA + + + + VIA TORINO 38-B + 00145 + ROMA + RM + IT + + + + + + + TD01 + EUR + 2019-05-11 + 852S1 + 34.32 + Rif ordine 908 + + + + + 1 + USB4 + 1.00 + Pz. + 18.07 + 18.07 + 0.00 + N4 + + + 2 + USB + 1.00 + Pz. + 16.60 + 16.60 + 0.00 + N4 + + + 0.00 + N4 + -0.35 + 34.32 + 0.00 + I + Esenzione Art.8 comma 1 DPR 633/72 + + + + diff --git a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py index f5a65ee9678d..3bad814cd46e 100644 --- a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py +++ b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py @@ -515,6 +515,15 @@ def test_39_xml_import_withholding(self): self.assertAlmostEquals(invoice.withholding_tax_amount, 86.0) self.assertAlmostEquals(invoice.amount_net_pay, 1134.0) + def test_46_xml_import(self): + wiz_values = {'e_invoice_detail_level': '0'} + res = self.run_wizard('test46', 'IT05979361218_016.xml', wiz_values=wiz_values) + invoice_id = res.get('domain')[0][2][0] + invoice = self.invoice_model.browse(invoice_id) + self.assertAlmostEqual(invoice.e_invoice_amount_untaxed, 34.32) + self.assertEqual(invoice.e_invoice_amount_tax, 0.0) + self.assertEqual(invoice.e_invoice_amount_total, 34.32) + def test_01_xml_link(self): """ E-invoice lines are created. diff --git a/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py b/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py index b1913a7af48f..6ca3d667834c 100644 --- a/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py +++ b/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py @@ -1098,7 +1098,8 @@ def set_roundings(self, FatturaBody, invoice): _('Round up and down tax is not set') ) - line_sequence = max(invoice.invoice_line_ids.mapped('sequence')) + # invoice may have no lines at all if imported with minimum detail level + line_sequence = max(invoice.invoice_line_ids.mapped('sequence') or [0]) line_vals = [] for summary in FatturaBody.DatiBeniServizi.DatiRiepilogo: to_round = float(summary.Arrotondamento or 0.0)