Merge branch 'main' of https://git.cnapp.co.in/gitadmin/api
This commit is contained in:
commit
208d356009
Binary file not shown.
@ -40,7 +40,7 @@ export const getProductsWithOpenInventoryInfo = async (req, res) => {
|
|||||||
{
|
{
|
||||||
$group: {
|
$group: {
|
||||||
_id: "$products.SKU",
|
_id: "$products.SKU",
|
||||||
pdCount: { $sum: 1 },
|
totalPdOpeningInventory: { $sum: "$products.openingInventory" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -57,20 +57,20 @@ export const getProductsWithOpenInventoryInfo = async (req, res) => {
|
|||||||
{
|
{
|
||||||
$group: {
|
$group: {
|
||||||
_id: "$products.SKU",
|
_id: "$products.SKU",
|
||||||
rdCount: { $sum: 1 },
|
totalRdOpeningInventory: { $sum: "$products.openingInventory" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Step 5: Prepare a mapping of PD and RD counts by SKU
|
// Step 5: Prepare a mapping of PD and RD copening inventories by SKU
|
||||||
const pdMap = {};
|
const pdMap = {};
|
||||||
pdOIs.forEach((pd) => {
|
pdOIs.forEach((pd) => {
|
||||||
pdMap[pd._id] = pd.pdCount;
|
pdMap[pd._id] = pd.totalPdOpeningInventory;
|
||||||
});
|
});
|
||||||
|
|
||||||
const rdMap = {};
|
const rdMap = {};
|
||||||
rdOIs.forEach((rd) => {
|
rdOIs.forEach((rd) => {
|
||||||
rdMap[rd._id] = rd.rdCount;
|
rdMap[rd._id] = rd.totalRdOpeningInventory;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Step 6: Combine product info with PD/RD counts using SKU
|
// Step 6: Combine product info with PD/RD counts using SKU
|
||||||
@ -139,7 +139,7 @@ export const getProductsWithStockInfo = async (req, res) => {
|
|||||||
{
|
{
|
||||||
$group: {
|
$group: {
|
||||||
_id: "$products.SKU",
|
_id: "$products.SKU",
|
||||||
pdCount: { $sum: 1 },
|
totalpdStock: { $sum: "$products.Stock" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -156,20 +156,20 @@ export const getProductsWithStockInfo = async (req, res) => {
|
|||||||
{
|
{
|
||||||
$group: {
|
$group: {
|
||||||
_id: "$products.SKU",
|
_id: "$products.SKU",
|
||||||
rdCount: { $sum: 1 },
|
totalrdStock: { $sum: "$products.Stock" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Step 5: Prepare a mapping of PD and RD counts by SKU
|
// Step 5: Prepare a mapping of PD and RD Stocks by SKU
|
||||||
const pdMap = {};
|
const pdMap = {};
|
||||||
pdStocks.forEach((pd) => {
|
pdStocks.forEach((pd) => {
|
||||||
pdMap[pd._id] = pd.pdCount;
|
pdMap[pd._id] = pd.totalpdStock;
|
||||||
});
|
});
|
||||||
|
|
||||||
const rdMap = {};
|
const rdMap = {};
|
||||||
rdStocks.forEach((rd) => {
|
rdStocks.forEach((rd) => {
|
||||||
rdMap[rd._id] = rd.rdCount;
|
rdMap[rd._id] = rd.totalrdStock;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Step 6: Combine product info with PD/RD counts using SKU
|
// Step 6: Combine product info with PD/RD counts using SKU
|
||||||
|
@ -242,7 +242,7 @@ export const uploadRetaildistributors = async (req, res) => {
|
|||||||
tradeName: item.trade_name,
|
tradeName: item.trade_name,
|
||||||
user: Retaildistributor._id,
|
user: Retaildistributor._id,
|
||||||
};
|
};
|
||||||
console.log(addressData);
|
// console.log(addressData);
|
||||||
let addressUpdated = false;
|
let addressUpdated = false;
|
||||||
if (existingAddress) {
|
if (existingAddress) {
|
||||||
const addressUpdates = [];
|
const addressUpdates = [];
|
||||||
|
@ -46,9 +46,9 @@ export const uploadOpeningInventorypd = async (req, res) => {
|
|||||||
|
|
||||||
// Map headers from the Excel file to your schema
|
// Map headers from the Excel file to your schema
|
||||||
const headerMapping = {
|
const headerMapping = {
|
||||||
SKU: "SKU",
|
"SKU": "SKU",
|
||||||
"Product Name": "productName",
|
"Product Name": "productName",
|
||||||
"Opening Inventory (Qty)": "openingInventory",
|
"Opening Inventory (Qty in Ltr/ Kg) ": "openingInventory",
|
||||||
};
|
};
|
||||||
|
|
||||||
const requiredHeaders = Object.keys(headerMapping);
|
const requiredHeaders = Object.keys(headerMapping);
|
||||||
@ -262,9 +262,9 @@ export const uploadOpeningInventoryrd = async (req, res) => {
|
|||||||
|
|
||||||
// Map headers from the Excel file to your schema
|
// Map headers from the Excel file to your schema
|
||||||
const headerMapping = {
|
const headerMapping = {
|
||||||
SKU: "SKU",
|
"SKU": "SKU",
|
||||||
"Product Name": "productName",
|
"Product Name": "productName",
|
||||||
"Opening Inventory (Qty)": "openingInventory",
|
"Opening Inventory (Qty in Ltr/ Kg) ": "openingInventory",
|
||||||
};
|
};
|
||||||
|
|
||||||
const requiredHeaders = Object.keys(headerMapping);
|
const requiredHeaders = Object.keys(headerMapping);
|
||||||
|
Loading…
Reference in New Issue
Block a user