Formalize DGII tax form mapping
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import unittest
|
||||
from collections import Counter
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
from xml.etree import ElementTree as ET
|
||||
@@ -51,6 +52,7 @@ class AccountDoTestCase(ModuleTestCase):
|
||||
Tax = pool.get('account.tax')
|
||||
TaxCode = pool.get('account.tax.code')
|
||||
TaxRule = pool.get('account.tax.rule')
|
||||
DgiiTaxMapping = pool.get('account.do.dgii.tax.mapping')
|
||||
CreateChart = pool.get('account.create_chart', type='wizard')
|
||||
|
||||
currency, = Currency.create([{
|
||||
@@ -131,6 +133,14 @@ class AccountDoTestCase(ModuleTestCase):
|
||||
('company', '=', company.id),
|
||||
('kind', '=', 'purchase'),
|
||||
], limit=1))
|
||||
self.assertEqual(DgiiTaxMapping.search_count([]), 55)
|
||||
self.assertTrue(DgiiTaxMapping.search([
|
||||
('tax_template', '=', ModelData.get_id(
|
||||
'account_do', 'do_tax_cheques_020')),
|
||||
('form', '=', 'ir2'),
|
||||
('box', '=', 'financial_expenses_check_transfer_tax_020'),
|
||||
('effective_from', '=', date(2026, 7, 3)),
|
||||
], limit=1))
|
||||
self.assertTrue(Tax.search([
|
||||
('company', '=', company.id),
|
||||
('description', '=', 'ITBIS 18% Ventas'),
|
||||
@@ -361,6 +371,52 @@ class AccountDoUnitTestCase(unittest.TestCase):
|
||||
"Decimal('0.20')/100",
|
||||
taxes['do_tax_cheques_020']['rate'])
|
||||
|
||||
def test_dgii_tax_mapping_formalizes_every_tax_template(self):
|
||||
taxes = {
|
||||
record_id: values
|
||||
for _, record_id, model, values in _iter_xml_records('tax_do.xml')
|
||||
if model == 'account.tax.template'
|
||||
}
|
||||
mappings = {
|
||||
record_id: values
|
||||
for _, record_id, model, values in _iter_xml_records(
|
||||
'dgii_tax_mapping_data.xml')
|
||||
if model == 'account.do.dgii.tax.mapping'
|
||||
}
|
||||
mapped_taxes = {
|
||||
values['tax_template'] for values in mappings.values()}
|
||||
|
||||
self.assertEqual(len(mappings), 55)
|
||||
self.assertEqual(mapped_taxes, set(taxes))
|
||||
for record_id, values in mappings.items():
|
||||
with self.subTest(record_id=record_id):
|
||||
self.assertTrue(values.get('form'))
|
||||
self.assertTrue(values.get('box'))
|
||||
self.assertTrue(values.get('box_label'))
|
||||
self.assertTrue(values.get('amount_source'))
|
||||
self.assertIn(values.get('operator'), {'+', '-', 'info'})
|
||||
self.assertTrue(values.get('flow'))
|
||||
self.assertTrue(values.get('legal_basis'))
|
||||
tax = taxes[values['tax_template']]
|
||||
if tax.get('type') != 'none':
|
||||
self.assertTrue(values.get('account_template'))
|
||||
|
||||
by_tax = {
|
||||
values['tax_template']: values
|
||||
for values in mappings.values()
|
||||
}
|
||||
self.assertEqual(by_tax['do_tax_itbis_18_venta']['form'], 'it1')
|
||||
self.assertEqual(by_tax['do_tax_itbis_18_venta']['box'], '16')
|
||||
self.assertEqual(by_tax['do_tax_itbis_18_compra']['box'], '22')
|
||||
self.assertEqual(by_tax['do_tax_itbis_exento']['form'], 'it1_annex_a')
|
||||
self.assertEqual(by_tax['do_tax_itbis_exento']['box'], '04')
|
||||
self.assertEqual(by_tax['do_tax_ret_itbis_75_inf']['box'], '56')
|
||||
self.assertEqual(by_tax['do_tax_ret_isr_ext_27']['form'], '609')
|
||||
self.assertEqual(by_tax['do_tax_cheques_015']['effective_to'],
|
||||
'2026-07-02')
|
||||
self.assertEqual(by_tax['do_tax_cheques_020']['effective_from'],
|
||||
'2026-07-03')
|
||||
|
||||
def test_tax_code_templates_use_expected_signs(self):
|
||||
codes = {
|
||||
record_id: values
|
||||
|
||||
Reference in New Issue
Block a user