Skip to content

Commit

Permalink
Merge pull request ONDC-Official#1 from abhinavv245/draft_log_utility
Browse files Browse the repository at this point in the history
B2B and Logistics fixes
tanyamadaan authored Dec 29, 2023
2 parents fe5ed71 + c6dd73b commit 482fe86
Showing 56 changed files with 6,941 additions and 111 deletions.
3 changes: 2 additions & 1 deletion utilities/logistics-b2b/log-verification-utility/.gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package-lock.json
*.env
.vscode
/public/logs/*
/public/server/*
verification-logs
/utils/*.json
/utils/*.txt
@@ -12,4 +13,4 @@ test.js
!LICENSE.md
logFlow*.json
.DS_Store
log_report.json
log_report.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module.exports = {
isQuoteMatching: (data) => {
const quotePrice = parseFloat(data?.price?.value);
let quotePrice = parseFloat(data?.price?.value);
const breakupArr = data.breakup;
let totalBreakup = 0;
breakupArr.forEach((breakup) => {
totalBreakup += parseFloat(breakup?.price?.value);

});
totalBreakup= parseFloat(totalBreakup).toFixed(2)
quotePrice=quotePrice.toFixed(2)
if (quotePrice != totalBreakup) return false;
else return true;
},
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
const onConfirmSchema = require("./on_confirm");
const onInitSchema = require("./on_init");
const onSearchSchema = require("./on_search");
const selectSchema = require("./select");
const onSelectSchema = require("./on_select");
const onUpdateSchema = require("./on_update");
const searchSchema = require("./search");
const initSchema = require("./init");
const masterSchema = require("./master");
const confirmSchema = require("./confirm");
const statusSchema = require("./status");
const updateSchema = require("./update");
const onStatusSchema = require("./on_status");

const { isLengthValid } = require("./keywords/init");
const { isQuoteMatching } = require("./keywords/onInit");
const { isFutureDated } = require("./keywords/confirm");
@@ -42,7 +30,33 @@ const formatted_error = (errors) => {
return error_json;
};

const validate_schema = (data, schema) => {
const loadSchema = (schemaType, version) => {
try {
return require(`./${version}/${schemaType}.js`);
} catch (error) {
console.log("Error Occurred while importing", error);
}
};

const validate_schema = (data, schema,version) => {
const searchSchema = loadSchema("search", version);
const onSearchSchema = loadSchema("on_search", version);

const selectSchema = loadSchema("select", version);
const onSelectSchema = loadSchema("on_select", version);

const initSchema = loadSchema("init", version);
const onInitSchema = loadSchema("on_init", version);

const confirmSchema = loadSchema("confirm", version);
const onConfirmSchema = loadSchema("on_confirm", version);

const updateSchema = loadSchema("update", version);
const onUpdateSchema = loadSchema("on_update", version);

const statusSchema = loadSchema("status", version);
const onStatusSchema = loadSchema("on_status", version);

const Ajv = require("ajv");
const ajv = new Ajv({
allErrors: true,
@@ -96,8 +110,9 @@ const validate_schema = (data, schema) => {
return error_list;
};

const validate_schema_b2b_master = (data) => {
error_list = validate_schema(data, masterSchema);
const validate_schema_b2b_master = (data,version) => {
const masterSchema = loadSchema("master", version);
error_list = validate_schema(data, masterSchema,version);
return formatted_error(error_list);
};

Original file line number Diff line number Diff line change
@@ -628,8 +628,6 @@ module.exports = {
},
},
isQuoteMatching: true,
errorMessage:
"price is not matching with the total breakup price",
required: ["price", "breakup", "ttl"],
},
payments: {
Original file line number Diff line number Diff line change
@@ -549,8 +549,7 @@ module.exports = {
},
},
isQuoteMatching: true,
errorMessage:
"price is not matching with the total breakup price",

required: ["price", "breakup", "ttl"],
},
payments: {
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ module.exports = {
},
"@ondc/org/title_type": {
type: "string",
enum: ["item", "discount", "Packing charges", "delivery ", "tax", "misc"]
enum: ["item", "discount", "packing", "delivery ", "tax", "misc"]
},
price: {
type: "object",
@@ -321,8 +321,7 @@ module.exports = {
},
},
isQuoteMatching: true,
errorMessage:
"price is not matching with the total breakup price",

required: ["price", "breakup", "ttl"],
},
},
Original file line number Diff line number Diff line change
@@ -568,8 +568,7 @@ module.exports = {
},
},
isQuoteMatching: true,
errorMessage:
"price is not matching with the total breakup price",

required: ["price", "breakup", "ttl"],
},
payments: {
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ module.exports = {
properties: {
domain: {
type: "string",
const: "ONDC:RET10",
},
location: {
type: "object",
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ module.exports = {
properties: {
domain: {
type: "string",
const: "ONDC:RET10",
},
location: {
type: "object",
Original file line number Diff line number Diff line change
@@ -177,7 +177,8 @@ module.exports = {
type: "object",
properties: {
code: {
type: "string"
type: "string",
enum: ["BUYER_TERMS"],
},
},
required: ["code"],
@@ -191,7 +192,8 @@ module.exports = {
type: "object",
properties: {
code: {
type: "string"
type: "string",
enum: ["ITEM_REQ", "PACKAGING_REQ"],
},
},
required: ["code"],
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ module.exports = {
properties: {
domain: {
type: "string",
const: "ONDC:RET10",
},
location: {
type: "object",
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ module.exports = {
properties: {
domain: {
type: "string",
const: "ONDC:RET10",
},
location: {
type: "object",
Loading

0 comments on commit 482fe86

Please sign in to comment.