diff --git a/edocument.py b/edocument.py
index 57c77c6..a61ea94 100644
--- a/edocument.py
+++ b/edocument.py
@@ -4,14 +4,43 @@
# full copyright notices and license terms.
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 decimal import Decimal
class Invoice(Invoice):
'EDocument XRechnung'
__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):
""" load our own template if 'version' is ours
"""
diff --git a/locale/de.po b/locale/de.po
index c06b9e6..691c523 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -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'."
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 #
@@ -18,3 +22,50 @@ msgctxt "selection:party.configuration,identifier_types:"
msgid "X-Rechnung Route-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"
diff --git a/message.xml b/message.xml
index 7d38804..ec96f4c 100644
--- a/message.xml
+++ b/message.xml
@@ -8,5 +8,9 @@ full copyright notices and license terms. -->
No XRechnung routing ID is stored for the party '%(partyname)s'.
+
+ The UNECE tax category is not configured for tax '%(taxname)s'.
+
+
diff --git a/party.py b/party.py
index 7079640..38cc321 100644
--- a/party.py
+++ b/party.py
@@ -21,6 +21,7 @@ class Party(metaclass=PoolMeta):
'edocument_xrechnung.msg_missing_xrechnung_route_id',
partyname = self.rec_name,
))
+
# end Party
diff --git a/template/XRechnung-2.2/XRechnung.xml b/template/XRechnung-2.2/XRechnung.xml
index d43aa45..6c6d5f8 100644
--- a/template/XRechnung-2.2/XRechnung.xml
+++ b/template/XRechnung-2.2/XRechnung.xml
@@ -30,7 +30,26 @@
${value.name}
- ${getattr(value.tax_identifier, 'code', None)}
+ ${getattr(this.seller_trade_tax_identifier, 'code', None)}
+
+
+
+ ${value.bank_accounts[0].numbers[0].number_compact}
+ ${value.name}
+
+
+
+
+ ${value.base}
+ ${value.amount}
+
+ ${this.tax_category_code(value)}
+ ${this.tax_rate(value)}
+
+ VAT
+
+
+
urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.1
@@ -59,7 +78,7 @@
${PartyTaxScheme(this.seller_trade_tax_identifier)}
- ${PartyLegalEntity(this.invoice.company.party)}
+ ${PartyLegalEntity(this.seller_trade_party)}
${Contact(this.seller_trade_party)}
@@ -89,14 +108,13 @@
30
${this.payment_reference}
- DE00 1234 5678 0000 1234 56
- ${this.invoice.company.party.name}
+ ${PayeeFinancialAccount(this.seller_trade_party)}
-
+
${this.invoice.payment_term.rec_name}
-
+
false
Neukundenrabatt
5.00
@@ -109,27 +127,19 @@
- ${this.invoice.total_amount}
-
- 35.25
- 6.70
-
- S
- 19.00
-
- VAT
-
-
-
+ ${this.invoice.tax_amount}
+
+ ${TaxSubTotal(taxline)}
+
- 40.25
- 35.25
- 41.95
- 5.00
- 0.00
- 0.00
- 41.95
+ ${this.invoice.untaxed_amount}
+ ${this.invoice.untaxed_amount}
+ ${this.invoice.total_amount}
+ 0.00
+ 0.00
+ ${this.prepaid_amount(this.invoice)}
+ ${this.invoice.amount_to_pay}
1