diff --git a/sii/resource.py b/sii/resource.py index fe42f24..caa3b27 100644 --- a/sii/resource.py +++ b/sii/resource.py @@ -92,6 +92,9 @@ def get_iva_values(invoice, in_invoice, is_export=False, is_import=False): continue else: vals['sujeta_a_iva'] = True + if is_export: + vals['sujeta_a_iva'] = False + vals['detalle_iva_exento']['BaseImponible'] += base_imponible invoice_total -= (base_imponible + cuota) tax_type = inv_tax.tax_id.type @@ -109,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' diff --git a/spec/serialization_spec.py b/spec/serialization_spec.py index 44c1d53..530f3a0 100644 --- a/spec/serialization_spec.py +++ b/spec/serialization_spec.py @@ -345,30 +345,28 @@ 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'): + total_base = sum([x.base for x in self.out_invoice.tax_line if 'IVA' in x.name]) expect( - self.grouped_detalle_iva[21.0]['BaseImponible'] + self.detalle_iva['BaseImponible'] ).to(equal( - self.out_invoice.tax_line[0].base + total_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: