mirror of
https://gitlab.com/datalifeit/trytond-account_es_sii
synced 2023-12-14 06:13:02 +01:00
Update way of amount total is calculated. And add a warning when set to draft and invoice it this invoice are in a SII book sended
This commit is contained in:
parent
1835f06e50
commit
833f77ca33
|
@ -54,8 +54,14 @@ class BaseTrytonInvoiceMapper(Model):
|
|||
def get_invoice_total(self, invoice):
|
||||
taxes = self.total_invoice_taxes(invoice)
|
||||
total = 0
|
||||
taxes_used = {}
|
||||
for tax in taxes:
|
||||
total += (tax.company_base + tax.company_amount)
|
||||
base = tax.company_base
|
||||
parent = tax.tax.parent if tax.tax.parent else tax.tax
|
||||
if parent.id in taxes_used.keys() and base == taxes_used[parent.id]:
|
||||
continue
|
||||
total += (base + tax.company_amount)
|
||||
taxes_used[parent.id] = base
|
||||
return total
|
||||
|
||||
counterpart_id_type = attrgetter('party.sii_identifier_type')
|
||||
|
@ -99,7 +105,7 @@ class BaseTrytonInvoiceMapper(Model):
|
|||
invoice_tax.tax.tax_used and
|
||||
not invoice_tax.tax.recargo_equivalencia)]
|
||||
|
||||
def taxes(self, invoice):
|
||||
def total_invoice_taxes(self, invoice):
|
||||
return [invoice_tax for invoice_tax in invoice.taxes if (
|
||||
invoice_tax.tax.invoice_used and
|
||||
not invoice_tax.tax.recargo_equivalencia)]
|
||||
|
|
17
invoice.py
17
invoice.py
|
@ -61,6 +61,12 @@ class Invoice:
|
|||
'sii_received_key', 'sii_issued_key', 'sii_subjected_key',
|
||||
'sii_excemption_key', 'sii_intracomunity_key']
|
||||
cls._check_modify_exclude += sii_fields
|
||||
cls._error_messages.update({
|
||||
'invoices_sii': 'The next invoices are related with SII books:\n'
|
||||
'%s.\n\nIf yuo edit them take care if you need to update '
|
||||
'again to SII',
|
||||
})
|
||||
|
||||
cls._buttons.update({
|
||||
'reset_sii_keys': {
|
||||
'invisible': Bool(Eval('sii_state', None)),
|
||||
|
@ -197,6 +203,17 @@ class Invoice:
|
|||
if to_write:
|
||||
cls.write(*to_write)
|
||||
|
||||
@classmethod
|
||||
def draft(cls, invoices):
|
||||
super(Invoice, cls).draft(invoices)
|
||||
invoices_sii = ''
|
||||
for invoice in invoices:
|
||||
if invoice.sii_state:
|
||||
invoices_sii += '\n%s: %s' % (invoice.number, invoice.sii_state)
|
||||
if invoices_sii:
|
||||
warning_name = 'invoices_sii_report'
|
||||
cls.raise_user_warning(warning_name, 'invoices_sii', invoices_sii)
|
||||
|
||||
|
||||
class Sale:
|
||||
__metaclass__ = PoolMeta
|
||||
|
|
Loading…
Reference in a new issue