From 11ee2946884ddac60947761a04f3dda295781ec5 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 4 Jun 2025 10:27:02 +0700 Subject: fix cart tax --- src-migrate/modules/cart/components/Summary.tsx | 6 +++--- src-migrate/modules/cart/stores/useCartStore.ts | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/cart/components/Summary.tsx b/src-migrate/modules/cart/components/Summary.tsx index 68db6323..312160fb 100644 --- a/src-migrate/modules/cart/components/Summary.tsx +++ b/src-migrate/modules/cart/components/Summary.tsx @@ -197,12 +197,12 @@ const CartSummary = ({
- + Grand Total - - Rp {formatCurrency(displayGrandTotal)} + + Rp {formatCurrency(grandTotal || 0)}
diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts index 69cf0384..be48b1ed 100644 --- a/src-migrate/modules/cart/stores/useCartStore.ts +++ b/src-migrate/modules/cart/stores/useCartStore.ts @@ -193,13 +193,12 @@ const transformCookieItemToProduct = (item: any): CartItem => ({ package_price: item.package_price, }); -// Helper function to compute cart summary const computeSummary = (cart: CartProps): Summary => { if (!cart?.products) { return { subtotal: 0, discount: 0, total: 0, grandTotal: 0, tax: 0 }; } - const PPN = parseFloat(process.env.NEXT_PUBLIC_PPN || '0'); + const PPN = parseFloat(process.env.NEXT_PUBLIC_PPN || '1.11'); let subtotal = 0; let discount = 0; @@ -216,8 +215,10 @@ const computeSummary = (cart: CartProps): Summary => { } const total = subtotal - discount; - const grandTotal = total * (1 + PPN); - const tax = grandTotal - total; + + // PERBAIKAN: + const tax = total * (PPN - 1); + const grandTotal = total + tax; return { subtotal, discount, total, grandTotal, tax }; }; -- cgit v1.2.3