diff --git a/document.py b/document.py
index 4cd893a..ec56906 100644
--- a/document.py
+++ b/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',
diff --git a/tests/facturx-basic.xml b/tests/facturx-basic.xml
new file mode 100644
index 0000000..593f771
--- /dev/null
+++ b/tests/facturx-basic.xml
@@ -0,0 +1,192 @@
+
+
+
+
+ urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:basic
+
+
+
+ RE2024.01234
+ 380
+
+ 20240617
+
+
+ Description of invoice
+
+
+ Some notes to the customer.
+
+
+ Goes to field comment.
+ 42
+
+
+
+
+
+ 1
+
+
+ Name of Product 1
+
+
+
+ 1350.00
+
+
+
+ 1.0
+
+
+
+ VAT
+ S
+ 19.00
+
+
+ 1350.00
+
+
+
+
+
+ 2
+
+ Description of Line 2
+
+
+
+ 3
+ Name of Product 2
+
+
+
+ 950.00
+ 1.0
+
+
+ 800.00
+ 1.0
+
+
+
+ 1.5
+
+
+
+ VAT
+ S
+ 19.00
+
+
+ 1200.00
+
+
+
+
+
+ 3
+
+
+ Name of Product 3
+
+
+
+ 150.00
+
+
+
+ 2.0
+
+
+
+ VAT
+ S
+ 7.00
+
+
+ 300.00
+
+
+
+
+
+ Name of the Supplier
+
+
+
+ 12345
+ Street of Supplier No 1
+ Berlin
+ DE
+ Berlin
+
+
+
+ Our Company
+
+
+
+ 23456
+ Address Line 1
+ Address Line 2
+ Potsdam
+ DE
+ Brandenburg
+
+
+
+
+
+
+
+
+
+ RE2024.01234
+ EUR
+
+ 30
+
+ DE02300209000106531065
+
+
+ DE02300209000106531065
+
+
+
+ 484.5
+ VAT
+ 2550.0
+ S
+ 19.00
+
+
+ 21.0
+ VAT
+ 300.0
+ S
+ 7.00
+
+
+ Payment description
+
+ 20240701
+
+ mandat id
+
+
+ 1350.00
+ 2850.00
+ 505.5
+ 3355.50
+ 3355.50
+
+
+
+
diff --git a/tests/facturx-extended.xml b/tests/facturx-extended.xml
index 66ad2ae..28552a1 100644
--- a/tests/facturx-extended.xml
+++ b/tests/facturx-extended.xml
@@ -44,7 +44,7 @@
- 1.0
+ 1.0
@@ -117,8 +117,8 @@
- 1.5
- 1.5
+ 1.5
+ 1.5
20240101
@@ -150,7 +150,7 @@
- 2.0
+ 2.0
diff --git a/tryton.cfg b/tryton.cfg
index da80e85..db07b00 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -2,6 +2,7 @@
version=7.0.0
depends:
document_incoming_invoice
+ edocument_unece
xml:
message.xml
configuration.xml