Skip to content

Commit

Permalink
Merge pull request ONDC-Official#62 from abhinavv245/main
Browse files Browse the repository at this point in the history
minor bug fix
  • Loading branch information
tanya-ondc authored Feb 20, 2024
2 parents 621c33d + 5cd1e12 commit bed7df7
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ module.exports = {
location: { required: ["address", "gps"] },
},
},
required: ["type", "location", "time", "contact"],
required: ["type", "location", "contact"],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ module.exports = {
required: ["phone"],
},
},
required: ["type", "location", "time", "contact"],
required: ["type", "location", "contact"],
},
},
rateable: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ module.exports = {
required: ["unit", "value"],
},
count: {
type: "string",
type: "integer",
},
},
required: ["measure", "count"],
Expand Down Expand Up @@ -552,7 +552,7 @@ module.exports = {
required: ["unit", "value"],
},
count: {
type: "string",
type: "integer",
},
},
required: ["measure", "count"],
Expand Down Expand Up @@ -582,7 +582,7 @@ module.exports = {
required: ["unit", "value"],
},
count: {
type: "string",
type: "integer",
},
},
required: ["measure", "count"],
Expand Down Expand Up @@ -614,7 +614,7 @@ module.exports = {
type: "string",
},
},
"add-ons": {
"add_ons": {
type: "array",
items: {
type: "object",
Expand Down Expand Up @@ -824,10 +824,10 @@ module.exports = {
required: ["label", "range"],
},
matched: {
type: "string",
type: "boolean",
},
recommended: {
type: "string",
type: "boolean",
},
tags: {
type: "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ module.exports = {
},
duration: {
type: "string",
<<<<<<< HEAD
},
timestamp: {
type: "string",
=======
const: {
$data:
"/on_confirm/0/message/order/items/0/time/duration",
Expand All @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit bed7df7

Please sign in to comment.