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"}
]
}]
doc_statusis what a state does to the document: 0 keeps it a draft, 1 submits it, 2 cancels it.allowedis the role that may press the action. S11 uses roles every site has; a role that is not on the site is made at install, empty, for the retailer to give to staff.conditiondecides when the action is offered; it reads the record and two read-only helpers.send_email_alertmails whoever may act next.- A state's
update_fieldwrites only one of your app's own fields, because a workflow writes it and then submits. The till's own records take no workflow. The first workflow on a record type makes iVendFramework add its Workflow State field there; it stays at uninstall, as the retailer's.
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