mirror of
https://gitlab.com/datalifeit/trytond-aeat_sii
synced 2023-12-13 20:30:37 +01:00
Update query function to take more than 10.000 registar from SII
This commit is contained in:
parent
ce06680172
commit
35040fa7d2
29
aeat.py
29
aeat.py
|
@ -513,9 +513,10 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
|
||||
self._save_response(res)
|
||||
|
||||
def query_issued_invoices(self):
|
||||
def query_issued_invoices(self, last_invoice=None):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
mapper = pool.get('aeat.sii.issued.invoice.mapper')(pool=pool)
|
||||
|
||||
headers = mapping.get_headers(
|
||||
name=tools.unaccent(self.company.party.name),
|
||||
|
@ -529,7 +530,9 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
res = srv.query(
|
||||
headers,
|
||||
year=self.fiscalyear.name,
|
||||
period=self.period.start_date.month)
|
||||
period=self.period.start_date.month,
|
||||
mapper=mapper,
|
||||
last_invoice=last_invoice)
|
||||
|
||||
registers = \
|
||||
res.RegistroRespuestaConsultaLRFacturasEmitidas
|
||||
|
@ -544,10 +547,14 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
invoice.number: invoice.id
|
||||
for invoice in invoices_list
|
||||
}
|
||||
pagination = res.IndicadorPaginacion
|
||||
last_invoice = invoices_list[-1]
|
||||
self.lines = tuple(
|
||||
SIIReportLine(
|
||||
invoice=invoices_ids.get(reg.IDFactura.NumSerieFacturaEmisor),
|
||||
state=reg.EstadoFactura.EstadoRegistro,
|
||||
last_modify_date=_datetime(
|
||||
reg.EstadoFactura.TimestampUltimaModificacion),
|
||||
communication_code=reg.EstadoFactura.CodigoErrorRegistro,
|
||||
communication_msg=reg.EstadoFactura.DescripcionErrorRegistro,
|
||||
issuer_vat_number=(
|
||||
|
@ -592,6 +599,9 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
)
|
||||
self.save()
|
||||
|
||||
if pagination == 'S':
|
||||
self.query_issued_invoices(last_invoice=last_invoice)
|
||||
|
||||
def submit_recieved_invoices(self):
|
||||
pool = Pool()
|
||||
mapper = pool.get('aeat.sii.recieved.invoice.mapper')(pool=pool)
|
||||
|
@ -649,9 +659,10 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
self.csv = response.CSV
|
||||
self.save()
|
||||
|
||||
def query_recieved_invoices(self):
|
||||
def query_recieved_invoices(self, last_invoice=None):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
mapper = pool.get('aeat.sii.recieved.invoice.mapper')(pool=pool)
|
||||
SIIReportLine = pool.get('aeat.sii.report.lines')
|
||||
SIIReportLineTax = pool.get('aeat.sii.report.line.tax')
|
||||
|
||||
|
@ -667,10 +678,13 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
res = srv.query(
|
||||
headers,
|
||||
year=self.fiscalyear.name,
|
||||
period=self.period.start_date.month)
|
||||
period=self.period.start_date.month,
|
||||
mapper=mapper,
|
||||
last_invoice=last_invoice)
|
||||
|
||||
_logger.debug(res)
|
||||
registers = res.RegistroRespuestaConsultaLRFacturasRecibidas
|
||||
pagination = res.IndicadorPaginacion
|
||||
|
||||
# FIXME: the reference is not forced to be unique
|
||||
lines_to_create = []
|
||||
|
@ -698,6 +712,8 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
sii_report_line = {
|
||||
'report': self.id,
|
||||
'state': reg.EstadoFactura.EstadoRegistro,
|
||||
'last_modify_date': _datetime(
|
||||
reg.EstadoFactura.TimestampUltimaModificacion),
|
||||
'communication_code': (
|
||||
reg.EstadoFactura.CodigoErrorRegistro),
|
||||
'communication_msg': (
|
||||
|
@ -759,9 +775,13 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
break
|
||||
if invoices:
|
||||
sii_report_line['invoice'] = invoices[0].id
|
||||
last_invoice = invoices[0]
|
||||
lines_to_create.append(sii_report_line)
|
||||
SIIReportLine.create(lines_to_create)
|
||||
|
||||
if pagination == 'S':
|
||||
self.query_recieved_invoices(last_invoice=last_invoice)
|
||||
|
||||
|
||||
class SIIReportLine(ModelSQL, ModelView):
|
||||
'''
|
||||
|
@ -777,6 +797,7 @@ class SIIReportLine(ModelSQL, ModelView):
|
|||
'operation_type') != 'C0',
|
||||
})
|
||||
state = fields.Selection(AEAT_INVOICE_STATE, 'State')
|
||||
last_modify_date = fields.Char('Last Modification Date', readonly=True)
|
||||
communication_code = fields.Integer(
|
||||
'Communication Code', readonly=True)
|
||||
communication_msg = fields.Char(
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<field name="invoice"/>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<label name="last_modify_date"/>
|
||||
<field name="last_modify_date"/>
|
||||
<label name="communication_msg"/>
|
||||
<field name="communication_msg"/>
|
||||
<label name="issuer_vat_number"/>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<field name="vat_code"/>
|
||||
<field name="identifier_type"/>
|
||||
<field name="state"/>
|
||||
<field name="last_modify_date"/>
|
||||
<field name="communication_code"/>
|
||||
<field name="communication_msg"/>
|
||||
<field name="issuer_vat_number"/>
|
||||
|
|
Loading…
Reference in a new issue