Add load data field in AEAT report to allow search invoice date or accounting date

task-032569
This commit is contained in:
Raimon Esteve 2018-08-27 12:31:05 +02:00
parent b1f4158843
commit c1751b5e57
4 changed files with 75 additions and 8 deletions

49
aeat.py
View File

@ -266,6 +266,19 @@ class SIIReport(Workflow, ModelSQL, ModelView):
'readonly': ((Eval('state') != 'draft')
| (Eval('lines', [0]) & Eval('period'))),
}, depends=['state', 'fiscalyear'])
load_date = fields.Date('Load Date',
domain=['OR', [
('load_date', '=', None),
], [
('load_date', '>=', Eval('load_date_start')),
('load_date', '<=', Eval('load_date_end')),
]
], depends=['load_date_start', 'load_date_end'],
help='Filter invoices to the date whitin the period.')
load_date_start = fields.Function(fields.Date('Load Date Start'),
'on_change_with_load_date_start')
load_date_end = fields.Function(fields.Date('Load Date End'),
'on_change_with_load_date_end')
operation_type = fields.Selection(COMMUNICATION_TYPE, 'Operation Type',
required=True,
states={
@ -348,11 +361,6 @@ class SIIReport(Workflow, ModelSQL, ModelView):
def default_company():
return Transaction().context.get('company')
@fields.depends('company')
def on_change_with_currency(self, name=None):
if self.company:
return self.company.currency.id
@staticmethod
def default_fiscalyear():
FiscalYear = Pool().get('account.fiscalyear')
@ -367,11 +375,29 @@ class SIIReport(Workflow, ModelSQL, ModelView):
def default_version():
return '1.1'
@fields.depends('period')
def on_change_period(self):
if not self.period:
self.load_date = None
@fields.depends('company')
def on_change_with_company_vat(self):
if self.company:
return self.company.party.sii_vat_code
@fields.depends('company')
def on_change_with_currency(self, name=None):
if self.company:
return self.company.currency.id
@fields.depends('period')
def on_change_with_load_date_start(self, name=None):
return self.period.start_date if self.period else None
@fields.depends('period')
def on_change_with_load_date_end(self, name=None):
return self.period.end_date if self.period else None
@classmethod
def copy(cls, records, default=None):
if default is None:
@ -452,22 +478,29 @@ class SIIReport(Workflow, ModelSQL, ModelView):
('sii_book_key', '=', report.book),
('move.period', '=', report.period.id),
('state', 'in', ['posted', 'paid']),
]
]
if report.operation_type == 'A0':
domain.append(('sii_state', 'in', [None, 'Incorrecto']))
elif report.operation_type in ('A1', 'A4'):
domain.append(('sii_state', 'in', [
'AceptadoConErrores', 'AceptadaConErrores']))
if report.load_date:
domain.append(['OR', [
('invoice_date', '<=', report.load_date),
('accounting_date', '=', None),
], [
('accounting_date', '<=', report.load_date),
]])
_logger.debug('Searching invoices for SII report: %s', domain)
for invoice in Invoice.search(domain):
to_create.append({
'report': report,
'invoice': invoice,
})
})
if to_create:
ReportLine.create(to_create)

View File

@ -170,6 +170,18 @@ msgctxt "field:aeat.sii.report,lines:"
msgid "Lines"
msgstr "Líneas"
msgctxt "field:aeat.sii.report,load_date:"
msgid "Load Date"
msgstr "Data límit"
msgctxt "field:aeat.sii.report,load_date_end:"
msgid "Load Date End"
msgstr "Fins data límit"
msgctxt "field:aeat.sii.report,load_date_start:"
msgid "Load Date Start"
msgstr "Desde data límit"
msgctxt "field:aeat.sii.report,operation_type:"
msgid "Operation Type"
msgstr "Tipo de operación"
@ -398,6 +410,10 @@ msgctxt "field:party.party,sii_vat_country:"
msgid "SII VAT Country"
msgstr "País NIF SII"
msgctxt "help:aeat.sii.report,load_date:"
msgid "Filter invoices to the date whitin the period."
msgstr "Filtra les factures fins la data dins del període."
msgctxt "model:aeat.sii.issued.invoice.mapper,name:"
msgid "Tryton Issued Invoice to AEAT mapper"
msgstr "Correspondencia Tryton - Aeat facturas emitidas"

View File

@ -170,6 +170,18 @@ msgctxt "field:aeat.sii.report,lines:"
msgid "Lines"
msgstr "Líneas"
msgctxt "field:aeat.sii.report,load_date:"
msgid "Load Date"
msgstr "Fecha límite"
msgctxt "field:aeat.sii.report,load_date_end:"
msgid "Load Date End"
msgstr "Hasta fecha límite"
msgctxt "field:aeat.sii.report,load_date_start:"
msgid "Load Date Start"
msgstr "Desde fecha límite"
msgctxt "field:aeat.sii.report,operation_type:"
msgid "Operation Type"
msgstr "Tipo de operación"
@ -398,6 +410,10 @@ msgctxt "field:party.party,sii_vat_country:"
msgid "SII VAT Country"
msgstr "País NIF SII"
msgctxt "help:aeat.sii.report,load_date:"
msgid "Filter invoices to the date whitin the period."
msgstr "Filtra las facturas hasta la fecha dentro del período."
msgctxt "model:aeat.sii.issued.invoice.mapper,name:"
msgid "Tryton Issued Invoice to AEAT mapper"
msgstr "Correspondencia Tryton - Aeat facturas emitidas"

View File

@ -18,6 +18,8 @@
<field name="fiscalyear"/>
<label name="period"/>
<field name="period"/>
<label name="load_date"/>
<field name="load_date"/>
<label name="send_date"/>
<field name="send_date"/>
<button name="load_invoices" colspan="2"/>