-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_br_fiscal: add icms difal regulation
- Loading branch information
1 parent
361af15
commit 7c83c6c
Showing
14 changed files
with
195 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
l10n_br_fiscal/data/l10n_br_fiscal_icms_difal_definition_data.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="True"> | ||
<record id="tax_icms_difal_regulation" model="l10n_br_fiscal.icms.difal.regulation"> | ||
<field name="name">Regulamento do ICMS Difal</field> | ||
<field | ||
name="unique_base_state_ids" | ||
eval="[(6, 0, [ | ||
ref('base.state_br_ac'), | ||
ref('base.state_br_al'), | ||
ref('base.state_br_am'), | ||
ref('base.state_br_ap'), | ||
ref('base.state_br_ba'), | ||
ref('base.state_br_ce'), | ||
ref('base.state_br_df'), | ||
ref('base.state_br_es'), | ||
ref('base.state_br_go'), | ||
ref('base.state_br_ma'), | ||
ref('base.state_br_mg'), | ||
ref('base.state_br_ms'), | ||
ref('base.state_br_mt'), | ||
ref('base.state_br_pa'), | ||
ref('base.state_br_pb'), | ||
ref('base.state_br_pe'), | ||
ref('base.state_br_pi'), | ||
ref('base.state_br_pr'), | ||
ref('base.state_br_rj'), | ||
ref('base.state_br_rn'), | ||
ref('base.state_br_ro'), | ||
ref('base.state_br_rr'), | ||
ref('base.state_br_rs'), | ||
ref('base.state_br_sc'), | ||
ref('base.state_br_se'), | ||
ref('base.state_br_sp'), | ||
ref('base.state_br_to') | ||
])]" | ||
/> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (C) 2023 Felipe Motter Pereira - Akretion <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class ICMSDifalRegulation(models.Model): | ||
_name = "l10n_br_fiscal.icms.difal.regulation" | ||
_description = "ICMS Difal Regulation" | ||
|
||
name = fields.Text(required=True, index=True) | ||
|
||
unique_base_state_ids = fields.Many2many( | ||
comodel_name="res.country.state", | ||
relation="icms_difal_regulation_unique_base_state_rel", | ||
column1="icms_difal_regulation", | ||
column2="state_id", | ||
string="States with Unique Base", | ||
domain=[("country_id.code", "=", "BR")], | ||
) | ||
|
||
double_base_state_ids = fields.Many2many( | ||
comodel_name="res.country.state", | ||
relation="icms_difal_regulation_double_base_state_rel", | ||
column1="icms_difal_regulation", | ||
column2="state_id", | ||
string="States with Double Base", | ||
domain=[("country_id.code", "=", "BR")], | ||
) | ||
|
||
@api.constrains("unique_base_state_ids", "double_base_state_ids") | ||
def _check_duplicity(self): | ||
for state in self.unique_base_state_ids: | ||
if state in self.double_base_state_ids: | ||
raise UserError(_("You cannot have two bases for same state.")) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Copyright 2020 Akretion - Renato Lima <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import exceptions | ||
from odoo.tests import SavepointCase | ||
from odoo.tools import float_compare | ||
|
||
|
@@ -303,3 +304,45 @@ def test_compute_taxes_03(self): | |
} | ||
|
||
self._check_compute_taxes_result(test_result, compute_result, currency) | ||
|
||
def test_difal(self): | ||
"""Testa o calculo dos impostos de compra - entrada de importação""" | ||
|
||
kwargs = self._create_compute_taxes_kwargs() | ||
currency = kwargs["company"].currency_id | ||
|
||
kwargs["partner"] = self.env.ref("l10n_br_base.res_partner_cliente10_mg") | ||
|
||
fiscal_taxes = self.env["l10n_br_fiscal.tax"] | ||
fiscal_taxes |= self.env.ref("l10n_br_fiscal.tax_icms_4") | ||
|
||
difal_regulation = self.env.ref("l10n_br_fiscal.tax_icms_difal_regulation") | ||
kwargs["company"].icms_difal_regulation_id = False | ||
|
||
with self.assertRaises(exceptions.UserError): | ||
fiscal_taxes.compute_taxes(**kwargs) | ||
|
||
kwargs["company"].icms_difal_regulation_id = difal_regulation | ||
|
||
compute_result = fiscal_taxes.compute_taxes(**kwargs) | ||
|
||
test_result = { | ||
"amount_included": 1.38, | ||
"amount_not_included": 0.0, | ||
"amount_withholding": 0.0, | ||
"estimate_tax": 0.0, | ||
"taxes": { | ||
"icms": { | ||
"icms_dest_base": 34.58, | ||
"icms_dest_value": 4.84, | ||
}, | ||
}, | ||
} | ||
|
||
self._check_compute_taxes_result(test_result, compute_result, currency) | ||
|
||
difal_regulation.unique_base_state_ids = [(5, 0, 0)] | ||
difal_regulation.double_base_state_ids = [(5, 0, 0)] | ||
|
||
with self.assertRaises(exceptions.UserError): | ||
fiscal_taxes.compute_taxes(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters