Skip to content

template-apparel-erp: Wholesale portal route group (wholesale)/ — NET-30 orders, tier-gated #1257

@willgriffin

Description

@willgriffin

Parent

Epic: #1245

What to build

B2B portal at b2b.<tenant>.demo.local — the (wholesale)/ route group of template-apparel-erp. Authenticated wholesale customers place line-sheet orders against negotiated terms.

Auth

Uses @happyvertical/smrt-users session. Customers gain access by having customerType: 'wholesale' on their Customer record. Non-wholesale customers visiting the subdomain get redirected to the storefront.

Pages

  • / — account summary: outstanding balance, recent orders, payment-due dates
  • /line-sheet — full line sheet (Styles × Makeups × Colorways × Sizes grid) with wholesale prices and per-unit case packs
  • /order/new — line-sheet order builder: bulk-quantity entry per size grid, running totals, MOQ enforcement
  • /orders — order history, status, tracking
  • /orders/[id] — order detail with downloadable PO confirmation PDF
  • /invoices — open invoices, due dates, "Pay invoice" link (NET-30: separate flow, no Stripe at point of order)

Tier gate

The (wholesale)/ route group is hidden entirely if the tenant's commerce.wholesalePortal feature is off (Starter tier). The subdomain returns 404 in that case.

Order flow

Creates a WholesaleOrder (Contract STI, already shipped). Status flow: DRAFT (in the builder) → SENT (submitted by buyer) → ACCEPTED (sales team approves) → COMPLETED (fulfilled). Invoice generated on ACCEPTED with NET-30 due date. Stock reserved on ACCEPTED, not on SENT (so buyers can submit speculative orders without holding inventory).

Acceptance criteria

  • Subdomain b2b.<tenant>.demo.local routes to (wholesale)/
  • Wholesale customers can log in and view their account summary
  • Non-wholesale customers redirected to storefront
  • Tier gate: tenant on Starter → 404 for the entire route group
  • Line-sheet order builder works end-to-end, creates a WholesaleOrder
  • On approval, Invoice generated with NET-30 due date, AR journal entry posted, stock reserved
  • Manual verification: log in as wholesale customer, place a 200-unit line-sheet order, approve it from admin, confirm invoice + stock reservation + AR journal

Blocked by

  • #1251 — template scaffold

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions