From 324e13f5c53acadfc47f78b84f5356b34f7041ce Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Mon, 14 Mar 2022 19:34:17 +0000 Subject: [PATCH] Show age in days --- web/src/pages/BudgetSidebar.vue | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/web/src/pages/BudgetSidebar.vue b/web/src/pages/BudgetSidebar.vue index 4b2697d..cf793a1 100644 --- a/web/src/pages/BudgetSidebar.vue +++ b/web/src/pages/BudgetSidebar.vue @@ -19,18 +19,36 @@ const OffBudgetAccounts = computed(() => accountStore.OffBudgetAccounts); const OnBudgetAccountsBalance = computed(() => accountStore.OnBudgetAccountsBalance); const OffBudgetAccountsBalance = computed(() => accountStore.OffBudgetAccountsBalance); +const days = 24 * 60 * 60 * 1000; +function daysSinceLastReconciled(account: Account) { + if(!account.LastReconciled.Valid) + return false; + + const now = new Date().getTime(); + const diff = new Date(now).getTime() - account.LastReconciled.Time.getTime(); + return Math.floor(diff / days); + //const recently = 7 * days; +} + function isRecentlyReconciled(account: Account) { if(!account.LastReconciled.Valid) return false; const now = new Date().getTime(); - const recently = 7 * 24 * 60 * 60 * 1000; + const recently = 7 * days; return new Date(now - recently).getTime() < account.LastReconciled.Time.getTime(); } function getAccountName(account: Account) { - const reconciledMarker = isRecentlyReconciled(account) ? "" : " *"; - return account.Name + reconciledMarker; + const days = daysSinceLastReconciled(account); + if(days === false) + return account.Name + " *"; + + if(days <= 7) + return account.Name; + + //const reconciledMarker = isRecentlyReconciled(account) ? "" : " *"; + return account.Name + " " + days; }