From 22281ed4a6c7e4caa48abcfed60364c22d4e0cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Arturo=20Garc=C3=ADa?= Date: Mon, 10 Aug 2026 02:23:01 -0400 Subject: [PATCH] Classify foreign ISR withholdings separately Assign payments to non-residents to the dedicated ISREXT group in both localization datasets and tax rules. Add regression checks for national and foreign ISR groups. --- ir.py | 2 -- tax_do_en.xml | 4 +-- tax_do_es_419.xml | 6 ++--- tax_rule_do_en.xml | 2 +- tax_rule_do_es_419.xml | 4 +-- tests/__init__.py | 1 - tests/test_module.py | 55 ++++++++++++++++++++++++++++++------------ 7 files changed, 48 insertions(+), 26 deletions(-) diff --git a/ir.py b/ir.py index d3e975b..ea9f6d3 100644 --- a/ir.py +++ b/ir.py @@ -2,11 +2,9 @@ # this repository contains the full copyright notices and license terms. from sql import Table - from trytond.pool import PoolMeta from trytond.transaction import Transaction - LEGACY_OBSOLETE_IDS = { 'do_tax_itbis_8_compra', 'do_tax_itbis_8_venta', 'do_tax_itbis_9_compra', 'do_tax_itbis_9_venta', diff --git a/tax_do_en.xml b/tax_do_en.xml index 24c1eae..9ec5373 100644 --- a/tax_do_en.xml +++ b/tax_do_en.xml @@ -292,7 +292,7 @@ Foreign ISR Withholding 27% percentage - + @@ -303,7 +303,7 @@ Foreign ISR Withholding 10% percentage - + diff --git a/tax_do_es_419.xml b/tax_do_es_419.xml index 47a95db..e9c3778 100644 --- a/tax_do_es_419.xml +++ b/tax_do_es_419.xml @@ -283,7 +283,7 @@ Retención ISR Exterior 27% percentage - + @@ -294,7 +294,7 @@ Retención ISR Exterior 10% percentage - + @@ -589,4 +589,4 @@ Art. 20 Ley 288-04, mod. art. 7 Ley 173-07 — tasa 3% - \ No newline at end of file + diff --git a/tax_rule_do_en.xml b/tax_rule_do_en.xml index c058e27..f60c99f 100644 --- a/tax_rule_do_en.xml +++ b/tax_rule_do_en.xml @@ -63,7 +63,7 @@ - + diff --git a/tax_rule_do_es_419.xml b/tax_rule_do_es_419.xml index 33fd119..b8ffc32 100644 --- a/tax_rule_do_es_419.xml +++ b/tax_rule_do_es_419.xml @@ -52,7 +52,7 @@ - + @@ -311,4 +311,4 @@ - \ No newline at end of file + diff --git a/tests/__init__.py b/tests/__init__.py index 8b13789..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ - diff --git a/tests/test_module.py b/tests/test_module.py index c39a124..943699a 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -1,5 +1,5 @@ -import unittest import datetime +import unittest from collections import Counter from configparser import ConfigParser from decimal import Decimal @@ -75,15 +75,18 @@ IFRS_ACCOUNT_TYPE_AUDIT = { IFRS_POLICY_COVERAGE = { 'NIC 1': {'11', '12', '21', '23', '3106', '7101', '7102'}, 'NIC 2': {'1103', '110305', '5101', '5106'}, - 'NIIF 9': {'110205', '110701', '110702', '110703', '120701', - '120702', '120703', '4208', '6206', '310604'}, + 'NIIF 9': { + '110205', '110701', '110702', '110703', '120701', '120702', + '120703', '4208', '6206', '310604'}, 'NIIF 15': {'110601', '210501', '4101', '4102', '4103', '4104'}, - 'NIIF 16': {'120501', '120591', '120592', '230201', '230202', - '6112', '6203'}, + 'NIIF 16': { + '120501', '120591', '120592', '230201', '230202', '6112', + '6203'}, 'NIC 12': {'120601', '230301', '6301', '6302', '6303'}, 'NIC 16': {'120101', '120191', '120192', '6110', '6116'}, - 'NIC 36': {'111002', '120192', '120292', '120392', '120592', - '120892', '120992', '6116', '6117', '4206'}, + 'NIC 36': { + '111002', '120192', '120292', '120392', '120592', '120892', + '120992', '6116', '6117', '4206'}, 'NIC 37': {'220101', '230401', '6118', '4207'}, 'NIC 38': {'120901', '120991', '120992', '6111', '6117'}, 'NIC 40': {'120801', '120891', '120892', '4209', '6207'}, @@ -198,7 +201,8 @@ class AccountDoTestCase(ModuleTestCase): template_id = ModelData.get_id( 'account_do', 'do_account_root_es_419') except KeyError: - self.skipTest('The es_419 chart is loaded only for es_419 databases') + self.skipTest( + 'The es_419 chart is loaded only for es_419 databases') template = AccountTemplate(template_id) session_id, _start, _end = CreateChart.create() @@ -358,12 +362,14 @@ class AccountDoTestCase(ModuleTestCase): ], limit=1)) self.assertTrue(Tax.search([ ('company', '=', company.id), - ('description', '=', 'ITBIS Withholding Large Taxpayer 30%'), + ('description', '=', + 'ITBIS Withholding Large Taxpayer 30%'), ('rate', '=', Decimal('-0.054')), ], limit=1)) self.assertTrue(Tax.search([ ('company', '=', company.id), - ('description', '=', 'ITBIS Withholding Informal Supplier 75%'), + ('description', '=', + 'ITBIS Withholding Informal Supplier 75%'), ('rate', '=', Decimal('-0.135')), ], limit=1)) check_015, = Tax.search([ @@ -434,7 +440,8 @@ class SpanishAccountDoTestCase(ModuleTestCase): language = 'es_419' test_spanish_chart_creates_spanish_accounts_and_taxes = ( - AccountDoTestCase.test_spanish_chart_creates_spanish_accounts_and_taxes) + AccountDoTestCase + .test_spanish_chart_creates_spanish_accounts_and_taxes) @with_transaction() def test_migrate_pre_language_identifiers(self): @@ -609,7 +616,8 @@ class AccountDoUnitTestCase(unittest.TestCase): with self.subTest(filename=filename): self.assertTrue(root.findall('data')) self.assertEqual( - {data.get('language') for data in root.findall('data')}, + {data.get('language') + for data in root.findall('data')}, {language}) def test_english_accounting_terminology_is_consistent(self): @@ -710,7 +718,8 @@ class AccountDoUnitTestCase(unittest.TestCase): ref = field.get('ref') if ref and '.' not in ref and ref not in ids: missing.append( - (filename, record.get('id'), field.get('name'), ref)) + (filename, record.get('id'), + field.get('name'), ref)) self.assertEqual(missing, []) def test_chart_template_codes_are_unique(self): @@ -804,12 +813,14 @@ class AccountDoUnitTestCase(unittest.TestCase): for _, record_id, _, _ in _iter_xml_records( 'tax_do_en.xml', 'tax_code_do_en.xml') } - self.assertFalse([record_id for record_id in ids if 'otros' in record_id]) + self.assertFalse([ + record_id for record_id in ids if 'otros' in record_id]) def test_tax_templates_are_complete(self): taxes = { record_id: values - for _, record_id, model, values in _iter_xml_records('tax_do_en.xml') + for _, record_id, model, values + in _iter_xml_records('tax_do_en.xml') if model == 'account.tax.template' } accounts = { @@ -853,6 +864,16 @@ class AccountDoUnitTestCase(unittest.TestCase): self.assertIn( "Decimal('10')/100", taxes['do_tax_isc_bebidas_alc']['rate']) + self.assertEqual( + taxes['do_tax_ret_isr_hon_5']['group'], 'do_tax_group_isr') + self.assertEqual( + taxes['do_tax_ret_isr_serv_10']['group'], 'do_tax_group_isr') + self.assertEqual( + taxes['do_tax_ret_isr_ext_27']['group'], + 'do_tax_group_isr_ext') + self.assertEqual( + taxes['do_tax_ret_isr_ext_10']['group'], + 'do_tax_group_isr_ext') self.assertEqual( taxes['do_tax_ret_isr_bovine_1']['start_date'], 'datetime.date(2025, 6, 20)') @@ -967,6 +988,9 @@ class AccountDoUnitTestCase(unittest.TestCase): if model == 'account.tax.rule.line.template' } self.assertIn('do_tax_rule_bank_check_transfer', rules) + self.assertEqual( + lines['do_trline_supp_ext_isr27']['group'], + 'do_tax_group_isr_ext') self.assertEqual( lines['do_trline_bank_check_transfer_015']['origin_tax'], 'do_tax_cheques_015') @@ -986,4 +1010,5 @@ class AccountDoUnitTestCase(unittest.TestCase): lines['do_trline_bank_check_transfer_020']['start_date'], 'datetime.date(2026, 7, 3)') + del ModuleTestCase