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