Skip to content

Commit

Permalink
Merge PR #1125 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Feb 11, 2025
2 parents 7727581 + 6e6e1fa commit 7136e69
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<DespatchAdvice xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2">
<cbc:UBLVersionID>2.2</cbc:UBLVersionID>
<cbc:ID>ABCDE/IN/00424</cbc:ID>
<cbc:IssueDate>2023-05-01</cbc:IssueDate>
<cac:OrderReference>
<cbc:ID>000185</cbc:ID>
</cac:OrderReference>
<cac:DespatchSupplierParty>
<cbc:CustomerAssignedAccountID>1069</cbc:CustomerAssignedAccountID>
<cac:Party>
<cac:PartyName>
<cbc:Name/>
</cac:PartyName>
<cac:PostalAddress>
<cbc:StreetName/>
<cbc:CityName/>
<cbc:PostalZone/>
<cac:Country>
<cbc:IdentificationCode/>
</cac:Country>
</cac:PostalAddress>
<cac:Contact>
<cbc:Telephone/>
<cbc:Telefax/>
<cbc:ElectronicMail/>
</cac:Contact>
</cac:Party>
</cac:DespatchSupplierParty>
<cac:DeliveryCustomerParty>
<cac:Party>
<cac:PartyName>
<cbc:Name/>
</cac:PartyName>
<cac:PostalAddress>
<cbc:StreetName/>
<cbc:CityName/>
<cbc:PostalZone/>
<cbc:CountrySubentity/>
<cac:Country>
<cbc:IdentificationCode/>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID/>
<cac:TaxScheme>
<cbc:ID/>
<cbc:TaxTypeCode/>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:Contact>
<cbc:Name/>
<cbc:Telephone/>
<cbc:Telefax/>
<cbc:ElectronicMail/>
</cac:Contact>
</cac:Party>
</cac:DeliveryCustomerParty>
<cac:Shipment>
<cbc:ID/>
<cac:Delivery>
<cac:EstimatedDeliveryPeriod>
<cbc:EndDate>2025-01-14</cbc:EndDate>
<cbc:EndTime>12:13:23</cbc:EndTime>
</cac:EstimatedDeliveryPeriod>
</cac:Delivery>
</cac:Shipment>
<cac:DespatchLine>
<cbc:ID>1</cbc:ID>
<cbc:DeliveredQuantity unitCode="BOUT" unitCodeListAgencyName="WAMAS">100.0</cbc:DeliveredQuantity>
<cac:OrderLineReference>
<cbc:LineID/>
</cac:OrderLineReference>
<cac:Item>
<cac:BuyersItemIdentification>
<cbc:ID>99098 2</cbc:ID>
</cac:BuyersItemIdentification>
</cac:Item>
</cac:DespatchLine>
</DespatchAdvice>
<DespatchAdvice xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2">
<cbc:UBLVersionID>2.2</cbc:UBLVersionID>
<cbc:ID>ABCDE/IN/00409</cbc:ID>
<cbc:IssueDate>2023-05-01</cbc:IssueDate>
<cac:OrderReference>
<cbc:ID>000176</cbc:ID>
</cac:OrderReference>
<cac:DespatchSupplierParty>
<cbc:CustomerAssignedAccountID>1069</cbc:CustomerAssignedAccountID>
<cac:Party>
<cac:PartyName>
<cbc:Name/>
</cac:PartyName>
<cac:PostalAddress>
<cbc:StreetName/>
<cbc:CityName/>
<cbc:PostalZone/>
<cac:Country>
<cbc:IdentificationCode/>
</cac:Country>
</cac:PostalAddress>
<cac:Contact>
<cbc:Telephone/>
<cbc:Telefax/>
<cbc:ElectronicMail/>
</cac:Contact>
</cac:Party>
</cac:DespatchSupplierParty>
<cac:DeliveryCustomerParty>
<cac:Party>
<cac:PartyName>
<cbc:Name/>
</cac:PartyName>
<cac:PostalAddress>
<cbc:StreetName/>
<cbc:CityName/>
<cbc:PostalZone/>
<cbc:CountrySubentity/>
<cac:Country>
<cbc:IdentificationCode/>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID/>
<cac:TaxScheme>
<cbc:ID/>
<cbc:TaxTypeCode/>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:Contact>
<cbc:Name/>
<cbc:Telephone/>
<cbc:Telefax/>
<cbc:ElectronicMail/>
</cac:Contact>
</cac:Party>
</cac:DeliveryCustomerParty>
<cac:Shipment>
<cbc:ID/>
<cac:Delivery>
<cac:EstimatedDeliveryPeriod>
<cbc:EndDate>2025-01-14</cbc:EndDate>
<cbc:EndTime>12:13:23</cbc:EndTime>
</cac:EstimatedDeliveryPeriod>
</cac:Delivery>
</cac:Shipment>
<cac:DespatchLine>
<cbc:ID>1</cbc:ID>
<cbc:DeliveredQuantity unitCode="BOUT" unitCodeListAgencyName="WAMAS">114.0</cbc:DeliveredQuantity>
<cac:OrderLineReference>
<cbc:LineID/>
</cac:OrderLineReference>
<cac:Item>
<cac:BuyersItemIdentification>
<cbc:ID>12766</cbc:ID>
</cac:BuyersItemIdentification>
</cac:Item>
</cac:DespatchLine><cac:DespatchLine>
<cbc:ID>1</cbc:ID>
<cbc:DeliveredQuantity unitCode="BOUT" unitCodeListAgencyName="WAMAS">115.0</cbc:DeliveredQuantity>
<cac:OrderLineReference>
<cbc:LineID/>
</cac:OrderLineReference>
<cac:Item>
<cac:BuyersItemIdentification>
<cbc:ID>12766</cbc:ID>
</cac:BuyersItemIdentification>
</cac:Item>
</cac:DespatchLine>
</DespatchAdvice>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WAMAS ODOO 00000720250114132733WEAKQ0051000212712 ODOO 20250114070918 19700101010000202501140710472025011413132320250114070939 0001069
WAMAS ODOO 00000820250114132733WEAPQ0050000212712 000ABCDE/IN/00424 ODOO 000185 0000019623 00099098 2 00000DISPONIBLE 000000100000000000000000 BOUT 19700101 12 eCAM 173980 N
WAMAS ODOO 00000920250114132733WEAPQ0050000212712 000ABCDE/IN/00409 ODOO 000176 0000019623 00012766 00000DISPONIBLE 000000114000000000000000 BOUT 19700101 12 eCAM 173970 N
WAMAS ODOO 00001020250114132733WEAPQ0050000212712 000ABCDE/IN/00409 ODOO 000176 0000019623 00012766 00000DISPONIBLE 000000115000000000000000 BOUT 19700101 12 eCAM 173970 N
16 changes: 13 additions & 3 deletions base_wamas_ubl/lib/wamas/tests/test_wamas2ubl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ def test_convert_wamas2ubl_picking(self):
lst_expected_output = "WAMAS2UBL-SAMPLE_AUSKQ_WATEKQ_WATEPQ-DESPATCH_ADVICE.xml"
self._convert_wamas2ubl(input_file, lst_expected_output)

def test_convert_wamas2ubl_reception(self):
input_file = "WAMAS2UBL-SAMPLE_WEAKQ_WEAPQ.wamas"
lst_expected_output = "WAMAS2UBL-SAMPLE_WEAKQ_WEAPQ-DESPATCH_ADVICE.xml"
def test_convert_wamas2ubl_reception_simple(self):
input_file = "WAMAS2UBL-SAMPLE_SIMPLE_WEAKQ_WEAPQ.wamas"
lst_expected_output = "WAMAS2UBL-SAMPLE_SIMPLE_WEAKQ_WEAPQ-DESPATCH_ADVICE.xml"
self._convert_wamas2ubl(input_file, lst_expected_output)

def test_convert_wamas2ubl_reception_combined(self):
"""
Test a reception with a single header concerning multiple receptions
This happens when a supplier deliver goods for multiple INs
"""
input_file = "WAMAS2UBL-SAMPLE_COMB_WEAKQ_WEAPQ.wamas"
lst_expected_output = "WAMAS2UBL-SAMPLE_COMB_WEAKQ_WEAPQ-DESPATCH_ADVICE.xml"
self._convert_wamas2ubl(input_file, lst_expected_output)

def test_convert_wamas2ubl_return(self):
Expand Down
33 changes: 26 additions & 7 deletions base_wamas_ubl/lib/wamas/wamas2ubl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import argparse
import logging
from collections import OrderedDict
from pprint import pformat

from freezegun import freeze_time
Expand Down Expand Up @@ -45,29 +46,44 @@ def get_head(self, telegram_type, key_name, head=None):
key,
)

def get_line(self, telegram_type, transfer_key_name, package_key_name=False):
def get_line(
self,
telegram_type,
transfer_key1_name,
transfer_key2_name=False,
package_key_name=False,
):
"""Process a list of dict as lines of the transfers
Parameters:
telegram_type: the key to get the list out of data
transfer_key_name: the key in the dict that serves to identify the
transfer_key1_name: the key in the dict that serves to identify the
parent in transfers
transfer_key2_name: the key in the dict that serves to identify a sub-transfer
package_key_name: the key in the dict that serves to identify the
related package
"""
transfers = {}
if telegram_type not in self.data:
raise ValueError("Missing telegram: %s" % telegram_type)

for line in self.data[telegram_type]:
key = line[transfer_key_name]
key = line.get(transfer_key1_name)
if key not in self.transfers:
_logger.debug(
"Found %s (line) record for unknown transfer, ignoring: %s",
telegram_type,
key,
)
continue
self.transfers[key].setdefault("lines", []).append(line)

# Create a key for the sub-transfer
if transfer_key2_name and line.get(transfer_key2_name):
key = (key, line[transfer_key2_name])
if key not in transfers:
# Copy parent transfer data
transfers[key] = OrderedDict(self.transfers[line[transfer_key1_name]])
transfers[key].setdefault("lines", []).append(line)
if not package_key_name:
continue
package_id = line[package_key_name]
Expand All @@ -80,7 +96,8 @@ def get_line(self, telegram_type, transfer_key_name, package_key_name=False):
)
continue
line["package"] = package
self.transfers[key].setdefault("packages", []).append(package)
transfers[key].setdefault("packages", []).append(package)
self.transfers = transfers


def wamas2dict(msg):
Expand Down Expand Up @@ -121,7 +138,7 @@ def dict2ubl(msg_type, data, extra_data=False):

if msg_type == "ReceptionResponse":
extractor.get_head("WEAKQ", "IvWevk_WevId_WevNr")
extractor.get_line("WEAPQ", "IvWevp_WevId_WevNr")
extractor.get_line("WEAPQ", "IvWevp_WevId_WevNr", "IvWevp_WEAP_WeaId_WeaNr")
elif msg_type == "ReturnResponse":
extractor.get_head("KRETKQ", "IvKretk_KretId_KretNr")
extractor.get_line("KRETPQ", "IvKretp_KretId_KretNr")
Expand All @@ -131,7 +148,9 @@ def dict2ubl(msg_type, data, extra_data=False):
extractor.get_line("AUSPQ", "IvAusp_UrAusId_AusNr")
else:
extractor.get_head("WATEKQ", "IvTek_TeId", extractor.packages)
extractor.get_line("WATEPQ", "IvAusp_UrAusId_AusNr", "IvTep_TeId")
extractor.get_line(
"WATEPQ", "IvAusp_UrAusId_AusNr", package_key_name="IvTep_TeId"
)
else:
raise Exception("Invalid message type: %s" % msg_type)

Expand Down
1 change: 1 addition & 0 deletions base_wamas_ubl/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Jacques-Etienne Baudoux <je@bcim.be>
* Tuan Tran <anhtuan@trobz.com>
* Telmo Santos <telmo.santos@camptocamp.com>

0 comments on commit 7136e69

Please sign in to comment.