{
  "version": "2026-05-11",
  "globalRules": {
    "queryParam": "business_day_id",
    "validation": {
      "branchScoped": true,
      "description": "business_day_id must belong to authenticated user's branch"
    },
    "precedence": "When supported and provided, business_day_id filter overrides date-range filtering.",
    "immutability": {
      "description": "business_day_id is immutable on protected update endpoints",
      "updatePayloadRule": "prohibited"
    }
  },
  "businessDayLifecycle": {
    "open": {
      "method": "POST",
      "path": "/api/v1/business-days/open",
      "supportsBusinessDayFilter": false
    },
    "active": {
      "method": "GET",
      "path": "/api/v1/business-days/active",
      "supportsBusinessDayFilter": false,
      "notFoundWhenNoActive": true
    },
    "close": {
      "method": "POST",
      "path": "/api/v1/business-days/close",
      "supportsBusinessDayFilter": false
    },
    "reopen": {
      "method": "POST",
      "path": "/api/v1/business-days/reopen",
      "businessDayIdInBody": true,
      "branchScopedValidation": true
    },
    "summary": {
      "method": "GET",
      "path": "/api/v1/business-days/summary",
      "supportsBusinessDayFilter": true,
      "defaultsToActiveWhenMissing": true
    },
    "reconciliation": {
      "method": "GET",
      "path": "/api/v1/business-days/reconciliation",
      "supportsBusinessDayFilter": true,
      "defaultsToActiveWhenMissing": true
    },
    "closingValidation": {
      "method": "GET",
      "path": "/api/v1/business-days/closing-validation",
      "supportsBusinessDayFilter": true,
      "defaultsToActiveWhenMissing": true
    },
    "history": {
      "method": "GET",
      "path": "/api/v1/business-days/history",
      "supportsBusinessDayFilter": false
    }
  },
  "moduleMatrix": {
    "orders": {
      "dateColumnFallback": "created_at",
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/orders",
          "supportsBusinessDayFilter": true,
          "dateParams": ["date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/orders/by-date-range",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"],
          "dateRequiredWithoutBusinessDay": true
        },
        {
          "method": "GET",
          "path": "/api/v1/orders/status/{status}",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/orders/type/{type}",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/orders/pending",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/orders/preparing",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/orders/ready",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "POST",
          "path": "/api/v1/orders",
          "requiresActiveBusinessDay": true
        }
      ]
    },
    "drafts": {
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/drafts",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "POST",
          "path": "/api/v1/drafts",
          "requiresActiveBusinessDay": true
        },
        {
          "method": "POST",
          "path": "/api/v1/drafts/{id}/submit",
          "requiresActiveBusinessDay": true
        },
        {
          "method": "PUT",
          "path": "/api/v1/drafts/{id}",
          "businessDayIdMutable": false
        }
      ]
    },
    "payments": {
      "dateColumnFallback": "paid_at",
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/payments",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/payments/by-date-range",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"],
          "dateRequiredWithoutBusinessDay": true
        },
        {
          "method": "POST",
          "path": "/api/v1/payments",
          "requiresActiveBusinessDay": true
        },
        {
          "method": "POST",
          "path": "/api/v1/payments/partial",
          "requiresActiveBusinessDay": true
        }
      ]
    },
    "expenses": {
      "dateColumnFallback": "expense_date",
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/expenses",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/expenses/summary",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "POST",
          "path": "/api/v1/expenses",
          "requiresActiveBusinessDay": true
        },
        {
          "method": "PUT",
          "path": "/api/v1/expenses/{id}",
          "businessDayIdMutable": false
        },
        {
          "method": "PATCH",
          "path": "/api/v1/expenses/{id}",
          "businessDayIdMutable": false
        }
      ]
    },
    "supplierInvoices": {
      "dateColumnFallback": "invoice_date",
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/supplier-invoices",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/supplier-invoices/by-supplier/{supplierId}",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/supplier-invoices/pending",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/supplier-invoices/summary",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "POST",
          "path": "/api/v1/supplier-invoices",
          "requiresActiveBusinessDay": true
        },
        {
          "method": "PUT",
          "path": "/api/v1/supplier-invoices/{id}",
          "businessDayIdMutable": false
        }
      ]
    },
    "supplierPayments": {
      "dateColumnFallback": "payment_date",
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/supplier-payments",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/supplier-payments/by-invoice/{invoiceId}",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/supplier-payments/by-supplier/{supplierId}",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "GET",
          "path": "/api/v1/supplier-payments/summary",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "POST",
          "path": "/api/v1/supplier-payments",
          "requiresActiveBusinessDay": true
        }
      ]
    },
    "stockTransfers": {
      "dateColumnFallback": "transfer_date",
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/stock-transfers",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/stock-transfers/summary",
          "supportsBusinessDayFilter": true
        },
        {
          "method": "POST",
          "path": "/api/v1/stock-transfers",
          "requiresActiveBusinessDay": true
        },
        {
          "method": "PUT",
          "path": "/api/v1/stock-transfers/{id}",
          "businessDayIdMutable": false
        }
      ]
    },
    "financialReports": {
      "endpoints": [
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/dashboard",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/profit-and-loss",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/revenue-by-method",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/expense-summary",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/total-revenue",
          "supportsBusinessDayFilter": true,
          "dateParams": ["from_date", "to_date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/branch-comparison",
          "supportsBusinessDayFilter": false
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/daily-summary",
          "supportsBusinessDayFilter": false,
          "requiredParams": ["date"]
        },
        {
          "method": "GET",
          "path": "/api/v1/financial-reports/monthly-summary",
          "supportsBusinessDayFilter": false,
          "requiredParams": ["year", "month"]
        }
      ]
    }
  },
  "errorContract": {
    "validationError": {
      "status": 422,
      "shape": {
        "message": "string",
        "errors": {
          "field": ["string"]
        }
      }
    },
    "foreignBusinessDayExample": {
      "status": 422,
      "errorsField": "business_day_id"
    },
    "noActiveBusinessDayExample": {
      "status": 422,
      "errorsField": "business_day"
    },
    "immutableMutationExample": {
      "status": 422,
      "errorsField": "business_day_id",
      "messageContains": "prohibited"
    }
  },
  "frontendActions": {
    "sanitizeUpdatePayload": [
      "business_day_id"
    ],
    "defaultFilterStrategy": {
      "preferActiveBusinessDay": true,
      "fallbackToDateRangeWhenNoDay": true
    }
  }
}