From 450324d29eb1d4746e086e20ca45381ddff81246 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Mon, 14 Mar 2022 19:48:45 +0000 Subject: [PATCH] Extract AccountWithReconciled --- web/src/components/AccountWithReconciled.vue | 31 +++++++++++++++ web/src/pages/BudgetSidebar.vue | 41 ++------------------ 2 files changed, 34 insertions(+), 38 deletions(-) create mode 100644 web/src/components/AccountWithReconciled.vue diff --git a/web/src/components/AccountWithReconciled.vue b/web/src/components/AccountWithReconciled.vue new file mode 100644 index 0000000..044c754 --- /dev/null +++ b/web/src/components/AccountWithReconciled.vue @@ -0,0 +1,31 @@ + + + \ No newline at end of file diff --git a/web/src/pages/BudgetSidebar.vue b/web/src/pages/BudgetSidebar.vue index cf793a1..0407e76 100644 --- a/web/src/pages/BudgetSidebar.vue +++ b/web/src/pages/BudgetSidebar.vue @@ -4,6 +4,7 @@ import Currency from "../components/Currency.vue" import { useBudgetsStore } from "../stores/budget" import { Account, useAccountStore } from "../stores/budget-account" import { useSettingsStore } from "../stores/settings" +import AccountWithReconciled from "../components/AccountWithReconciled.vue"; const settings = useSettingsStore(); const ExpandMenu = computed(() => settings.Menu.Expand); @@ -18,38 +19,6 @@ const OnBudgetAccounts = computed(() => accountStore.OnBudgetAccounts); 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 * days; - return new Date(now - recently).getTime() < account.LastReconciled.Time.getTime(); -} - -function getAccountName(account: Account) { - const days = daysSinceLastReconciled(account); - if(days === false) - return account.Name + " *"; - - if(days <= 7) - return account.Name; - - //const reconciledMarker = isRecentlyReconciled(account) ? "" : " *"; - return account.Name + " " + days; -}