From 0b67cf5512580ac5ca274fd6511543307462e75e Mon Sep 17 00:00:00 2001 From: Diego Paradeda Date: Tue, 3 Dec 2024 16:27:47 -0300 Subject: [PATCH 1/2] [IMP] l10n_br_nfe: computed impostoDevol added to nfe --- l10n_br_fiscal/models/document_line.py | 4 ++ l10n_br_fiscal/models/document_line_mixin.py | 10 +++++ .../views/document_fiscal_line_mixin_view.xml | 8 ++++ l10n_br_nfe/models/document_line.py | 41 ++++++++++++++++++- 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/l10n_br_fiscal/models/document_line.py b/l10n_br_fiscal/models/document_line.py index 6490c69c4d35..dfaecc493fdd 100644 --- a/l10n_br_fiscal/models/document_line.py +++ b/l10n_br_fiscal/models/document_line.py @@ -50,3 +50,7 @@ class DocumentLine(models.Model): force_compute_delivery_costs_by_total = fields.Boolean( related="document_id.force_compute_delivery_costs_by_total" ) + + edoc_purpose = fields.Selection( + related="document_id.edoc_purpose", + ) diff --git a/l10n_br_fiscal/models/document_line_mixin.py b/l10n_br_fiscal/models/document_line_mixin.py index 1ac41117f2b5..ed1cd3ea2585 100644 --- a/l10n_br_fiscal/models/document_line_mixin.py +++ b/l10n_br_fiscal/models/document_line_mixin.py @@ -151,6 +151,11 @@ def _operation_domain(self): readonly=True, ) + operation_fiscal_type = fields.Selection( + related="fiscal_operation_id.fiscal_type", + readonly=True, + ) + fiscal_operation_line_id = fields.Many2one( comodel_name="l10n_br_fiscal.operation.line", string="Operation Line", @@ -568,6 +573,11 @@ def _operation_domain(self): "('cst_out_id', '=', ipi_cst_id)]", ) + # IPI Devolvido Fields + p_devol = fields.Float(string="Percentual de mercadoria devolvida") + + ipi_devol_value = fields.Monetary(string="Valor do IPI devolvido") + # II Fields ii_tax_id = fields.Many2one( comodel_name="l10n_br_fiscal.tax", diff --git a/l10n_br_fiscal/views/document_fiscal_line_mixin_view.xml b/l10n_br_fiscal/views/document_fiscal_line_mixin_view.xml index a11242c6a9cd..6786a14908c1 100644 --- a/l10n_br_fiscal/views/document_fiscal_line_mixin_view.xml +++ b/l10n_br_fiscal/views/document_fiscal_line_mixin_view.xml @@ -9,6 +9,7 @@ + @@ -496,6 +497,13 @@ /> + + + + Date: Fri, 6 Dec 2024 17:01:34 -0300 Subject: [PATCH 2/2] [IMP] l10n_br_account_nfe: add credit note test case --- .../tests/test_nfe_with_ipi.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/l10n_br_account_nfe/tests/test_nfe_with_ipi.py b/l10n_br_account_nfe/tests/test_nfe_with_ipi.py index a792623680fc..5e01d7a339e1 100644 --- a/l10n_br_account_nfe/tests/test_nfe_with_ipi.py +++ b/l10n_br_account_nfe/tests/test_nfe_with_ipi.py @@ -50,3 +50,44 @@ def test_nfe_with_ipi(self): self.assertEqual(self.move_out_venda.nfe40_vIPI, 50.0) self.assertEqual(self.move_out_venda.nfe40_vProd, 1000.00) self.assertEqual(self.move_out_venda.nfe40_vNF, 1050.00) + + def test_nfe_credit_note(self): + """ + Test fiscal document field: nfe40_impostoDevol (no demo) + """ + partner_a = self.env["res.partner"].create({"name": "Test partner A"}) + fiscal_doc = self.env["l10n_br_fiscal.document"].create( + { + "fiscal_operation_id": self.env.ref( + "l10n_br_fiscal.fo_devolucao_venda" + ).id, + "document_type_id": self.env.ref("l10n_br_fiscal.document_55").id, + "edoc_purpose": "4", + "issuer": "company", + "partner_id": partner_a.id, + "fiscal_operation_type": "in", + } + ) + product_id = self.env.ref("product.product_product_10") + fiscal_doc_line = self.env["l10n_br_fiscal.document.line"].create( + { + "document_id": fiscal_doc.id, + "name": "Return - credit note", + "product_id": product_id.id, + "fiscal_operation_type": "in", + "fiscal_operation_id": self.env.ref( + "l10n_br_fiscal.fo_devolucao_venda" + ).id, + "fiscal_operation_line_id": self.env.ref( + "l10n_br_fiscal.fo_devolucao_venda_devolucao_venda" + ).id, + "p_devol": 50, + "ipi_devol_value": 1, + } + ) + fiscal_doc_line._onchange_product_id_fiscal() + + self.assertEqual(fiscal_doc_line.nfe40_impostoDevol.nfe40_pDevol, 50.00) + self.assertEqual( + fiscal_doc_line.nfe40_impostoDevol.nfe40_IPI.nfe40_vIPIDevol, 1.00 + )