bug fixed

This commit is contained in:
Sibunnayak 2024-11-06 18:29:16 +05:30
parent 2ae2b593ca
commit 769ed76eed

View File

@ -80,13 +80,12 @@ export const getProductsWithOpenInventoryInfo = async (req, res) => {
name: product.name, name: product.name,
brand: product.brand?.brandName || "N/A", // Access brandName here brand: product.brand?.brandName || "N/A", // Access brandName here
category: product.category?.categoryName || "N/A", // Access categoryName here category: product.category?.categoryName || "N/A", // Access categoryName here
allPDs: parseFloat((pdMap[product.SKU] || 0).toFixed(2)), allPDs: (pdMap[product.SKU] || 0).toFixed(2),
allRDs: parseFloat((rdMap[product.SKU] || 0).toFixed(2)), allRDs: (rdMap[product.SKU] || 0).toFixed(2),
allPdAndRd: parseFloat(( allPdAndRd: (
(pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0)
).toFixed(2)), ).toFixed(2),
})); }));
// Step 7: Get total count for pagination // Step 7: Get total count for pagination
const totalCount = await Product.countDocuments(searchCriteria); const totalCount = await Product.countDocuments(searchCriteria);
@ -181,11 +180,11 @@ export const getProductsWithStockInfo = async (req, res) => {
name: product.name, name: product.name,
brand: product.brand?.brandName || "N/A", // Access brandName here brand: product.brand?.brandName || "N/A", // Access brandName here
category: product.category?.categoryName || "N/A", // Access categoryName here category: product.category?.categoryName || "N/A", // Access categoryName here
allPDs: parseFloat((pdMap[product.SKU] || 0).toFixed(2)), allPDs: (pdMap[product.SKU] || 0).toFixed(2),
allRDs: parseFloat((rdMap[product.SKU] || 0).toFixed(2)), allRDs: (rdMap[product.SKU] || 0).toFixed(2),
allPdAndRd: parseFloat(( allPdAndRd: (
(pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0)
).toFixed(2)), ).toFixed(2),
})); }));
// Step 7: Get total count for pagination // Step 7: Get total count for pagination
@ -269,10 +268,10 @@ export const DownloadProductsWithOpenInventoryInfo = async (req, res) => {
"Category Name": product.category?.categoryName || "N/A", // Category Name "Category Name": product.category?.categoryName || "N/A", // Category Name
"Brand Name": product.brand?.brandName || "N/A", // Brand Name "Brand Name": product.brand?.brandName || "N/A", // Brand Name
"Total At PDs And Retailers": ( "Total At PDs And Retailers": (
parseFloat((pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0)
).toFixed(2)), // Total At PDs & Retailers ).toFixed(2), // Total At PDs & Retailers
"All PDs": parseFloat((pdMap[product.SKU] || 0).toFixed(2)), // All PDs "All PDs": (pdMap[product.SKU] || 0).toFixed(2), // All PDs
"All Retailers": parseFloat((rdMap[product.SKU] || 0).toFixed(2)), // All Retailers "All Retailers": (rdMap[product.SKU] || 0).toFixed(2), // All Retailers
})); }));
// Define headers (first row in the sheet) // Define headers (first row in the sheet)
@ -396,10 +395,10 @@ export const DownloadProductsWithStockInfo = async (req, res) => {
"Category Name": product.category?.categoryName || "N/A", // Category Name "Category Name": product.category?.categoryName || "N/A", // Category Name
"Brand Name": product.brand?.brandName || "N/A", // Brand Name "Brand Name": product.brand?.brandName || "N/A", // Brand Name
"Total At PDs And Retailers": ( "Total At PDs And Retailers": (
parseFloat((pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0)
).toFixed(2)), // Total At PDs & Retailers ).toFixed(2), // Total At PDs & Retailers
"All PDs": parseFloat((pdMap[product.SKU] || 0).toFixed(2)), // All PDs "All PDs": (pdMap[product.SKU] || 0).toFixed(2), // All PDs
"All Retailers": parseFloat((rdMap[product.SKU] || 0).toFixed(2)), // All Retailers "All Retailers": (rdMap[product.SKU] || 0).toFixed(2), // All Retailers
})); }));
// Define headers (first row in the sheet) // Define headers (first row in the sheet)