From d1d0e84c002d255d3727307ebdb48c12bf9c7e02 Mon Sep 17 00:00:00 2001 From: Jagannath-Padhy Date: Fri, 3 May 2024 09:37:07 +0530 Subject: [PATCH] on_update fulfillment deliveryObj and location,id check --- schema/Retail/Update/on_update.ts | 2 +- utils/Retail/Update/onUpdate.ts | 32 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/schema/Retail/Update/on_update.ts b/schema/Retail/Update/on_update.ts index 983ab1c8..ef7b16b6 100644 --- a/schema/Retail/Update/on_update.ts +++ b/schema/Retail/Update/on_update.ts @@ -194,7 +194,7 @@ export const onUpdateSchema = { required: ['locality', 'city', 'area_code', 'state'], }, }, - required: ['id', 'gps', 'address'], + required: ['gps', 'address'], }, time: { type: 'object', diff --git a/utils/Retail/Update/onUpdate.ts b/utils/Retail/Update/onUpdate.ts index b6675aec..2f5d0f03 100644 --- a/utils/Retail/Update/onUpdate.ts +++ b/utils/Retail/Update/onUpdate.ts @@ -240,8 +240,38 @@ export const checkOnUpdate = (data: any, msgIdSet: any, apiSeq: any, settlementD logger.error(`Error while checking for item IDs for /${apiSeq}, ${error.stack}`) } - // Compare return_request object + try { + // For Delivery Object + const DELobj = _.filter(on_update.fulfillments, { type: 'Delivery' }) + let del_start_location: any = {} + if (!DELobj.length) { + logger.error(`Delivery object is mandatory for ${apiSeq}`) + const key = `missingDelivery` + onupdtObj[key] = `Delivery object is mandatory for ${apiSeq}` + } else { + // Checking for start object inside Delivery + if (!_.isEmpty(DELobj[0]?.start)) { + const del_obj_start = DELobj[0]?.start + if (!_.isEmpty(del_obj_start?.location)) { + del_start_location = del_obj_start.location + if (!del_start_location.id) { + onupdtObj['Delivery.start.location.id'] = `Delivery fulfillment start location id is missing in ${apiSeq}` + } + } + else { + onupdtObj['Delivery.start.location'] = `Delivery fulfillment start location object is missing in ${apiSeq}` + logger.error(`Delivery fulfillment start location is missing in ${apiSeq}`) + } + } else { + onupdtObj['DeliveryFulfillment.start'] = `Delivery fulfillment start object is missing in ${apiSeq}` + } + } + } catch (error: any) { + logger.error(`Error while checking Fulfillments Delivery Obj in /${apiSeq}, ${error.stack}`) + } + + // Compare return_request object if (flow === '6-b') { // Checking for quote_trail price and item quote price try {