Fix problem when upload Intracomunitari invoices the 'cuota Deducible' field are not filled well.

This commit is contained in:
Bernat Brunet Torruella 2018-03-20 13:25:47 +01:00
parent 6e3bafae6e
commit a4d1a428e9

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from decimal import Decimal
from logging import getLogger
from operator import attrgetter
@ -145,6 +146,16 @@ class RecievedTrytonInvoiceMapper(mapping.RecievedInvoiceMapper,
serial_number = attrgetter('reference')
specialkey_or_trascendence = attrgetter('sii_received_key')
move_date = attrgetter('move.date')
deductible_amount = _amount_getter('tax_amount') # most of the times
def deductible_amount(self, invoice):
# Only for 3.4 and 3.8 version
credit_note = invoice.type in {'in_credit_note', 'out_credit_note'}
val = Decimal(0)
for tax in self.taxes(invoice):
val += tax.amount
# On 4.X change the return for: return val
return val if val is None or not credit_note else -val
tax_reagyp_rate = BaseTrytonInvoiceMapper.tax_rate
tax_reagyp_amount = BaseTrytonInvoiceMapper.tax_amount