xrechnung weiter, line fehlt noch

This commit is contained in:
Frederik Jaeckel 2022-10-18 17:33:17 +02:00
parent 265e38c24f
commit 7e35688043
5 changed files with 121 additions and 26 deletions

View file

@ -4,14 +4,43 @@
# full copyright notices and license terms. # full copyright notices and license terms.
import genshi.template import genshi.template
import os import os, html
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.modules.edocument_uncefact.edocument import Invoice from trytond.modules.edocument_uncefact.edocument import Invoice
from decimal import Decimal
class Invoice(Invoice): class Invoice(Invoice):
'EDocument XRechnung' 'EDocument XRechnung'
__name__ = 'edocument.xrechnung.invoice' __name__ = 'edocument.xrechnung.invoice'
def prepaid_amount(self, invoice):
""" compute already paid amount
"""
return invoice.total_amount - invoice.amount_to_pay
def tax_rate(self, tax):
""" get tax-rate in procent
"""
return (tax.tax.rate * Decimal('100.0')).quantize(Decimal('0.01'))
def tax_category_code(self, tax):
""" read tax-category, fire exception if missing
"""
if len(tax.tax.unece_category_code or '') == 0:
raise UserError(gettext(
'edocument_xrechnung.mds_tax_category_missing',
taxname = tax.rec_name,
))
return tax.tax.unece_category_code
def quote_text(self, text):
""" replace critical chars
"""
if text is not None:
return html.quote(text)
def _get_template(self, version): def _get_template(self, version):
""" load our own template if 'version' is ours """ load our own template if 'version' is ours
""" """

View file

@ -10,6 +10,10 @@ msgctxt "model:ir.message,text:msg_missing_xrechnung_route_id"
msgid "No XRechnung routing ID is stored for the party '%(partyname)s'." msgid "No XRechnung routing ID is stored for the party '%(partyname)s'."
msgstr "Für die Partei '%(partyname)s' ist keine XRechnung-Leitweg-ID hinterlegt." msgstr "Für die Partei '%(partyname)s' ist keine XRechnung-Leitweg-ID hinterlegt."
msgctxt "model:ir.message,text:mds_tax_category_missing"
msgid "The UNECE tax category is not configured for tax '%(taxname)s'."
msgstr "Für die Steuer '%(taxname)s' ist die UNECE-Steuerkategorie nicht konfiguriert."
####################### #######################
# party.configuration # # party.configuration #
@ -18,3 +22,50 @@ msgctxt "selection:party.configuration,identifier_types:"
msgid "X-Rechnung Route-ID" msgid "X-Rechnung Route-ID"
msgstr "X-Rechnung Leitweg-ID" msgstr "X-Rechnung Leitweg-ID"
###############
# account.tax #
###############
msgctxt "field:account.tax,xrtax_category:"
msgid "Tax Category"
msgstr "Steuerkategorie"
msgctxt "help:account.tax,xrtax_category:"
msgid "Tax Category for eDocument - XRechnung"
msgstr "Steuerkategorie für eDocument - XRechnung"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Standard"
msgstr "Standardsatz"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Products at zero rate"
msgstr "Waren zum Nullsatz"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Exempt"
msgstr "Steuerbefreit"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Reverse charge mechanism"
msgstr "Umkehrung der Steuerschuldnerschaft"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Tax-exempt for intra-community supply of goods and services in the EEA"
msgstr "Steuerbefreit für die innergem. Lieferung von W. u. D. im EWR"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Free export item; Tax not levied"
msgstr "Kostenloser Exportartikel; Steuer nicht erhoben"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Non-tax services"
msgstr "Dienstleistungen außerhalb des Steuerbereichs"
msgctxt "selection:account.tax,xrtax_category:"
msgid "General indirect tax of the Canary Islands"
msgstr "Allgemeine indirekte Steuer der kanarischen Inseln"
msgctxt "selection:account.tax,xrtax_category:"
msgid "Tax on production; services and imports in Ceuta and Melilla"
msgstr "Steuer für Produktion; Dienstleistungen und Einfuhr in Ceuta und Melilla"

View file

@ -8,5 +8,9 @@ full copyright notices and license terms. -->
<record model="ir.message" id="msg_missing_xrechnung_route_id"> <record model="ir.message" id="msg_missing_xrechnung_route_id">
<field name="text">No XRechnung routing ID is stored for the party '%(partyname)s'.</field> <field name="text">No XRechnung routing ID is stored for the party '%(partyname)s'.</field>
</record> </record>
<record model="ir.message" id="mds_tax_category_missing">
<field name="text">The UNECE tax category is not configured for tax '%(taxname)s'.</field>
</record>
</data> </data>
</tryton> </tryton>

View file

@ -21,6 +21,7 @@ class Party(metaclass=PoolMeta):
'edocument_xrechnung.msg_missing_xrechnung_route_id', 'edocument_xrechnung.msg_missing_xrechnung_route_id',
partyname = self.rec_name, partyname = self.rec_name,
)) ))
# end Party # end Party

View file

@ -30,7 +30,26 @@
</py:def> </py:def>
<py:def function="PartyLegalEntity(value, company_id=True)"> <py:def function="PartyLegalEntity(value, company_id=True)">
<cbc:RegistrationName>${value.name}</cbc:RegistrationName> <cbc:RegistrationName>${value.name}</cbc:RegistrationName>
<cbc:CompanyID py:if test="company_id">${getattr(value.tax_identifier, 'code', None)}</cbc:CompanyID> <cbc:CompanyID py:if="company_id">${getattr(this.seller_trade_tax_identifier, 'code', None)}</cbc:CompanyID>
</py:def>
<py:def function="PayeeFinancialAccount(value)">
<py:if test="len(value.bank_accounts)>0">
<cbc:ID>${value.bank_accounts[0].numbers[0].number_compact}</cbc:ID>
<cbc:Name>${value.name}</cbc:Name>
</py:if>
</py:def>
<py:def function="TaxSubTotal(value)">
<cac:TaxSubtotal>
<cbc:TaxableAmount py:attrs="{'currencyID': value.currency.code}">${value.base}</cbc:TaxableAmount>
<cbc:TaxAmount py:attrs="{'currencyID': value.currency.code}">${value.amount}</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>${this.tax_category_code(value)}</cbc:ID>
<cbc:Percent>${this.tax_rate(value)}</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</py:def> </py:def>
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.1</cbc:CustomizationID> <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.1</cbc:CustomizationID>
@ -59,7 +78,7 @@
${PartyTaxScheme(this.seller_trade_tax_identifier)} ${PartyTaxScheme(this.seller_trade_tax_identifier)}
</cac:PartyTaxScheme> </cac:PartyTaxScheme>
<cac:PartyLegalEntity> <cac:PartyLegalEntity>
${PartyLegalEntity(this.invoice.company.party)} ${PartyLegalEntity(this.seller_trade_party)}
</cac:PartyLegalEntity> </cac:PartyLegalEntity>
<cac:Contact> <cac:Contact>
${Contact(this.seller_trade_party)} ${Contact(this.seller_trade_party)}
@ -89,14 +108,13 @@
<cbc:PaymentMeansCode>30</cbc:PaymentMeansCode> <cbc:PaymentMeansCode>30</cbc:PaymentMeansCode>
<cbc:PaymentID>${this.payment_reference}</cbc:PaymentID> <cbc:PaymentID>${this.payment_reference}</cbc:PaymentID>
<cac:PayeeFinancialAccount> <cac:PayeeFinancialAccount>
<cbc:ID>DE00 1234 5678 0000 1234 56</cbc:ID> ${PayeeFinancialAccount(this.seller_trade_party)}
<cbc:Name>${this.invoice.company.party.name}</cbc:Name>
</cac:PayeeFinancialAccount> </cac:PayeeFinancialAccount>
</cac:PaymentMeans> </cac:PaymentMeans>
<cac:PaymentTerms py:if test="this.invoice.payment_term is not None"> <cac:PaymentTerms py:if="this.invoice.payment_term is not None">
<cbc:Note>${this.invoice.payment_term.rec_name}</cbc:Note> <cbc:Note>${this.invoice.payment_term.rec_name}</cbc:Note>
</cac:PaymentTerms> </cac:PaymentTerms>
<cac:AllowanceCharge py:if test="False"> <cac:AllowanceCharge py:if="False">
<cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>Neukundenrabatt</cbc:AllowanceChargeReason> <cbc:AllowanceChargeReason>Neukundenrabatt</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="EUR">5.00</cbc:Amount> <cbc:Amount currencyID="EUR">5.00</cbc:Amount>
@ -109,27 +127,19 @@
</cac:TaxCategory> </cac:TaxCategory>
</cac:AllowanceCharge> </cac:AllowanceCharge>
<cac:TaxTotal> <cac:TaxTotal>
<cbc:TaxAmount py:attrs={'currencyID': this.invoice.currency.code}>${this.invoice.total_amount}</cbc:TaxAmount> <cbc:TaxAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.tax_amount}</cbc:TaxAmount>
<cac:TaxSubtotal> <py:for each="taxline in this.invoice.taxes">
<cbc:TaxableAmount py:attrs={'currencyID': this.invoice.currency.code}>35.25</cbc:TaxableAmount> ${TaxSubTotal(taxline)}
<cbc:TaxAmount py:attrs={'currencyID': this.invoice.currency.code}>6.70</cbc:TaxAmount> </py:for>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>19.00</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal> </cac:TaxTotal>
<cac:LegalMonetaryTotal> <cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount py:attrs={'currencyID': this.invoice.currency.code}>40.25</cbc:LineExtensionAmount> <cbc:LineExtensionAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.untaxed_amount}</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount py:attrs={'currencyID': this.invoice.currency.code}>35.25</cbc:TaxExclusiveAmount> <cbc:TaxExclusiveAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.untaxed_amount}</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount py:attrs={'currencyID': this.invoice.currency.code}>41.95</cbc:TaxInclusiveAmount> <cbc:TaxInclusiveAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.total_amount}</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount py:attrs={'currencyID': this.invoice.currency.code}>5.00</cbc:AllowanceTotalAmount> <cbc:AllowanceTotalAmount py:if="False" py:attrs="{'currencyID': this.invoice.currency.code}">0.00</cbc:AllowanceTotalAmount>
<cbc:ChargeTotalAmount py:attrs={'currencyID': this.invoice.currency.code}>0.00</cbc:ChargeTotalAmount> <cbc:ChargeTotalAmount py:attrs="{'currencyID': this.invoice.currency.code}">0.00</cbc:ChargeTotalAmount>
<cbc:PrepaidAmount py:attrs={'currencyID': this.invoice.currency.code}>0.00</cbc:PrepaidAmount> <cbc:PrepaidAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.prepaid_amount(this.invoice)}</cbc:PrepaidAmount>
<cbc:PayableAmount py:attrs={'currencyID': this.invoice.currency.code}>41.95</cbc:PayableAmount> <cbc:PayableAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.amount_to_pay}</cbc:PayableAmount>
</cac:LegalMonetaryTotal> </cac:LegalMonetaryTotal>
<cac:InvoiceLine> <cac:InvoiceLine>
<cbc:ID>1</cbc:ID> <cbc:ID>1</cbc:ID>