From 7f10d924ea8d51b61d98f890bdeba1ee63f68db3 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 19 Oct 2022 14:14:34 +0700 Subject: [PATCH] financial --- src/views/Dashboard/DashboardProject.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index 92cb313..7922ef8 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -59,7 +59,7 @@ const DashboardProject = () => { const [estAtCompletion, setEstAtCompletion] = useState(null) const [bcwp, setBcwp] = useState(null) const [costDeviation, setCostDeviation] = useState(null) - const [remToComplete, setRemToComplete] = useState(null) + const [remToComplete, setRemToComplete] = useState(0) const [totalInvoice, setTotalInvoice] = useState(null) const [cashIn, setCashIn] = useState(null) const [outstandingBalance, setOutstandingBalance] = useState(null) @@ -95,6 +95,15 @@ const DashboardProject = () => { } }, [activeTabIdx]); + useEffect(() => { + let deviation = 0; + if(plannedCost && totalCost){ + deviation = plannedCost - totalCost; + } + setRemToComplete(deviation) + + }, [plannedCost, totalCost]); + const getProjectDetail = async () => { setIsReadyProjectDetail(false); const URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`; @@ -160,7 +169,7 @@ const DashboardProject = () => { setCurrentBudget(result.data.data[0].data.budget_control.current_budget?.toString()) setActualToDate(result.data.data[0].data.budget_control.acwp?.toString()) setBcwp(result.data.data[0].data.budget_control.current_budget?.toString()) - setRemToComplete(result.data.data[0].data.budget_control.rem_to_complete?.toString()) + // setRemToComplete(result.data.data[0].data.budget_control.rem_to_complete?.toString()) setAddCostToComplete(result.data.data[0].data.budget_control.add_cost_to_complete?.toString()) setEstAtCompletion(result.data.data[0].data.budget_control.estimated_at_completion?.toString()) setCostDeviation(result.data.data[0].data.budget_control.cost_deviation?.toString()) @@ -596,10 +605,10 @@ const DashboardProject = () => { Rem. to Complete - {/* {isReadyProjectDetail && isReadyIntegrationInvoice ? */} - {/* remToComplete ? renderFormatRupiah(plannedCost - totalCost, 'Rp.') : '-' */} - {/* : */} - {/* } */} + {isReadyProjectDetail && isReadyIntegrationInvoice ? + remToComplete ? renderFormatRupiah(remToComplete, 'Rp.') : '-' + : + }