Skip to content

feat(shillinq): build purchasing-approval-delegation - #3180

Draft
rubenvdlinde wants to merge 4 commits into
developmentfrom
quality/build-purchasing-approval-delegation
Draft

rubenvdlinde wants to merge 4 commits into
developmentfrom
quality/build-purchasing-approval-delegation

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Builds openspec/changes/purchasing-approval-delegation (continuation of the earlier partial pass).

Tasks done

  • 1.1 x-openregister-approval-chains purchase-order-approval on PurchaseOrder.approve: cumulative tiers on totalExclVat (cents) — teamleider from 1 cent, facility_manager from EUR 10,000, procurement_manager from EUR 50,000 — with separation of duties and advanceTransition. The three roles map to shillinq_teamleider, shillinq_facility_manager and shillinq_procurement_manager in authorization.roles (the same way the commitment chain maps its roles). The order record now stores totalExclVat, so the chain has an amount to route on.
  • 1.2 Approval sidebar tab on the purchase order page: the shared tasks widget over the order's OpenRegister flow tasks (role, state, handler, deadline; outcomes offered to who may decide). Manifest configuration only.
  • 1.4 (part) supplier-invoice-approval chain on SupplierInvoice.approveMatched (controller from EUR 10,000 incl. VAT) and the same Approval tab on the invoice page.
  • 5.1 Release note below.
  • 1.3 The in-app approval engine is retired: PurchaseOrderApprovalService (+ interface), PurchaseOrderApprovalController, route purchaseOrderApproval#decide, MCP tool shillinq.purchase_order.decide, PurchaseOrderApprovalGuard (no longer on approve), PurchaseOrderApprovalEntry, the ApprovalDecision value objects and the delegated enum value. blockSendUntilApproved() → markSent(), which waits for statusCode approved. previewApprovalChain() reads the schema tiers through the new PurchaseOrderApprovalTiers. PurchaseOrderDecisionLockListener now refuses any user write that adds or changes the approvalChain history (stricter than before: no grant opens it any more). New repair step ResetPendingApprovalPurchaseOrders drops the undeclared lifecycleState: pending_approval.

Tasks left, and why

  • 1.1 / 1.3 live checks (re-import provisions steps for a seed order, repair on an instance, a live approval materialising its Commitment, hydra gates): need an instance.
  • 1.4 rest: ThreeWayMatchingEngine fires no SupplierInvoice transition today, so handing matched invoices to approveMatched is new engine behaviour still to build.
  • 2.1: OpenRegister has the task delegate verb with mandate and on_behalf_of, but the shared tasks widget in @conduction/nextcloud-vue has no delegate action; it belongs there.
  • 3.1: OpenRegister publishes no PHP contract to read an object's approval tasks, so the audit export cannot add decider / on-behalf-of / mandate server side yet.
  • check:manifest-budget already fails on development (1,340,650 B vs 1,316,700 B); these two tabs add about 1.7 KB. One vitest failure (dunningNextRun.spec.js) is red on development too.
  • 4.1 issue on openregister: its text must be shown to Ruben before posting, so it is not posted.
  • 5.1 release note: purchase order approval now runs on OpenRegister's chain and works; single hand-overs come with 2.1; an absence period ("while I am away") is not available yet.

Tests

  • Added: PurchaseOrderApprovalChainFragmentTest, PurchaseOrderApprovalTiersTest, ResetPendingApprovalPurchaseOrdersTest; rewrote the purchase order service, controller, integration, register-schema, audit-trail, guard and MCP provider tests onto the new path; removed the tests of the retired classes.
  • Unit suite before: 12796 tests, 0 failures. After: 12768 tests, 0 failures (the retired engine's tests removed, new ones added).
  • php -l, phpcs (0 errors) and phpstan (no errors) on the touched lib files.

Generated by Claude Code

Purchase order approval moves onto OpenRegister's declared approval chain
(REQ-PAD-001, tasks 1.1 and 1.3): the PurchaseOrder schema declares the
purchase-order-approval chain with cumulative tiers on totalExclVat, and the
in-object chain, its service, controller, route, MCP tool and guard are
retired. Sending waits for statusCode approved; the preview reads the
schema tiers; a repair step clears the undeclared pending_approval state.

Assisted-by: ClaudeCode:claude-opus-5-5
The purchase order page shows its OpenRegister approval steps in an
Approval sidebar tab through the shared tasks widget, so a user who may
decide a step approves it there (REQ-PAD-001, task 1.2).

Assisted-by: ClaudeCode:claude-opus-5-5
A matched supplier invoice from EUR 10.000 waits for a controller step of
the declared supplier-invoice-approval chain on approveMatched, shown in an
Approval tab on the invoice page (REQ-PAD-004, part of task 1.4). The tasks
file names what is left and why.

Assisted-by: ClaudeCode:claude-opus-5-5
Task 1.4: the three-way matching engine hands every matched supplier
invoice to its approveMatched transition and lets OpenRegister's
supplier-invoice-approval chain decide. Below the controller tier the
match approves the invoice; from EUR 10.000 the write is refused as
approval-chain-pending and the invoice stays matched until the
controller approves. SchemaRecordStore keeps the cause of a failed save
so that refusal can be told apart from a storage failure.

Adds ThreeWayMatchingEngineApprovalHandOverTest and the Playwright spec
for tasks 1.2, 1.4 and (fixme) 2.1; existing engine tests and the golden
record now expect the approved transition after matched.

Assisted-by: ClaudeCode:claude-opus-5-5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant