diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js index 66aa4f1..2eadac4 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/schemaValidator.js @@ -57,6 +57,9 @@ const validate_schema = (data, schema,version) => { const statusSchema = loadSchema("status", version); const onStatusSchema = loadSchema("on_status", version); + const cancelSchema = loadSchema("cancel", version); + const onCancelSchema = loadSchema("on_cancel", version); + const Ajv = require("ajv"); const ajv = new Ajv({ allErrors: true, @@ -84,6 +87,8 @@ const validate_schema = (data, schema,version) => { .addSchema(onUpdateSchema) .addSchema(statusSchema) .addSchema(onStatusSchema) + .addSchema(cancelSchema) + .addSchema(onCancelSchema) .addKeyword("isEndTimeGreater", { validate: (schema, data) => isEndTimeGreater(data), }) diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/cancel.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/cancel.js new file mode 100644 index 0000000..55a5e8b --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/cancel.js @@ -0,0 +1,110 @@ +module.exports = { + $id: "http://example.com/schema/cancelSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/on_confirm/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { + $data: "/on_confirm/0/context/location/country/code", + }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "cancel", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/on_confirm/0/context/transaction_id" }, + }, + message_id: { + type: "string", + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + const: "PT30S", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order_id: { + type: "string", + const: { $data: "/on_confirm/0/message/order/id" }, + }, + cancellation_reason_id: { + order_id: { + type: "string", + }, + }, + + }, + additionalProperties: false, + required: ["order_id", "cancellation_reason_id"], + }, + }, + required: ["context", "message"], + +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js index cece70e..952da95 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/confirm.js @@ -105,6 +105,10 @@ module.exports = { properties: { id: { type: "string", + not: { + const: { $data: "3/context/transaction_id" }, + }, + errorMessage:"Order ID must not be the same as Transaction ID - ${3/context/transaction_id}." }, state: { type: "string", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js index 70d6924..dae8f08 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/init.js @@ -263,6 +263,8 @@ module.exports = { }, tax_id: { type: "string", + pattern: "^[0-9]{2}[A-Z]{5}[0-9]{4}[0-9A-Z]{4}$", + errorMessage: "should be valid", }, email: { type: "string", @@ -493,7 +495,8 @@ module.exports = { }, collected_by:{ type:"string", - enum:["BAP","BPP"] + enum:["BAP","BPP"], + const: { $data: "/on_select/0/message/order/payments/0/collected_by" }, } }, required: ["type","collected_by"], diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js index d01fe98..abd8ad0 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/master.js @@ -73,6 +73,18 @@ module.exports = { items: { $ref: "onStatusSchema#", }, + }, + cancel: { + type: "array", + items: { + $ref: "cancelSchema#", + }, + }, + on_cancel: { + type: "array", + items: { + $ref: "onCancelSchema#", + }, } }, }; 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 new file mode 100644 index 0000000..570a209 --- /dev/null +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_cancel.js @@ -0,0 +1,799 @@ +const constants = require("../../../utils/constants"); +module.exports = { + $id: "http://example.com/schema/onCancelSchema", + type: "object", + properties: { + context: { + type: "object", + properties: { + domain: { + type: "string", + }, + location: { + type: "object", + properties: { + city: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/city/code" }, + }, + }, + required: ["code"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + const: { $data: "/search/0/context/location/country/code" }, + }, + }, + required: ["code"], + }, + }, + required: ["city", "country"], + }, + action: { + type: "string", + const: "on_cancel", + }, + version: { + type: "string", + const: "2.0.2", + }, + bap_id: { + type: "string", + }, + bap_uri: { + type: "string", + }, + bpp_id: { + type: "string", + }, + bpp_uri: { + type: "string", + }, + transaction_id: { + type: "string", + const: { $data: "/select/0/context/transaction_id" }, + errorMessage: + "Transaction ID should be same across the transaction: ${/select/0/context/transaction_id}", + }, + message_id: { + type: "string", + }, + timestamp: { + type: "string", + format: "date-time", + }, + ttl: { + type: "string", + }, + }, + required: [ + "domain", + "location", + "action", + "version", + "bap_id", + "bap_uri", + "bpp_id", + "bpp_uri", + "transaction_id", + "message_id", + "timestamp", + "ttl", + ], + }, + message: { + type: "object", + properties: { + order: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/confirm/0/message/order/id" }, + }, + state: { + type: "string", + enum: ["Cancelled"], + }, + cancellation: { + type: "object", + properties: { + reason: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + cancelled_by: { + type: "string", + }, + }, + required: ["reason", "cancelled_by"], + }, + provider: { + type: "object", + properties: { + id: { + type: "string", + const: { $data: "/select/0/message/order/provider/id" }, + }, + locations: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + }, + required: ["id"], + }, + }, + }, + required: ["id", "locations"], + }, + items: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + payment_ids: { + type: "array", + items: { + type: "string", + }, + }, + fulfillment_ids: { + type: "array", + items: { + type: "string", + }, + }, + quantity: { + type: "object", + properties: { + selected: { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + }, + additionalProperties: false, + required: ["selected"], + }, + }, + required: ["id", "fulfillment_ids", "quantity", "payment_ids"], + }, + }, + billing: { + type: "object", + properties: { + name: { + type: "string", + const: { $data: "/init/0/message/order/billing/name" }, + }, + address: { + type: "string", + const: { $data: "/init/0/message/order/billing/address" }, + }, + state: { + type: "object", + properties: { + name: { + type: "string", + const: { + $data: "/init/0/message/order/billing/state/name", + }, + }, + }, + required: ["name"], + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + const: { + $data: "/init/0/message/order/billing/city/name", + }, + }, + required: ["name"], + }, + email: { + type: "string", + const: { $data: "/init/0/message/order/billing/email" }, + }, + phone: { + type: "string", + const: { $data: "/init/0/message/order/billing/phone" }, + }, + }, + required: ["name", "address", "state", "city", "phone"], + }, + fulfillments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + "@ondc/org/provider_name": { + type: "string", + }, + type: { + type: "string", + }, + tracking: { + type: "boolean", + }, + state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + enum: ["Cancelled"], + }, + }, + required: ["code"], + }, + }, + required: ["descriptor"], + }, + stops: { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + enum: ["start", "end"], + }, + location: { + type: "object", + properties: { + id: { + type: "string", + }, + descriptor: { + type: "object", + properties: { + name: { + type: "string", + }, + images: { + type: "array", + items: { + type: "string", + }, + }, + }, + required: ["name"], + }, + gps: { + type: "string", + pattern: + "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$", + errorMessage: "Incorrect gps value", + }, + address: { + type: "string", + }, + city: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + country: { + type: "object", + properties: { + code: { + type: "string", + }, + }, + required: ["code"], + }, + area_code: { + type: "string", + }, + state: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + }, + }, + time: { + type: "object", + properties: { + range: { + type: "object", + properties: { + start: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + end: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + }, + required: ["start", "end"], + }, + timestamp: { + type: "string", + pattern: + "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", + errorMessage: + "should be in RFC 3339 (YYYY-MM-DDTHH:MN:SS.MSSZ) Format", + }, + }, + required: ["range"], + }, + instructions: { + type: "object", + properties: { + name: { + type: "string", + }, + short_desc: { + type: "string", + }, + long_desc: { + type: "string", + }, + images: { + type: "array", + items: { + type: "string", + }, + }, + }, + required: [ + "name", + "short_desc", + "long_desc", + "images", + ], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + email: { + type: "string", + }, + }, + required: ["phone"], + }, + agent: { + type: "object", + properties: { + person: { + type: "object", + properties: { + name: { + type: "string", + }, + }, + required: ["name"], + }, + contact: { + type: "object", + properties: { + phone: { + type: "string", + }, + }, + required: ["phone"], + }, + }, + required: ["person", "contact"], + }, + }, + if: { properties: { type: { const: "start" } } }, + then: { + properties: { + location: { required: ["id", "descriptor", "gps"] }, + }, + }, + else: { + properties: { + location: { required: ["address", "gps"] }, + }, + }, + required: ["type", "location", "time", "contact"], + }, + }, + }, + required: [ + "id", + "@ondc/org/provider_name", + "type", + "tracking", + "state", + "stops", + ], + }, + }, + quote: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + breakup: { + type: "array", + items: { + type: "object", + properties: { + "@ondc/org/item_id": { + type: "string", + }, + "@ondc/org/item_quantity": { + type: "object", + properties: { + count: { + type: "integer", + }, + }, + required: ["count"], + }, + title: { + type: "string", + }, + "@ondc/org/title_type": { + type: "string", + enum: [ + "item", + "discount", + "packing", + "delivery", + "tax", + "misc", + "refund", + ], + }, + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + item: { + type: "object", + properties: { + price: { + type: "object", + properties: { + currency: { + type: "string", + }, + value: { + type: "string", + }, + }, + required: ["currency", "value"], + }, + }, + required: ["price"], + }, + }, + }, + }, + ttl: { + type: "string", + }, + }, + isQuoteMatching: true, + + required: ["price", "breakup", "ttl"], + }, + payments: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + params: { + type: "object", + properties: { + currency: { + type: "string", + }, + transaction_id: { + type: "string", + }, + amount: { + type: "string", + }, + }, + required: ["currency", "amount"], + }, + status: { + type: "string", + enum: ["PAID", "NOT-PAID"], + }, + type: { + type: "string", + enum: [ + "PRE-FULFILLMENT", + "ON-FULFILLMENT", + "POST-FULFILLMENT", + ], + + const: { + $data: "/on_confirm/0/message/order/payments/0/type", + }, + }, + collected_by: { + type: "string", + const: { + $data: + "/on_confirm/0/message/order/payments/0/collected_by", + }, + enum: ["BAP", "BPP"], + }, + "@ondc/org/buyer_app_finder_fee_type": { + type: "string", + const: { + $data: + "/confirm/0/message/order/payments/0/@ondc~1org~1buyer_app_finder_fee_type", + }, + }, + "@ondc/org/buyer_app_finder_fee_amount": { + type: "string", + const: { + $data: + "/confirm/0/message/order/payments/0/@ondc~1org~1buyer_app_finder_fee_amount", + }, + }, + "@ondc/org/settlement_basis": { + type: "string", + const: { + $data: + "/on_confirm/0/message/order/payments/0/@ondc~1org~1settlement_basis", + }, + }, + "@ondc/org/settlement_window": { + type: "string", + const: { + $data: + "/on_confirm/0/message/order/payments/0/@ondc~1org~1settlement_window", + }, + }, + "@ondc/org/withholding_amount": { + type: "string", + const: { + $data: + "/on_confirm/0/message/order/payments/0/@ondc~1org~1withholding_amount", + }, + }, + "@ondc/org/settlement_details": { + type: "array", + items: { + type: "object", + properties: { + settlement_counterparty: { + type: "string", + enum: ["seller-app", "buyer-app"], + }, + settlement_phase: { + type: "string", + }, + settlement_type: { + type: "string", + enum: ["upi", "neft", "rtgs"], + }, + beneficiary_name: { + type: "string", + }, + upi_address: { + type: "string", + }, + settlement_bank_account_no: { + type: "string", + }, + settlement_ifsc_code: { + type: "string", + }, + bank_name: { + type: "string", + }, + branch_name: { + type: "string", + }, + }, + allOf: [ + { + if: { + properties: { + settlement_type: { + const: "upi", + }, + }, + }, + then: { + required: ["upi_address"], + }, + }, + { + if: { + properties: { + settlement_type: { + const: ["neft", "rtgs"], + }, + }, + }, + then: { + required: [ + "settlement_ifsc_code", + "settlement_bank_account_no", + ], + }, + }, + ], + required: ["settlement_counterparty", "settlement_type"], + }, + }, + }, + if: { properties: { type: { const: "ON-FULFILLMENT" } } }, + then: { + properties: { + collected_by: { + const: "BPP", + }, + }, + }, + required: [ + "id", + "params", + "status", + "type", + "collected_by", + "@ondc/org/buyer_app_finder_fee_type", + "@ondc/org/buyer_app_finder_fee_amount", + "@ondc/org/settlement_basis", + "@ondc/org/settlement_window", + "@ondc/org/withholding_amount", + ], + }, + }, + + documents: { + type: "array", + items: { + type: "object", + properties: { + url: { + type: "string", + }, + label: { + type: "string", + }, + }, + required: ["url", "label"], + }, + }, + created_at: { + type: "string", + format: "date-time", + const: { $data: "/confirm/0/message/order/created_at" }, + errorMessage: + "order/created_at should remain same as in /confirm - ${/confirm/0/message/order/created_at}", + }, + updated_at: { + type: "string", + format: "date-time", + }, + tags: { + type: "array", + minItems: 3, + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: constants.TERMS, + }, + }, + }, + list: { + type: "array", + items: { + type: "object", + properties: { + descriptor: { + properties: { + code: { + type: "string", + enum: constants.B2B_BPP_TERMS, + }, + }, + }, + value: { + type: "string", + }, + }, + required: ["descriptor", "value"], + }, + }, + }, + required: ["descriptor", "list"], + }, + }, + }, + additionalProperties: false, + required: [ + "id", + "state", + "provider", + "items", + "billing", + "fulfillments", + "quote", + "payments", + "cancellation", + ], + }, + }, + required: ["order"], + }, + }, + required: ["context", "message"], +}; diff --git a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js index 54867f3..daa224a 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/B2B_json_schema/v2/on_init.js @@ -117,6 +117,7 @@ module.exports = { }, }, required: ["id"], + additionalProperties: false }, provider_location: { type: "object", @@ -129,6 +130,7 @@ module.exports = { }, }, required: ["id"], + additionalProperties: false }, items: { type: "array", 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 716a3f2..9afe1df 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 @@ -734,58 +734,60 @@ module.exports = { }, }, return_terms: { - type: "object", - properties: { - fulfillment_state: { - type: "object", - properties: { - descriptor: { - type: "object", - properties: { - code: { - type: "string", + type: "array", + items: { + properties: { + fulfillment_state: { + type: "object", + properties: { + descriptor: { + type: "object", + properties: { + code: { + type: "string", + }, }, + required: ["code"], }, - required: ["code"], }, + required: ["descriptor"], }, - required: ["descriptor"], - }, - return_eligible: { - type: "boolean", - }, - return_time: { - type: "object", - properties: { - duration: { - type: "string", - }, + return_eligible: { + type: "boolean", }, - required: ["duration"], - }, - return_location: { - type: "object", - properties: { - address: { - type: "string", + return_time: { + type: "object", + properties: { + duration: { + type: "string", + }, }, - gps: { - type: "string", + required: ["duration"], + }, + return_location: { + type: "object", + properties: { + address: { + type: "string", + }, + gps: { + type: "string", + }, }, + required: ["address", "gps"], + }, + fulfillment_managed_by: { + type: "string", }, - required: ["address", "gps"], - }, - fulfillment_managed_by: { - type: "string", }, + required: [ + "fulfillment_state", + "return_eligible", + "return_time", + "return_location", + "fulfillment_managed_by", + ], }, - required: [ - "fulfillment_state", - "return_eligible", - "return_time", - "return_location", - "fulfillment_managed_by", - ], }, replacement_terms: { @@ -864,7 +866,7 @@ module.exports = { }, }, }, - additionalProperties:false, + additionalProperties: false, required: [ "id", "descriptor", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js index 56701b7..4f4e201 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onCancelSchema.js @@ -522,7 +522,7 @@ module.exports = { properties: { code: { type: "string", - const: "rto_event", + enum: constants.CANCELLATION_TAGS_CODES, }, list: { type: "array", diff --git a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js index 71dd9a7..30a361c 100644 --- a/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js +++ b/utilities/logistics-b2b/log-verification-utility/schema/logistics_api_json_schema/v1.2/onSearchSchema.js @@ -304,6 +304,7 @@ module.exports = { additionalProperties:false, required: [ "id", + "parent_item_id", "category_id", "fulfillment_id", "descriptor", 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 7aff9a5..0812e7e 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,9 +157,23 @@ module.exports = { }, duration: { type: "string", +<<<<<<< HEAD }, timestamp: { type: "string", +======= + const: { + $data: + "/on_confirm/0/message/order/items/0/time/duration", + }, + }, + timestamp: { + type: "string", + const: { + $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/b2b/b2bConfirm.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bConfirm.js index 2309ecf..17a33b3 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bConfirm.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bConfirm.js @@ -11,7 +11,7 @@ const checkConfirm = async (data, msgIdSet) => { let payments = confirm?.payments; let items = confirm.items; - const selectedItems = dao.getValue("slctdItemsArray"); + const selectedItems = dao.getValue("onSlctdItemsArray"); try { console.log("Comparing items object with /select"); diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js index 2bc9084..2d6bbbf 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bInit.js @@ -9,7 +9,7 @@ const checkInit = (data, msgIdSet) => { init = init.message.order; let items = init.items; - const selectedItems = dao.getValue("slctdItemsArray"); + const selectedItems = dao.getValue("onSlctdItemsArray"); try { console.log("Comparing items object with /select"); diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js index 9ed628e..72b9b68 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSearch.js @@ -72,7 +72,6 @@ const checkOnSearch = async (data, msgIdSet) => { itemTags.forEach((tag) => { let { descriptor, list } = tag; - console.log(descriptor.code); if (descriptor?.code === "attribute" && constants.ATTR_DOMAINS.includes(domain)) { if (domain === "ONDC:RET12") { diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSelect.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSelect.js index 49714a9..d948165 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSelect.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnSelect.js @@ -12,6 +12,8 @@ const checkOnSelect = async (data, msgIdSet) => { let fulfillments = onSelect?.fulfillments; let ffState, ffId; let deliveryQuoteItem = false; + let deliveryCharge = 0 + dao.setValue("onSlctdItemsArray", items) const selectedItems = dao.getValue("slctdItemsArray"); try { console.log("Checking fulfillment object in /on_select"); @@ -54,6 +56,8 @@ const checkOnSelect = async (data, msgIdSet) => { breakup["@ondc/org/item_id"] === ffId ) { deliveryQuoteItem = true; + deliveryCharge= breakup?.price?.value + console.log("deliverycharge",deliveryCharge); } if ( breakup["@ondc/org/title_type"] === "item" && @@ -82,8 +86,8 @@ const checkOnSelect = async (data, msgIdSet) => { if (!deliveryQuoteItem && ffState === "Serviceable") { onSelectObj.deliveryQuoteErr = `Delivery charges should be provided in quote/breakup when fulfillment is 'Serviceable'`; } - if (deliveryQuoteItem && ffState === "Non-serviceable") { - onSelectObj.deliveryQuoteErr = `Delivery charges are not required in quote/breakup when fulfillment is 'Non-serviceable'`; + if (deliveryQuoteItem && deliveryCharge!=0 && ffState === "Non-serviceable") { + onSelectObj.deliveryQuoteErr = `Delivery charges are not required or should be zero in quote/breakup when fulfillment is 'Non-serviceable'`; } if (ffState === "Non-serviceable" && !data.error) { diff --git a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js index 32a9a12..bdb1ef6 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/b2b/b2bOnStatus.js @@ -70,7 +70,7 @@ const checkOnStatus = (data, msgIdSet) => { } } }); - if(invoice) onStatusObj.invoiceErr=`/documents (Invoice) is not required before order is picked up` + if(invoice) onStatusObj.invoiceErr=`/documents (Invoice) is not required before order is picked up for Non RFQ Flow.` } //Order-picked-up diff --git a/utilities/logistics-b2b/log-verification-utility/utils/constants.js b/utilities/logistics-b2b/log-verification-utility/utils/constants.js index fdc48b3..7b3912a 100755 --- a/utilities/logistics-b2b/log-verification-utility/utils/constants.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/constants.js @@ -168,7 +168,8 @@ module.exports = Object.freeze({ "RTO-Disposed", "Cancelled", ], - CANCELLATION_TAGS_LIST:["retry_count","rto_id","cancellation_reason_id","sub_reason_id","cancelled_by"], + CANCELLATION_TAGS_CODES:["rto_event","precancel_state"], + CANCELLATION_TAGS_LIST:["retry_count","rto_id","cancellation_reason_id","sub_reason_id","cancelled_by","fulfillment_state","updated_at"], FASHION_ATTRIBUTES : ["brand","colour","size","gender","material"], ELECTRONICS_ATTRIBUTES: ["brand","model"], MANDATORY_ATTRIBUTES: ["brand"], diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js index 1dbeee1..1d1624b 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnCancel.js @@ -10,7 +10,7 @@ const checkOnCancel = (data, msgIdSet) => { let version = on_cancel.context.core_version; let messageId = on_cancel.context.message_id; const providerId = on_cancel.message?.provider?.id; - + let selectedItem; on_cancel = on_cancel.message.order; let onSearchItemsArr = dao.getValue(`${on_cancel?.provider?.id}itemsArr`); let ffState; @@ -44,9 +44,10 @@ const checkOnCancel = (data, msgIdSet) => { } catch (error) { console.log(error); } + if (onSearchItemsArr) { - let selectedItem = onSearchItemsArr.filter( - (element) => element.parent_item_id === dao.getValue("selectedItem") + selectedItem = onSearchItemsArr.filter( + (element) => element?.parent_item_id === dao.getValue("selectedItem") ); selectedItem = selectedItem[0]; } @@ -68,12 +69,15 @@ const checkOnCancel = (data, msgIdSet) => { onCancelObj.ordrStatErr = `Order state should be 'Cancelled' for fulfillment state - ${ffState}`; } if (fulfillments.length > 1) { - if (!fulfillment.start.time.timestamp) { + if (!fulfillment?.start?.time?.timestamp) { onCancelObj.msngPickupTimeErr = `Pickup timestamp (fulfillments/start/time/timestamp) is missing for fulfillment state - ${ffState}`; } } - if (fulfillment.start.time.timestamp && dao.getValue("pickupTime")) { + if ( + fulfillment?.start?.time?.timestamp && + dao.getValue("pickupTime") + ) { if ( !_.isEqual( dao.getValue("pickupTime"), @@ -88,28 +92,33 @@ const checkOnCancel = (data, msgIdSet) => { if (version === "1.2.0") { if (dao.getValue("rts") === "yes") { if (!fulfillment?.start?.time) { - onCancelObj.msngStrtTime = `Pickup time range (fulfillments/start/time) is missing`; + onCancelObj.msngStrtTime = `Pickup time range (fulfillments/start/time) is missing for fulfillment type - '${fulfillment.type}'`; } if (!fulfillment?.end?.time) { - onCancelObj.msngDlvryTime = `Delivery time range (fulfillments/end/time) is missing`; + onCancelObj.msngDlvryTime = `Delivery time range (fulfillments/end/time) is missing for fulfillment type - '${fulfillment.type}'`; } } let fulTags = fulfillment?.tags; - let rtoID; - fulTags.forEach((tag) => { - if (tag.code === "rto_event") { - const lists = tag.list; - lists.forEach((list) => { - if (list.code === "rto_id") { - rtoID = list.value; + if (!fulTags) { + onCancelObj.msngflfllmntTags = `fulfillments/tags are required in case of RTO (rto_event, pre_cancel_state)`; + } else { + let rtoID; + + fulTags.forEach((tag) => { + if (tag.code === "rto_event") { + const lists = tag.list; + lists.forEach((list) => { + if (list.code === "rto_id") { + rtoID = list.value; - if (rtoID !== selectedItem.fulfillment_id) { - onCancelObj.rtoIdTagsErr = `rto_id '${rtoID}' in fulfillments/tags does not match with the one provided in on_search '${selectedItem.fulfillment_id}' in /fulfillments`; + if (rtoID !== selectedItem.fulfillment_id) { + onCancelObj.rtoIdTagsErr = `rto_id '${rtoID}' in fulfillments/tags does not match with the one provided in on_search '${selectedItem.fulfillment_id}' in /fulfillments`; + } } - } - }); - } - }); + }); + } + }); + } } } } else if (fulfillment.type === "RTO" || fulfillment.type === "Return") { @@ -135,7 +144,7 @@ const checkOnCancel = (data, msgIdSet) => { } }); } catch (error) { - console.log(`Error checking fulfillments/start in /on_cancel`); + console.trace(`Error checking fulfillments/start in /on_cancel`); } return onCancelObj; diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnTrack.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnTrack.js index 440291e..27566c1 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnTrack.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/logOnTrack.js @@ -8,18 +8,22 @@ const checkOnTrack = (data, msgIdSet) => { let on_track = data; let contextTimestamp = on_track?.context?.timestamp; - on_track = on_track.message.tracking; + on_track = on_track?.message?.tracking; - if (on_track?.location.updated_at > contextTimestamp) { + if (on_track?.location?.updated_at > contextTimestamp) { onTrackObj.updatedAtErr = `tracking/location/updated_at cannot be future dated w.r.t context/timestamp`; } - if (on_track?.location.time.timestamp > contextTimestamp) { - onTrackObj.updatedAtErr = `tracking/location/time/timestamp cannot be future dated w.r.t context/timestamp`; + if (on_track?.location?.time?.timestamp > contextTimestamp) { + onTrackObj.lctnTimeAtErr = `tracking/location/time/timestamp cannot be future dated w.r.t context/timestamp`; } + console.log(on_track?.location?.updated_at, on_track?.location?.time?.timestamp); + if(on_track?.location?.updated_at < on_track?.location?.time?.timestamp){ + onTrackObj.updatedAtLctnErr = `tracking/location/time/timestamp cannot be future dated w.r.t tracking/location/updated_at`; + } return onTrackObj; }; diff --git a/utilities/logistics-b2b/log-verification-utility/utils/logistics/msgValidator.js b/utilities/logistics-b2b/log-verification-utility/utils/logistics/msgValidator.js index c7679dc..08ab857 100644 --- a/utilities/logistics-b2b/log-verification-utility/utils/logistics/msgValidator.js +++ b/utilities/logistics-b2b/log-verification-utility/utils/logistics/msgValidator.js @@ -7,6 +7,7 @@ const checkOnUpdate = require("./logOnUpdate"); const checkUpdate = require("./logUpdate"); const checkOnStatus = require("./logOnStatus"); const checkOnCancel = require("./logOnCancel"); +const checkOnTrack = require("./logOnTrack"); const checkSearch = require("./logSearch"); const _ = require("lodash"); @@ -32,17 +33,20 @@ const logisticsVal = async (element, action, msgIdSet) => { return checkOnConfirm(element, msgIdSet); case "update": - return checkUpdate(element,msgIdSet); + return checkUpdate(element, msgIdSet); case "on_update": - return checkOnUpdate(element,msgIdSet) + return checkOnUpdate(element, msgIdSet); case "on_status": - return checkOnStatus(element,msgIdSet) + return checkOnStatus(element, msgIdSet); - case "on_cancel": - return checkOnCancel(element,msgIdSet) + case "on_cancel": + return checkOnCancel(element, msgIdSet); + + case "on_track": + return checkOnTrack(element, msgIdSet); } return busnsErr; }; -module.exports = { logisticsVal }; \ No newline at end of file +module.exports = { logisticsVal };