diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_cancel.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_cancel.js index 570a209..097447c 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_cancel.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_cancel.js @@ -438,7 +438,7 @@ module.exports = { location: { required: ["address", "gps"] }, }, }, - required: ["type", "location", "time", "contact"], + required: ["type", "location", "contact"], }, }, }, diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js index 31c6737..cf3c0a3 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_confirm.js @@ -426,7 +426,7 @@ module.exports = { required: ["phone"], }, }, - required: ["type", "location", "time", "contact"], + required: ["type", "location", "contact"], }, }, rateable: { diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js index 9afe1df..a5d8c44 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_search.js @@ -522,7 +522,7 @@ module.exports = { required: ["unit", "value"], }, count: { - type: "string", + type: "integer", }, }, required: ["measure", "count"], @@ -552,7 +552,7 @@ module.exports = { required: ["unit", "value"], }, count: { - type: "string", + type: "integer", }, }, required: ["measure", "count"], @@ -582,7 +582,7 @@ module.exports = { required: ["unit", "value"], }, count: { - type: "string", + type: "integer", }, }, required: ["measure", "count"], @@ -614,7 +614,7 @@ module.exports = { type: "string", }, }, - "add-ons": { + "add_ons": { type: "array", items: { type: "object", @@ -824,10 +824,10 @@ module.exports = { required: ["label", "range"], }, matched: { - type: "string", + type: "boolean", }, recommended: { - type: "string", + type: "boolean", }, tags: { type: "array", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js index 9c89d02..87ba678 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/select.js @@ -124,8 +124,9 @@ module.exports = { format: "duration", }, }, - required: ["id", "locations", "ttl"], - errorMessage: "id, locations are mandatory attributes and ttl is required for RFQ Flow" + required: ["id", "locations"], + errorMessage: + "id, locations are mandatory attributes and ttl is required for RFQ Flow", }, items: { type: "array", @@ -369,7 +370,9 @@ module.exports = { }, }, additionalProperties: false, - required: ["id", "type", "stops"], + if: { properties: { type: { const: "Delivery" } } }, + then: { required: ["id", "type", "stops"] }, + else: { required: ["id", "type"] }, }, }, payments: { diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js index 0812e7e..55d31d2 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onUpdateSchema.js @@ -157,11 +157,6 @@ module.exports = { }, duration: { type: "string", -<<<<<<< HEAD - }, - timestamp: { - type: "string", -======= const: { $data: "/on_confirm/0/message/order/items/0/time/duration", @@ -173,7 +168,6 @@ module.exports = { $data: "/on_confirm/0/message/order/items/0/time/timestamp", }, ->>>>>>> patch-reference-implementations-remote/main }, }, required: ["label", "duration", "timestamp"], 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; }; diff --git a/utilities/logistics-b2b/log-verification-utility/utils/utils.js b/utilities/logistics-b2b/log-verification-utility/utils/utils.js index 4dcd474..e6e9502 100755 --- a/utilities/logistics-b2b/log-verification-utility/utils/utils.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/utils.js @@ -199,11 +199,11 @@ const timestampCheck = (date) => { const getVersion = (data,vertical) => { if(vertical==='logistics'){ - if (data?.search[0]?.context?.core_version === "1.1.0") return "v1.1"; + if (data?.search && data?.search[0]?.context?.core_version === "1.1.0") return "v1.1"; else return "v1.2"; } if(vertical==='b2b'){ - if (data?.search[0]?.context?.version === "2.0.1") return "v1"; + if (data?.search && data?.search[0]?.context?.version === "2.0.1") return "v1"; else return "v2"; } @@ -386,12 +386,12 @@ function findDifferencesInArrays(array1, array2) { const differences = []; // Check if arrays have the same length - if (array1.length !== array2.length) { + if (array1?.length !== array2?.length) { return differences; } // Iterate over each item in the arrays - for (let i = 0; i < array1.length; i++) { + for (let i = 0; i < array1?.length; i++) { const item1 = array1[i]; const item2 = array2[i];