Skip to content

Commit 6c3a6f2

Browse files
pedrobaezaozono
authored andcommitted
[FIX] l10n_es_aeat_mod303: Include both signs (debit and credit) in tax fee fields
Given this regular invoice: 1, IVA 10%, 10 €, 1 € tax 2, IVA 21%, -1 €, -0,21 € tax that can happen when you return some packages (like returnable bottles), you have a valid invoice with total positive amount to due, but in 303, the -0.21 € of the tax fee is not included as there's no other positive tax fee to compensate that negative amount, and the tax map line indicated that only credit operations are included. As the move type is already checked for avoiding to include refunds, we can change to include both move lines types (debit and credit) for this. In fact, in the base, both are already included. As this can happen as well with other taxes and with supplier invoices, all involved fields are changed in the same commit.
1 parent fcacebf commit 6c3a6f2

File tree

3 files changed

+63
-25
lines changed

3 files changed

+63
-25
lines changed

l10n_es_aeat_mod303/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
{
99
"name": "AEAT modelo 303",
10-
"version": "12.0.1.1.0",
10+
"version": "12.0.1.2.0",
1111
"category": "Accounting",
1212
"author": "Guadaltech,"
1313
"AvanzOSC,"

l10n_es_aeat_mod303/data/tax_code_map_mod303_data.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<field name="to_regularize" eval="True"/>
107107
<field name="move_type">regular</field>
108108
<field name="field_type">amount</field>
109-
<field name="sum_type">credit</field>
109+
<field name="sum_type">both</field>
110110
<field name="inverse" eval="False"/>
111111
<!-- Cuota facturas de compra (haber):
112112
P_IVA4_IC_BC_2, P_IVA4_SP_IN_1, P_IVA4_IC_BI_2,
@@ -136,7 +136,7 @@
136136
<field name="to_regularize" eval="True"/>
137137
<field name="move_type">regular</field>
138138
<field name="field_type">amount</field>
139-
<field name="sum_type">credit</field>
139+
<field name="sum_type">both</field>
140140
<field name="inverse" eval="False"/>
141141
<!-- Cuota facturas de compra (haber):
142142
P_IVA4_SP_EX_1, P_IVA4_ISP_2
@@ -192,8 +192,8 @@
192192
<field name="to_regularize" eval="True"/>
193193
<field name="move_type">refund</field>
194194
<field name="field_type">amount</field>
195-
<field name="sum_type">debit</field>
196-
<field name="inverse" eval="True"/>
195+
<field name="sum_type">both</field>
196+
<field name="inverse" eval="False"/>
197197
<!-- Cuota facturas rectificativas de compra (debe):
198198
P_IVA4_IC_BC_2, P_IVA4_SP_IN_1, P_IVA4_IC_BI_2, P_IVA4_SP_EX_1, P_IVA4_ISP_2
199199
P_IVA10_IC_BC_2, P_IVA10_SP_IN_1, P_IVA10_IC_BI_2, P_IVA10_SP_EX_1, P_IVA10_ISP_2
@@ -220,7 +220,7 @@
220220
<field name="to_regularize" eval="True"/>
221221
<field name="move_type">regular</field>
222222
<field name="field_type">amount</field>
223-
<field name="sum_type">credit</field>
223+
<field name="sum_type">both</field>
224224
<field name="inverse" eval="False"/>
225225
<!-- Cuota facturas de venta (haber): S_REQ05 -->
226226
<field name="tax_ids" eval="[(6, False, [ref('l10n_es.account_tax_template_s_req05')])]"/>
@@ -245,7 +245,7 @@
245245
<field name="to_regularize" eval="True"/>
246246
<field name="move_type">regular</field>
247247
<field name="field_type">amount</field>
248-
<field name="sum_type">credit</field>
248+
<field name="sum_type">both</field>
249249
<field name="inverse" eval="False"/>
250250
<!-- Cuota facturas de venta (haber): S_REQ014 -->
251251
<field name="tax_ids" eval="[(6, False, [ref('l10n_es.account_tax_template_s_req014')])]"/>
@@ -270,7 +270,7 @@
270270
<field name="to_regularize" eval="True"/>
271271
<field name="move_type">regular</field>
272272
<field name="field_type">amount</field>
273-
<field name="sum_type">credit</field>
273+
<field name="sum_type">both</field>
274274
<field name="inverse" eval="False"/>
275275
<!-- Cuota facturas de venta (haber): S_REQ52 -->
276276
<field name="tax_ids" eval="[(6, False, [ref('l10n_es.account_tax_template_s_req52')])]"/>
@@ -295,8 +295,8 @@
295295
<field name="to_regularize" eval="True"/>
296296
<field name="move_type">refund</field>
297297
<field name="field_type">amount</field>
298-
<field name="sum_type">debit</field>
299-
<field name="inverse" eval="True"/>
298+
<field name="sum_type">both</field>
299+
<field name="inverse" eval="False"/>
300300
<!-- Cuotas de facturas rectificativas de venta (debe):
301301
S_REQ05, S_REQ014, S_REQ52 -->
302302
<field name="tax_ids" eval="[(6, False, [ref('l10n_es.account_tax_template_s_req05'), ref('l10n_es.account_tax_template_s_req014'), ref('l10n_es.account_tax_template_s_req52')])]"/>
@@ -324,8 +324,8 @@
324324
<field name="to_regularize" eval="True"/>
325325
<field name="move_type">regular</field>
326326
<field name="field_type">amount</field>
327-
<field name="sum_type">debit</field>
328-
<field name="inverse" eval="False"/>
327+
<field name="sum_type">both</field>
328+
<field name="inverse" eval="True"/>
329329
<!-- Cuota facturas de compra (debe):
330330
P_REQ05, P_REQ014, P_REQ5.2
331331
P_IVA4_SC, P_IVA4_BC, P_IVA4_ISP_1, P_IVA4_SP_EX_2,
@@ -353,8 +353,8 @@
353353
<field name="to_regularize" eval="True"/>
354354
<field name="move_type">regular</field>
355355
<field name="field_type">amount</field>
356-
<field name="sum_type">debit</field>
357-
<field name="inverse" eval="False"/>
356+
<field name="sum_type">both</field>
357+
<field name="inverse" eval="True"/>
358358
<!-- Cuota facturas de compra (debe):
359359
P_IVA4_BI, P_IVA10_BI, P_IVA21_BI -->
360360
<field name="tax_ids" eval="[(6, False, [ref('l10n_es.account_tax_template_p_iva4_bi'), ref('l10n_es.account_tax_template_p_iva10_bi'), ref('l10n_es.account_tax_template_p_iva21_bi')])]"/>
@@ -379,8 +379,8 @@
379379
<field name="to_regularize" eval="True"/>
380380
<field name="move_type">regular</field>
381381
<field name="field_type">amount</field>
382-
<field name="sum_type">debit</field>
383-
<field name="inverse" eval="False"/>
382+
<field name="sum_type">both</field>
383+
<field name="inverse" eval="True"/>
384384
<!-- Cuota facturas de compra (debe):
385385
P_IVA4_IBC, P_IVA10_IBC, P_IVA21_IBC -->
386386
<field name="tax_ids" eval="[(6, False, [ref('l10n_es.account_tax_template_p_iva4_ibc'), ref('l10n_es.account_tax_template_p_iva10_ibc'), ref('l10n_es.account_tax_template_p_iva21_ibc')])]"/>

l10n_es_aeat_mod303/tests/test_l10n_es_aeat_mod303.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,16 @@ def setUp(self):
300300
sale = self._invoice_sale_create('2017-01-13')
301301
self._invoice_refund(sale, '2017-01-14')
302302

303+
def _check_tax_lines(self):
304+
for field, result in iter(self.taxes_result.items()):
305+
_logger.debug('Checking tax line: %s' % field)
306+
lines = self.model303.tax_line_ids.filtered(
307+
lambda x: x.field_number == int(field))
308+
self.assertAlmostEqual(
309+
sum(lines.mapped('amount')), result, 2,
310+
"Incorrect result in field %s" % field
311+
)
312+
303313
def test_model_303(self):
304314
# Test default counterpart
305315
self.assertEqual(self.model303._default_counterpart_303().id,
@@ -315,15 +325,7 @@ def test_model_303(self):
315325
})
316326
if self.debug:
317327
self._print_tax_lines(self.model303.tax_line_ids)
318-
# Check tax lines
319-
for field, result in iter(self.taxes_result.items()):
320-
_logger.debug('Checking tax line: %s' % field)
321-
lines = self.model303.tax_line_ids.filtered(
322-
lambda x: x.field_number == int(field))
323-
self.assertAlmostEqual(
324-
sum(lines.mapped('amount')), result, 2,
325-
"Incorrect result in field %s" % field
326-
)
328+
self._check_tax_lines()
327329
# Check result
328330
_logger.debug('Checking results')
329331
devengado = sum([self.taxes_result.get(b, 0.) for b in (
@@ -403,3 +405,39 @@ def test_model_303(self):
403405
self.model303_4t.period_type = '1T'
404406
self.model303_4t.onchange_period_type()
405407
self.assertEqual(self.model303_4t.exonerated_390, '2')
408+
409+
def test_model_303_negative_special_case(self):
410+
self.taxes_sale = {
411+
# tax code: (base, tax_amount)
412+
'S_IVA4B': (1000, 40),
413+
'S_IVA21B//neg': (-140, -29.4),
414+
}
415+
self.taxes_purchase = {
416+
# tax code: (base, tax_amount)
417+
'P_IVA4_BC': (240, 9.6),
418+
'P_IVA21_SC//neg': (-23, -4.83),
419+
}
420+
self.taxes_result = {
421+
# Régimen General - Base imponible 4%
422+
'1': 1000, # S_IVA4B
423+
# Régimen General - Cuota 4%
424+
'3': 40, # S_IVA4B
425+
# Régimen General - Base imponible 21%
426+
'7': -140, # S_IVA21B
427+
# Régimen General - Cuota 21%
428+
'9': -29.4, # S_IVA21B
429+
# Modificación bases y cuotas - Base (Compras y ventas)
430+
'14': 0,
431+
# Modificación bases y cuotas - Cuota (Compras y ventas)
432+
'15': 0,
433+
# Cuotas soportadas en op. int. corrientes - Base
434+
'28': 240 - 23, # P_IVA4_IC_BC, P_IVA21_SC
435+
# Cuotas soportadas en op. int. corrientes - Cuota
436+
'29': 9.6 - 4.83, # P_IVA4_IC_BC, P_IVA21_SC
437+
}
438+
self._invoice_sale_create('2020-01-01')
439+
self._invoice_purchase_create('2020-01-01')
440+
self.model303.date_start = '2020-01-01'
441+
self.model303.date_end = '2020-03-31'
442+
self.model303.button_calculate()
443+
self._check_tax_lines()

0 commit comments

Comments
 (0)