diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-04 10:27:02 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-04 10:27:02 +0700 |
| commit | 11ee2946884ddac60947761a04f3dda295781ec5 (patch) | |
| tree | 875da186c8eea4ae2f9755b1f05d591f94b1dc81 /src-migrate/modules/cart/stores | |
| parent | 69ca10032089ca3a73b201fd69df4398e8242b74 (diff) | |
<miqdad> fix cart tax
Diffstat (limited to 'src-migrate/modules/cart/stores')
| -rw-r--r-- | src-migrate/modules/cart/stores/useCartStore.ts | 9 |
1 files changed, 5 insertions, 4 deletions
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 }; }; |
