From 5cd1e123eff30446dba2568637ba834ba1c6240b Mon Sep 17 00:00:00 2001 From: Abhinav Goyal Date: Tue, 20 Feb 2024 15:35:26 +0530 Subject: [PATCH] updated linked order val in on_confirm for logistics --- .../utils/logistics/logOnConfirm.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnConfirm.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnConfirm.js index 5133fd0..822a3ed 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnConfirm.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnConfirm.js @@ -12,6 +12,7 @@ const checkOnConfirm = (data, msgIdSet) => { on_confirm = on_confirm.message.order; let items= on_confirm.items; let fulfillments = on_confirm.fulfillments; + let linkedOrder = on_confirm["@ondc/org/linked_order"] let rts = dao.getValue("rts"); let p2h2p = dao.getValue("p2h2p") let awbNo= dao.getValue("awbNo"); @@ -51,6 +52,27 @@ const checkOnConfirm = (data, msgIdSet) => { console.log(`Error checking fulfillment object in /on_confirm`); } + try { + console.log("checking linked order in /confirm"); + + const orderWeight =linkedOrder?.order?.weight?.value; + + let totalUnitWeight=0; + + linkedOrder?.items.forEach(item=>{ + const quantity = item?.quantity?.measure?.value + const count = item?.quantity?.count + + const unitWeight = (quantity*count) + totalUnitWeight+=unitWeight; + }) + + if(totalUnitWeight.toFixed(2)!=orderWeight.toFixed(2)){ + onCnfrmObj.weightErr=`Total order weight '${orderWeight} does not match the total unit weight of items '${totalUnitWeight}'` + } + } catch (error) { + console.log(error); + } dao.setValue("awbNo",awbNo); return onCnfrmObj; };