diff --git a/resources/Reports/OpeningInventoryReports.js b/resources/Reports/OpeningInventoryReports.js index a310944..6f2ec19 100644 --- a/resources/Reports/OpeningInventoryReports.js +++ b/resources/Reports/OpeningInventoryReports.js @@ -80,13 +80,12 @@ export const getProductsWithOpenInventoryInfo = async (req, res) => { name: product.name, brand: product.brand?.brandName || "N/A", // Access brandName here category: product.category?.categoryName || "N/A", // Access categoryName here - allPDs: parseFloat((pdMap[product.SKU] || 0).toFixed(2)), - allRDs: parseFloat((rdMap[product.SKU] || 0).toFixed(2)), - allPdAndRd: parseFloat(( + allPDs: (pdMap[product.SKU] || 0).toFixed(2), + allRDs: (rdMap[product.SKU] || 0).toFixed(2), + allPdAndRd: ( (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) - ).toFixed(2)), + ).toFixed(2), })); - // Step 7: Get total count for pagination const totalCount = await Product.countDocuments(searchCriteria); @@ -181,11 +180,11 @@ export const getProductsWithStockInfo = async (req, res) => { name: product.name, brand: product.brand?.brandName || "N/A", // Access brandName here category: product.category?.categoryName || "N/A", // Access categoryName here - allPDs: parseFloat((pdMap[product.SKU] || 0).toFixed(2)), - allRDs: parseFloat((rdMap[product.SKU] || 0).toFixed(2)), - allPdAndRd: parseFloat(( + allPDs: (pdMap[product.SKU] || 0).toFixed(2), + allRDs: (rdMap[product.SKU] || 0).toFixed(2), + allPdAndRd: ( (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) - ).toFixed(2)), + ).toFixed(2), })); // 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 "Brand Name": product.brand?.brandName || "N/A", // Brand Name "Total At PDs And Retailers": ( - parseFloat((pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) - ).toFixed(2)), // Total At PDs & Retailers - "All PDs": parseFloat((pdMap[product.SKU] || 0).toFixed(2)), // All PDs - "All Retailers": parseFloat((rdMap[product.SKU] || 0).toFixed(2)), // All Retailers + (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) + ).toFixed(2), // Total At PDs & Retailers + "All PDs": (pdMap[product.SKU] || 0).toFixed(2), // All PDs + "All Retailers": (rdMap[product.SKU] || 0).toFixed(2), // All Retailers })); // 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 "Brand Name": product.brand?.brandName || "N/A", // Brand Name "Total At PDs And Retailers": ( - parseFloat((pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) - ).toFixed(2)), // Total At PDs & Retailers - "All PDs": parseFloat((pdMap[product.SKU] || 0).toFixed(2)), // All PDs - "All Retailers": parseFloat((rdMap[product.SKU] || 0).toFixed(2)), // All Retailers + (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) + ).toFixed(2), // Total At PDs & Retailers + "All PDs": (pdMap[product.SKU] || 0).toFixed(2), // All PDs + "All Retailers": (rdMap[product.SKU] || 0).toFixed(2), // All Retailers })); // Define headers (first row in the sheet)