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 | |
| parent | 69ca10032089ca3a73b201fd69df4398e8242b74 (diff) | |
<miqdad> fix cart tax
Diffstat (limited to 'src-migrate')
| -rw-r--r-- | src-migrate/modules/cart/components/Summary.tsx | 6 | ||||
| -rw-r--r-- | src-migrate/modules/cart/stores/useCartStore.ts | 9 |
2 files changed, 8 insertions, 7 deletions
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 = ({ <div className={style.divider} /> - <Skeleton isLoaded={isLoaded}> + <Skeleton isLoaded={isLoaded} className={style.line}> <span className={clsxm(style.label, style.grandTotal)}> Grand Total </span> - <span className={clsxm(style.value, style.grandTotalValue)}> - Rp {formatCurrency(displayGrandTotal)} + <span className={style.value}> + Rp {formatCurrency(grandTotal || 0)} </span> </Skeleton> </div> 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 }; }; |
