Get Sales Order Financials (Proforma)
GET/api/sales-orders/:salesOrder/financials
Recalculates and returns proforma (on-the-fly) line-level financials for a single sales order. The endpoint runs SalesOrderLineFinancialManager::calculate() for the order before responding, so figures always reflect current FIFO cost assignments — including the bundle cost-based revenue correction (SKU-7157).
Authentication: Requires Bearer token.
Response (wrapped in {data}):
- id: Sales order ID
- is_tax_included, currency (code cached at time of sale), currency_rate
- sales_order_lines[]: per-line proforma P&L:
- product: {id, sku, name} (present when the line is a product line)
- description, quantity, price (per-unit amount in tenant currency), tax_allocation, tax_rate_id
- revenue: recognized revenue for the line (after any bundle cost-based correction)
- revenue_allocation_basis: "document" (revenue follows the order document) or "cost_corrected" (bundle-group revenue re-allocated in proportion to actual COGS so no component shows a phantom line-level loss — SKU-7157)
- document_revenue: pre-correction revenue computed from the order document (quantity × amount − included tax); equals revenue unless revenue_allocation_basis is cost_corrected
- bundle_id: parent bundle product ID when the line was expanded from a bundle (null otherwise)
- bundle_proration_basis: how the bundle's price was prorated across components at order entry — "cost", "price", or "quantity" (null for non-bundle or legacy lines)
- bundle: {id, sku, name} (present when bundle_id is set)
- revenue_allocated, credits, discount, total_revenue
- cogs, cost_allocated, cogs_returned, total_cost
- profit, profit_margin
- per_unit: {revenue, revenue_allocated, credits, discount, total_revenue, cogs, cost_allocated, cogs_returned, total_cost, profit}
- cost_breakdown: cost category → amount map
- cost_breakdown_layers[]: FIFO layer-level cost detail (layer_kind, fifo_layer_id, fifo_layer_date, quantity, source_type, source_label, source_id, breakdown, total, unit_cost)
- fifo_layers[]: {id, name, quantity, unit_cost, total_cost, layer_date}
Request
Responses
- 200
OK