From 035617c8e841445f9b452185595b94fe2baf4f4f Mon Sep 17 00:00:00 2001 From: chamikaJ Date: Fri, 30 May 2025 16:50:15 +0530 Subject: [PATCH] fix(finance-table): correct cost calculations in finance table - Updated the cost display logic to show actual costs from logs instead of estimated costs. - Adjusted the total cost calculation to reflect the difference between total actual and fixed costs. - Enhanced the accumulation of actual costs in the finance table's totals computation. --- .../finance/finance-tab/finance-table/finance-table.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/worklenz-frontend/src/pages/projects/projectView/finance/finance-tab/finance-table/finance-table.tsx b/worklenz-frontend/src/pages/projects/projectView/finance/finance-tab/finance-table/finance-table.tsx index d7540c58..c5f7ee8b 100644 --- a/worklenz-frontend/src/pages/projects/projectView/finance/finance-tab/finance-table/finance-table.tsx +++ b/worklenz-frontend/src/pages/projects/projectView/finance/finance-tab/finance-table/finance-table.tsx @@ -119,7 +119,7 @@ const FinanceTable = ({ case FinanceTableColumnKeys.ESTIMATED_COST: return {formatNumber(formattedTotals.estimated_cost)}; case FinanceTableColumnKeys.COST: - return {formatNumber(formattedTotals.estimated_cost)}; + return {formatNumber(formattedTotals.actual_cost_from_logs)}; case FinanceTableColumnKeys.FIXED_COST: return {formatNumber(formattedTotals.fixed_cost)}; case FinanceTableColumnKeys.TOTAL_BUDGET: @@ -335,7 +335,7 @@ const FinanceTable = ({ case FinanceTableColumnKeys.TOTAL_ACTUAL: return {formatNumber(task.total_actual)}; case FinanceTableColumnKeys.COST: - return {formatNumber(task.estimated_cost || 0)}; + return {formatNumber((task.total_actual || 0) - (task.fixed_cost || 0))}; default: return null; } @@ -364,6 +364,7 @@ const FinanceTable = ({ hours: acc.hours + (task.estimated_seconds || 0), total_time_logged: acc.total_time_logged + (task.total_time_logged_seconds || 0), estimated_cost: acc.estimated_cost + (task.estimated_cost || 0), + actual_cost_from_logs: acc.actual_cost_from_logs + ((task.total_actual || 0) - (task.fixed_cost || 0)), fixed_cost: acc.fixed_cost + (task.fixed_cost || 0), total_budget: acc.total_budget + (task.total_budget || 0), total_actual: acc.total_actual + (task.total_actual || 0), @@ -373,6 +374,7 @@ const FinanceTable = ({ hours: 0, total_time_logged: 0, estimated_cost: 0, + actual_cost_from_logs: 0, fixed_cost: 0, total_budget: 0, total_actual: 0, @@ -386,6 +388,7 @@ const FinanceTable = ({ hours: formatSecondsToTimeString(totals.hours), total_time_logged: formatSecondsToTimeString(totals.total_time_logged), estimated_cost: totals.estimated_cost, + actual_cost_from_logs: totals.actual_cost_from_logs, fixed_cost: totals.fixed_cost, total_budget: totals.total_budget, total_actual: totals.total_actual,