Skip to main content

Confirm a purchase order

The example connects a simulated ERP, Getriebe and a simulated supplier. The ERP sends a purchase request. A reviewer approves it in the Worklist. Getriebe submits the purchase order and waits for confirmation or the deadline. Start with the TypeScript workspace.

Install the workspace according to its README and run:

Terminal window
pnpm example:purchase-order-messages

The demo uses a loopback Effect server and its own SQLite database. It deploys the BPMN and both XSD files, opens approval tasks, and records the order IDs accepted by the supplier adapter.

Run What to observe
PO-4711 The supplier’s confirmation is consumed. The message wins, the instance completes, and the Worklist has no follow-up.
PO-4712 The timer wins and the Worklist opens Follow up with supplier. The subsequent confirmation is recorded as late. The follow-up remains open.

The output includes the instance ID, outgoing message ID, reply receipt ID and winner. The example also repeats the ERP submission with the same message ID and payload and checks that the original start receipt returns.

  1. Run pnpm example:purchase-order-messages --serve. Copy its loopback origin, using it in place of http://127.0.0.1:PORT below.

  2. In another terminal, run GETRIEBE_API_ORIGIN=http://127.0.0.1:PORT pnpm dev:worklist. Open the URL printed by Vite and sign in as reviewer with password reviewer.

  3. Submit from a separate terminal.

    Terminal window
    node apps/server/examples/purchase-order/erp.ts http://127.0.0.1:PORT ERP-4711 1250.50
  4. Refresh the Worklist if needed. Claim and open Approve purchase request and complete it with purchaseOrderId set to PO-4711 and supplierId set to SUPPLIER-1. Find the accepted order ID in the server terminal.

  5. Confirm during the ten-second wait window.

    Terminal window
    node apps/server/examples/purchase-order/supplier.ts http://127.0.0.1:PORT PO-4711

Repeat with new request and order IDs. Wait ten seconds and refresh for Follow up with supplier before confirming the second order. The late receipt and its arrival time appear in the authorized instance detail.

Open purchase-order.bpmn, purchase-request.xsd and purchase-order-messages.xsd from apps/server/examples/purchase-order/ together in Modeler. Select the start, Send Task or catch to inspect its typed mappings. The Correlation section on the Send Task connects the outgoing and reply fields. The Event-Based Gateway exposes the two possible continuations.

Use the modeling guide to change the model and the server reference for the delivery and receipt API.