From 79e4638bcbf01a182b68054552428f21a77a0a93 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Thu, 4 Apr 2024 16:57:41 -0300 Subject: [PATCH 1/3] [RFC] l10n_br_coa_generic: refactor withholding tax --- l10n_br_coa_generic/data/account.account.template.csv | 1 + .../data/l10n_br_coa.account.tax.group.account.template.csv | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/l10n_br_coa_generic/data/account.account.template.csv b/l10n_br_coa_generic/data/account.account.template.csv index ceea5b322a1c..65f60e91531f 100644 --- a/l10n_br_coa_generic/data/account.account.template.csv +++ b/l10n_br_coa_generic/data/account.account.template.csv @@ -68,6 +68,7 @@ coa_generic_114107,1.1.4.1.07,CSLL a Compensar,,l10n_br_coa.data_account_type_cu coa_generic_114108,1.1.4.1.08,IRRF a Compensar,,l10n_br_coa.data_account_type_current_assets_other_credits,0,l10n_br_coa_generic_template coa_generic_114109,1.1.4.1.09,ISS a Compensar,,l10n_br_coa.data_account_type_current_assets_other_credits,0,l10n_br_coa_generic_template coa_generic_114110,1.1.4.1.10,II a Compensar,,l10n_br_coa.data_account_type_current_assets_other_credits,0,l10n_br_coa_generic_template +coa_generic_114111,1.1.4.1.11,INSS a Compensar,,l10n_br_coa.data_account_type_current_assets_other_credits,0,l10n_br_coa_generic_template coa_generic_114201,1.1.4.2.01,Adto Quinzenal,,l10n_br_coa.data_account_type_current_assets_other_credits,1,l10n_br_coa_generic_template coa_generic_114202,1.1.4.2.02,Adto Salarial,,l10n_br_coa.data_account_type_current_assets_other_credits,1,l10n_br_coa_generic_template coa_generic_114203,1.1.4.2.03,Adto de Férias,,l10n_br_coa.data_account_type_current_assets_other_credits,1,l10n_br_coa_generic_template diff --git a/l10n_br_coa_generic/data/l10n_br_coa.account.tax.group.account.template.csv b/l10n_br_coa_generic/data/l10n_br_coa.account.tax.group.account.template.csv index b58c2b43762b..e8ca6eebc224 100644 --- a/l10n_br_coa_generic/data/l10n_br_coa.account.tax.group.account.template.csv +++ b/l10n_br_coa_generic/data/l10n_br_coa.account.tax.group.account.template.csv @@ -7,3 +7,9 @@ "l10n_br_coa_generic.account_tax_group_account_template_csll","l10n_br_coa.tax_group_csll","l10n_br_coa_generic.coa_generic_217107","l10n_br_coa_generic.coa_generic_114107",l10n_br_coa_generic.coa_generic_611209,l10n_br_coa_generic.coa_generic_611229,l10n_br_coa_generic_template "l10n_br_coa_generic.account_tax_group_account_template_irpj","l10n_br_coa.tax_group_irpj","l10n_br_coa_generic.coa_generic_217106","l10n_br_coa_generic.coa_generic_114106",l10n_br_coa_generic.coa_generic_611210,l10n_br_coa_generic.coa_generic_611230,l10n_br_coa_generic_template "l10n_br_coa_generic.account_tax_group_account_template_ii","l10n_br_coa.tax_group_ii","l10n_br_coa_generic.coa_generic_217113","l10n_br_coa_generic.coa_generic_114110",l10n_br_coa_generic.coa_generic_611211,l10n_br_coa_generic.coa_generic_611231,l10n_br_coa_generic_template +"l10n_br_coa_generic.account_tax_group_account_template_pis_wh","l10n_br_coa.tax_group_pis_wh","l10n_br_coa_generic.coa_generic_217105","l10n_br_coa_generic.coa_generic_114105",,,l10n_br_coa_generic_template +"l10n_br_coa_generic.account_tax_group_account_template_confins_wh","l10n_br_coa.tax_group_cofins_wh","l10n_br_coa_generic.coa_generic_217104","l10n_br_coa_generic.coa_generic_114104",,,l10n_br_coa_generic_template +"l10n_br_coa_generic.account_tax_group_account_template_issqn_wh","l10n_br_coa.tax_group_issqn_wh","l10n_br_coa_generic.coa_generic_217108","l10n_br_coa_generic.coa_generic_114109",,,l10n_br_coa_generic_template +"l10n_br_coa_generic.account_tax_group_account_template_csll_wh","l10n_br_coa.tax_group_csll_wh","l10n_br_coa_generic.coa_generic_217107","l10n_br_coa_generic.coa_generic_114107",,,l10n_br_coa_generic_template +"l10n_br_coa_generic.account_tax_group_account_template_irpj_wh","l10n_br_coa.tax_group_irpj_wh","l10n_br_coa_generic.coa_generic_217106","l10n_br_coa_generic.coa_generic_114106",,,l10n_br_coa_generic_template +"l10n_br_coa_generic.account_tax_group_account_template_inss_wh","l10n_br_coa.tax_group_inss_wh","l10n_br_coa_generic.coa_generic_216101","l10n_br_coa_generic.coa_generic_114111",,,l10n_br_coa_generic_template From 625b4c6276cf807461140cd02903b4f23a4f6988 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Thu, 18 Apr 2024 13:21:15 -0300 Subject: [PATCH 2/3] [RFC] l10n_br_coa: refactor withholding tax --- l10n_br_coa/data/account_tax_template.xml | 332 +------------------ l10n_br_coa/models/account_chart_template.py | 26 +- l10n_br_coa/models/account_tax_mixin.py | 15 +- l10n_br_coa/models/account_tax_template.py | 1 + l10n_br_coa/views/account_tax.xml | 1 + 5 files changed, 47 insertions(+), 328 deletions(-) diff --git a/l10n_br_coa/data/account_tax_template.xml b/l10n_br_coa/data/account_tax_template.xml index 0d863dfef2a8..597bf0aeee6b 100644 --- a/l10n_br_coa/data/account_tax_template.xml +++ b/l10n_br_coa/data/account_tax_template.xml @@ -228,34 +228,9 @@ sale + - - @@ -287,34 +262,9 @@ purchase + - - @@ -368,34 +318,9 @@ sale + - - @@ -427,34 +352,9 @@ purchase + - - @@ -508,34 +408,9 @@ sale + - - @@ -567,34 +442,9 @@ purchase + - - @@ -621,39 +471,14 @@ IRPJ WH - IRPJ WH + IRPJ WH Saída 0.00 sale + - - @@ -680,39 +505,14 @@ IRPJ WH - IRPJ WH + IRPJ WH Entrada 0.00 purchase + - - @@ -739,39 +539,14 @@ CSLL WH - CSLL WH + CSLL WH Saída 0.00 sale + - - @@ -798,39 +573,14 @@ CSLL WH - CSLL WH + CSLL WH Entrada 0.00 purchase + - - @@ -851,34 +601,9 @@ sale + - - @@ -899,34 +624,9 @@ purchase + - - diff --git a/l10n_br_coa/models/account_chart_template.py b/l10n_br_coa/models/account_chart_template.py index 837578fdf8bc..8ad38afbd44e 100644 --- a/l10n_br_coa/models/account_chart_template.py +++ b/l10n_br_coa/models/account_chart_template.py @@ -75,12 +75,20 @@ def _load_template( "l10n_br_coa.account.tax.group.account.template" ].search(domain) if group_tax_account_template: - if tax.deductible: account = group_tax_account_template.ded_account_id refund_account = ( group_tax_account_template.ded_refund_account_id ) + elif tax.withholdable: + if tax.type_tax_use == "purchase": + account = group_tax_account_template.account_id + refund_account = ( + group_tax_account_template.refund_account_id + ) + else: + account = False + refund_account = False else: account = group_tax_account_template[ acc_names.get(tax.type_tax_use, {}).get("account_id") @@ -89,12 +97,12 @@ def _load_template( acc_names.get(tax.type_tax_use, {}).get("refund_account_id") ] - if account_ref.get(account.id): + if account: account_id = account_ref[account.id].id else: account_id = False - if account_ref.get(refund_account.id): + if refund_account: refund_account_id = account_ref[refund_account.id].id else: refund_account_id = False @@ -115,9 +123,9 @@ def _load_template( 0, 0, { - "factor_percent": 100 - if not tax.deductible - else -100, + "factor_percent": -100 + if tax.deductible or tax.withholdable + else 100, "repartition_type": "tax", "account_id": account_id, }, @@ -137,9 +145,9 @@ def _load_template( 0, 0, { - "factor_percent": 100 - if not tax.deductible - else -100, + "factor_percent": -100 + if tax.deductible or tax.withholdable + else 100, "repartition_type": "tax", "account_id": refund_account_id, }, diff --git a/l10n_br_coa/models/account_tax_mixin.py b/l10n_br_coa/models/account_tax_mixin.py index b260f8aebb8b..c01fda5e97ba 100644 --- a/l10n_br_coa/models/account_tax_mixin.py +++ b/l10n_br_coa/models/account_tax_mixin.py @@ -13,14 +13,23 @@ class AccountTaxMixin(models.AbstractModel): default=True, ) - @api.onchange("deductible") + withholdable = fields.Boolean( + string="Withholdable Tax?", + default=False, + ) + + @api.onchange("deductible", "withholdable") def _onchange_deductible(self): for repartition in self.invoice_repartition_line_ids.filtered( lambda r: r.repartition_type == "tax" ): - repartition.factor_percent = 100 if not self.deductible else -100 + repartition.factor_percent = ( + -100 if self.deductible or self.withholdable else 100 + ) for repartition in self.refund_repartition_line_ids.filtered( lambda r: r.repartition_type == "tax" ): - repartition.factor_percent = 100 if not self.deductible else -100 + repartition.factor_percent = ( + -100 if self.deductible or self.withholdable else 100 + ) diff --git a/l10n_br_coa/models/account_tax_template.py b/l10n_br_coa/models/account_tax_template.py index c59ae52b5791..e1d05e5b6aa1 100644 --- a/l10n_br_coa/models/account_tax_template.py +++ b/l10n_br_coa/models/account_tax_template.py @@ -11,4 +11,5 @@ class AccountTaxTemplate(models.Model): def _get_tax_vals(self, company, tax_template_to_tax): values = super()._get_tax_vals(company, tax_template_to_tax) values["deductible"] = self.deductible + values["withholdable"] = self.withholdable return values diff --git a/l10n_br_coa/views/account_tax.xml b/l10n_br_coa/views/account_tax.xml index d83c75761230..5df8d39141c7 100644 --- a/l10n_br_coa/views/account_tax.xml +++ b/l10n_br_coa/views/account_tax.xml @@ -8,6 +8,7 @@ + From 17d8e86d14ef9d4646093c449bad3319949f2a5a Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Thu, 18 Apr 2024 13:21:41 -0300 Subject: [PATCH 3/3] [FIX] l10n_br_coa: fix account.tax confins wh out group --- l10n_br_coa/data/account_tax_template.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_br_coa/data/account_tax_template.xml b/l10n_br_coa/data/account_tax_template.xml index 597bf0aeee6b..c547c04b3a67 100644 --- a/l10n_br_coa/data/account_tax_template.xml +++ b/l10n_br_coa/data/account_tax_template.xml @@ -319,7 +319,7 @@ - +