Fix errors when query issued and received invoices.
This commit refs #21251
This commit is contained in:
parent
e04ee7ac22
commit
0815ecc62a
39
aeat.py
39
aeat.py
|
@ -671,24 +671,25 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
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),
|
||||
'amount': _decimal(detail.CuotaRepercutida),
|
||||
'surcharge_rate': _decimal(
|
||||
detail.TipoRecargoEquivalencia),
|
||||
'surcharge_amount': _decimal(
|
||||
detail.CuotaRecargoEquivalencia),
|
||||
})
|
||||
taxes = SIIReportLineTax.create(taxes_to_create)
|
||||
elif sujeta.Exenta:
|
||||
exemption = sujeta.Exenta.DetalleExenta[0].CausaExencion
|
||||
for exempt in EXCEMPTION_CAUSE:
|
||||
if exempt[0] == exemption:
|
||||
exemption = exempt[1]
|
||||
break
|
||||
if sujeta:
|
||||
if sujeta.NoExenta:
|
||||
for detail in sujeta.NoExenta.DesgloseIVA.DetalleIVA:
|
||||
taxes_to_create.append({
|
||||
'base': _decimal(detail.BaseImponible),
|
||||
'rate': _decimal(detail.TipoImpositivo),
|
||||
'amount': _decimal(detail.CuotaRepercutida),
|
||||
'surcharge_rate': _decimal(
|
||||
detail.TipoRecargoEquivalencia),
|
||||
'surcharge_amount': _decimal(
|
||||
detail.CuotaRecargoEquivalencia),
|
||||
})
|
||||
taxes = SIIReportLineTax.create(taxes_to_create)
|
||||
elif sujeta.Exenta:
|
||||
exemption = sujeta.Exenta.DetalleExenta[0].CausaExencion
|
||||
for exempt in EXCEMPTION_CAUSE:
|
||||
if exempt[0] == exemption:
|
||||
exemption = exempt[1]
|
||||
break
|
||||
|
||||
sii_report_line = {
|
||||
'report': self.id,
|
||||
|
@ -843,7 +844,7 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
_logger.debug(res)
|
||||
registers = res.RegistroRespuestaConsultaLRFacturasRecibidas
|
||||
pagination = res.IndicadorPaginacion
|
||||
last_invoice = registers[-1].IDFactura
|
||||
last_invoice = registers and registers[-1].IDFactura or None
|
||||
|
||||
# FIXME: the reference is not forced to be unique
|
||||
lines_to_create = []
|
||||
|
|
Loading…
Reference in New Issue