Skip to content

Purchase Requests (طلبات الشراء)

Internal purchase requisitions — departments request items before a formal Purchase Order is created.

Status Workflow

StatusEditableCan SubmitCan ApproveCan RejectCan Cancel
draftYesYesNoNoYes
pending_approvalNoNoYesYesYes
approvedNoNoNoNoYes
rejectedYesYesNoNoNo
convertedNoNoNoNoNo
cancelledNoNoNoNoNo

Entity Attributes

PurchaseRequest

FieldTypeDescription
idintegerPrimary key
company_idintegerTenant company
branch_idintegerBranch (nullable)
request_numberstringAuto-generated (e.g., PR-2026-00001)
datedateRequest date
requested_byintegerUser ID of requester
departmentstringDepartment name (EN)
department_arstringDepartment name (AR)
needed_bydateRequired-by date
priorityenumlow, normal, high, urgent
reason / reason_arstringJustification
notes / notes_arstringAdditional notes
cost_center_idintegerOptional cost center
statusenumSee workflow above
approved_byintegerApprover user ID
approved_atdatetimeApproval timestamp
rejection_reasonstringReason for rejection
subtotaldecimal(15,3)Sum of item estimated totals

PurchaseRequestItem

FieldTypeDescription
idintegerPrimary key
purchase_request_idintegerFK to purchase request
sort_orderintegerDisplay order
product_idintegerRequested product
product_variant_idintegerOptional variant
unit_idintegerUnit of measure
description / description_arstringItem description
quantitydecimal(15,3)Requested quantity
estimated_pricedecimal(15,3)Estimated unit price
estimated_totaldecimal(15,3)quantity x estimated_price
preferred_supplier_idintegerOptional preferred supplier
notesstringItem-level notes

API Endpoints

MethodEndpointPermissionDescription
GET/api/purchases/requestspurchases.requests.viewList purchase requests
POST/api/purchases/requestspurchases.requests.createCreate purchase request
GET/api/purchases/requests/{id}purchases.requests.viewShow purchase request
PUT/api/purchases/requests/{id}purchases.requests.updateUpdate purchase request
DELETE/api/purchases/requests/{id}purchases.requests.deleteDelete draft request
POST/api/purchases/requests/{id}/submit-approvalpurchases.requests.approveSubmit for approval
POST/api/purchases/requests/{id}/approvepurchases.requests.approveApprove request
POST/api/purchases/requests/{id}/rejectpurchases.requests.approveReject request
POST/api/purchases/requests/{id}/cancelpurchases.requests.approveCancel request

Query Parameters (List)

ParameterTypeDescription
statusstringFilter by status
requested_byintegerFilter by requester user ID
prioritystringFilter by priority
branch_idintegerFilter by branch
date_fromdateStart date filter
date_todateEnd date filter
searchstringSearch in request_number, department, reason

Examples

Create Purchase Request

bash
curl -X POST /api/purchases/requests \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2026-02-25",
    "department": "IT",
    "department_ar": "تقنية المعلومات",
    "needed_by": "2026-03-15",
    "priority": "high",
    "reason": "Equipment replacement",
    "items": [
      {
        "product_id": 1,
        "unit_id": 1,
        "quantity": 10,
        "estimated_price": 25.000
      }
    ]
  }'
dart
final response = await dio.post('/api/purchases/requests', data: {
  'date': '2026-02-25',
  'department': 'IT',
  'department_ar': 'تقنية المعلومات',
  'needed_by': '2026-03-15',
  'priority': 'high',
  'reason': 'Equipment replacement',
  'items': [
    {
      'product_id': 1,
      'unit_id': 1,
      'quantity': 10,
      'estimated_price': 25.000,
    }
  ],
});

Reject Request

bash
curl -X POST /api/purchases/requests/1/reject \
  -H "Authorization: Bearer {token}" \
  -d '{"reason": "Budget exceeded"}'
dart
await dio.post('/api/purchases/requests/1/reject', data: {
  'reason': 'Budget exceeded',
});

Business Rules

  • Purchase requests are auto-numbered using the PR sequence (e.g., PR-2026-00001)
  • Only draft and rejected requests can be edited or resubmitted
  • Only draft requests can be deleted
  • Submitting for approval requires at least one item
  • Rejection requires a reason string
  • The subtotal is automatically recalculated when items change

Moon ERP API Documentation