diff --git a/l10n_br_fiscal/data/operation_data.xml b/l10n_br_fiscal/data/operation_data.xml index 04464ba5c5be..c7873fa40b74 100644 --- a/l10n_br_fiscal/data/operation_data.xml +++ b/l10n_br_fiscal/data/operation_data.xml @@ -42,6 +42,36 @@ 00 + + ST CFOP 6404 + + + ST CFOP 6401 + + + + + + + + + approved + + + + + + + + approved + + Venda ST contribuinte substituto @@ -50,6 +80,15 @@ approved 04 + + icms + @@ -62,6 +101,18 @@ 00 + + + + + + + approved + + Revenda ST contribuinte substituído @@ -70,6 +121,15 @@ approved 00 + + icms + out - + @@ -285,7 +285,7 @@ /> 1 - + out @@ -385,7 +385,7 @@ /> 1 - + out @@ -946,5 +946,116 @@ + + + + + + + 1 + + + out + + + + + Teste ST + + + 100 + 1 + out + + + + + + + + + + + 100 + + + + + + + + + + + + + + + + + 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..d68a609b6531 100644 --- a/l10n_br_fiscal/demo/product_demo.xml +++ b/l10n_br_fiscal/demo/product_demo.xml @@ -1978,4 +1978,126 @@ + + + Office Lamp ST 6404 + icms + + 35.0 + 40.0 + consu + 0.01 + + + FURN_8889 + + + + + + + + + + fiscal_type + + 00 + selection + + + + + + icms_origin + + 5 + selection + + + + + + + + Office Lamp ST 6401 + icms + + 35.0 + 40.0 + consu + 0.01 + + + FURN_8880 + + + + + + + + + + fiscal_type + + 04 + 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..3708acdac00a 100644 --- a/l10n_br_fiscal/tests/test_fiscal_document_generic.py +++ b/l10n_br_fiscal/tests/test_fiscal_document_generic.py @@ -15,6 +15,12 @@ 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_6404 = cls.env.ref( + "l10n_br_fiscal.demo_nfe_other_state_st_6404" + ) + cls.nfe_other_state_st_6401 = cls.env.ref( + "l10n_br_fiscal.demo_nfe_other_state_st_6401" + ) cls.nfe_not_taxpayer = cls.env.ref("l10n_br_fiscal.demo_nfe_nao_contribuinte") cls.nfe_not_taxpayer_pf = cls.env.ref( @@ -174,7 +180,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 +297,96 @@ def test_nfe_other_state(self): "from COFINS 3% for Venda de Contribuinte p/ Fora do Estado.", ) + def test_nfe_other_state_st_6404(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_6404._onchange_document_serie_id() + self.nfe_other_state_st_6404._onchange_fiscal_operation_id() + + for line in self.nfe_other_state_st_6404.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() + + self.assertEqual( + line.cfop_id.code, + "6404", + "Error to mapping CFOP 6404" + " for Revenda de Contribuinte p/ Fora do Estado.", + ) + + # ICMS + line.with_company(empresa_lucro_presumido.id)._onchange_fiscal_taxes() + self.assertEqual( + line.icms_tax_id.id, + self.env.ref("l10n_br_fiscal.tax_icms_antst").id, + "Error to mapping ICMS Cobrado Ant. por ST" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + self.assertEqual( + line.icms_cst_id.code, + "60", + "Error to mapping CST 60 from ICMS Cobrado Ant. por ST" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + + def test_nfe_other_state_st_6401(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_6401._onchange_document_serie_id() + self.nfe_other_state_st_6401._onchange_fiscal_operation_id() + + for line in self.nfe_other_state_st_6401.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() + + self.assertEqual( + line.cfop_id.code, + "6401", + "Error to mapping CFOP 6401" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + + # ICMS + line.with_company(empresa_lucro_presumido.id)._onchange_fiscal_taxes() + self.assertEqual( + line.icms_tax_id.id, + self.env.ref("l10n_br_fiscal.tax_icms_12_st").id, + "Error to mapping ICMS 010 12%" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + self.assertEqual( + line.icmsst_tax_id.id, + self.env.ref("l10n_br_fiscal.tax_icmsst_p30_50").id, + "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 10 from ICMS 010 12%" + " for Venda de Contribuinte p/ Fora do Estado.", + ) + def test_nfe_not_taxpayer(self): """Test NFe not taxpayer."""