From d256b1fca3fea0f15984923926cff6eb465458a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20Juli=C3=A0?= Date: Wed, 20 Nov 2019 11:23:59 +0100 Subject: [PATCH 1/6] Mark NoSujetaIva to False and sum BaseImponible when export E2 --- sii/resource.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sii/resource.py b/sii/resource.py index eb92d20..3ecec71 100644 --- a/sii/resource.py +++ b/sii/resource.py @@ -67,7 +67,9 @@ def get_iva_values(invoice, in_invoice, is_export=False, is_import=False): for inv_tax in invoice.tax_line: if 'iva' in inv_tax.name.lower(): vals['sujeta_a_iva'] = True - + if is_export: + vals['sujeta_a_iva'] = False + vals['detalle_iva_exento']['BaseImponible'] += inv_tax.base base_iva = inv_tax.base base_imponible = sign * base_iva cuota = inv_tax.tax_amount From f0249992e3039965b12dcf71045d55dbcf8c2684 Mon Sep 17 00:00:00 2001 From: guilleJB Date: Thu, 13 Apr 2023 18:27:17 +0200 Subject: [PATCH 2/6] use base imponible --- sii/resource.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sii/resource.py b/sii/resource.py index 6405231..d20446d 100644 --- a/sii/resource.py +++ b/sii/resource.py @@ -94,7 +94,7 @@ def get_iva_values(invoice, in_invoice, is_export=False, is_import=False): vals['sujeta_a_iva'] = True if is_export: vals['sujeta_a_iva'] = False - vals['detalle_iva_exento']['BaseImponible'] += inv_tax.base + vals['detalle_iva_exento']['BaseImponible'] += base_imponible invoice_total -= (base_imponible + cuota) tax_type = inv_tax.tax_id.type @@ -112,7 +112,7 @@ def get_iva_values(invoice, in_invoice, is_export=False, is_import=False): # detectan como IVA exento elif not is_export and not is_import and is_iva_exento: vals['iva_exento'] = True - vals['detalle_iva_exento']['BaseImponible'] += inv_tax.base + vals['detalle_iva_exento']['BaseImponible'] += base_imponible else: if in_invoice: cuota_key = 'CuotaSoportada' From efa9e58090a889a8c198c7f6e88f568572b76cff Mon Sep 17 00:00:00 2001 From: guilleJB Date: Mon, 1 Jul 2024 16:01:07 +0200 Subject: [PATCH 3/6] Fix indent --- sii/resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sii/resource.py b/sii/resource.py index 56d00e8..caa3b27 100644 --- a/sii/resource.py +++ b/sii/resource.py @@ -92,7 +92,7 @@ def get_iva_values(invoice, in_invoice, is_export=False, is_import=False): continue else: vals['sujeta_a_iva'] = True - if is_export: + if is_export: vals['sujeta_a_iva'] = False vals['detalle_iva_exento']['BaseImponible'] += base_imponible invoice_total -= (base_imponible + cuota) From b3383da9cb66aca5dd6b83bf51742a16a9b6fbfe Mon Sep 17 00:00:00 2001 From: guilleJB Date: Mon, 1 Jul 2024 16:01:15 +0200 Subject: [PATCH 4/6] Fix tests --- spec/serialization_spec.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/spec/serialization_spec.py b/spec/serialization_spec.py index 44c1d53..88ea26c 100644 --- a/spec/serialization_spec.py +++ b/spec/serialization_spec.py @@ -345,30 +345,27 @@ def group_by_tax_rate(iva_values, in_invoice): detalle_iva = ( self.factura_emitida['FacturaExpedida']['TipoDesglose'] ['DesgloseTipoOperacion']['Entrega']['Sujeta'] - ['NoExenta']['DesgloseIVA']['DetalleIVA'] - ) - self.grouped_detalle_iva = group_by_tax_rate( - detalle_iva, in_invoice=False + ['Exenta']['DetalleExenta'] ) + self.detalle_iva = detalle_iva with it('la BaseImponible debe ser la original'): expect( - self.grouped_detalle_iva[21.0]['BaseImponible'] + self.detalle_iva['BaseImponible'] ).to(equal( self.out_invoice.tax_line[0].base )) - with it('la CuotaRepercutida debe ser la original'): + with it('la Causa Exención tiene que ser E2'): expect( - self.grouped_detalle_iva[21.0]['CuotaRepercutida'] - ).to(equal( - self.out_invoice.tax_line[0].tax_amount - )) - with it('el TipoImpositivo debe ser la original'): + self.detalle_iva['CausaExencion'] + ).to(equal('E2')) + with it('No lleva ni tipo impositivo ni Cuota'): expect( - self.grouped_detalle_iva[21.0]['TipoImpositivo'] - ).to(equal( - self.out_invoice.tax_line[0].tax_id.amount * 100 - )) + self.detalle_iva.get('TipoImpositivo','NOTEXIST') + ).to(equal('NOTEXIST')) + expect( + self.detalle_iva.get('CuotaRepercutida','NOTEXIST') + ).to(equal('NOTEXIST')) with context('si es una operación de alquiler (CRE "12" o "13")'): with before.all: From 70212a506286ed45a0e715cc2b94c7a173a295ad Mon Sep 17 00:00:00 2001 From: guilleJB Date: Mon, 1 Jul 2024 16:04:36 +0200 Subject: [PATCH 5/6] TEST: Fix total base --- spec/serialization_spec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/serialization_spec.py b/spec/serialization_spec.py index 88ea26c..08b9dac 100644 --- a/spec/serialization_spec.py +++ b/spec/serialization_spec.py @@ -350,10 +350,11 @@ def group_by_tax_rate(iva_values, in_invoice): self.detalle_iva = detalle_iva with it('la BaseImponible debe ser la original'): + total_base = sum([x.base for x in self.out_invoice.tax_line[0] if 'IVA' in x.name]) expect( self.detalle_iva['BaseImponible'] ).to(equal( - self.out_invoice.tax_line[0].base + total_base )) with it('la Causa Exención tiene que ser E2'): expect( From 45f3b82767ff722c0abffd4077ab89b211c1355a Mon Sep 17 00:00:00 2001 From: guilleJB Date: Mon, 1 Jul 2024 16:06:06 +0200 Subject: [PATCH 6/6] TEST: Fix total base 2 --- spec/serialization_spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/serialization_spec.py b/spec/serialization_spec.py index 08b9dac..530f3a0 100644 --- a/spec/serialization_spec.py +++ b/spec/serialization_spec.py @@ -350,7 +350,7 @@ def group_by_tax_rate(iva_values, in_invoice): self.detalle_iva = detalle_iva with it('la BaseImponible debe ser la original'): - total_base = sum([x.base for x in self.out_invoice.tax_line[0] if 'IVA' in x.name]) + total_base = sum([x.base for x in self.out_invoice.tax_line if 'IVA' in x.name]) expect( self.detalle_iva['BaseImponible'] ).to(equal(