depency edocument_unece, fix quantity-unit
This commit is contained in:
parent
c5843caf00
commit
7b0ca66b42
4 changed files with 212 additions and 18 deletions
29
document.py
29
document.py
|
@ -25,14 +25,14 @@ from trytond.protocols.jsonrpc import JSONEncoder
|
|||
xml_types = [
|
||||
(['xsd', 'Factur-X_1.07.2_MINIMUM', 'Factur-X_1.07.2_MINIMUM.xsd'],
|
||||
'Factur-X minimum', 'facturx_minimal'),
|
||||
(['xsd', 'Factur-X_1.07.2_EXTENDED', 'Factur-X_1.07.2_EXTENDED.xsd'],
|
||||
'Factur-X extended', 'facturx_extended'),
|
||||
(['xsd', 'Factur-X_1.07.2_EN16931', 'Factur-X_1.07.2_EN16931.xsd'],
|
||||
'Factur-X EN16931', ''),
|
||||
(['xsd', 'Factur-X_1.07.2_BASIC', 'Factur-X_1.07.2_BASIC.xsd'],
|
||||
'Factur-X basic', ''),
|
||||
'Factur-X basic', 'facturx_basic'),
|
||||
(['xsd', 'Factur-X_1.07.2_BASICWL', 'Factur-X_1.07.2_BASICWL.xsd'],
|
||||
'Factur-X basic-wl', ''),
|
||||
(['xsd', 'Factur-X_1.07.2_EN16931', 'Factur-X_1.07.2_EN16931.xsd'],
|
||||
'Factur-X EN16931', ''),
|
||||
(['xsd', 'Factur-X_1.07.2_EXTENDED', 'Factur-X_1.07.2_EXTENDED.xsd'],
|
||||
'Factur-X extended', 'facturx_extended'),
|
||||
(['xsd', 'CII D22B XSD', 'CrossIndustryInvoice_100pD22B.xsd'],
|
||||
'CrossIndustryInvoice D22', ''),
|
||||
(['xsd', 'os-UBL-2.1', 'xsd/maindoc', 'UBL-Invoice-2.1.xsd'],
|
||||
|
@ -416,11 +416,13 @@ class Incoming(metaclass=PoolMeta):
|
|||
'document_incoming_invoice_xml.msg_convert_error',
|
||||
msg='factur-x minimal not supported'))
|
||||
|
||||
def _readxml_facturx_basic(self, xmltree):
|
||||
""" read facturx - basic
|
||||
"""
|
||||
self._readxml_facturx_extended(xmltree)
|
||||
|
||||
def _readxml_facturx_extended(self, xmltree):
|
||||
""" read factur-x extended
|
||||
|
||||
Returns:
|
||||
record: model account.invoice
|
||||
"""
|
||||
Configuration = Pool().get('document.incoming.configuration')
|
||||
|
||||
|
@ -501,7 +503,6 @@ class Incoming(metaclass=PoolMeta):
|
|||
create_party=False)
|
||||
if buyer_party:
|
||||
self.parsed_data['buyer_party'] = buyer_party
|
||||
print('\n# buyer_party-read:', buyer_party)
|
||||
|
||||
# invoice - lines
|
||||
# rsm:CrossIndustryInvoice/
|
||||
|
@ -690,11 +691,9 @@ class Incoming(metaclass=PoolMeta):
|
|||
|
||||
# uom
|
||||
xml_uom = Uom(ModelData.get_id('product', 'uom_unit'))
|
||||
for x_attr in line_data.get('attributes', []):
|
||||
x_uom = x_attr.get('uom', None)
|
||||
if not x_uom:
|
||||
continue
|
||||
units = Uom.search([('symbol', '=', x_uom)])
|
||||
unit_code = line_data.get('quantity', {}).pop('unit_code', None)
|
||||
if unit_code:
|
||||
units = Uom.search([('unece_code', '=', unit_code)])
|
||||
if units:
|
||||
xml_uom = units[0]
|
||||
|
||||
|
@ -940,6 +939,8 @@ class Incoming(metaclass=PoolMeta):
|
|||
('ram:ChargeFreeQuantity', 'chargefree', Decimal),
|
||||
('ram:PackageQuantity', 'package', Decimal),
|
||||
])[0]
|
||||
result['quantity']['unit_code'] = self._readxml_getattrib(
|
||||
xmldata, xpath_quantity + ['ram:BilledQuantity'], 'unitCode')
|
||||
# notice ignored fields
|
||||
for x in [
|
||||
'ShipToTradeParty', 'UltimateShipToTradeParty',
|
||||
|
|
192
tests/facturx-basic.xml
Normal file
192
tests/facturx-basic.xml
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?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>
|
||||
<ram:GuidelineSpecifiedDocumentContextParameter>
|
||||
<ram:ID>urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:basic</ram:ID>
|
||||
</ram:GuidelineSpecifiedDocumentContextParameter>
|
||||
</rsm:ExchangedDocumentContext>
|
||||
<rsm:ExchangedDocument>
|
||||
<ram:ID>RE2024.01234</ram:ID>
|
||||
<ram:TypeCode>380</ram:TypeCode>
|
||||
<ram:IssueDateTime>
|
||||
<udt:DateTimeString format="102">20240617</udt:DateTimeString>
|
||||
</ram:IssueDateTime>
|
||||
<ram:IncludedNote>
|
||||
<ram:Content>Description of invoice</ram:Content>
|
||||
</ram:IncludedNote>
|
||||
<ram:IncludedNote>
|
||||
<ram:Content>Some notes to the customer.</ram:Content>
|
||||
</ram:IncludedNote>
|
||||
<ram:IncludedNote>
|
||||
<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:SpecifiedTradeProduct>
|
||||
<ram:Name>Name of Product 1</ram:Name>
|
||||
</ram:SpecifiedTradeProduct>
|
||||
<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:IncludedNote>
|
||||
<ram:Content>Description of Line 2</ram:Content>
|
||||
</ram:IncludedNote>
|
||||
</ram:AssociatedDocumentLineDocument>
|
||||
<ram:SpecifiedTradeProduct>
|
||||
<ram:GlobalID>3</ram:GlobalID>
|
||||
<ram:Name>Name of Product 2</ram:Name>
|
||||
</ram:SpecifiedTradeProduct>
|
||||
<ram:SpecifiedLineTradeAgreement>
|
||||
<ram:GrossPriceProductTradePrice>
|
||||
<ram:ChargeAmount currencyID="EUR">950.00</ram:ChargeAmount>
|
||||
<ram:BasisQuantity unitCode="C62">1.0</ram:BasisQuantity>
|
||||
</ram:GrossPriceProductTradePrice>
|
||||
<ram:NetPriceProductTradePrice>
|
||||
<ram:ChargeAmount currencyID="EUR">800.00</ram:ChargeAmount>
|
||||
<ram:BasisQuantity unitCode="C62">1.0</ram:BasisQuantity>
|
||||
</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:SpecifiedTradeProduct>
|
||||
<ram:Name>Name of Product 3</ram:Name>
|
||||
</ram:SpecifiedTradeProduct>
|
||||
<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:TypeCode>VAT</ram:TypeCode>
|
||||
<ram:CategoryCode>S</ram:CategoryCode>
|
||||
<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: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:CountrySubDivisionName>Brandenburg</ram:CountrySubDivisionName>
|
||||
</ram:PostalTradeAddress>
|
||||
</ram:BuyerTradeParty>
|
||||
<ram:BuyerOrderReferencedDocument>
|
||||
<ram:IssuerAssignedID/>
|
||||
</ram:BuyerOrderReferencedDocument>
|
||||
</ram:ApplicableHeaderTradeAgreement>
|
||||
<ram:ApplicableHeaderTradeDelivery>
|
||||
</ram:ApplicableHeaderTradeDelivery>
|
||||
<ram:ApplicableHeaderTradeSettlement>
|
||||
<ram:PaymentReference>RE2024.01234</ram:PaymentReference>
|
||||
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
|
||||
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
<ram:TypeCode>30</ram:TypeCode>
|
||||
<ram:PayerPartyDebtorFinancialAccount>
|
||||
<ram:IBANID>DE02300209000106531065</ram:IBANID>
|
||||
</ram:PayerPartyDebtorFinancialAccount>
|
||||
<ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:IBANID>DE02300209000106531065</ram:IBANID>
|
||||
</ram:PayeePartyCreditorFinancialAccount>
|
||||
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
<ram:ApplicableTradeTax>
|
||||
<ram:CalculatedAmount currencyID="EUR">484.5</ram:CalculatedAmount>
|
||||
<ram:TypeCode>VAT</ram:TypeCode>
|
||||
<ram:BasisAmount>2550.0</ram:BasisAmount>
|
||||
<ram:CategoryCode>S</ram:CategoryCode>
|
||||
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
|
||||
</ram:ApplicableTradeTax>
|
||||
<ram:ApplicableTradeTax>
|
||||
<ram:CalculatedAmount currencyID="EUR">21.0</ram:CalculatedAmount>
|
||||
<ram:TypeCode>VAT</ram:TypeCode>
|
||||
<ram:BasisAmount>300.0</ram:BasisAmount>
|
||||
<ram:CategoryCode>S</ram:CategoryCode>
|
||||
<ram:RateApplicablePercent>7.00</ram:RateApplicablePercent>
|
||||
</ram:ApplicableTradeTax>
|
||||
<ram:SpecifiedTradePaymentTerms>
|
||||
<ram:Description>Payment description</ram:Description>
|
||||
<ram:DueDateDateTime>
|
||||
<udt:DateTimeString format="102">20240701</udt:DateTimeString>
|
||||
</ram:DueDateDateTime>
|
||||
<ram:DirectDebitMandateID>mandat id</ram:DirectDebitMandateID>
|
||||
</ram:SpecifiedTradePaymentTerms>
|
||||
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
||||
<ram:LineTotalAmount currencyID="EUR">1350.00</ram:LineTotalAmount>
|
||||
<ram:TaxBasisTotalAmount currencyID="EUR">2850.00</ram:TaxBasisTotalAmount>
|
||||
<ram:TaxTotalAmount currencyID="EUR">505.5</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>
|
|
@ -44,7 +44,7 @@
|
|||
</ram:NetPriceProductTradePrice>
|
||||
</ram:SpecifiedLineTradeAgreement>
|
||||
<ram:SpecifiedLineTradeDelivery>
|
||||
<ram:BilledQuantity unitCode="C62">1.0</ram:BilledQuantity>
|
||||
<ram:BilledQuantity unitCode="KGM">1.0</ram:BilledQuantity>
|
||||
</ram:SpecifiedLineTradeDelivery>
|
||||
<ram:SpecifiedLineTradeSettlement>
|
||||
<ram:ApplicableTradeTax>
|
||||
|
@ -117,8 +117,8 @@
|
|||
</ram:NetPriceProductTradePrice>
|
||||
</ram:SpecifiedLineTradeAgreement>
|
||||
<ram:SpecifiedLineTradeDelivery>
|
||||
<ram:BilledQuantity unitCode="C62">1.5</ram:BilledQuantity>
|
||||
<ram:PackageQuantity unitCode="C62">1.5</ram:PackageQuantity>
|
||||
<ram:BilledQuantity unitCode="KGM">1.5</ram:BilledQuantity>
|
||||
<ram:PackageQuantity unitCode="KGM">1.5</ram:PackageQuantity>
|
||||
<ram:ActualDeliverySupplyChainEvent>
|
||||
<ram:OccurrenceDateTime>
|
||||
<udt:DateTimeString format="102">20240101</udt:DateTimeString>
|
||||
|
@ -150,7 +150,7 @@
|
|||
</ram:NetPriceProductTradePrice>
|
||||
</ram:SpecifiedLineTradeAgreement>
|
||||
<ram:SpecifiedLineTradeDelivery>
|
||||
<ram:BilledQuantity unitCode="C62">2.0</ram:BilledQuantity>
|
||||
<ram:BilledQuantity unitCode="MTR">2.0</ram:BilledQuantity>
|
||||
</ram:SpecifiedLineTradeDelivery>
|
||||
<ram:SpecifiedLineTradeSettlement>
|
||||
<ram:ApplicableTradeTax>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
version=7.0.0
|
||||
depends:
|
||||
document_incoming_invoice
|
||||
edocument_unece
|
||||
xml:
|
||||
message.xml
|
||||
configuration.xml
|
||||
|
|
Loading…
Reference in a new issue