iVendNextDevelopers Request a sandbox

A back-office check that blocks a document (check by workflow) — the recipe

Some checks must stop a document until they pass: a goods receipt that must match what was ordered, or carry a code for every unit, before it is booked. Inside the shop that would be code run at submit, which partners do not ship. This recipe gets the same result with configuration and your own service: the document's workflow books it only at a Verified step that only your service can take. It is for an iVendNext Partner, or the CitiXsys Consulting Team.

Reference implementation: samples/s22_customer_loyalty/ — apply_config.py (receipt_workflow) and service/receipts.py: a Purchase Receipt is verified only when no row receives more than its purchase order still waits for.

When to use it. The check reads data your service holds or reads over the API, and the people submitting can wait a few seconds. For a check on the till's sale before payment, use a check before payment (recipe); for a format or a limit on one record's own fields, a save rule (chapter 7).

Steps

  1. The workflow (configuration, over the API — a manifest may not put a workflow on the shop's own record types):

    State Books the document Who may move it on
    Draft no the clerk: Send for Verification
    Pending Verification no your service's role only: Verify · a manager: Override
    Overridden yes —
    Verified yes —

    ⚠ List Overridden before Verified. A submit through the API that steps around the workflow lands in the first state that books; listed first, it is recorded as Overridden, never as Verified.

    ⚠ Self-approval: allow it on Send for Verification (the clerk sends their own document on) and refuse it on Verify, Override and cancelling. With every step refusing it, the clerk who made a document cannot even send it.

  2. Take the submit right from every other role on that record type (the shop's Role Permissions Manager, or apply_config.py). A workflow alone does not stop a submit through the API; without this step anyone with the submit right books the document unchecked. Keep it for your service's role (the Verify step books the document) and the manager's (the Override step). Record every row you change, and its reason.

  3. Your service follows the record type on the event feed. Each save of a document in Pending Verification writes an event, a moment after the save. Read the document, run your check, then (the key that reads the document also needs read on the records it names, such as a receipt's supplier):

    • passes: take the Verify action through the API (ivendnext_mpos.api.v1.apply_workflow); the document books;
    • fails: leave it where it is and add a comment saying why, in words the clerk can act on.
  4. Act once. A document already past Pending Verification is left alone, so a replayed event changes nothing.

  5. Test it: your check on the laptop (the sample's tests), then on a sandbox: Verify refused for the manager and taken by your service; a clerk's submit refused before Verified, in the form and through the API; Override refused for a role that does not hold it.

What is refused, and why

When your service is down, and when the till is offline

Technical notes

Bounds

What was proven where

Needs this serves

This page in the kit