diff --git a/resources/Reports/OpeningInventoryReports.js b/resources/Reports/OpeningInventoryReports.js index 05e521d..a310944 100644 --- a/resources/Reports/OpeningInventoryReports.js +++ b/resources/Reports/OpeningInventoryReports.js @@ -80,11 +80,11 @@ 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: (pdMap[product.SKU] || 0).toFixed(2), - allRDs: (rdMap[product.SKU] || 0).toFixed(2), - allPdAndRd: ( + allPDs: parseFloat((pdMap[product.SKU] || 0).toFixed(2)), + allRDs: parseFloat((rdMap[product.SKU] || 0).toFixed(2)), + allPdAndRd: parseFloat(( (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) - ).toFixed(2), + ).toFixed(2)), })); // Step 7: Get total count for pagination @@ -181,11 +181,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: (pdMap[product.SKU] || 0).toFixed(2), - allRDs: (rdMap[product.SKU] || 0).toFixed(2), - allPdAndRd: ( + allPDs: parseFloat((pdMap[product.SKU] || 0).toFixed(2)), + allRDs: parseFloat((rdMap[product.SKU] || 0).toFixed(2)), + allPdAndRd: parseFloat(( (pdMap[product.SKU] || 0) + (rdMap[product.SKU] || 0) - ).toFixed(2), + ).toFixed(2)), })); // Step 7: Get total count for pagination @@ -269,10 +269,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": ( - (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 + 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 })); // Define headers (first row in the sheet) @@ -396,10 +396,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": ( - (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 + 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 })); // Define headers (first row in the sheet)