This document defines the fundamental business rules that govern SEAPEDIA's marketplace behavior. These rules apply across multiple levels and must be reflected consistently in both frontend and backend.
SEAPEDIA is a multi-seller marketplace, but each cart may only contain products from one store at a time.
flowchart TD
A[Buyer adds product to cart] --> B{Cart is empty?}
B -->|Yes| C[Add product, set cart to store]
B -->|No| D{Product from same store?}
D -->|Yes| E[Add product to cart]
D -->|No| F[Show conflict dialog]
F --> G{Buyer choice}
G -->|Clear cart & switch| H[Clear cart, add new product]
G -->|Cancel| I[Keep current cart]
- A cart is scoped to a single store (
carts.storeId) - If a buyer tries to add a product from a different store, the system shows a confirmation dialog
- The buyer can choose to clear the cart and switch to the new store
- The buyer can also cancel and keep the current cart
- This rule is enforced on both frontend (UI guard) and backend (API validation)
- Frontend:
apps/web/src/features/buyer/— cart components check store before add - Backend:
services/commerce/src/modules/buyers/buyers-cart.service.ts— validates storeId matches
deliveryFee = { instant: 30000, next_day: 15000, regular: 10000 }
discountedSubtotal = max(0, subtotal - discountAmount)
taxBase = discountedSubtotal + deliveryFee
ppn = round(taxBase * 0.12)
totalAmount = taxBase + ppn
- Subtotal — Sum of (price × quantity) for all cart items
- Discount — Applied from Voucher or Promo code (cannot be combined)
- Delivery Fee — Based on selected delivery method
- PPN 12% — Applied to (discounted subtotal + delivery fee)
- Final Total — Tax base + PPN
Cart: Samsung Galaxy A15 (Rp 2,899,000) × 1
Discount: HEMAT25K (Rp 25,000 voucher)
Delivery: Instant (Rp 30,000)
subtotal = 2,899,000
discountAmount = 25,000
discountedSubtotal = 2,874,000
deliveryFee = 30,000
taxBase = 2,874,000 + 30,000 = 2,904,000
ppn = round(2,904,000 × 0.12) = 348,480
totalAmount = 2,904,000 + 348,480 = 3,252,480
services/commerce/src/modules/orders/orders-checkout.service.ts:25-31—calculateTotals()
| Method | Delivery Fee | SLA |
|---|---|---|
| Instant | Rp 30,000 | 2 hours |
| Next Day | Rp 15,000 | 24 hours |
| Regular | Rp 10,000 | 48 hours |
- Delivery fee is set during checkout based on the selected method
- The delivery fee is paid by the Buyer as part of the total
- The delivery fee is earned 100% by the Driver upon job completion
Drivers earn 100% of the delivery fee for each completed delivery.
- The delivery fee is stored on the
deliveryJobsrecord at creation time - Upon job completion, the delivery fee is credited to the driver's earnings
- Earnings are calculated as the sum of
deliveryFeefrom all completed delivery jobs - The earning amount is displayed in the job detail view before the driver accepts
services/commerce/src/modules/driver/driver.service.ts:165-171— earnings calculation
- Seller income is calculated as the sum of
subtotalfrom fully completed (pesanan_selesai) orders - Delivery fees, PPN, and other checkout components are excluded from seller income
- Refunded or returned orders are not counted as seller income
- If seller income was already recorded, a reversal transaction is created
services/commerce/src/modules/orders/orders-seller.service.ts— income report
- Buyer spending is calculated as the sum of
totalAmountfrom fully completed (pesanan_selesai) orders - This excludes cancelled, refunded, or returned orders
- The spending report shows the total amount deducted from the buyer's wallet
services/commerce/src/modules/orders/orders-buyer.service.ts— expense report
- Every non-admin user has a wallet with a balance
- Balance is stored in IDR (integer, no decimals)
- Top-up is a dummy simulation — balance is credited immediately
- Wallet is charged during checkout
- Refunds from overdue orders are credited back to the wallet
- Wallet transaction history records all top-ups, payments, and refunds
| Type | Description |
|---|---|
topup |
Balance credited (dummy simulation) |
payment |
Balance deducted (checkout) |
refund |
Balance credited (overdue return) |
See ORDER-LIFECYCLE.md for the complete order lifecycle.
- Initial order status after checkout:
sedang_dikemas - Seller must process the order before a Driver can take it
- Only one Driver can take a job at a time
- Every status change is recorded with a timestamp in
order_status_history - Overdue orders are automatically moved to
dikembalikan
See DISCOUNTS.md for the complete discount system.
- Voucher and Promo cannot be combined in a single checkout
- If both are provided, the system applies the higher-value discount
- Expired or fully-used discounts cannot be applied
- Discount is applied before PPN calculation
- Discount is reflected in the checkout summary
- Store names must be unique across the platform
- A Seller may only manage their own store
- Uniqueness is enforced via database constraints and backend validation
- Store slug is auto-generated from the store name
- Products must belong to a store
- A Seller may only create/update/delete products under their own store
- Product stock must be non-negative
- Stock is reduced during checkout
- Stock is restored during overdue refund
soldCountis incremented when a delivery job is completed
- Application reviews are about the platform experience, not specific products
- Guests may submit application reviews
- Product reviews are only available to buyers who completed an order
- One review per buyer per product (unique constraint)
- All user-generated content must be rendered safely (XSS prevention)