ServiceRequest model + migration #122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Type
Feature
Lineage
Child of spike #121 (client request flow design). Part of Phase 3 (Property Features).
Repo
ldraney/landscaping-assistantUser Story
As admin, I need a data model to track client requests (package changes and projects) so I can quote prices and manage the approval workflow.
Context
Clients request package changes ("add trimming") and projects ("build a retaining wall") through a unified flow. Both need the same lifecycle: requested → quoted → accepted → paid → scheduled → completed (or declined at eligible stages). The ServiceRequest model captures this with a
request_typefield to distinguish the two.Also adds
monthly_priceto the existing Service model for package pricing.File Targets
db/migrate/*_create_service_requests.rb(new)db/migrate/*_add_monthly_price_to_services.rb(new)app/models/service_request.rb(new)app/models/property.rb(add has_many :service_requests)app/models/crew_member.rb(add has_many :service_requests)db/seeds.rb(add prices to existing services)spec/models/service_request_spec.rb(new)Acceptance Criteria
Status Transition Graph (as delivered)
Note: The
acceptedstate was added during implementation (not in original spec) to separate "client agrees to price" from "client has paid." This is the correct business workflow for landscaping where payment may be handled in person.Known gap:
quoted → declinedandaccepted → declinedtransitions are missing — tracked in #206.No other transitions are valid.
declinedandcompletedare terminal states.Test Expectations
spec/models/service_request_spec.rb: validations, status transitions, associationsbundle exec rspecConstraints
crew_member_idreferencescrew_memberstable (clients are crew_members with role=client)Feature Flag
None
Checklist
Related
docs/user-stories-auth.md— ServiceRequest ERDScope Review: NEEDS_REFINEMENT
Review note:
review-1347-2026-06-07Three issues must be resolved before this ticket is agent-ready.
user_idcolumn has no backing table. There is nouserstable in the database. The app stores identity askeycloak_usernameoncrew_members. The ERD'sUserentity is a Phase 4 concept. Clarify whetheruser_idshould be a string column (Keycloak sub/username) or a FK tocrew_members.declined? The flow diagram is ambiguous. Add an explicit transition table.arch-rails-apparchitecture note does not exist in pal-e-docs.File targets, repo placement, dependencies (#121 done), and decomposition all check out.
Scope refinement (post review-1347-2026-06-07):
user_id→crew_member_id: Changed to FK oncrew_members— clients are crew_members withrole=client. Nouserstable exists.declinedreachable fromrequestedandquotedonly.crew_member.rbfor thehas_manyassociation.Scope Review: APPROVED (re-review)
Review note:
review-1347-2026-06-07-r2All three issues from the initial review have been resolved:
user_idreplaced withcrew_member_idreferencing existingcrew_memberstable. Verified table exists in committed schema.Template is complete, all 7 file targets verified against codebase, acceptance criteria are testable, no decomposition needed. Ticket is ready for implementation.
Carried forward (non-blocking):
[SCOPE]Createarch-rails-apparchitecture note in pal-e-docs.ldraney referenced this issue2026-06-13 22:06:54 +00:00