handle tax childs
This commit is contained in:
parent
6c47581745
commit
f3b4849e0c
2 changed files with 16 additions and 8 deletions
20
mixin.py
20
mixin.py
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
import datetime
|
||||||
import html
|
import html
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
|
@ -100,21 +101,30 @@ class EdocumentMixin(object):
|
||||||
""" get tax of invoice-line,
|
""" get tax of invoice-line,
|
||||||
fire exception if no/multiple taxes exists
|
fire exception if no/multiple taxes exists
|
||||||
"""
|
"""
|
||||||
if len(line.invoice_taxes) != 1:
|
if len(line.taxes) != 1:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_linetax_invalid_number',
|
'edocument_xrechnung.msg_linetax_invalid_number',
|
||||||
linename=line.rec_name,
|
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 = tax.start_date or datetime.date.min
|
||||||
|
end_date = tax.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']
|
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:
|
if unece_category_code not in allowed_cat:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
||||||
taxname=line.invoice_taxes[0].tax.rec_name,
|
taxname=tax.rec_name,
|
||||||
allowed=', '.join(allowed_cat)))
|
allowed=', '.join(allowed_cat)))
|
||||||
|
|
||||||
return line.invoice_taxes[0].tax
|
return tax
|
||||||
|
|
||||||
def taxident_data(self, tax_identifier):
|
def taxident_data(self, tax_identifier):
|
||||||
""" get tax-scheme-id and codes
|
""" 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: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:SpecifiedLineTradeDelivery>
|
||||||
<ram:SpecifiedLineTradeSettlement>
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
<py:for each="tax in line.invoice_taxes">
|
${TradeTax(this.invoice_line_tax(line))}
|
||||||
${TradeTax(tax.tax)}
|
|
||||||
</py:for>
|
|
||||||
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
<ram:LineTotalAmount py:attrs="{'currencyID': this.invoice.currency.code}">${line.amount}</ram:LineTotalAmount>
|
<ram:LineTotalAmount py:attrs="{'currencyID': this.invoice.currency.code}">${line.amount}</ram:LineTotalAmount>
|
||||||
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
|
Loading…
Reference in a new issue