Handle when Shandex ships a non-GTIN item
parent
ee576aa67f
commit
8db72f8dfe
|
@ -378,6 +378,30 @@ def get_product_from_gtin(gtin):
|
|||
).first()
|
||||
return result
|
||||
|
||||
|
||||
def get_product_from_itmref(itmref):
|
||||
#pprint.pprint(gtin)
|
||||
with yamamotoyama.get_connection() as database:
|
||||
result = database.query(
|
||||
"""
|
||||
select
|
||||
[ITM].[ITMREF_0],
|
||||
[ITM].[ITMDES1_0],
|
||||
[ITM].[EANCOD_0],
|
||||
[ITM].[ZCASEUPC_0],
|
||||
[ITM].[STU_0]
|
||||
from PROD.ITMMASTER ITM
|
||||
join PROD.ITMFACILIT ITF
|
||||
on ITM.ITMREF_0 = ITF.ITMREF_0
|
||||
and ITF.STOFCY_0 = 'WON'
|
||||
where
|
||||
[ITM].[ITMREF_0] = :itmref
|
||||
""",
|
||||
itmref=itmref,
|
||||
).first()
|
||||
return result
|
||||
|
||||
|
||||
def process_file(edi_filename: pathlib.Path, x3_customer_mapping):
|
||||
"""
|
||||
Convert a specific EDI file into an import file.
|
||||
|
@ -442,15 +466,24 @@ def process_file(edi_filename: pathlib.Path, x3_customer_mapping):
|
|||
_, _, qty_str, uom = fields[:4]
|
||||
#warehouse_shipment.sohnum = sohnum
|
||||
if fields[0] == "LIN":
|
||||
if len(fields) >= 6:
|
||||
#LIN**VN*10077652082224*LT*09032026C#
|
||||
_, _, _, gtin, _, lot = fields[:6]
|
||||
if fields[0] == "AMT":
|
||||
#AMT*LP*53.90
|
||||
_, _, price = fields[:3]
|
||||
lookup_values = get_product_from_gtin(gtin)
|
||||
itmref = lookup_values['ITMREF_0']
|
||||
itmdes = lookup_values['ITMDES1_0']
|
||||
sau = lookup_values['STU_0']
|
||||
else:
|
||||
#LIN**VN*TYTSTRTL487296BASE
|
||||
_, _, _, itmref = fields[:4]
|
||||
lot = ''
|
||||
lookup_values = get_product_from_itmref(itmref)
|
||||
itmref = lookup_values['ITMREF_0']
|
||||
itmdes = lookup_values['ITMDES1_0']
|
||||
sau = lookup_values['STU_0']
|
||||
if fields[0] == "AMT":
|
||||
#AMT*LP*53.90
|
||||
_, _, price = fields[:3]
|
||||
subdetail = WarehouseShipmentSubDetail(
|
||||
qtypcu=-1 * int(qty_str),
|
||||
lot=lot,
|
||||
|
|
Loading…
Reference in New Issue