import cross-industry-invoice-d22
This commit is contained in:
parent
83bb948e78
commit
48385f9250
3 changed files with 261 additions and 7 deletions
20
document.py
20
document.py
|
@ -34,7 +34,7 @@ xml_types = [
|
||||||
(['xsd', 'Factur-X_1.07.2_EXTENDED', 'Factur-X_1.07.2_EXTENDED.xsd'],
|
(['xsd', 'Factur-X_1.07.2_EXTENDED', 'Factur-X_1.07.2_EXTENDED.xsd'],
|
||||||
'Factur-X extended', 'facturx_extended'),
|
'Factur-X extended', 'facturx_extended'),
|
||||||
(['xsd', 'CII D22B XSD', 'CrossIndustryInvoice_100pD22B.xsd'],
|
(['xsd', 'CII D22B XSD', 'CrossIndustryInvoice_100pD22B.xsd'],
|
||||||
'CrossIndustryInvoice D22', ''),
|
'CrossIndustryInvoice D22', 'crossindustryinvoice_d22'),
|
||||||
(['xsd', 'os-UBL-2.1', 'xsd/maindoc', 'UBL-Invoice-2.1.xsd'],
|
(['xsd', 'os-UBL-2.1', 'xsd/maindoc', 'UBL-Invoice-2.1.xsd'],
|
||||||
'XRechnung - Invoice', ''),
|
'XRechnung - Invoice', ''),
|
||||||
(['xsd', 'os-UBL-2.1', 'xsd', 'maindoc', 'UBL-CreditNote-2.1.xsd'],
|
(['xsd', 'os-UBL-2.1', 'xsd', 'maindoc', 'UBL-CreditNote-2.1.xsd'],
|
||||||
|
@ -409,6 +409,11 @@ class Incoming(metaclass=PoolMeta):
|
||||||
invoice.on_change_lines()
|
invoice.on_change_lines()
|
||||||
return invoice
|
return invoice
|
||||||
|
|
||||||
|
def _readxml_crossindustryinvoice_d22(self, xmltree):
|
||||||
|
""" read cross industry invoice d22
|
||||||
|
"""
|
||||||
|
self._readxml_facturx_extended(xmltree, xmode='ciid22')
|
||||||
|
|
||||||
def _readxml_facturx_minimal(self, xmltree):
|
def _readxml_facturx_minimal(self, xmltree):
|
||||||
""" add missing values to conversion-result
|
""" add missing values to conversion-result
|
||||||
|
|
||||||
|
@ -436,7 +441,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
"""
|
"""
|
||||||
self._readxml_facturx_extended(xmltree)
|
self._readxml_facturx_extended(xmltree)
|
||||||
|
|
||||||
def _readxml_facturx_extended(self, xmltree):
|
def _readxml_facturx_extended(self, xmltree, xmode=None):
|
||||||
""" read factur-x extended
|
""" read factur-x extended
|
||||||
"""
|
"""
|
||||||
Configuration = Pool().get('document.incoming.configuration')
|
Configuration = Pool().get('document.incoming.configuration')
|
||||||
|
@ -470,11 +475,12 @@ class Incoming(metaclass=PoolMeta):
|
||||||
date_path = xpath_exchg_doc + [
|
date_path = xpath_exchg_doc + [
|
||||||
'ram:IssueDateTime', 'udt:DateTimeString']
|
'ram:IssueDateTime', 'udt:DateTimeString']
|
||||||
date_format = self._readxml_getattrib(xmltree, date_path, 'format')
|
date_format = self._readxml_getattrib(xmltree, date_path, 'format')
|
||||||
if date_format != '102':
|
if xmode not in ['ciid22']:
|
||||||
raise UserError(gettext(
|
if date_format != '102':
|
||||||
'document_incoming_invoice_xml.msg_convert_error',
|
raise UserError(gettext(
|
||||||
msg='invalid date-format: %(code)s (expect: 102)' % {
|
'document_incoming_invoice_xml.msg_convert_error',
|
||||||
'code': str(date_format)}))
|
msg='invalid date-format: %(code)s (expect: 102)' % {
|
||||||
|
'code': str(date_format)}))
|
||||||
p_data['invoice_date'] = self._readxml_convertdate(
|
p_data['invoice_date'] = self._readxml_convertdate(
|
||||||
self._readxml_getvalue(xmltree, date_path))
|
self._readxml_getvalue(xmltree, date_path))
|
||||||
|
|
||||||
|
|
168
tests/crossindustryinvoice-d22.xml
Normal file
168
tests/crossindustryinvoice-d22.xml
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
||||||
|
xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100"
|
||||||
|
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
|
||||||
|
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<rsm:ExchangedDocumentContext>
|
||||||
|
</rsm:ExchangedDocumentContext>
|
||||||
|
<rsm:ExchangedDocument>
|
||||||
|
<ram:ID>RE2024.01234</ram:ID>
|
||||||
|
<ram:TypeCode>380</ram:TypeCode>
|
||||||
|
<ram:IssueDateTime>
|
||||||
|
<udt:DateTimeString>20240617</udt:DateTimeString>
|
||||||
|
</ram:IssueDateTime>
|
||||||
|
<ram:IncludedNote>
|
||||||
|
<ram:Content>Description of invoice</ram:Content>
|
||||||
|
</ram:IncludedNote>
|
||||||
|
<ram:IncludedNote>
|
||||||
|
<ram:ContentCode>1</ram:ContentCode>
|
||||||
|
<ram:Content>Some notes to the customer.</ram:Content>
|
||||||
|
</ram:IncludedNote>
|
||||||
|
<ram:IncludedNote>
|
||||||
|
<ram:ContentCode>22</ram:ContentCode>
|
||||||
|
<ram:Content>Goes to field comment.</ram:Content>
|
||||||
|
<ram:SubjectCode>42</ram:SubjectCode>
|
||||||
|
</ram:IncludedNote>
|
||||||
|
</rsm:ExchangedDocument>
|
||||||
|
<rsm:SupplyChainTradeTransaction>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>1</ram:LineID>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount currencyID="EUR">1350.00</ram:ChargeAmount>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="KGM">1.0</ram:BilledQuantity>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount currencyID="EUR">1350.00</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>2</ram:LineID>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount currencyID="EUR">800.00</ram:ChargeAmount>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="KGM">1.5</ram:BilledQuantity>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount currencyID="EUR">1200.00</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:LineID>3</ram:LineID>
|
||||||
|
</ram:AssociatedDocumentLineDocument>
|
||||||
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:NetPriceProductTradePrice>
|
||||||
|
<ram:ChargeAmount currencyID="EUR">150.00</ram:ChargeAmount>
|
||||||
|
</ram:NetPriceProductTradePrice>
|
||||||
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:BilledQuantity unitCode="MTR">2.0</ram:BilledQuantity>
|
||||||
|
</ram:SpecifiedLineTradeDelivery>
|
||||||
|
<ram:SpecifiedLineTradeSettlement>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:RateApplicablePercent>7.00</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
<ram:LineTotalAmount currencyID="EUR">300.00</ram:LineTotalAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
||||||
|
</ram:SpecifiedLineTradeSettlement>
|
||||||
|
</ram:IncludedSupplyChainTradeLineItem>
|
||||||
|
<ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:SellerTradeParty>
|
||||||
|
<ram:Name>Name of the Supplier</ram:Name>
|
||||||
|
<ram:SpecifiedLegalOrganization>
|
||||||
|
</ram:SpecifiedLegalOrganization>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:PostcodeCode>12345</ram:PostcodeCode>
|
||||||
|
<ram:LineOne>Street of Supplier No 1</ram:LineOne>
|
||||||
|
<ram:CityName>Berlin</ram:CityName>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
<ram:CountryName>Germany</ram:CountryName>
|
||||||
|
<ram:CountrySubDivisionID>DE-BE</ram:CountrySubDivisionID>
|
||||||
|
<ram:CountrySubDivisionName>Berlin</ram:CountrySubDivisionName>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
</ram:SellerTradeParty>
|
||||||
|
<ram:BuyerTradeParty>
|
||||||
|
<ram:Name>Our Company</ram:Name>
|
||||||
|
<ram:SpecifiedLegalOrganization>
|
||||||
|
</ram:SpecifiedLegalOrganization>
|
||||||
|
<ram:PostalTradeAddress>
|
||||||
|
<ram:PostcodeCode>23456</ram:PostcodeCode>
|
||||||
|
<ram:LineOne>Address Line 1</ram:LineOne>
|
||||||
|
<ram:LineTwo>Address Line 2</ram:LineTwo>
|
||||||
|
<ram:CityName>Potsdam</ram:CityName>
|
||||||
|
<ram:CountryID>DE</ram:CountryID>
|
||||||
|
<ram:CountryName>Germany</ram:CountryName>
|
||||||
|
<ram:CountrySubDivisionID>DE-RR</ram:CountrySubDivisionID>
|
||||||
|
<ram:CountrySubDivisionName>Brandenburg</ram:CountrySubDivisionName>
|
||||||
|
</ram:PostalTradeAddress>
|
||||||
|
</ram:BuyerTradeParty>
|
||||||
|
<ram:BuyerOrderReferencedDocument>
|
||||||
|
<ram:IssuerAssignedID></ram:IssuerAssignedID>
|
||||||
|
</ram:BuyerOrderReferencedDocument>
|
||||||
|
</ram:ApplicableHeaderTradeAgreement>
|
||||||
|
<ram:ApplicableHeaderTradeDelivery>
|
||||||
|
</ram:ApplicableHeaderTradeDelivery>
|
||||||
|
<ram:ApplicableHeaderTradeSettlement>
|
||||||
|
<ram:PaymentReference>RE2024.01234</ram:PaymentReference>
|
||||||
|
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
|
||||||
|
<ram:InvoiceDateTime>
|
||||||
|
<udt:DateTimeString>20240617</udt:DateTimeString>
|
||||||
|
</ram:InvoiceDateTime>
|
||||||
|
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||||
|
<ram:TypeCode>1</ram:TypeCode>
|
||||||
|
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:CalculatedAmount currencyID="EUR">484.50</ram:CalculatedAmount>
|
||||||
|
<ram:TypeCode>VAT</ram:TypeCode>
|
||||||
|
<ram:BasisAmount>2550.00</ram:BasisAmount>
|
||||||
|
<ram:CategoryCode>S</ram:CategoryCode>
|
||||||
|
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:ApplicableTradeTax>
|
||||||
|
<ram:CalculatedAmount currencyID="EUR">21.00</ram:CalculatedAmount>
|
||||||
|
<ram:BasisAmount>300.00</ram:BasisAmount>
|
||||||
|
<ram:RateApplicablePercent>7.00</ram:RateApplicablePercent>
|
||||||
|
</ram:ApplicableTradeTax>
|
||||||
|
<ram:SpecifiedTradePaymentTerms>
|
||||||
|
<ram:DueDateDateTime>
|
||||||
|
<udt:DateTimeString>20240701</udt:DateTimeString>
|
||||||
|
</ram:DueDateDateTime>
|
||||||
|
<ram:PartialPaymentAmount currencyID="EUR">3355.50</ram:PartialPaymentAmount>
|
||||||
|
</ram:SpecifiedTradePaymentTerms>
|
||||||
|
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||||
|
<ram:LineTotalAmount currencyID="EUR">2850.00</ram:LineTotalAmount>
|
||||||
|
<ram:TaxBasisTotalAmount currencyID="EUR">2850.00</ram:TaxBasisTotalAmount>
|
||||||
|
<ram:TaxTotalAmount currencyID="EUR">505.50</ram:TaxTotalAmount>
|
||||||
|
<ram:GrandTotalAmount currencyID="EUR">3355.50</ram:GrandTotalAmount>
|
||||||
|
<ram:DuePayableAmount currencyID="EUR">3355.50</ram:DuePayableAmount>
|
||||||
|
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||||
|
</ram:ApplicableHeaderTradeSettlement>
|
||||||
|
</rsm:SupplyChainTradeTransaction>
|
||||||
|
</rsm:CrossIndustryInvoice>
|
|
@ -7,6 +7,86 @@
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
|
parsed_data_ci_invoice = {
|
||||||
|
'buyer_party': {
|
||||||
|
'city': 'Potsdam',
|
||||||
|
'name': 'Our Company',
|
||||||
|
'postal_code': '23456',
|
||||||
|
'street': 'Address Line 1\nAddress Line 2'},
|
||||||
|
'invoice_date': date(2024, 6, 17),
|
||||||
|
'invoice_number': 'RE2024.01234',
|
||||||
|
'lines_data': [{
|
||||||
|
'taxes': [{
|
||||||
|
'type': 'VAT',
|
||||||
|
'percent': Decimal('19.00'),
|
||||||
|
'category_code': 'S'}],
|
||||||
|
'total': {'amount': Decimal('1350.00')},
|
||||||
|
'line_no': '1',
|
||||||
|
'quantity': {
|
||||||
|
'billed': Decimal('1.0'),
|
||||||
|
'unit_code': 'KGM'},
|
||||||
|
'unit_net_price': {'amount': Decimal('1350.00')},
|
||||||
|
}, {
|
||||||
|
'taxes': [{
|
||||||
|
'type': 'VAT',
|
||||||
|
'percent': Decimal('19.00'),
|
||||||
|
'category_code': 'S'}],
|
||||||
|
'total': {'amount': Decimal('1200.00')},
|
||||||
|
'line_no': '2',
|
||||||
|
'quantity': {
|
||||||
|
'billed': Decimal('1.5'),
|
||||||
|
'unit_code': 'KGM'},
|
||||||
|
'unit_net_price': {'amount': Decimal('800.00')},
|
||||||
|
}, {
|
||||||
|
'taxes': [{'percent': Decimal('7.00')}],
|
||||||
|
'total': {'amount': Decimal('300.00')},
|
||||||
|
'line_no': '3',
|
||||||
|
'quantity': {
|
||||||
|
'billed': Decimal('2.0'),
|
||||||
|
'unit_code': 'MTR'},
|
||||||
|
'unit_net_price': {'amount': Decimal('150.00')}}],
|
||||||
|
'note_list': [{
|
||||||
|
'Content': 'Description of invoice',
|
||||||
|
'ContentCode': None,
|
||||||
|
'SubjectCode': None,
|
||||||
|
}, {
|
||||||
|
'Content': 'Some notes to the customer.',
|
||||||
|
'ContentCode': '1',
|
||||||
|
'SubjectCode': None,
|
||||||
|
}, {
|
||||||
|
'Content': 'Goes to field comment.',
|
||||||
|
'ContentCode': '22',
|
||||||
|
'SubjectCode': '42'}],
|
||||||
|
'payment': {
|
||||||
|
'bank': [{'type': '1'}],
|
||||||
|
'currency': 'EUR',
|
||||||
|
'reference': 'RE2024.01234',
|
||||||
|
'taxes': [{
|
||||||
|
'base': Decimal('2550.00'),
|
||||||
|
'type': 'VAT',
|
||||||
|
'amount': Decimal('484.50'),
|
||||||
|
'percent': Decimal('19.00'),
|
||||||
|
'category_code': 'S',
|
||||||
|
}, {
|
||||||
|
'base': Decimal('300.00'),
|
||||||
|
'amount': Decimal('21.00'),
|
||||||
|
'percent': Decimal('7.00')}],
|
||||||
|
'terms': [{
|
||||||
|
'amount': Decimal('3355.50'),
|
||||||
|
'duedate': date(2024, 7, 1)}]},
|
||||||
|
'seller_party': {
|
||||||
|
'city': 'Berlin',
|
||||||
|
'name': 'Name of the Supplier',
|
||||||
|
'postal_code': '12345',
|
||||||
|
'street': 'Street of Supplier No 1'},
|
||||||
|
'total': {
|
||||||
|
'amount': Decimal('2850.00'),
|
||||||
|
'duepayable': Decimal('3355.50'),
|
||||||
|
'grand': Decimal('3355.50'),
|
||||||
|
'taxbase': Decimal('2850.00'),
|
||||||
|
'taxtotal': Decimal('505.50')}}
|
||||||
|
|
||||||
|
|
||||||
parsed_data_facturx_en16931 = {
|
parsed_data_facturx_en16931 = {
|
||||||
'buyer_party': {
|
'buyer_party': {
|
||||||
'city': 'Potsdam',
|
'city': 'Potsdam',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue