feat(approvals): change_requests + quotes parent tables (PMS-484) #357
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/mokosh-server!357
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-484-approvals-parent-tables"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PMS-470 widened the polymorphic approvals surface to accept
/change-requests/{id}/approvalsand/quotes/{id}/approvalsbutheld the route handlers at 400 stubs because the parent tables that
assert_parent_existsneeds did not exist. PMS-484 ships those parenttables and flips the stubs into real round-trip handlers.
Migration 078 creates minimal change_requests + quotes tables:
status CHECK ('draft' | 'submitted' | 'approved' | 'rejected'),
timestamps + idx_change_requests_tenant.
same CHECK on status + idx_quotes_tenant.
Schema is deliberately minimal - just enough for the approval flow to
verify parent existence within the tenant and label rows in the SPA
approval timeline. A richer change-management / sales workflow is its
own follow-up.
Route handlers:
assert_parent_exists("change_requests", ...)then funnel intoservice.list_for_entity/service.create_for_entitywithApprovalTarget::ChangeRequest. Same pattern for the quote pair.Tests:
creates an approval against it via /change-requests/{id}/approvals,
asserts target=="change_request" + entity_id round-trips, lists
approvals on the change_request, then decides approve.
(change-requests, quotes, time-entries) with a zero UUID and pins
the 404 from the parent-existence check, replacing the prior
"placeholder returns 400" test now that the placeholders are gone.
#PMS-484
PMS-470 widened the polymorphic approvals surface to accept `/change-requests/{id}/approvals` and `/quotes/{id}/approvals` but held the route handlers at 400 stubs because the parent tables that `assert_parent_exists` needs did not exist. PMS-484 ships those parent tables and flips the stubs into real round-trip handlers. Migration 078 creates minimal change_requests + quotes tables: - change_requests: id PK, tenant_id FK, title, summary, requested_by_id, status CHECK ('draft' | 'submitted' | 'approved' | 'rejected'), timestamps + idx_change_requests_tenant. - quotes: same shape plus total_cents BIGINT + currency CHAR(3), same CHECK on status + idx_quotes_tenant. Schema is deliberately minimal - just enough for the approval flow to verify parent existence within the tenant and label rows in the SPA approval timeline. A richer change-management / sales workflow is its own follow-up. Route handlers: - list_for_change_request / create_for_change_request use `assert_parent_exists("change_requests", ...)` then funnel into `service.list_for_entity` / `service.create_for_entity` with `ApprovalTarget::ChangeRequest`. Same pattern for the quote pair. Tests: - change_request_approval_round_trip seeds a change_request row, creates an approval against it via /change-requests/{id}/approvals, asserts target=="change_request" + entity_id round-trips, lists approvals on the change_request, then decides approve. - quote_approval_round_trip mirrors the above for the quote prefix. - unknown_parent_returns_404 sweeps every polymorphic prefix (change-requests, quotes, time-entries) with a zero UUID and pins the 404 from the parent-existence check, replacing the prior "placeholder returns 400" test now that the placeholders are gone. #PMS-484