iVendNextDevelopers My apps

Approvals across stores — a store manager's limit, head office above it — the recipe

This recipe is Approvals by workflow (S11) grown for a chain. A price change names its store; the store manager of that store approves it up to a limit, and head office approves anything above; each store sees only its own requests; a small outside service applies the change once.

Next: the sample, S14 · Price change approvals across storesAll recipes

In the App library: Price change approvals across stores

Requests in two stores: a store manager approves within their limit, head office above it, and the price row follows

Reference implementation: samples/s14_approvals_stores/ (a manifest, an outside service, tests).

When to use it. When the person who may approve depends on the store and on the size of the change, and the retailer has more than one store.

Steps

  1. Four roles. The install makes each role the manifest names that iVendNext does not have, empty, for the customer to give to staff. The sample names PP APS Requester, PP APS Store Manager, PP APS Head Office and PP APS Applier; the customer gives each to the right people. In a real roll-out use the chain's own roles, which the install leaves as they are. ⚠ No one holds a raising role and an approving role, and no one holds both approving roles. The retailer's own self-approval check covers the Approve action only.

  2. Install the app (samples/s14_approvals_stores/manifest.json). It holds one record type and one workflow:

    • the price change request: item, price list, store (fixed once raised), new price, reason, change tracking on;
    • a workflow of five states: Requested → Store Approved → Head Office Approved → Price set (stored as Applied), and Rejected. The store manager approves or rejects; head office approves (from Requested or Store Approved) or rejects (from any); the service applies from either approved state. Every row writes all nine rights out. The store manager, head office and service can read and write requests.
  3. Fence each person to their store — in the retailer's iVendNext. For every requester and store manager, one User Permission on POS Profile (their store). iVendNext then shows them, and lets them approve, their own store's requests only; a requester cannot raise a request for another store. Head office and the service have no store fence: they see all stores. The install gives the requester select on POS Profile (role_rights), so the Store box lists the stores their User Permission allows, and head office the same, for the list's Store filter.

    What each person sees: the store manager store manager's list and head office head office's list.

  4. Set the limit. A store manager's limit is one number for the chain: the service's LIMIT_PCT setting, a percentage of the price now (10 when unset). Who may approve is the workflow's roles plus the store's User Permission from step 3.

  5. The service's key: read and write on Item Price, fenced by a User Permission on the price lists it serves (Applicable For Item Price only), plus read and write on the request type (its workflow action saves the request). It cannot raise a request.

  6. Run the outside service (approvals_stores.py apply) as often as you like. For each request in Store Approved or Head Office Approved, oldest first, it checks, and only then writes the price and takes the Apply action (Desk shows it as Mark price set) — once, and a rerun after a kill finishes it without writing the price again. It refuses and says why:

    • It refuses a request whose item, price list, price or store changed after it was raised; ten or more recorded changes; no recorded approval; no or two price rows;
    • an approval given by the person who raised the request — at any step, not only the last;
    • a store approval whose price row changed after the approval (an earlier request applied, another role's edit): the limit was judged against a price that is gone, so the manager rejects it and it is raised again. This stops two requests approved side by side adding up past the limit — two +10% requests would otherwise make +21%; requests approved one after another each still move the price by up to the limit (below). A head-office approval names the price it wants and is applied whatever the row holds;
    • a change above the store manager's limit that head office has not approved: it waits, and the report says so.
    • a request rejected while the service was applying it: the action fails, and the service puts the price back and says so — within one run. If a run was killed after writing the price and the request is rejected before the next run, no run looks at it again: check that price row by hand.

    A refusal is written only in the service's report: keep the report. The request's own history shows who approved at each step and the service's Apply.

    Where the service does not run (Try does not run it), the Store price applier sets the price on its price list (Item Price) first, then presses Mark price set: the button records the step and writes no price. Give Store price applier to someone who already edits prices (the role brings no right on Item Price), and mark a request over the limit only after head office approved it: by hand, no service checks the limit.

    What it looks like: the manager's action the manager approves, a change within the limit applied applied, a change above the limit waiting waiting for head office, then head office's yes and the service's apply applied after head office, and the price row the price row.

  7. Schedule the export (approvals_stores.py export --day <date> --out <folder>): the day's requests with the store and who approved at each step, who applied and who rejected, and a column changed_after_raise that says yes where the item, price list, price or store was edited after the request was raised (iVendNext lets a requester edit an Applied request; the history keeps the truth, and the file now says so).

Know these limits

What is refused, and why

Needs this serves

This page in the kit