Fix for bilingual SKUs with multiple GTINs

master
bleeson 2025-07-23 14:55:18 -07:00
parent 317292b98f
commit ee576aa67f
1 changed files with 11 additions and 4 deletions

View File

@ -84,7 +84,7 @@ def determine_edi_action(edi_filename: pathlib.Path):
"""
944s from Shandex are either:
-Intersite transfer receipt
-Comanufacturer PO receipt
-Comanufacturer receipt
-Customer return
"""
transaction = ''
@ -205,8 +205,15 @@ def gtin_to_sku(gtin):
where replace(ZCASEUPC_0, ' ', '') = :gtin
""",
gtin=gtin,
).first()
return result
).all()
#bilingual products have multiple gtin records, guess at the correct one
best_itmref = ''
for record in result:
if best_itmref == '':
best_itmref = record['ITMREF_0']
elif record['ITMREF_0'].startswith('C'):
best_itmref = record['ITMREF_0']
return best_itmref
def process_intersite_receipt(edi_filename: pathlib.Path):
@ -288,7 +295,7 @@ def process_coman_receipt(edi_filename: pathlib.Path):
# W07*2025*CA**PN*10077652321019*LT*18JUN2027SE***UK*10077652321019
# N9*LI*1
_, qty_str, uom, _, _, gtin, _, lot = fields[:8]
itmref = gtin_to_sku(gtin)['ITMREF_0']
itmref = gtin_to_sku(gtin)
subdetail = ReceiptSubDetail(
pcu=fix_uom(uom),
qtypcu=int(qty_str),