summaryrefslogtreecommitdiff
path: root/src-migrate/modules/cart/stores
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-22 10:10:19 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-22 10:10:19 +0700
commit5cc3c938da3dfde636b918b8f2fdef33f3c61419 (patch)
tree222177fe6dce70fc608698c700de17032105998a /src-migrate/modules/cart/stores
parent238c675eecaf6f4f953d87c4b0a128bfa139cff4 (diff)
parent6d9c1067b6e857eb95f12864cc88117350ae6cfb (diff)
Merge branch 'new-release' into CR/form-merchant
# Conflicts: # src/lib/form/components/Merchant.jsx
Diffstat (limited to 'src-migrate/modules/cart/stores')
-rw-r--r--src-migrate/modules/cart/stores/useCartStore.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts
index c2ebf50f..e7d2cdd3 100644
--- a/src-migrate/modules/cart/stores/useCartStore.ts
+++ b/src-migrate/modules/cart/stores/useCartStore.ts
@@ -43,17 +43,20 @@ export const useCartStore = create<State & Action>((set, get) => ({
updateCartItem: (updatedCart) => {
const cart = get().cart;
if (!cart) return;
-
+
set({ cart: updatedCart });
const summary = computeSummary(updatedCart);
set({ summary });
},
-
+
}));
const computeSummary = (cart: CartProps) => {
let subtotal = 0;
let discount = 0;
+
+ const PPN: number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0;
+
for (const item of cart?.products) {
if (!item.selected) continue;
@@ -67,8 +70,9 @@ const computeSummary = (cart: CartProps) => {
discount += price - item.price.price_discount * item.quantity;
}
let total = subtotal - discount;
- let tax = Math.round(total * 0.11);
- let grandTotal = total + tax;
+ let grandTotal = total * PPN;
+ let tax = grandTotal - total;
+ // let grandTotal = total + tax;
- return { subtotal, discount, total, tax, grandTotal };
+ return { subtotal, discount, total, grandTotal, tax };
}; \ No newline at end of file