Skip to content

Commit

Permalink
Merge pull request ONDC-Official#4 from abhinavv245/draft_log_utility
Browse files Browse the repository at this point in the history
B2B and logistics fixes
  • Loading branch information
tanyamadaan authored Jan 24, 2024
2 parents 482fe86 + bc5c327 commit ae45864
Show file tree
Hide file tree
Showing 36 changed files with 1,197 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
const contextTime = data?.context?.timestamp;
const created_at = data?.message?.order?.created_at;
const updated_at = data?.message?.order?.updated_at;
console.log(contextTime,updated_at);
if (
(created_at && created_at > contextTime) ||
(updated_at && updated_at > contextTime)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
isLengthValid: (data) => {
if (data.name.length + data.building.length + data.locality.length > 190)
if (data?.name?.length + data?.building?.length + data?.locality?.length > 190)
return false;
else return true;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
isQuoteMatching: (data) => {
let quotePrice = parseFloat(data?.price?.value);
const breakupArr = data.breakup;
const breakupArr = data?.breakup;
let totalBreakup = 0;
breakupArr.forEach((breakup) => {
totalBreakup += parseFloat(breakup?.price?.value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
isEndTimeGreater: (data) => {
const startTime = parseInt(data.start);
const endTime = parseInt(data.end);
const startTime = parseInt(data?.start);
const endTime = parseInt(data?.end);
return startTime < endTime;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ module.exports = {
properties: {
code: {
type: "string",
enum: ["Serviceable", "Non-Serviceable"],
enum: ["Serviceable", "Non-serviceable"],
},
},
required: ["code"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const constants = require("../../../utils/constants");
module.exports = {
$id: "http://example.com/schema/confirmSchema",
type: "object",
Expand Down Expand Up @@ -58,7 +59,7 @@ module.exports = {
type: "string",
const: { $data: "/select/0/context/transaction_id" },
errorMessage:
"Transaction ID should be same across the transaction: ${/search/0/context/transaction_id}",
"Transaction ID should be same across the transaction: ${/select/0/context/transaction_id}",
},
message_id: {
type: "string",
Expand All @@ -70,7 +71,7 @@ module.exports = {
errorMessage:
"Message ID should not be equal to transaction_id: ${1/transaction_id}",
},
]
],
},
timestamp: {
type: "string",
Expand Down Expand Up @@ -119,13 +120,12 @@ module.exports = {
locations: {
type: "array",
const: { $data: "/init/0/message/order/provider/locations" },
errorMessage:"mismatch from /init",
errorMessage: "mismatch from /init",
items: {
type: "object",
properties: {
id: {
type: "string",

},
},
required: ["id"],
Expand Down Expand Up @@ -209,12 +209,22 @@ module.exports = {
type: "string",
anyOf: [
{
const: { $data: "/init/0/message/order/items/0/tags/0/list/0/value" },
const: {
$data:
"/select/0/message/order/items/0/tags/0/list/0/value",
},
errorMessage:
"Buyer terms should be same as provided in /select",
},
{
const: { $data: "/init/0/message/order/items/0/tags/0/list/1/value" },
}
]
const: {
$data:
"/select/0/message/order/items/0/tags/0/list/1/value",
},
errorMessage:
"Buyer terms should be same as provided in /select",
},
],
},
},
required: ["descriptor", "value"],
Expand Down Expand Up @@ -276,7 +286,7 @@ module.exports = {
const: { $data: "/init/0/message/order/billing/phone" },
},
},

required: ["name", "address", "state", "city", "tax_id", "phone"],
},
fulfillments: {
Expand Down Expand Up @@ -307,8 +317,10 @@ module.exports = {
properties: {
gps: {
type: "string",
pattern: "^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$",
errorMessage: "Incorrect gps value",
pattern:
"^(-?[0-9]{1,3}(?:.[0-9]{6,15})?),( )*?(-?[0-9]{1,3}(?:.[0-9]{6,15})?)$",
errorMessage:
"Incorrect gps value (minimum of six decimal places are required)",
},
address: {
type: "string",
Expand Down Expand Up @@ -421,12 +433,18 @@ module.exports = {
type: "string",
anyOf: [
{
const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/0/value" },
const: {
$data:
"/init/0/message/order/fulfillments/0/tags/0/list/0/value",
},
},
{
const: { $data: "/init/0/message/order/fulfillments/0/tags/0/list/1/value" },
}
]
const: {
$data:
"/init/0/message/order/fulfillments/0/tags/0/list/1/value",
},
},
],
},
},
if: {
Expand Down Expand Up @@ -501,7 +519,14 @@ module.exports = {
},
"@ondc/org/title_type": {
type: "string",
enum: ["item", "discount", "packing", "delivery", "tax", "misc"]
enum: [
"item",
"discount",
"packing",
"delivery",
"tax",
"misc",
],
},
price: {
type: "object",
Expand Down Expand Up @@ -602,23 +627,36 @@ module.exports = {
type: "string",
enum: ["PAID", "NOT-PAID"],
},

type: {
type: "string",
enum: [
"PRE-FULFILLMENT",
"ON-FULFILLMENT",
"POST-FULFILLMENT",
],
const: { $data: "/select/0/message/order/payments/0/type" },
},
collected_by: {
type: "string",
enum: ["BAP", "BPP"],
},
"@ondc/org/buyer_app_finder_fee_type": {
type: "string",
},
"@ondc/org/buyer_app_finder_fee_amount": {
type: "string",
},
"@ondc/org/settlement_basis": {
type: "string",
},
"@ondc/org/settlement_window": {
type: "string",
},
"@ondc/org/withholding_amount": {
type: "string",
},

"@ondc/org/settlement_details": {
type: "array",
items: {
Expand Down Expand Up @@ -687,26 +725,47 @@ module.exports = {
},
},
},
required: [
"params",
"status",
"type",
"collected_by",
"@ondc/org/buyer_app_finder_fee_type",
"@ondc/org/buyer_app_finder_fee_amount",
],
if: { properties: { collected_by: { const: "BPP" } } },
then: {
required: [
"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",
"@ondc/org/settlement_details",
],
},
else: {
required: [
"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",
],
},
},
},
tags: {
type: "array",
minItems: 3,
items: {
type: "object",
properties: {
descriptor: {
properties: {
code: {
type: "string",
enum: ["buyer_id"],
enum: constants.TERMS
},
},
},
Expand All @@ -719,7 +778,7 @@ module.exports = {
properties: {
code: {
type: "string",
enum: ["buyer_id_code", "buyer_id_no"],
enum: constants.B2B_BPP_TERMS
},
},
},
Expand All @@ -736,18 +795,15 @@ module.exports = {
},
created_at: {
type: "string",
const: { $data: "3/context/timestamp" },
errorMessage:
"created_at does not match context timestamp - ${3/context/timestamp}",
},
updated_at: {
type: "string",
const: { $data: "3/context/timestamp" },
const: { $data: "1/created_at" },
errorMessage:
"updated_at does not match context timestamp - ${3/context/timestamp}",
"does not match created_at timestamp - ${1/created_at}",
},
},
additionalProperties:false,
additionalProperties: false,
required: [
"id",
"state",
Expand All @@ -759,11 +815,13 @@ module.exports = {
"payments",
"created_at",
"updated_at",
"tags"
],
},
},
required: ["order"],
},
},
isFutureDated: true,
required: ["context", "message"],
};
Loading

0 comments on commit ae45864

Please sign in to comment.