Staff Margins (View as buyer)
Get Staff Margins for Products (View as buyer only)
Staff-only margin overlay for a 'View as buyer' session. Answers 403 (`reason: staff_margins_unavailable`) to every caller except a staff view token whose staff user holds `portal.manage` AND `financials.index` (checked live on each request) — a buyer login never receives cost data. Not embedded in the catalog payload: the portal fetches it only while 'Show margins' is on. Sent with `Cache-Control: no-store`.
Get Staff Margins for Special Order List Parts (View as buyer only)
Staff-only: margin $ and % on Special order list parts at their dealer price (`dealer`) and pre-order price (`preorder`), against both cost bases. `replacement` = the supplier price of the product an earlier order created from the part, else the list's STAFF-ONLY cost (synced from the sheet's cost tab, never part of any buyer response), moved by the tenant's replacement cost adjustment; `average` = that product's FIFO average cost, else null (never stocked). A basis with no cost is null (never 0). Same access rule as the products endpoint: only a 'View as buyer' session whose staff user may manage the portal and see costs; every other caller (a buyer above all) gets 403 and no data. Responses are `Cache-Control: no-store, private`.
Get Staff Cart Margin (View as buyer only)
Staff-only: the shared cart's margin at what the buyer would pay now, in its current `order_mode` (stock, or preorder on the catalogs' pre-order ladders), after every earned order-value discount, per cost basis, plus each line's. Same access rule as the products endpoint (403 to buyers). A line with no cost on a basis is left out of that basis and counted in `missing_cost_lines`. Margin = (price − cost) / price. `average` = FIFO average cost of stock on hand (what SKU books as COGS); `replacement` = the default supplier's price. A basis with no cost is null (never 0). When the tenant sets a replacement cost adjustment (Portal settings → Staff margin overlay, e.g. −15 'at special' for a merchant that only buys at the supplier's specials), `replacement` is the supplier price moved by it, `bases.replacement` names it, and `replacement_adjustment` = {percent, label} (null = none). A product with no FIFO cost (never stocked) shows the adjusted replacement figure as its headline. Special order list parts on the cart are counted in `bases` (net — no order-value discount touches them) and listed in `special_order_lines`, costed from the product an earlier order created or else from the list's staff-only cost.