Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a9629a3
Added: Retail
shreyvishal Jul 18, 2025
03926f6
Added: Changes
shreyvishal Jul 18, 2025
8976709
Added: Changes for Xinput
shreyvishal Jul 19, 2025
39d2b3f
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
8e8b1e2
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
860f7d2
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
d7469eb
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
6a77a55
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
2cef2f3
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
4d6afaf
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
90c0a61
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
4168a90
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
6f4dd87
Added: Changes for xinput in jsonata in on_Search
shreyvishal Jul 19, 2025
caa3ff8
Added: Changes for Toursim
shreyvishal Aug 17, 2025
dae0eef
Added: Changes for Toursim
shreyvishal Aug 17, 2025
e887be0
Added: Changes for mobility domain
shreyvishal Oct 6, 2025
5119c12
buig fx
aniketceminds Dec 4, 2025
3f6984b
buig fx
aniketceminds Dec 4, 2025
6b11a27
buig fx
aniketceminds Dec 4, 2025
eaf9c3e
buig fx
aniketceminds Dec 4, 2025
8cbb6d8
buig fx
aniketceminds Dec 4, 2025
5dc4f8b
buig fx
aniketceminds Dec 4, 2025
8e03b48
buig fx
aniketceminds Dec 4, 2025
f8ec412
buig fx
aniketceminds Dec 4, 2025
3f89b7b
Added: Changes
shreyvishal Dec 5, 2025
a4fb9e9
Added: Changes
shreyvishal Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/beckn-bpp-adapter/server/mappings/context.jsonata
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"action": $action,
"timestamp": $moment().toISOString(),
"version": "1.1.0",
"bap_uri": bap_uri,
"bap_id": bap_id,
"bap_uri": bap_uri ? bap_uri : "http://34.93.45.226:8081/bap/receiver",
"bap_id": bap_id ? bap_id : "sandbox-retail-np1.com",
"bpp_id": $env.BPP_ID,
"bpp_uri": $env.BPP_URI
}
6 changes: 6 additions & 0 deletions plugins/beckn-bpp-adapter/server/mappings/on_search.jsonata
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
$string($v.location_id.id)
})[] :
[],
"xinput": {
"form": {
"url": $xInput(%.%.context),
"mime_type": "text/html"
}
},
"tags": $tags(cat_attr_tag_relations),
"time": {
"duration": service.time_slot_per_client_in_min ? $string(service.time_slot_per_client_in_min) : ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,18 @@ export default ({ strapi }: { strapi: Strapi }) => ({
order_transaction_id: transaction_id,
publishedAt: isoString,
domain,
bap_id,
bap_uri,
bap_id: bap_id ? bap_id : "sandbox-retail-np1.com",
bap_uri: bap_uri ? bap_uri : "http://34.93.45.226:8081/bap/receiver",
currency: payments?.[0]?.params?.amount || "INR",
total_amount: payments?.[0]?.params?.amount || 100,
transaction_id: payments?.[0]?.id
};
console.log("orderData ==>>>>>>", orderData);
// Create order
createOrder = await strapi.entityService.create("api::order.order", {
data: orderData
});
console.log("createOrder ==>>>>>>", createOrder);
orderId = createOrder.id;

// Create order address
Expand Down Expand Up @@ -207,12 +209,14 @@ export default ({ strapi }: { strapi: Strapi }) => ({

// Update the order with the modified tags
console.log("Orderis", orderId);
await strapi.entityService.update("api::order.order", orderId, {
const updateOrder = await strapi.entityService.update("api::order.order", orderId, {
data: {
tags: items // Assuming 'items' is a writable field; adjust based on your Strapi schema
}
});

console.log("updateOrder ==>>>>>>", updateOrder);

strapi.log.info(
`Order ${orderId} has been successfully updated with tag IDs.`
);
Expand All @@ -230,11 +234,11 @@ export default ({ strapi }: { strapi: Strapi }) => ({
...billingInfo,
publishedAt: isoString
};
await strapi.entityService.create(
const createOrderAddress = await strapi.entityService.create(
"api::order-address.order-address",
{ data: orderAddressData }
);

console.log("createOrderAddress ==>>>>>>", createOrderAddress);
// Find or create customer
const [existingCustomer] = await strapi.entityService.findMany(
"api::customer.customer",
Expand All @@ -254,6 +258,7 @@ export default ({ strapi }: { strapi: Strapi }) => ({
"api::order-fulfillment-location.order-fulfillment-location",
{ data: shippingDetail }
);
console.log("createShipping ==>>>>>>", createShipping);
const stopsIds = [createShipping.id];

if (endLocationDetail) {
Expand Down Expand Up @@ -301,11 +306,13 @@ export default ({ strapi }: { strapi: Strapi }) => ({
"api::order-fulfillment.order-fulfillment",
{ data: orderFulfillmentDetail }
);
console.log("orderFulfillmentRes ==>>>>>>", orderFulfillmentRes);
orderFulFillmentId = orderFulfillmentRes.id;

await onConfirm(message);
trx.commit();
} catch (err) {
console.log("err ==>>>>>>", JSON.stringify(err.details, null, 2));
trx.rollback();
}
});
Expand Down Expand Up @@ -397,6 +404,7 @@ export default ({ strapi }: { strapi: Strapi }) => ({
populate
}
);
console.log("itemDetails ==>>>>>>", itemDetails);
const commonService = strapi.plugin(PLUGIN).service("commonService");
await Promise.all(
itemDetails.map(async (itemDetail) => {
Expand Down Expand Up @@ -432,6 +440,7 @@ export default ({ strapi }: { strapi: Strapi }) => ({
fulfilment_id: {}
}
);
console.log("orderFulfillment ==>>>>>>", orderFulfillment);
const billingDetails = billing;
const fulfillmentDetails = fulfillments;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default ({ strapi: any }: { strapi: Strapi }) => ({
async index(body, domain) {
try {
const dummyProvider = {
DOMAIN: "Retail",
DOMAIN: "Retail:dev",
provider_name: "Sample Provider",
provider_short_desc: "Your one-stop shop for daily essentials.",
provider_long_desc:
Expand Down
54 changes: 32 additions & 22 deletions plugins/beckn-bpp-adapter/server/tl/tl.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,32 @@ export const context = async (data: any, action: string) => {
};

export const xInput = async (context: KeyValuePair) => {
console.log("context====>", context, "\n\n\n");
const { action, domain } = context;
let formId;
if (action === "init" && domain === "dsep:scholarships") {
if (
action === "init" &&
domain === `dsep:scholarships:${process.env.BECKN_ENV}`
) {
formId = "dsepScholarshipDetailsForm";
} else if (action === "init" && domain === "dsep:jobs") {
} else if (
action === "init" &&
domain === `dsep:jobs:${process.env.BECKN_ENV}`
) {
formId = "dsepJobsApplyForm";
} else if (
action === "select" &&
domain === "online-dispute-resolution:0.1.0"
(action === "select" || action === "search") &&
domain === `online-dispute-resolution:0.1.0:${process.env.BECKN_ENV}`
) {
formId = "odrDisputeDetailsForm";
} else if (
action === "init" &&
domain === "online-dispute-resolution:0.1.0"
domain === `online-dispute-resolution:0.1.0:${process.env.BECKN_ENV}`
) {
formId = "odrConsentForm";
} else if (
action === "select" &&
domain === "supply-chain-services:assembly"
domain === `supply-chain-services:assembly:${process.env.BECKN_ENV}`
) {
formId = "industryAssemblyDetailsForm";
} else if (action === "rating" && isMobility(context)) {
Expand Down Expand Up @@ -90,16 +97,17 @@ export const quote = async (items: KeyValuePair[]) => {

// Domain-specific base price name mappings
const domainBasePriceNames = {
"Retail": "Item Price",
"dhp:pharmacy:0.1.0": "Item Price",
"supply-chain-services:assembly": "Base Price",
"mobility:1.1.0": "Base Fare",
"tourism": "Sub Total",
"dsep:courses": "Course Fee",
"hospitality": "Room Tariff",
"retail:1.1.0": "Item Price",
"uei:p2p_trading": "P2P Energy Cost",
"uei:charging": "Cost of Charge"
"Retail:dev": "Base Price",
"dhp:pharmacy:0.1.0:dev": "Base Price",
"supply-chain-services:assembly:dev": "Base Price",
"mobility:1.1.0:dev": "Base Fare",
"tourism:dev": "Sub Total",
"dsep:courses:dev": "Course Fee",
"hospitality:dev": "Room Tariff",
"retail:1.1.0:dev": "Base Price",
"uei:p2p_trading:dev": "P2P Energy Cost",
"uei:charging:dev": "Cost of Charge",
"retail:1.1.0": "Base Price"
};

export const quotePrice = async (
Expand Down Expand Up @@ -141,9 +149,9 @@ export const quotePrice = async (
title: price_bareakup_id.title,
price: {
currency: price_bareakup_id.currency,
value: adjustedValue.toString(),
value: adjustedValue.toString()
},
item: { id: `${item.id || ""}` },
item: { id: `${item.id || ""}` }
});
});

Expand All @@ -153,9 +161,9 @@ export const quotePrice = async (
title: basePriceName,
price: {
currency: scProduct.currency,
value: (Number(scProduct.base_fee) * selectedQuantity).toString(),
value: (Number(scProduct.base_fee) * selectedQuantity).toString()
},
item: { id: `${item.id || ""}` },
item: { id: `${item.id || ""}` }
});
}
} else {
Expand All @@ -166,6 +174,8 @@ export const quotePrice = async (
}
});

console.log("Items Final====>", JSON.stringify(items, null, 2));

// Calculate total priceValue as sum of all breakup.price.value plus any base_fee values
const breakupPriceValue = breakup.reduce(
(accumulator, currentValue) =>
Expand All @@ -176,9 +186,9 @@ export const quotePrice = async (
return {
price: {
value: (breakupPriceValue + totalPriceValue).toString(),
currency: items?.[0]?.sc_retail_product?.currency,
currency: items?.[0]?.sc_retail_product?.currency
},
breakup,
breakup
};
};

Expand Down
43 changes: 29 additions & 14 deletions plugins/beckn-bpp-adapter/server/tl/tl.service.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
import jsonata from "jsonata";
import path from 'path';
import path from "path";
import appRootPath from "app-root-path";
import fs from 'fs';
import fs from "fs";
import { ObjectUtil } from "../util/object.util";
import * as tlHelpers from './tl.helper'
import * as tlHelpers from "./tl.helper";

export class TLService {
static async transform(data: any, action: string) {

if (action) {
const expression = jsonata(fs.readFileSync(path.join(appRootPath.toString(), `/server/mappings/${action}.jsonata`), "utf8"));
console.log("Transforming %s data: \n%o", action, JSON.stringify(data));
let transformed = await expression.evaluate(data, { action, ...tlHelpers });
transformed = ObjectUtil.removeEmptyObjectKeys(transformed)
console.log("Transformed %s data: \n%o", action, JSON.stringify(transformed));
return transformed;
}
return {};
static async transform(data: any, action: string) {
if (action) {
const expression = jsonata(
fs.readFileSync(
path.join(
appRootPath.toString(),
`/server/mappings/${action}.jsonata`
),
"utf8"
)
);
// console.log("Transforming %s data: \n%o", action, JSON.stringify(data));
console.log(`Transforming ${action} data: \n${JSON.stringify(data)}`);
let transformed = await expression.evaluate(data, {
action,
...tlHelpers
});
transformed = ObjectUtil.removeEmptyObjectKeys(transformed);
console.log(
"Transformed %s data: \n%o",
action,
JSON.stringify(transformed)
);
return transformed;
}
return {};
}
}
101 changes: 51 additions & 50 deletions plugins/beckn-bpp-adapter/server/util/search.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,56 +103,57 @@ export class SearchUtil {
filteredProviders = [];
}
} else if (isTourism(context)) {
let checkInReq: KeyValuePair | null = null;
fulfillment?.stops.map((fulfillmentStop: KeyValuePair) => {
if (fulfillmentStop?.type?.toLowerCase() === CHECK_IN) {
checkInReq = fulfillmentStop;
}
});
if (checkInReq) {
filteredProviders = providers.filter((providerItem: KeyValuePair) => {
providerItem.items = providerItem.items.filter(
(item: KeyValuePair) => {
let checkInItem: any = null;
item?.item_fulfillment_ids?.forEach(
(fulfillment: KeyValuePair) => {
if (
fulfillment?.fulfilment_id?.type?.toLowerCase() === CHECK_IN
) {
checkInItem = fulfillment;
}
}
);
const checkInGps = checkInReq?.location?.gps.split(",") || [];
const itemGps = checkInItem?.location_id?.gps.split(",") || [];
const checkInLat = checkInGps[0];
const checkInLong = checkInGps[1];
const itemLat = itemGps[0];
const itemLong = itemGps[1];
console.log(
moment(checkInReq?.time?.timestamp).format("YYYY-MM-DD"),
moment(checkInItem?.timestamp).format("YYYY-MM-DD"),
checkInGps.length &&
itemGps.length &&
!isInRange(checkInLat, checkInLong, itemLat, itemLong)
);
if (
moment(checkInReq?.time?.timestamp).format("YYYY-MM-DD") !==
moment(checkInItem?.timestamp).format("YYYY-MM-DD") ||
(checkInGps.length &&
itemGps.length &&
!isInRange(checkInLat, checkInLong, itemLat, itemLong))
) {
return false;
}
return true;
}
);
return providerItem.items.length > 0;
});
} else {
filteredProviders = [];
}
// let checkInReq: KeyValuePair | null = null;
// fulfillment?.stops?.map((fulfillmentStop: KeyValuePair) => {
// if (fulfillmentStop?.type?.toLowerCase() === CHECK_IN) {
// checkInReq = fulfillmentStop;
// }
// });
// if (checkInReq) {
// filteredProviders = providers.filter((providerItem: KeyValuePair) => {
// providerItem.items = providerItem.items.filter(
// (item: KeyValuePair) => {
// let checkInItem: any = null;
// item?.item_fulfillment_ids?.forEach(
// (fulfillment: KeyValuePair) => {
// if (
// fulfillment?.fulfilment_id?.type?.toLowerCase() === CHECK_IN
// ) {
// checkInItem = fulfillment;
// }
// }
// );
// const checkInGps = checkInReq?.location?.gps.split(",") || [];
// const itemGps = checkInItem?.location_id?.gps.split(",") || [];
// const checkInLat = checkInGps[0];
// const checkInLong = checkInGps[1];
// const itemLat = itemGps[0];
// const itemLong = itemGps[1];
// console.log(
// moment(checkInReq?.time?.timestamp).format("YYYY-MM-DD"),
// moment(checkInItem?.timestamp).format("YYYY-MM-DD"),
// checkInGps.length &&
// itemGps.length &&
// !isInRange(checkInLat, checkInLong, itemLat, itemLong)
// );
// if (
// moment(checkInReq?.time?.timestamp).format("YYYY-MM-DD") !==
// moment(checkInItem?.timestamp).format("YYYY-MM-DD") ||
// (checkInGps.length &&
// itemGps.length &&
// !isInRange(checkInLat, checkInLong, itemLat, itemLong))
// ) {
// return false;
// }
// return true;
// }
// );
// return providerItem.items.length > 0;
// });
// } else {
// filteredProviders = [];
// }
return providers;
} else if (isMobility(context)) {
let customerLocation: KeyValuePair | null = null;
fulfillment?.stops.map((fulfillmentStop: KeyValuePair) => {
Expand Down
Loading