xml erzeugen bei 40%
This commit is contained in:
parent
baf871e506
commit
265e38c24f
12 changed files with 357 additions and 1 deletions
6
.hgignore
Normal file
6
.hgignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
syntax: glob
|
||||||
|
build/*
|
||||||
|
dist/*
|
||||||
|
mds_edocument_xrechnung.egg-info/*
|
||||||
|
__pycache__/*
|
||||||
|
locale/convert_de2en.py
|
|
@ -4,7 +4,13 @@
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
from .edocument import Invoice
|
||||||
|
from .party import PartyConfiguration, Party
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
|
Invoice,
|
||||||
|
Party,
|
||||||
|
PartyConfiguration,
|
||||||
module='edocument_xrechnung', type_='model')
|
module='edocument_xrechnung', type_='model')
|
||||||
|
|
26
edocument.py
Normal file
26
edocument.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the edcoment-module for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
import genshi.template
|
||||||
|
import os
|
||||||
|
from trytond.modules.edocument_uncefact.edocument import Invoice
|
||||||
|
|
||||||
|
|
||||||
|
class Invoice(Invoice):
|
||||||
|
'EDocument XRechnung'
|
||||||
|
__name__ = 'edocument.xrechnung.invoice'
|
||||||
|
|
||||||
|
def _get_template(self, version):
|
||||||
|
""" load our own template if 'version' is ours
|
||||||
|
"""
|
||||||
|
if version == 'XRechnung-2.2':
|
||||||
|
loader = genshi.template.TemplateLoader(
|
||||||
|
os.path.join(os.path.dirname(__file__), 'template'),
|
||||||
|
auto_reload=True)
|
||||||
|
return loader.load(os.path.join(version, 'XRechnung.xml'))
|
||||||
|
else :
|
||||||
|
return super(Invoice, self)._get_template(version)
|
||||||
|
|
||||||
|
# end Invoice
|
20
locale/de.po
Normal file
20
locale/de.po
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
|
||||||
|
##############
|
||||||
|
# ir.message #
|
||||||
|
##############
|
||||||
|
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."
|
||||||
|
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# party.configuration #
|
||||||
|
#######################
|
||||||
|
msgctxt "selection:party.configuration,identifier_types:"
|
||||||
|
msgid "X-Rechnung Route-ID"
|
||||||
|
msgstr "X-Rechnung Leitweg-ID"
|
||||||
|
|
8
locale/en.po
Normal file
8
locale/en.po
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
msgctxt "selection:party.configuration,identifier_types:"
|
||||||
|
msgid "X-Rechnung Route-ID"
|
||||||
|
msgstr "X-Rechnung Route-ID"
|
||||||
|
|
12
message.xml
Normal file
12
message.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
37
party.py
Normal file
37
party.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the edcoment-module for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
from trytond.pool import PoolMeta
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.i18n import gettext
|
||||||
|
|
||||||
|
|
||||||
|
class Party(metaclass=PoolMeta):
|
||||||
|
__name__ = 'party.party'
|
||||||
|
|
||||||
|
def get_xrechnung_route_id(self):
|
||||||
|
""" search for route-id at party, fire-exception if missing
|
||||||
|
"""
|
||||||
|
for ident in self.identifiers:
|
||||||
|
if ident.type == 'edoc_route_id':
|
||||||
|
return ident.code
|
||||||
|
raise UserError(gettext(
|
||||||
|
'edocument_xrechnung.msg_missing_xrechnung_route_id',
|
||||||
|
partyname = self.rec_name,
|
||||||
|
))
|
||||||
|
# end Party
|
||||||
|
|
||||||
|
|
||||||
|
class PartyConfiguration(metaclass=PoolMeta):
|
||||||
|
__name__ = 'party.configuration'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __setup__(cls):
|
||||||
|
super(PartyConfiguration, cls).__setup__()
|
||||||
|
cls.identifier_types.selection.append(
|
||||||
|
('edoc_route_id', 'X-Rechnung Route-ID')
|
||||||
|
)
|
||||||
|
|
||||||
|
# end Configuration
|
2
setup.py
2
setup.py
|
@ -97,7 +97,7 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
package_data={
|
package_data={
|
||||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||||
'template/*.xml','versiondep.txt', 'README.rst']),
|
'template/*/*.xml','versiondep.txt', 'README.rst']),
|
||||||
},
|
},
|
||||||
|
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
|
|
176
template/XRechnung-2.2/XRechnung.xml
Normal file
176
template/XRechnung-2.2/XRechnung.xml
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ubl:Invoice
|
||||||
|
xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
|
||||||
|
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
||||||
|
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2"
|
||||||
|
xmlns:udt="urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2"
|
||||||
|
xmlns:py="http://genshi.edgewall.org/"
|
||||||
|
xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd">
|
||||||
|
|
||||||
|
<py:def function="PostalAddress(value)">
|
||||||
|
<cbc:StreetName>${', '.join((getattr(value, 'street', None) or '').split('\n'))}</cbc:StreetName>
|
||||||
|
<cbc:CityName>${getattr(value, 'city', None) or ''}</cbc:CityName>
|
||||||
|
<cbc:PostalZone>${getattr(value, 'postal_code', None) or ''}</cbc:PostalZone>
|
||||||
|
<cac:Country>
|
||||||
|
<cbc:IdentificationCode>${getattr(getattr(value, 'country', None), 'code', None)}</cbc:IdentificationCode>
|
||||||
|
</cac:Country>
|
||||||
|
</py:def>
|
||||||
|
<py:def function="PartyTaxScheme(value)">
|
||||||
|
<cbc:CompanyID>${getattr(value, 'code', None)}</cbc:CompanyID>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</py:def>
|
||||||
|
<py:def function="Contact(value)">
|
||||||
|
<cbc:Name>${value.name}</cbc:Name>
|
||||||
|
<cbc:Telephone>${value.phone}</cbc:Telephone>
|
||||||
|
<cbc:ElectronicMail>${value.email}</cbc:ElectronicMail>
|
||||||
|
</py:def>
|
||||||
|
<py:def function="PartyLegalEntity(value, company_id=True)">
|
||||||
|
<cbc:RegistrationName>${value.name}</cbc:RegistrationName>
|
||||||
|
<cbc:CompanyID py:if test="company_id">${getattr(value.tax_identifier, 'code', None)}</cbc:CompanyID>
|
||||||
|
</py:def>
|
||||||
|
|
||||||
|
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.1</cbc:CustomizationID>
|
||||||
|
<cbc:ID>${this.invoice.number}</cbc:ID>
|
||||||
|
<cbc:IssueDate>${this.invoice.invoice_date.isoformat()}</cbc:IssueDate>
|
||||||
|
<cbc:DueDate>${(getattr(this.invoice, 'payment_term_date', None) or this.invoice.invoice_date).isoformat()}</cbc:DueDate>
|
||||||
|
<cbc:InvoiceTypeCode>${this.type_code}</cbc:InvoiceTypeCode>
|
||||||
|
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
|
||||||
|
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
|
||||||
|
<cac:OrderReference>
|
||||||
|
<cbc:ID>bestell-nr</cbc:ID>
|
||||||
|
<cbc:SalesOrderID>auftrags-nr</cbc:SalesOrderID>
|
||||||
|
</cac:OrderReference>
|
||||||
|
<cac:ContractDocumentReference>
|
||||||
|
<cbc:ID>vertrags-nr</cbc:ID>
|
||||||
|
</cac:ContractDocumentReference>
|
||||||
|
<cac:ProjectReference>
|
||||||
|
<cbc:ID>proj-referenz</cbc:ID>
|
||||||
|
</cac:ProjectReference>
|
||||||
|
<cac:AccountingSupplierParty>
|
||||||
|
<cac:Party>
|
||||||
|
<cac:PostalAddress>
|
||||||
|
${PostalAddress(this.seller_trade_address)}
|
||||||
|
</cac:PostalAddress>
|
||||||
|
<cac:PartyTaxScheme>
|
||||||
|
${PartyTaxScheme(this.seller_trade_tax_identifier)}
|
||||||
|
</cac:PartyTaxScheme>
|
||||||
|
<cac:PartyLegalEntity>
|
||||||
|
${PartyLegalEntity(this.invoice.company.party)}
|
||||||
|
</cac:PartyLegalEntity>
|
||||||
|
<cac:Contact>
|
||||||
|
${Contact(this.seller_trade_party)}
|
||||||
|
</cac:Contact>
|
||||||
|
</cac:Party>
|
||||||
|
</cac:AccountingSupplierParty>
|
||||||
|
<cac:AccountingCustomerParty>
|
||||||
|
<cac:Party>
|
||||||
|
<cac:PartyIdentification>
|
||||||
|
<cbc:ID>${this.buyer_trade_party.code}</cbc:ID>
|
||||||
|
</cac:PartyIdentification>
|
||||||
|
<cac:PostalAddress>
|
||||||
|
${PostalAddress(this.buyer_trade_address)}
|
||||||
|
</cac:PostalAddress>
|
||||||
|
<cac:PartyTaxScheme>
|
||||||
|
${PartyTaxScheme(this.buyer_trade_tax_identifier)}
|
||||||
|
</cac:PartyTaxScheme>
|
||||||
|
<cac:PartyLegalEntity>
|
||||||
|
${PartyLegalEntity(this.buyer_trade_party, False)}
|
||||||
|
</cac:PartyLegalEntity>
|
||||||
|
<cac:Contact>
|
||||||
|
${Contact(this.buyer_trade_party)}
|
||||||
|
</cac:Contact>
|
||||||
|
</cac:Party>
|
||||||
|
</cac:AccountingCustomerParty>
|
||||||
|
<cac:PaymentMeans>
|
||||||
|
<cbc:PaymentMeansCode>30</cbc:PaymentMeansCode>
|
||||||
|
<cbc:PaymentID>${this.payment_reference}</cbc:PaymentID>
|
||||||
|
<cac:PayeeFinancialAccount>
|
||||||
|
<cbc:ID>DE00 1234 5678 0000 1234 56</cbc:ID>
|
||||||
|
<cbc:Name>${this.invoice.company.party.name}</cbc:Name>
|
||||||
|
</cac:PayeeFinancialAccount>
|
||||||
|
</cac:PaymentMeans>
|
||||||
|
<cac:PaymentTerms py:if test="this.invoice.payment_term is not None">
|
||||||
|
<cbc:Note>${this.invoice.payment_term.rec_name}</cbc:Note>
|
||||||
|
</cac:PaymentTerms>
|
||||||
|
<cac:AllowanceCharge py:if test="False">
|
||||||
|
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
|
||||||
|
<cbc:AllowanceChargeReason>Neukundenrabatt</cbc:AllowanceChargeReason>
|
||||||
|
<cbc:Amount currencyID="EUR">5.00</cbc:Amount>
|
||||||
|
<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:AllowanceCharge>
|
||||||
|
<cac:TaxTotal>
|
||||||
|
<cbc:TaxAmount py:attrs={'currencyID': this.invoice.currency.code}>${this.invoice.total_amount}</cbc:TaxAmount>
|
||||||
|
<cac:TaxSubtotal>
|
||||||
|
<cbc:TaxableAmount py:attrs={'currencyID': this.invoice.currency.code}>35.25</cbc:TaxableAmount>
|
||||||
|
<cbc:TaxAmount py:attrs={'currencyID': this.invoice.currency.code}>6.70</cbc:TaxAmount>
|
||||||
|
<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:LegalMonetaryTotal>
|
||||||
|
<cbc:LineExtensionAmount py:attrs={'currencyID': this.invoice.currency.code}>40.25</cbc:LineExtensionAmount>
|
||||||
|
<cbc:TaxExclusiveAmount py:attrs={'currencyID': this.invoice.currency.code}>35.25</cbc:TaxExclusiveAmount>
|
||||||
|
<cbc:TaxInclusiveAmount py:attrs={'currencyID': this.invoice.currency.code}>41.95</cbc:TaxInclusiveAmount>
|
||||||
|
<cbc:AllowanceTotalAmount py:attrs={'currencyID': this.invoice.currency.code}>5.00</cbc:AllowanceTotalAmount>
|
||||||
|
<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:PayableAmount py:attrs={'currencyID': this.invoice.currency.code}>41.95</cbc:PayableAmount>
|
||||||
|
</cac:LegalMonetaryTotal>
|
||||||
|
<cac:InvoiceLine>
|
||||||
|
<cbc:ID>1</cbc:ID>
|
||||||
|
<cbc:InvoicedQuantity unitCode="C62">0.5</cbc:InvoicedQuantity>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">35.00</cbc:LineExtensionAmount>
|
||||||
|
<cac:Item>
|
||||||
|
<cbc:Name>Reparaturdienstleistung in Stunden</cbc:Name>
|
||||||
|
<cac:SellersItemIdentification>
|
||||||
|
<cbc:ID>REP-012</cbc:ID>
|
||||||
|
</cac:SellersItemIdentification>
|
||||||
|
<cac:ClassifiedTaxCategory>
|
||||||
|
<cbc:ID>S</cbc:ID>
|
||||||
|
<cbc:Percent>19.00</cbc:Percent>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</cac:ClassifiedTaxCategory>
|
||||||
|
</cac:Item>
|
||||||
|
<cac:Price>
|
||||||
|
<cbc:PriceAmount currencyID="EUR">70.00</cbc:PriceAmount>
|
||||||
|
</cac:Price>
|
||||||
|
</cac:InvoiceLine>
|
||||||
|
<cac:InvoiceLine>
|
||||||
|
<cbc:ID>2</cbc:ID>
|
||||||
|
<cbc:InvoicedQuantity unitCode="C62">3</cbc:InvoicedQuantity>
|
||||||
|
<cbc:LineExtensionAmount currencyID="EUR">5.25</cbc:LineExtensionAmount>
|
||||||
|
<cac:Item>
|
||||||
|
<cbc:Name>Material</cbc:Name>
|
||||||
|
<cac:SellersItemIdentification>
|
||||||
|
<cbc:ID>MAT-987</cbc:ID>
|
||||||
|
</cac:SellersItemIdentification>
|
||||||
|
<cac:ClassifiedTaxCategory>
|
||||||
|
<cbc:ID>S</cbc:ID>
|
||||||
|
<cbc:Percent>19.00</cbc:Percent>
|
||||||
|
<cac:TaxScheme>
|
||||||
|
<cbc:ID>VAT</cbc:ID>
|
||||||
|
</cac:TaxScheme>
|
||||||
|
</cac:ClassifiedTaxCategory>
|
||||||
|
</cac:Item>
|
||||||
|
<cac:Price>
|
||||||
|
<cbc:PriceAmount currencyID="EUR">1.75</cbc:PriceAmount>
|
||||||
|
</cac:Price>
|
||||||
|
</cac:InvoiceLine>
|
||||||
|
</ubl:Invoice>
|
23
tests/__init__.py
Normal file
23
tests/__init__.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
|
import trytond.tests.test_tryton
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from trytond.modules.edocument_xrechnung.tests.test_edocument import EdocTestCase
|
||||||
|
|
||||||
|
__all__ = ['suite']
|
||||||
|
|
||||||
|
|
||||||
|
class EDocumentTestCase(\
|
||||||
|
EdocTestCase,\
|
||||||
|
):
|
||||||
|
'Test edocument module'
|
||||||
|
module = 'edocument_xrechnung'
|
||||||
|
|
||||||
|
# end EDocumentTestCase
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
suite = trytond.tests.test_tryton.suite()
|
||||||
|
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(EDocumentTestCase))
|
||||||
|
return suite
|
38
tests/test_edocument.py
Normal file
38
tests/test_edocument.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||||
|
from trytond.pool import Pool
|
||||||
|
from trytond.modules.edocument_uncefact.tests.test_edocument_uncefact import get_invoice
|
||||||
|
from unittest.mock import Mock, MagicMock
|
||||||
|
|
||||||
|
|
||||||
|
class EdocTestCase(ModuleTestCase):
|
||||||
|
'Test e-rechnung module'
|
||||||
|
module = 'edocument_xrechnung'
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_xrechn_export_xml(self):
|
||||||
|
""" run export
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Template = pool.get('edocument.xrechnung.invoice')
|
||||||
|
Address = pool.get('party.address')
|
||||||
|
Identifier = pool.get('party.identifier')
|
||||||
|
|
||||||
|
invoice = get_invoice()
|
||||||
|
invoice.party.get_xrechnung_route_id = Mock(return_value='xrechn-route-id-123')
|
||||||
|
invoice.identifiers = [
|
||||||
|
Mock(spec=Identifier,
|
||||||
|
type='edoc_route_id',
|
||||||
|
code='xrechn-route-id-123')
|
||||||
|
]
|
||||||
|
|
||||||
|
template = Template(invoice)
|
||||||
|
invoice_string = template.render('XRechnung-2.2')
|
||||||
|
with open('xrechnung-test.xml', 'wt') as fhdl:
|
||||||
|
fhdl.write(invoice_string.decode('utf8'))
|
||||||
|
|
||||||
|
# end EdocTestCase
|
|
@ -2,4 +2,8 @@
|
||||||
version=6.0.0
|
version=6.0.0
|
||||||
depends:
|
depends:
|
||||||
edocument_uncefact
|
edocument_uncefact
|
||||||
|
party
|
||||||
|
#extras_depend:
|
||||||
|
account_invoice
|
||||||
xml:
|
xml:
|
||||||
|
message.xml
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue