HOCO B2B
Team tasksAnis

SRV-15 — Cart & checkout rules

Server-side cart, re-validation of price/stock/promotions, minimum amount and quantities, max per order, credit check, checkout options and idempotent checkout.

FieldDetails
Task codeSRV-15
PhaseP1 — V1 build & integration
Product scopeV1
StatusDone (Mon 19 Oct 2026)
StartMon 19 Oct 2026
DueMon 19 Oct 2026
ResponsibleAnis — Full-stack developer
Co-responsible—
Effort1 person-day(s) planned · 5 from scratch · size S
Area · appServer · server
Depends onSRV-12, SRV-13
UnblocksSRV-16, SRV-19, SRV-40
Milestones—

Summary

Server-side cart, re-validation of price/stock/promotions, minimum amount and quantities, max per order, credit check, checkout options and idempotent checkout.

Description

The cart is server-side and shared across the reseller's devices (ORD-01, RWA-02), and checkout must never trust the client (cahier §5.3, §8, §12; ORD-02, ORD-03, PRC-05, FIN-05). This task implements Cart/CartItem, re-validation on every read (current customer-type price, promotions through the pricing hook, availability, visibility), the cart rules — orders.minAmount (ORDER_MIN_AMOUNT_NOT_MET), minimum quantity and step per variant (QUANTITY_NOT_ALLOWED), maximum per order, stock (STOCK_INSUFFICIENT without revealing the available quantity), basic credit check for the CREDIT method (CREDIT_LIMIT_EXCEEDED) — checkout options (addresses, enabled payment methods, delivery-fee estimate, note) and the idempotent cart.checkout that creates the order in SUBMITTED with snapshots and a CMD-YYYY-NNNNNN number. Every order then waits for back-office confirmation (ORD-14). Guests have no cart. Out of scope: the order state machine after submission (SRV-16) and promotion definitions (SRV-19).

Subtasks

#SubtaskOwner
1Cart and CartItem services: cart.get, items.add (idem), items.update, items.remove, clear; one active cart per resellerAnis
2Re-validation pipeline on read: visibility/status (PRODUCT_UNAVAILABLE), price by customer type, promotions hook, availability, line issues listAnis
3Quantity rules: minQty, qtyStep, maxQtyPerOrder per variant and orders.minAmount per orderAnis
4Stock check against available without exposing quantities (issue STOCK_INSUFFICIENT only)Anis
5Credit check for CREDIT payment via the CreditAccount read interface (ceiling − exposure), policy credit.overLimitPolicyAnis
6cart.checkoutOptions: addresses, payment methods enabled by setting, delivery-fee estimate from the delivery-fee policy, note limitsAnis
7cart.checkout: Idempotency-Key required, account ACTIVE gate, expectedTotal comparison (409 CART_CHANGED with re-validated cart), order + item snapshots, number allocation, cart emptied, promotion caps consumed — one transactionAnis
8Outbox order.submitted with channel RESELLER_APP or RESELLER_WEB from X-App-Platform / clientAnis
9Cart issue codes and checkout error payloads reviewed for the mobile cart screensImad

Deliverables

  • apps/server/src/modules/cart/{cart.service.ts,validation.ts,checkout.service.ts,router.ts}
  • packages/contracts/src/cart.ts implemented end to end
  • Cart rules section in /docs/srs/business-rules confirmed

Acceptance criteria

  • The same cart is returned from the mobile app and the web for one reseller (ORD-01, RWA-02)
  • Checkout below orders.minAmount returns 422 ORDER_MIN_AMOUNT_NOT_MET with the missing amount in details (ORD-02)
  • Checkout with a CREDIT payment above the available credit returns 422 CREDIT_LIMIT_EXCEEDED (FIN-05)
  • Replaying cart.checkout with the same Idempotency-Key returns the same order; a different body with the same key returns 409 IDEMPOTENCY_KEY_REUSED
  • A price change between cart view and checkout returns 409 CART_CHANGED and creates no order (PRC-05)
  • A successful checkout creates an order in SUBMITTED (never VALIDATED) visible in admin.orders.toConfirm (ORD-03, ORD-14)

Requirements covered

RequirementTitleRelease
ORD-01Server-side cart shared across the reseller's devices (mobile and web)V1
ORD-02Cart rules: minimum amount, minimum quantities and steps, maximum per order, stock and credit checksV1
ORD-03Checkout: address, note, payment method; a unique order number; immediately visible in the back-officeV1
PRC-05Prices and stock re-validated at cart and at checkout; the reseller only ever sees their own priceV1
FIN-05Basic credit control: ceiling, used and available credit checked at checkoutV1

Screens

ScreenNameApp
RA-17CartRA
RA-18CheckoutRA
RW-06CartRW
RW-07Checkout & confirmationRW

API surface

Endpoint groupOperations
Cart & checkout8

Test measures

  • DB tests for checkout atomicity (failure after number allocation rolls everything back)
  • Unit tests for quantity and minimum-amount rules
  • Concurrent double-tap test: two checkouts with the same key create one order

Risks

  • Credit exposure is owned by billing (SRV-18, later) — define the CreditAccount read interface now with a stub returning no ceiling, replaced when SRV-18 lands

KPI

  • Delivered by Mon 19 Oct 2026 within 1 person-day(s).
  • Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
  • Zero open critical defects, permission gaps or data-integrity regressions at sign-off.

Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.

On this page