iVendNextDevelopers My apps

Worked example: an approval

Part 6 of 7 · 7. Manifests

Back: Print formats that read other recordsNext: What is refused, and technical notes

A Purchase Order over 50,000 waits for a Purchase Manager, and approving it submits it; a smaller one the buyer submits (sample S11). It is one workflow on the customer's own record type, with no service, no key and no record type of its own, so we host nothing for it:

"workflows": [{
  "name": "PP APR Purchase Order Approval",
  "document_type": "Purchase Order",
  "send_email_alert": 1,
  "states": [
    {"state": "Draft",     "doc_status": 0, "allow_edit": "Purchase User"},
    {"state": "Approved",  "doc_status": 1, "allow_edit": "Purchase Manager"},
    {"state": "Rejected",  "doc_status": 0, "allow_edit": "Purchase User"},
    {"state": "Cancelled", "doc_status": 2, "allow_edit": "Purchase Manager"}
  ],
  "transitions": [
    {"state": "Draft", "action": "Approve", "next_state": "Approved",
     "allowed": "Purchase Manager", "condition": "doc.base_grand_total > 50000"},
    {"state": "Draft", "action": "Reject", "next_state": "Rejected",
     "allowed": "Purchase Manager", "condition": "doc.base_grand_total > 50000"},
    {"state": "Draft", "action": "Submit", "next_state": "Approved",
     "allowed": "Purchase User", "condition": "doc.base_grand_total <= 50000"},
    {"state": "Rejected", "action": "Review", "next_state": "Draft", "allowed": "Purchase User"},
    {"state": "Approved", "action": "Cancel", "next_state": "Cancelled", "allowed": "Purchase Manager"}
  ]
}]
ivn new acme_po_approval --from s11
ivn check
ivn try

As the buyer, raise a Purchase Order over the amount; as the approver, open it and press Approve: it reads Approved and it is submitted. Build your first app takes this sample to your customer, and Approvals by workflow adds more steps, more states, a required budget code or a mail with the order's print attached.

Back: Print formats that read other recordsNext: What is refused, and technical notes

This page in the kit