Fix bug in field type

This commit is contained in:
Bernat Brunet Torruella 2018-10-19 09:57:07 +02:00
parent 70b7da1079
commit 28b2d4f8a1
1 changed files with 16 additions and 8 deletions

24
aeat.py
View File

@ -592,10 +592,18 @@ class SIIReport(Workflow, ModelSQL, ModelView):
for reg in registers:
taxes_to_create = []
taxes = exemption = None
if reg.DatosFacturaEmitida.TipoDesglose.DesgloseFactura.Sujeta.\
NoExenta:
for detail in reg.DatosFacturaEmitida.TipoDesglose.\
DesgloseFactura.Sujeta.NoExenta.DesgloseIVA.DetalleIVA:
tipo_desglose = reg.DatosFacturaEmitida.TipoDesglose
if tipo_desglose.DesgloseFactura:
sujeta = tipo_desglose.DesgloseFactura.Sujeta
else:
if tipo_desglose.DesgloseTipoOperacion.PrestacionServicios:
sujeta = tipo_desglose.DesgloseTipoOperacion.\
PrestacionServicios.Sujeta
else:
sujeta = tipo_desglose.DesgloseTipoOperacion.Entrega.Sujeta
if sujeta.NoExenta:
for detail in sujeta.NoExenta.DesgloseIVA.DetalleIVA:
taxes_to_create.append({
'base': _decimal(detail.BaseImponible),
'rate': _decimal(detail.TipoImpositivo),
@ -606,10 +614,8 @@ class SIIReport(Workflow, ModelSQL, ModelView):
detail.CuotaRecargoEquivalencia),
})
taxes = SIIReportLineTax.create(taxes_to_create)
elif reg.DatosFacturaEmitida.TipoDesglose.DesgloseFactura.Sujeta.\
Exenta:
exemption = reg.DatosFacturaEmitida.TipoDesglose.\
DesgloseFactura.Sujeta.Exenta.DetalleExenta.CausaExencion
elif sujeta.Exenta:
exemption = sujeta.Exenta.DetalleExenta[0].CausaExencion
for exempt in EXCEMPTION_CAUSE:
if exempt[0] == exemption:
exemption = exempt[1]
@ -651,6 +657,7 @@ class SIIReport(Workflow, ModelSQL, ModelView):
reg.DatosPresentacion.TimestampPresentacion),
'csv': reg.DatosPresentacion.CSV,
'balance_state': reg.DatosPresentacion.CSV,
'aeat_register': reg,
}
lines_to_create.append(sii_report_line)
SIIReportLine.create(lines_to_create)
@ -797,6 +804,7 @@ class SIIReport(Workflow, ModelSQL, ModelView):
reg.DatosPresentacion.TimestampPresentacion),
'csv': reg.DatosPresentacion.CSV,
'balance_state': reg.DatosPresentacion.CSV,
'aeat_register': reg,
}
domain = [