From 4164ffe4a671881624b9204acacaac9deb3aa513 Mon Sep 17 00:00:00 2001 From: Malini Date: Fri, 26 Dec 2025 10:35:10 +0530 Subject: [PATCH] fixed --- .../src/pages/Admin/ValidationReview.jsx | 885 ++++++++++-------- 1 file changed, 472 insertions(+), 413 deletions(-) diff --git a/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx b/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx index e8d2712..bde3ccc 100644 --- a/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx +++ b/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx @@ -7,7 +7,6 @@ import { getBeforePreviousData, getQuarterPeriods } from '@/services/submissions import { getProductSubmissionHistory } from '@/services/submissions/submissionService'; import { Line } from 'react-chartjs-2'; - // Helper function to get months for quarter const getMonthsForQuarter = (quarter, year) => { const monthMap = { @@ -236,71 +235,6 @@ const ProductChart = ({ product, establishmentId }) => { }, plugins: { legend: { - // position: 'top', - // align: 'center', - // labels: { - // usePointStyle: true, - // boxWidth: 12, - // boxHeight: 12, - // padding: 12, - // font: { - // size: 12, - // lineHeight: '16px' - // }, - // generateLabels: function(chart) { - // const data = chart.data; - // if (data.labels.length && data.datasets.length) { - // return chart.data.datasets.map((dataset, i) => { - // const meta = chart.getDatasetMeta(i); - // let label = dataset.label || ''; - // label = ' ' + label.trim(); - - // // For Annual Capacity (dashed line) - // if (label.includes('Annual Capacity')) { - // return { - // text: label, - // fillStyle: 'transparent', - // hidden: !meta.visible, - // lineDash: [3, 3], - // lineWidth: 2, - // strokeStyle: dataset.borderColor, - // pointStyle: 'line', - // rotation: 0, - // datasetIndex: i - // }; - // } - - // // For Quantity (solid line) - // if (label.includes('Quantity')) { - // return { - // text: label, - // fillStyle: 'transparent', - // hidden: !meta.visible, - // lineDash: [], - // lineWidth: 2, - // strokeStyle: dataset.borderColor, - // pointStyle: 'line', - // rotation: 0, - // datasetIndex: i - // }; - // } - - // // For bar items (Previous, Current, Forecast) - square boxes - // return { - // text: label, - // fillStyle: dataset.backgroundColor, - // hidden: !meta.visible, - // lineWidth: 0, - // strokeStyle: 'transparent', - // pointStyle: 'rect', - // rotation: 0, - // datasetIndex: i - // }; - // }); - // } - // return []; - // } - // } display:false, }, tooltip: { @@ -618,7 +552,6 @@ const ValidationReview = () => { productId ); - let mappedDataMap = {}; submissionData?.products?.forEach((product) => { @@ -670,9 +603,6 @@ setAdditionalForecastMonths([ } }; - - - // Helper to get forecast data for a specific product const getCurrentYearForecastData = (productId) => { if (!showPreviousNext || !productId) { @@ -771,102 +701,96 @@ setAdditionalForecastMonths([ }; const calculateVariance = (previous, current) => { - const previousNum = parseFloat(previous) || 0; - const currentNum = parseFloat(current) || 0; - - if (previousNum === 0) { - return currentNum === 0 ? 0 : 100; - } - + const previousNum = Number(previous); + const currentNum = Number(current); + + if (isNaN(previousNum) || isNaN(currentNum)) return 0; + + // both 0 → no variance + if (previousNum === 0 && currentNum === 0) return 0; + + // 0 → value (special case) + if (previousNum === 0) return 100; + return ((currentNum - previousNum) / Math.abs(previousNum)) * 100; }; const formatPercentage = (variance) => { - const absVariance = Math.abs(variance); - - if (absVariance === 0) return '0%'; - - if (absVariance >= 1000) { - return `${variance > 0 ? '+' : ''}${Math.round(variance).toLocaleString()}%`; - } - - if (absVariance >= 100) { - return `${variance > 0 ? '+' : ''}${Math.round(variance)}%`; - } - - return `${variance > 0 ? '+' : ''}${variance.toFixed(1)}%`; + if (variance === 0) return '0%'; + + const sign = variance > 0 ? '+' : ''; + const abs = Math.abs(variance); + + if (abs >= 100) return `${sign}${Math.round(variance)}%`; + + return `${sign}${variance.toFixed(1)}%`; }; const getVarianceDisplay = (previousValue, currentValue, isFirstMonth = false) => { if (isFirstMonth) return null; - + if (previousValue == null || currentValue == null) return null; + const variance = calculateVariance(previousValue, currentValue); const absVariance = Math.abs(variance); - + if (absVariance === 0) { return (
- 0% + 0%
); } - + const isPositive = variance > 0; const arrow = isPositive ? '▲' : 'â–ŧ'; - - let colorClass = isPositive ? 'text-[#1E7C34]' : 'text-[#B52520]'; - - const percentage = formatPercentage(variance); - + const color = isPositive ? 'text-[#1E7C34]' : 'text-[#B52520]'; + return (
- {arrow} {percentage} + + {arrow} {formatPercentage(variance)} +
); }; -const getCellClass = (previousValue, currentValue, isFirstMonth = false) => { - if (isFirstMonth || !varianceHighlighting) return ''; + const getCellClass = (previousValue, currentValue, isFirstMonth = false) => { + if (isFirstMonth || !varianceHighlighting) return ''; - const variance = calculateVariance(previousValue, currentValue); - const absVariance = Math.abs(variance); + const variance = calculateVariance(previousValue, currentValue); + const absVariance = Math.abs(variance); + + // 🔴 threshold > 100 → only highlight above 100 + if (threshold > 100) { + if (absVariance <= 100) return ''; + return variance > 0 ? 'bg-[#F0FDF4]' : 'bg-[#FEF2F2]'; + } + + // đŸŸĸ NORMAL: highlight WITHIN threshold + if (absVariance > threshold) return ''; - // 🟡 Above 100 selected → ONLY > 100% highlight - if (threshold > 100) { - if (absVariance <= 100) return ''; return variance > 0 ? 'bg-[#F0FDF4]' : 'bg-[#FEF2F2]'; - } + }; - // đŸŸĸ Normal case (≤ threshold) - if (absVariance > threshold) return ''; + const getBorderClass = (previousValue, currentValue, isFirstMonth = false) => { + if (isFirstMonth || !varianceHighlighting) return ''; - return variance > 0 ? 'bg-[#F0FDF4]' : 'bg-[#FEF2F2]'; -}; + if (threshold > 100) return ''; + const variance = calculateVariance(previousValue, currentValue); + const absVariance = Math.abs(variance); + if (absVariance > threshold) return ''; -const getBorderClass = (previousValue, currentValue, isFirstMonth = false) => { - if (isFirstMonth || !varianceHighlighting) return ''; + return variance > 0 + ? 'border-2 border-[#1E7C34]' + : 'border-2 border-[#B52520]'; + }; - // 🔴 Above 100 selected → no border highlight - if (threshold > 100) return ''; + const getQuarterYearLabel = (quarter, year) => { + return `${quarter} ${year}`; + }; - const variance = calculateVariance(previousValue, currentValue); - const absVariance = Math.abs(variance); - - if (absVariance > threshold) return ''; - - return variance > 0 - ? 'border-2 border-[#1E7C34]' - : 'border-2 border-[#B52520]'; -}; - - -const getQuarterYearLabel = (quarter, year) => { - return `${quarter} ${year}`; -}; - - if (loading) { return (
@@ -939,29 +863,17 @@ const getQuarterYearLabel = (quarter, year) => { }; const previousLabel = getQuarterYearLabel(previousQuarter, previousYear); -const currentLabel = getQuarterYearLabel(currentQuarter, currentYear); + const currentLabel = getQuarterYearLabel(currentQuarter, currentYear); + const forecastLabel = getQuarterYearLabel(forecastQuarter, forecastYear); -// Next Year Forecast -const forecastLabel = getQuarterYearLabel(forecastQuarter, forecastYear ); - -// Optional: Previous Forecast (same year usually) -// const additionalForecastLabel = getQuarterYearLabel(forecastQuarter, currentYear); - - // Use generated year labels or fallback to full year display - // const previousLabel = yearLabels?.previous || `${previousQuarter} ${previousYear}`; - // const currentLabel = yearLabels?.current || `${currentQuarter} ${currentYear}`; - // const forecastLabel = yearLabels?.forecast || `${forecastQuarter} ${forecastYear}`; - // Calculate additional forecast label dynamically -const additionalForecastLabel = showPreviousNext - ? additionalForecastQuarter === "No" - ? "No" - : [additionalForecastQuarter, additionalForecastYear] - .filter(Boolean) - .join(" ") - : ""; - - + const additionalForecastLabel = showPreviousNext + ? additionalForecastQuarter === "No" + ? "No" + : [additionalForecastQuarter, additionalForecastYear] + .filter(Boolean) + .join(" ") + : ""; const establishmentDetails = [ { @@ -1089,7 +1001,20 @@ const additionalForecastLabel = showPreviousNext {submissionData?.products?.length > 0 ? (
- {submissionData.products.map((product, idx) => ( + {submissionData.products.map((product, idx) => { + // Check if previous quarter has any non-zero values + const isPreviousQuarterAllZeros = + (!product.previous_quantity_period_one || Number(product.previous_quantity_period_one) === 0) && + (!product.previous_quantity_period_two || Number(product.previous_quantity_period_two) === 0) && + (!product.previous_quantity_period_three || Number(product.previous_quantity_period_three) === 0); + + // For cost also check + const isPreviousQuarterCostAllZeros = + (!product.previous_cost_period_one || Number(product.previous_cost_period_one) === 0) && + (!product.previous_cost_period_two || Number(product.previous_cost_period_two) === 0) && + (!product.previous_cost_period_three || Number(product.previous_cost_period_three) === 0); + + return (
@@ -1175,141 +1100,138 @@ const additionalForecastLabel = showPreviousNext
- {varianceHighlighting && ( -
- {threshold > 100 - ? "Cells with variance > 100% will be highlighted" - : `Cells with variance ≤ ${threshold}% will be highlighted`} -
-)} - - - + {varianceHighlighting && ( +
+ {threshold > 100 + ? "Cells with variance > 100% will be highlighted" + : `Cells with variance ≤ ${threshold}% will be highlighted`} +
+ )}
- - - - {showPreviousNext ? ( - <> - {/* 12 columns when showPreviousNext is true */} - - - - - - ) : ( - <> - {/* 9 columns when showPreviousNext is false */} - - - - - )} - + + + + {showPreviousNext ? ( + <> + {/* 12 columns when showPreviousNext is true */} + + + + + + ) : ( + <> + {/* 9 columns when showPreviousNext is false */} + + + + + )} + - - {showPreviousNext ? ( - <> - {/* Previous Quarter Months */} - - - + + {showPreviousNext ? ( + <> + {/* Previous Quarter Months */} + + + - {/* Current Quarter Months */} - - - + {/* Current Quarter Months */} + + + - {/* Previous Forecast Months */} - - - + {/* Previous Forecast Months */} + + + - {/* Next Year Forecast Months */} - - - - - ) : ( - <> - {/* Previous Quarter Months */} - - - + {/* Next Year Forecast Months */} + + + + + ) : ( + <> + {/* Previous Quarter Months */} + + + - {/* Current Quarter Months */} - - - + {/* Current Quarter Months */} + + + - {/* Next Year Forecast Months */} - - - - - )} - - + {/* Next Year Forecast Months */} + + + + + )} + + @@ -1319,42 +1241,82 @@ const additionalForecastLabel = showPreviousNext {showPreviousNext ? ( <> - {/* Previous Quarter Data */} + {/* Previous Quarter – Month 1 (BASE) - NO VARIANCE */} - - - {/* Current Quarter Data */} - - - + + {/* Current Quarter – Month 2 */} + + + {/* Current Quarter – Month 3 */} + @@ -1363,19 +1325,19 @@ const additionalForecastLabel = showPreviousNext const historicalData = getCurrentYearForecastData(product?.product?.id); return ( <> - - - - - + + {/* Previous Quarter – Month 2 */} - - - - - - - @@ -1473,39 +1474,55 @@ const additionalForecastLabel = showPreviousNext {showPreviousNext ? ( <> - {/* Previous Quarter Cost */} + {/* Previous Cost – Month 1 (BASE) - NO VARIANCE */} - - - {/* Current Quarter Cost */} - - + + {/* Current Quarter Cost – Month 1 */} + + - - - - - + + {/* Previous Cost – Month 2 */} - - - - - - - )} - - - {showPreviousNext ? ( - <> - - - {/* Previous Forecast (colSpan 3) */} - - {/* Next Year Forecast (colSpan 3) */} - - - ) : ( - <> - {/* Previous Quarter (colSpan 3) */} - - {/* Current Quarter (colSpan 3) - āŽ‡āŽ™ā¯āŽ•ā¯āŽ¤āŽžāŽŠā¯ Reason (Current) āŽ‡āŽ°ā¯āŽ•ā¯āŽ• āŽĩā¯‡āŽŖā¯āŽŸā¯āŽŽā¯ */} - - {/* Next Year Forecast (colSpan 3) */} - - - )} - + + + + {showPreviousNext ? ( + <> + + + {/* Previous Forecast (colSpan 3) */} + + {/* Next Year Forecast (colSpan 3) */} + + + ) : ( + <> + {/* Previous Quarter (colSpan 3) */} + + {/* Current Quarter (colSpan 3) */} + + {/* Next Year Forecast (colSpan 3) */} + + + )} + +
- Metric - - {previousLabel || 'Q1 2024'} (PREVIOUS QUARTER) - - {currentLabel || 'Q2 2024'} (CURRENT QUARTER) - - {additionalForecastLabel || ''} (PREVIOUS FORECAST) - - {forecastLabel || 'Q3 2024'} (NEXT YEAR FORECAST) - - {previousLabel || 'Q1 2024'} (PREVIOUS QUARTER) - - {currentLabel || 'Q2 2024'} (CURRENT QUARTER) - - {forecastLabel || 'Q3 2024'} (NEXT YEAR FORECAST) -
+ Metric + + {previousLabel || 'Q1 2024'} (PREVIOUS QUARTER) + + {currentLabel || 'Q2 2024'} (CURRENT QUARTER) + + {additionalForecastLabel || ''} (PREVIOUS FORECAST) + + {forecastLabel || 'Q3 2024'} (NEXT YEAR FORECAST) + + {previousLabel || 'Q1 2024'} (PREVIOUS QUARTER) + + {currentLabel || 'Q2 2024'} (CURRENT QUARTER) + + {forecastLabel || 'Q3 2024'} (NEXT YEAR FORECAST) +
- {previousMonths?.previous_period_one || 'Jan'} - - {previousMonths?.previous_period_two || 'Feb'} - - {previousMonths?.previous_period_three || 'Mar'} -
+ {previousMonths?.previous_period_one || 'Jan'} + + {previousMonths?.previous_period_two || 'Feb'} + + {previousMonths?.previous_period_three || 'Mar'} + - {currentMonths?.current_period_one || 'Apr'} - - {currentMonths?.current_period_two || 'May'} - - {currentMonths?.current_period_three || 'Jun'} - + {currentMonths?.current_period_one || 'Apr'} + + {currentMonths?.current_period_two || 'May'} + + {currentMonths?.current_period_three || 'Jun'} + - {additionalForecastMonths?.[0] || 'Jul'} - - {additionalForecastMonths?.[1] || 'Aug'} - - {additionalForecastMonths?.[2] || 'Sep'} - + {additionalForecastMonths?.[0] || 'Jul'} + + {additionalForecastMonths?.[1] || 'Aug'} + + {additionalForecastMonths?.[2] || 'Sep'} + - {forecastMonths?.forecast_period_one || 'Oct'} - - {forecastMonths?.forecast_period_two || 'Nov'} - - {forecastMonths?.forecast_period_three || 'Dec'} - - {previousMonths?.previous_period_one || 'Jan'} - - {previousMonths?.previous_period_two || 'Feb'} - - {previousMonths?.previous_period_three || 'Mar'} - + {forecastMonths?.forecast_period_one || 'Oct'} + + {forecastMonths?.forecast_period_two || 'Nov'} + + {forecastMonths?.forecast_period_three || 'Dec'} + + {previousMonths?.previous_period_one || 'Jan'} + + {previousMonths?.previous_period_two || 'Feb'} + + {previousMonths?.previous_period_three || 'Mar'} + - {currentMonths?.current_period_one || 'Apr'} - - {currentMonths?.current_period_two || 'May'} - - {currentMonths?.current_period_three || 'Jun'} - + {currentMonths?.current_period_one || 'Apr'} + + {currentMonths?.current_period_two || 'May'} + + {currentMonths?.current_period_three || 'Jun'} + - {forecastMonths?.forecast_period_one || 'Jul'} - - {forecastMonths?.forecast_period_two || 'Aug'} - - {forecastMonths?.forecast_period_three || 'Sep'} -
+ {forecastMonths?.forecast_period_one || 'Jul'} + + {forecastMonths?.forecast_period_two || 'Aug'} + + {forecastMonths?.forecast_period_three || 'Sep'} +
- {product.previous_quantity_period_one || '0'} -
-
-
- {product.previous_quantity_period_two || '0'} - {getVarianceDisplay(product.previous_quantity_period_one, product.previous_quantity_period_two, true)} -
-
-
- {product.previous_quantity_period_three || '0'} - {getVarianceDisplay(product.previous_quantity_period_two, product.previous_quantity_period_three)} + + {product.previous_quantity_period_one || "0"} +
+ {/* Previous Quarter – Month 2 */} +
- {product.current_quantity_period_one || '0'} - {getVarianceDisplay(product.previous_quantity_period_three, product.current_quantity_period_one)} + + {product.previous_quantity_period_two || "0"} + + {/* If previous quarter has values, show variance from 2nd column */} + {!isPreviousQuarterAllZeros && getVarianceDisplay( + product.previous_quantity_period_one, + product.previous_quantity_period_two + )}
+ + {/* Previous Quarter – Month 3 */} +
- {product.current_quantity_period_two || '0'} - {getVarianceDisplay(product.current_quantity_period_one, product.current_quantity_period_two)} + + {product.previous_quantity_period_three || "0"} + + {/* If previous quarter has values, show variance */} + {!isPreviousQuarterAllZeros && getVarianceDisplay( + product.previous_quantity_period_two, + product.previous_quantity_period_three + )}
+ + {/* Current Quarter – Month 1 */} +
- {product.current_quantity_period_three || '0'} - {getVarianceDisplay(product.current_quantity_period_two, product.current_quantity_period_three)} + + {product.current_quantity_period_one || "0"} + + {/* If previous quarter is all zeros, treat this as FIRST month */} + {!isPreviousQuarterAllZeros && getVarianceDisplay( + product.previous_quantity_period_three, + product.current_quantity_period_one + )} +
+
+
+ + {product.current_quantity_period_two || "0"} + + {/* Always show variance for Month 2 (vs Month 1) */} + {getVarianceDisplay( + product.current_quantity_period_one, + product.current_quantity_period_two + )} +
+
+
+ + {product.current_quantity_period_three || "0"} + + {/* Always show variance for Month 3 (vs Month 2) */} + {getVarianceDisplay( + product.current_quantity_period_two, + product.current_quantity_period_three + )}
+
{historicalData.forecast_quantity_period_one || '0'} {getVarianceDisplay(product.current_quantity_period_three, historicalData.forecast_quantity_period_one)}
+
{historicalData.forecast_quantity_period_two || '0'} {getVarianceDisplay(historicalData.forecast_quantity_period_one, historicalData.forecast_quantity_period_two)}
+
{historicalData.forecast_quantity_period_three || '0'} {getVarianceDisplay(historicalData.forecast_quantity_period_two, historicalData.forecast_quantity_period_three)} @@ -1386,19 +1348,19 @@ const additionalForecastLabel = showPreviousNext })()} {/* NEXT YEAR FORECAST Data (original from submission) */} -
+
{product.forecast_quantity_period_one || '0'} {getVarianceDisplay(product.current_quantity_period_three, product.forecast_quantity_period_one)}
+
{product.forecast_quantity_period_two || '0'} {getVarianceDisplay(product.forecast_quantity_period_one, product.forecast_quantity_period_two)}
+
{product.forecast_quantity_period_three || '0'} {getVarianceDisplay(product.forecast_quantity_period_two, product.forecast_quantity_period_three)} @@ -1407,59 +1369,98 @@ const additionalForecastLabel = showPreviousNext ) : ( <> + {/* Previous Quarter – Month 1 */}
{product.previous_quantity_period_one || '0'}
{product.previous_quantity_period_two || '0'} - {getVarianceDisplay(product.previous_quantity_period_one, product.previous_quantity_period_two, true)} + {!isPreviousQuarterAllZeros && getVarianceDisplay( + product.previous_quantity_period_one, + product.previous_quantity_period_two + )}
+ + {/* Previous Quarter – Month 3 */} +
{product.previous_quantity_period_three || '0'} - {getVarianceDisplay(product.previous_quantity_period_two, product.previous_quantity_period_three)} + {!isPreviousQuarterAllZeros && getVarianceDisplay( + product.previous_quantity_period_two, + product.previous_quantity_period_three + )}
+ {/* Current Quarter – Month 1 */} +
{product.current_quantity_period_one || '0'} - {getVarianceDisplay(product.previous_quantity_period_three, product.current_quantity_period_one)} + {!isPreviousQuarterAllZeros && getVarianceDisplay( + product.previous_quantity_period_three, + product.current_quantity_period_one + )}
+ + {/* Current Quarter – Month 2 */} +
{product.current_quantity_period_two || '0'} - {getVarianceDisplay(product.current_quantity_period_one, product.current_quantity_period_two)} + {getVarianceDisplay( + product.current_quantity_period_one, + product.current_quantity_period_two + )}
+ + {/* Current Quarter – Month 3 */} +
{product.current_quantity_period_three || '0'} - {getVarianceDisplay(product.current_quantity_period_two, product.current_quantity_period_three)} + {getVarianceDisplay( + product.current_quantity_period_two, + product.current_quantity_period_three + )}
+ {/* Next Year Forecast – Month 1 */} +
{product.forecast_quantity_period_one || '0'} - {getVarianceDisplay(product.current_quantity_period_three, product.forecast_quantity_period_one)} + {getVarianceDisplay( + product.current_quantity_period_three, + product.forecast_quantity_period_one + )}
+ + {/* Next Year Forecast – Month 2 */} +
{product.forecast_quantity_period_two || '0'} - {getVarianceDisplay(product.forecast_quantity_period_one, product.forecast_quantity_period_two)} + {getVarianceDisplay( + product.forecast_quantity_period_one, + product.forecast_quantity_period_two + )}
+ + {/* Next Year Forecast – Month 3 */} +
{product.forecast_quantity_period_three || '0'} - {getVarianceDisplay(product.forecast_quantity_period_two, product.forecast_quantity_period_three)} + {getVarianceDisplay( + product.forecast_quantity_period_two, + product.forecast_quantity_period_three + )}
- {product.previous_cost_period_one || '0'} -
-
-
- {product.previous_cost_period_two || '0'} - {getVarianceDisplay(product.previous_cost_period_one, product.previous_cost_period_two, true)} -
-
-
- {product.previous_cost_period_three || '0'} - {getVarianceDisplay(product.previous_cost_period_two, product.previous_cost_period_three)} + + {product.previous_cost_period_one || "0"} +
+ {/* Previous Cost – Month 2 */} +
- {product.current_cost_period_one || '0'} - {getVarianceDisplay(product.previous_cost_period_three, product.current_cost_period_one)} + + {product.previous_cost_period_two || "0"} + + {!isPreviousQuarterCostAllZeros && getVarianceDisplay( + product.previous_cost_period_one, + product.previous_cost_period_two + )}
+ + {/* Previous Cost – Month 3 */} + +
+ + {product.previous_cost_period_three || "0"} + + {!isPreviousQuarterCostAllZeros && getVarianceDisplay( + product.previous_cost_period_two, + product.previous_cost_period_three + )} +
+
+
+ {product.current_cost_period_one || '0'} + {!isPreviousQuarterCostAllZeros && getVarianceDisplay(product.previous_cost_period_three, product.current_cost_period_one)} +
+
{product.current_cost_period_two || '0'} {getVarianceDisplay(product.current_cost_period_one, product.current_cost_period_two)}
+
{product.current_cost_period_three || '0'} {getVarianceDisplay(product.current_cost_period_two, product.current_cost_period_three)} @@ -1517,19 +1534,19 @@ const additionalForecastLabel = showPreviousNext const historicalData = getCurrentYearForecastData(product?.product?.id); return ( <> -
+
{historicalData.forecast_cost_period_one || '0'} {getVarianceDisplay(product.current_cost_period_three, historicalData.forecast_cost_period_one)}
+
{historicalData.forecast_cost_period_two || '0'} {getVarianceDisplay(historicalData.forecast_cost_period_one, historicalData.forecast_cost_period_two)}
+
{historicalData.forecast_cost_period_three || '0'} {getVarianceDisplay(historicalData.forecast_cost_period_two, historicalData.forecast_cost_period_three)} @@ -1540,19 +1557,19 @@ const additionalForecastLabel = showPreviousNext })()} {/* NEXT YEAR FORECAST Cost (original from submission) */} -
+
{product.forecast_cost_period_one || '0'} {getVarianceDisplay(product.current_cost_period_three, product.forecast_cost_period_one)}
+
{product.forecast_cost_period_two || '0'} {getVarianceDisplay(product.forecast_cost_period_one, product.forecast_cost_period_two)}
+
{product.forecast_cost_period_three || '0'} {getVarianceDisplay(product.forecast_cost_period_two, product.forecast_cost_period_three)} @@ -1561,110 +1578,151 @@ const additionalForecastLabel = showPreviousNext ) : ( <> + {/* Previous Cost – Month 1 */}
{product.previous_cost_period_one || '0'}
{product.previous_cost_period_two || '0'} - {getVarianceDisplay(product.previous_cost_period_one, product.previous_cost_period_two, true)} + {!isPreviousQuarterCostAllZeros && getVarianceDisplay( + product.previous_cost_period_one, + product.previous_cost_period_two + )}
+ + {/* Previous Cost – Month 3 */} +
{product.previous_cost_period_three || '0'} - {getVarianceDisplay(product.previous_cost_period_two, product.previous_cost_period_three)} + {!isPreviousQuarterCostAllZeros && getVarianceDisplay( + product.previous_cost_period_two, + product.previous_cost_period_three + )}
+ {/* Current Cost – Month 1 */} +
{product.current_cost_period_one || '0'} - {getVarianceDisplay(product.previous_cost_period_three, product.current_cost_period_one)} + {!isPreviousQuarterCostAllZeros && getVarianceDisplay( + product.previous_cost_period_three, + product.current_cost_period_one + )}
+ + {/* Current Cost – Month 2 */} +
{product.current_cost_period_two || '0'} - {getVarianceDisplay(product.current_cost_period_one, product.current_cost_period_two)} + {getVarianceDisplay( + product.current_cost_period_one, + product.current_cost_period_two + )}
+ + {/* Current Cost – Month 3 */} +
{product.current_cost_period_three || '0'} - {getVarianceDisplay(product.current_cost_period_two, product.current_cost_period_three)} + {getVarianceDisplay( + product.current_cost_period_two, + product.current_cost_period_three + )}
+ {/* Forecast Cost – Month 1 */} +
{product.forecast_cost_period_one || '0'} - {getVarianceDisplay(product.current_cost_period_three, product.forecast_cost_period_one)} + {getVarianceDisplay( + product.current_cost_period_three, + product.forecast_cost_period_one + )}
+ + {/* Forecast Cost – Month 2 */} +
{product.forecast_cost_period_two || '0'} - {getVarianceDisplay(product.forecast_cost_period_one, product.forecast_cost_period_two)} + {getVarianceDisplay( + product.forecast_cost_period_one, + product.forecast_cost_period_two + )}
+ + {/* Forecast Cost – Month 3 */} +
{product.forecast_cost_period_three || '0'} - {getVarianceDisplay(product.forecast_cost_period_two, product.forecast_cost_period_three)} + {getVarianceDisplay( + product.forecast_cost_period_two, + product.forecast_cost_period_three + )}
- Reason (Current) - - – - - {product.other_variation_reason || - (product?.variation_reason?.reason ? - (product.variation_reason.reason.startsWith('Other (specify)') ? '' : product.variation_reason.reason) - : 'No reason provided') - } - - – - - – - - – - - {product.other_variation_reason || - (product?.variation_reason?.reason ? - (product.variation_reason.reason.startsWith('Other (specify)') ? '' : product.variation_reason.reason) - : 'No reason provided') - } - - – -
+ Reason (Current) + + – + + {product.other_variation_reason || + (product?.variation_reason?.reason ? + (product.variation_reason.reason.startsWith('Other (specify)') ? '' : product.variation_reason.reason) + : 'No reason provided') + } + + – + + – + + – + + {product.other_variation_reason || + (product?.variation_reason?.reason ? + (product.variation_reason.reason.startsWith('Other (specify)') ? '' : product.variation_reason.reason) + : 'No reason provided') + } + + – +
Reason (Forecast) @@ -1726,7 +1784,8 @@ const additionalForecastLabel = showPreviousNext - ))} + ); + })} ) : (