handle tax childs #6
2 changed files with 16 additions and 8 deletions
20
mixin.py
20
mixin.py
|
@ -5,6 +5,7 @@
|
|||
|
||||
|
||||
from decimal import Decimal
|
||||
import datetime
|
||||
import html
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
|
@ -100,21 +101,30 @@ class EdocumentMixin(object):
|
|||
""" get tax of invoice-line,
|
||||
fire exception if no/multiple taxes exists
|
||||
"""
|
||||
if len(line.invoice_taxes) != 1:
|
||||
if len(line.taxes) != 1:
|
||||
raise UserError(gettext(
|
||||
'edocument_xrechnung.msg_linetax_invalid_number',
|
||||
linename=line.rec_name,
|
||||
numtax=len(line.invoice_taxes)))
|
||||
numtax=len(line.taxes)))
|
||||
|
||||
tax = line.taxes[0]
|
||||
date = line.invoice.accounting_date or line.invoice.invoice_date
|
||||
for child in tax.childs:
|
||||
start_date = child.start_date or datetime.date.min
|
||||
end_date = child.end_date or datetime.date.max
|
||||
if start_date <= date <= end_date:
|
||||
tax = child
|
||||
break
|
||||
|
||||
allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B']
|
||||
unece_category_code = self.get_category_code(line.invoice_taxes[0].tax)
|
||||
unece_category_code = self.get_category_code(tax)
|
||||
if unece_category_code not in allowed_cat:
|
||||
raise UserError(gettext(
|
||||
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
||||
taxname=line.invoice_taxes[0].tax.rec_name,
|
||||
taxname=tax.rec_name,
|
||||
allowed=', '.join(allowed_cat)))
|
||||
|
||||
return line.invoice_taxes[0].tax
|
||||
return tax
|
||||
|
||||
def taxident_data(self, tax_identifier):
|
||||
""" get tax-scheme-id and codes
|
||||
|
|
|
@ -83,9 +83,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<ram:BilledQuantity py:attrs="{'unitCode': line.unit.unece_code} if line.unit and line.unit.unece_code else {}">${line.quantity * this.type_sign}</ram:BilledQuantity>
|
||||
</ram:SpecifiedLineTradeDelivery>
|
||||
<ram:SpecifiedLineTradeSettlement>
|
||||
<py:for each="tax in line.invoice_taxes">
|
||||
${TradeTax(tax.tax)}
|
||||
</py:for>
|
||||
${TradeTax(this.invoice_line_tax(line))}
|
||||
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||
<ram:LineTotalAmount py:attrs="{'currencyID': this.invoice.currency.code}">${line.amount}</ram:LineTotalAmount>
|
||||
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||
|
|
Loading…
Reference in a new issue