diff --git a/l10n_br_fiscal/data/operation_data.xml b/l10n_br_fiscal/data/operation_data.xml index 04464ba5c5be..bf14d8c98e48 100644 --- a/l10n_br_fiscal/data/operation_data.xml +++ b/l10n_br_fiscal/data/operation_data.xml @@ -61,7 +61,21 @@ approved 00 + + ST + + + + + + + + approved + Revenda ST contribuinte substituído @@ -70,6 +84,12 @@ approved 00 + + icms + out - + @@ -285,7 +285,7 @@ /> 1 - + out @@ -385,7 +385,7 @@ /> 1 - + out @@ -946,5 +946,54 @@ + + + + + + + 1 + + + out + + + + + Teste ST + + + 100 + 1 + out + + + + + + + + + + + 100 + + + + + + + + + diff --git a/l10n_br_fiscal/demo/product_demo.xml b/l10n_br_fiscal/demo/product_demo.xml index da9bb80e4161..0d19eeafbbda 100644 --- a/l10n_br_fiscal/demo/product_demo.xml +++ b/l10n_br_fiscal/demo/product_demo.xml @@ -1978,4 +1978,64 @@ + + + Office Lamp ST + icms + + 35.0 + 40.0 + consu + 0.01 + + + FURN_8889 + + + + + + + + + + fiscal_type + + 00 + selection + + + + + + icms_origin + + 5 + selection + + + diff --git a/l10n_br_fiscal/tests/test_fiscal_document_generic.py b/l10n_br_fiscal/tests/test_fiscal_document_generic.py index 281ecbd945f4..51ab66b993a0 100644 --- a/l10n_br_fiscal/tests/test_fiscal_document_generic.py +++ b/l10n_br_fiscal/tests/test_fiscal_document_generic.py @@ -15,6 +15,7 @@ def setUpClass(cls): # Contribuinte cls.nfe_same_state = cls.env.ref("l10n_br_fiscal.demo_nfe_same_state") cls.nfe_other_state = cls.env.ref("l10n_br_fiscal.demo_nfe_other_state") + cls.nfe_other_state_st = cls.env.ref("l10n_br_fiscal.demo_nfe_other_state_st") cls.nfe_not_taxpayer = cls.env.ref("l10n_br_fiscal.demo_nfe_nao_contribuinte") cls.nfe_not_taxpayer_pf = cls.env.ref( @@ -174,7 +175,7 @@ def test_nfe_other_state(self): self.nfe_other_state._onchange_document_serie_id() self.nfe_other_state._onchange_fiscal_operation_id() - + self.nfe_other_state.action_document_confirm() for line in self.nfe_other_state.fiscal_line_ids: line._onchange_product_id_fiscal() line._onchange_commercial_quantity() @@ -291,6 +292,98 @@ def test_nfe_other_state(self): "from COFINS 3% for Venda de Contribuinte p/ Fora do Estado.", ) + def test_nfe_other_state_st(self): + """Testing NFe in another state with tax substitution.""" + empresa_lucro_presumido = self.env.ref("l10n_br_base.empresa_lucro_presumido") + self.nfe_other_state_st._onchange_document_serie_id() + self.nfe_other_state_st._onchange_fiscal_operation_id() + + for line in self.nfe_other_state_st.fiscal_line_ids: + line.with_company(empresa_lucro_presumido.id)._onchange_product_id_fiscal() + line.with_company( + empresa_lucro_presumido.id + )._onchange_commercial_quantity() + line.with_company(empresa_lucro_presumido.id)._onchange_ncm_id() + line.with_company( + empresa_lucro_presumido.id + )._onchange_fiscal_operation_id() + line.with_company( + empresa_lucro_presumido.id + )._onchange_fiscal_operation_line_id() + line.with_company(empresa_lucro_presumido.id)._onchange_fiscal_taxes() + + if "Revenda" in line.fiscal_operation_line_id.name: + self.assertEqual( + line.cfop_id.code, + "6404", + "Error to mapping CFOP 6404" + " for Revenda de Contribuinte p/ Fora do Estado.", + ) + + # ICMS + if line.product_id.icms_origin not in ICMS_ORIGIN_TAX_IMPORTED: + line.write( + { + "icms_tax_id": self.env.ref("l10n_br_fiscal.tax_icms_12_st").id, + } + ) + line.with_company(empresa_lucro_presumido.id)._onchange_fiscal_taxes() + self.assertEqual( + line.icms_tax_id.name, + "ICMS 010 12%", + "Error to mapping ICMS 010 12%" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + self.assertEqual( + line.icmsst_tax_id.name, + "ICMS 30% MVA 50", + "Error to mapping ICMS 30% MVA 50" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + self.assertEqual( + line.icms_cst_id.code, + "10", + "Error to mapping CST 00 from ICMS 7%" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + + # ICMS FCP + self.assertFalse( + line.icmsfcp_tax_id, + "Error to mapping ICMS FCP 2%" + " for Venda de Contribuinte Dentro do Estado.", + ) + + # PIS + self.assertEqual( + line.pis_tax_id.name, + "PIS 0,65%", + "Error to mapping PIS 0,65%" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + self.assertEqual( + line.pis_cst_id.code, + "01", + "Error to mapping CST 01 - Operação Tributável com Alíquota" + " Básica from PIS 0,65% for" + " Venda de Contribuinte p/ Fora do Estado.", + ) + + # PIS + self.assertEqual( + line.cofins_tax_id.name, + "COFINS 3%", + "Error to mapping COFINS 3%" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + self.assertEqual( + line.cofins_cst_id.code, + "01", + "Error to mapping CST 01 -" + " Operação Tributável com Alíquota Básica" + "from COFINS 3% for Venda de Contribuinte p/ Fora do Estado.", + ) + def test_nfe_not_taxpayer(self): """Test NFe not taxpayer."""