manicanldes-backend/docs/b2b-quotations-api.md

2.6 KiB
Raw Blame History

B2B quotations (Phase 3C)

Staff issue quotations to verified business accounts using an active account-specific price list. Issuance saves the account profile, price-list name, variant SKU and name, unit prices, MOQs, quantities, and merchandise total as immutable snapshots. An archived price list or later catalog price change cannot alter an issued quote.

Method Route Permission Purpose
GET /api/v1/b2b/quotes b2b.quote.read List scoped quotes with limit, offset, and optional accountId
POST /api/v1/b2b/quotes b2b.quote.manage Issue a quotation
GET /api/v1/b2b/quotes/:id b2b.quote.read Read the full snapshot and response
POST /api/v1/b2b/quotes/:id/response b2b.quote.manage Record customer acceptance, decline, or staff withdrawal

Issue with accountId, priceListId, expiresAt (RFC 3339 with timezone, within the next 90 days), optional customerReference, 1–100 distinct lines of { "variantId": "<UUID>", "quantity": 12 }, and idempotencyKey (UUID). Every quantity must meet its price-list MOQ. The response includes an opaque BQ-... quotation number, currency, fixed two-decimal merchandise total, account snapshot, and line snapshots. Repeating the same request and key returns the original quotation even if its price list has since been archived; changing the request with the same key returns a conflict.

A new quotation has status ISSUED, or EXPIRED once its deadline passes without a response. Recording { "kind": "ACCEPTED", "note": "Customer accepted by email", "idempotencyKey": "<UUID>" } changes the displayed status to ACCEPTED. DECLINED and WITHDRAWN are also available. Staff must record a note identifying the basis for the response. Only one response is allowed, and it must be recorded before expiry. Responses are immutable and support idempotent retries.

This is a merchandise-only quotation. It excludes tax, shipping, stock reservation, payment, and credit terms, and ACCEPTED does not create an order. Staff should communicate those limits before seeking acceptance; B2B order conversion belongs to a later phase. Apply the timestamped migration with pnpm db:deploy. Existing system Owner roles gain the quotation permissions; custom roles must be granted them explicitly.