edocument_xrechnung/template/XRechnung-2.2/XRechnung.xml
2022-10-19 17:15:56 +02:00

179 lines
8.5 KiB
XML

<?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>${this.taxident_data(value)['code']}</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>${this.taxident_data(value)['id']}</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="company_id">${this.taxident_data(this.seller_trade_tax_identifier)['code']}</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="TaxCategory(value, incl_reason=False)">
<cbc:ID>${this.tax_category_code(value)}</cbc:ID>
<cbc:Percent>${this.tax_rate(value)}</cbc:Percent>
<cbc:TaxExemptionReason
py:if="(this.tax_category_code(value) in ['E']) and (incl_reason==True)">${value.legal_notice or '-'}</cbc:TaxExemptionReason>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</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>
${TaxCategory(value.tax, True)}
</cac:TaxCategory>
</cac:TaxSubtotal>
</py:def>
<py:def function="InvoiceLine(value)">
<cac:InvoiceLine>
<cbc:ID>${value.id}</cbc:ID>
<cbc:InvoicedQuantity py:attrs="{'unitCode': this.uom_unece_code(value)}">${value.quantity}</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount py:attrs="{'currencyID': value.currency.code}">${value.amount}</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>${value.description or getattr(value.product, 'name', None)}</cbc:Name>
<cac:SellersItemIdentification py:if="getattr(value.product, 'code', None)">
<cbc:ID>${value.product.code}</cbc:ID>
</cac:SellersItemIdentification>
<cac:ClassifiedTaxCategory>
${TaxCategory(this.invoice_line_tax(value))}
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount py:attrs="{'currencyID': value.currency.code}">${value.unit_price}</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
</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:Note py:if="this.invoice_note()">${this.invoice_note()}</cbc:Note>
<cbc:DocumentCurrencyCode>${this.invoice.currency.code}</cbc:DocumentCurrencyCode>
<cbc:BuyerReference>${this.invoice.party.get_xrechnung_route_id()}</cbc:BuyerReference>
<cac:OrderReference py:if="this.invoice.reference">
<cbc:ID>${this.invoice.reference}</cbc:ID>
<cbc:SalesOrderID py:if="this.sales_order_nums()">${this.sales_order_nums()}</cbc:SalesOrderID>
</cac:OrderReference>
<cac:ContractDocumentReference py:if="False">
<cbc:ID>vertrags-nr</cbc:ID>
</cac:ContractDocumentReference>
<cac:ProjectReference py:if="False">
<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.seller_trade_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>
${PayeeFinancialAccount(this.seller_trade_party)}
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:PaymentTerms py:if="this.invoice.payment_term is not None">
<cbc:Note>${this.invoice.payment_term.rec_name}</cbc:Note>
</cac:PaymentTerms>
<cac:AllowanceCharge py:if="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.tax_amount}</cbc:TaxAmount>
<py:for each="taxline in this.invoice.taxes">
${TaxSubTotal(taxline)}
</py:for>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.untaxed_amount}</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.untaxed_amount}</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.total_amount}</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount py:if="False" py:attrs="{'currencyID': this.invoice.currency.code}">0.00</cbc:AllowanceTotalAmount>
<cbc:ChargeTotalAmount py:if="False" py:attrs="{'currencyID': this.invoice.currency.code}">0.00</cbc:ChargeTotalAmount>
<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}">${this.invoice.amount_to_pay}</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<py:for each="line in this.lines">
${InvoiceLine(line)}
</py:for>
</ubl:Invoice>