From 8dd3268738961ffc26e672bf7fce366fc34fef80 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 20 Feb 2025 11:08:33 +0700 Subject: [PATCH] refactor: simplify total calculation logic in quotation and debit note pages --- src/pages/05_quotation/MainPage.vue | 10 +--------- src/pages/12_debit-note/MainPage.vue | 7 ++++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index 4b280ef6..b73c5f35 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -390,15 +390,7 @@ async function storeDataLocal(id: string) { color: hsl(var(--info-bg)); " > - {{ - quotationStats[ - pageState.currentTab === 'Invoice' - ? 'paymentInProcess' - : (toCamelCase( - pageState.currentTab, - ) as keyof typeof quotationStats) - ] - }} + {{ Object.values(quotationStats).reduce((a, c) => a + c, 0) }} - {{ pageState.total }} + {{ + Object.entries(stats).reduce( + (sum, [key, value]) => (key === 'canceled' ? sum : sum + value), + 0, + ) + }}