This reference documents the GOAL Backend native Orders v1 REST API (/v1/sales/orders/*), the Order Statuses Master API (/v1/sales/master/order-statuses/*), and the Company Config policy (settings.sales.orders) powering the new /app/{companyId}/sales/goal-orders/* frontend module.
[!NOTE]
Legacy SB1/pre-sale order endpoints (/v1/pre-sale/orders/*) remain untouched for backwards compatibility with/app/{companyId}/sales/orders/*.
All endpoints require Bearer authentication, companyId query/body parameter, and GOAL V2 permissions on App\Models\Orders\Order:
| Action | V2 Permission Code |
|---|---|
| List / Dashboard / Deliveries / History | GOAL_V2_ORDERS_ORDER_LIST |
Order Detail (GET /{id}) |
GOAL_V2_ORDERS_ORDER_DETAILS |
Edit (DRAFT only) / Recalculate Promos / Status Master |
GOAL_V2_ORDERS_ORDER_UPDATE |
Confirm (DRAFT, PENDING, APPROVED → CONFIRMED) |
GOAL_V2_ORDERS_ORDER_CONFIRM |
| Approve / Authorize | GOAL_V2_ORDERS_ORDER_APPROVE |
| Discount Request / Apply / Reject | GOAL_V2_ORDERS_ORDER_REQUEST_DISCOUNT, APPLY_DISCOUNT, REJECT_DISCOUNT |
| Cancel / Restore | GOAL_V2_ORDERS_ORDER_CANCEL, GOAL_V2_ORDERS_ORDER_RESTORE |
| Print / Send Email / Export | GOAL_V2_ORDERS_ORDER_PRINT, SEND_EMAIL, EXPORT |
/v1/sales/orders)GET /v1/sales/ordersReturns paginated native GOAL orders sorted by order_date DESC, id DESC, with batch-hydrated dimension display names (zone_name, sales_team_name, sales_team_group_name, order_source_name) via OrderDimensionNameResolver.
| Query Parameter | Type | Default | Description |
|---|---|---|---|
companyId |
integer |
required | Tenant company ID. |
per_page |
integer |
15 (max 500) |
Page size (cast to int, clamped 1..500). |
date_from, date_to |
YYYY-MM-DD |
— | Inclusive order_date range filter (UI defaults to current day; max days governed by Company Config settings.sales.orders.max_date_range_days, default 3). |
status |
string |
— | Filters by order_status (16-status lifecycle). |
distribution_center_id |
string\|int |
— | Matches branch_code, warehouse_code, or warehouse_id. |
zone_id |
integer |
— | Matches territory_id. |
sales_team_id |
integer |
— | Matches sales_team_id. |
sales_team_group_id |
string\|int |
— | Matches portfolio_code or portfolio_id. |
order_source |
string |
— | Filters by capture channel (APP_MOBILE, ONLINE_STORE, BEES, MANUAL, etc.). |
search |
string |
— | Matches order_number, customer_name, customer_code, seller_name, purchase_order. |
GET /v1/sales/orders/{id}Accepts either UUID (uuid / uid) or numeric id via OrderController::resolveOrderId(). Returns the order with orderLines, company, user, and hydrated dimension names.
DRAFT Only) — PUT /v1/sales/orders/{id}Accepts UUID or numeric id. Enforced by UpdateOrderAction: returns 422 Unprocessable Entity if order_status !== 'DRAFT'.
GET /v1/sales/orders/dashboard (alias /summary)Computes KPIs and 6 interactive breakdowns directly from orders via GetOrdersDashboardAction:
total_orders, gross_total, net_total, avg_ticket, pending_approval_count, pending_approval_amount, discount_total, discount_rate, promoted_count (via has_promotions), promo_share, cancelled_count, cancel_rate, delivered_count, fulfillment_rate.by_distribution_center, by_status, by_zone, by_sales_team, by_sales_team_group, by_order_source, plus by_day_trend.POST /v1/sales/orders/{id}/recalculate-promotionsConnected to PromotionEngine (GBoni), BuildMobilePromotionsSnapshotAction, and PromotionBudgetGuard:
{
"companyId": 8,
"dry_run": true,
"preserve_manual_discounts": true,
"force_recalculate": false
}
order_metadata.promotions_preapplied === true (applied offline by goal_me) and force_recalculate === false, returns 200 OK with { "skipped": true, "reason": "PREAPPLIED_BY_MOBILE" }.dry_run: false): Idempotently replaces prior BONIFICATION lines (in PZA), updates subtotal/total_amount, and reserves budgets via PromotionBudgetGuard.| Method & Path | Description |
|---|---|
POST /v1/sales/orders/{id}/confirm |
Transitions DRAFT, PENDING, or APPROVED → CONFIRMED. |
POST /v1/sales/orders/{id}/approve |
Authorizes PENDING / PENDING_APPROVAL → APPROVED. |
POST /v1/sales/orders/{id}/cancel |
Cancels order and triggers PromotionBudgetGuard::releaseByOrderUid() (R12). |
POST /v1/sales/orders/{id}/restore |
Restores CANCELLED / REJECTED order back to PENDING. |
POST /v1/sales/orders/{id}/request-discount |
Sends DRAFT / PENDING order into PENDING_APPROVAL with discount request. |
POST /v1/sales/orders/{id}/apply-discount |
Applies commercial discount (Factura, Nota de Crédito, or Ambos). |
POST /v1/sales/orders/{id}/reject-discount |
Rejects pending discount request with mandatory reason. |
POST /v1/sales/orders/{id}/print |
Returns printable order payload. |
POST /v1/sales/orders/{id}/send-email |
Queues order summary email to customer or specified address. |
GET /v1/sales/orders/{id}/deliveries |
Read-only delivery records linked to the order (accepts UUID or ID). |
GET /v1/sales/orders/{id}/history |
Read-only status transition timeline (accepts UUID or ID). |
POST /v1/sales/orders/bulk/approve |
Bulk-authorizes order_ids[], returning { succeeded, failed }. |
POST /v1/sales/orders/bulk/cancel |
Bulk-cancels order_ids[] with reason, returning { succeeded, failed }. |
POST /v1/sales/orders/bulk/recalculate-promotions |
Bulk GBoni recalculation on order_ids[], returning { succeeded, failed }. |
[!IMPORTANT]
Operational fulfillment transitions (DELIVERY_PLANNED,INVOICED,PICKING,QUALITY_CHECK,HANDLING,READY_FOR_DELIVERY,STOCK_DISPATCHED,DELIVERED,LIQUIDATED) are driven exclusively by massive/downstream processes and are not manually triggerable from the Orders v1 UI.
/v1/sales/master/order-statuses)Backed by migration 2026_11_21_140000_create_order_statuses_table.php (order_statuses table, unique (company_id, code)). If the migration has not yet been executed, GET / safely returns 200 OK with data: [] and migration_pending: true.
| Method & Path | Description |
|---|---|
GET /v1/sales/master/order-statuses |
Lists company order statuses sorted by sort_order (view=A\|I\|D\|ALL). |
GET /v1/sales/master/order-statuses/{id} |
Retrieves a single status record. |
POST /v1/sales/master/order-statuses |
Creates or updates a status by (company_id, code). |
PUT /v1/sales/master/order-statuses/{id} |
Updates name, description, color (hex), badge_variant (soft\|filled\|outlined), sort_order, allow_edit, allow_cancel, is_terminal. |
DELETE /v1/sales/master/order-statuses/{id} |
Soft-deletes a status (status = 'D'). |
PUT /v1/sales/master/order-statuses/{id}/restore |
Restores a soft-deleted status (status = 'A'). |
POST /v1/sales/master/order-statuses/seed-defaults |
Idempotently seeds all 16 default lifecycle statuses & hex colors for companyId. |
GET /v1/sales/master/order-sources): Fixed ListOrderSourcesAction to query order_sources as a global master table (removed invalid company_id filter).settings.sales.orders): Registered in CompanySettingsCatalog with max_date_range_days (default 3, min 1, max 31) and default_date_mode (SINGLE | RANGE), publishable to Global Template Company (company_id = 1).