fix(contracts): align contract dropdown values with backend CHECK constraints (MAPPS-190) #178

Merged
vas2000-work merged 1 commit from fix/MAPPS-190-contract-dropdown-values into main 2026-06-16 01:42:18 +02:00
Owner

What

The contract create/edit form in src/pages/contracts.rs populated its Type, billing cycle, and line-item Type dropdowns with SelectOption VALUES that did not match the mokosh-server backend CHECK constraints. The default Contract Type ("Managed Services") submitted managed, which the backend rejects with a 422, so creating a contract failed out of the box. The filter dropdown and the contract-type humanize/badge helpers used the same wrong tags, so listing/filtering and label rendering would break once any record stored a correct value.

Change

Aligned all option VALUE strings to the authoritative backend set (labels kept human-readable):

  • contract_type: managed -> managed_services, time_materials -> time_and_materials, added warranty (now: managed_services, block_hours, time_and_materials, fixed_price, warranty). Form default changed managed -> managed_services.
  • billing_cycle: annual -> annually (now: monthly, quarterly, annually, one_time).
  • line-item item_type: recurring -> recurring_service, removed bogus usage, added retainer and product (now: recurring_service, block_hours, retainer, product, one_time). Both hardcoded item defaults (Add Item button and submit fallback) changed recurring -> recurring_service.
  • Updated the filter Type dropdown and the humanize_contract_type / contract_type_variant helpers to the same values so filtering and badges match stored data.

Authoritative sources confirmed by grep: mokosh-server/src/utils/validation.rs (CONTRACT_TYPES) and mokosh-server/migrations/009_contracts.sql (CHECK on billing_cycle and contract_line_items.item_type).

Testing

In ghcr.io/niceguyit/rust-builder-glibc:v1.0.1-rust1.94-trixie:

  • cargo fmt --all --check clean
  • cargo clippy --all-targets -- -D warnings no warnings
  • cargo check --target wasm32-unknown-unknown passes
## What The contract create/edit form in `src/pages/contracts.rs` populated its Type, billing cycle, and line-item Type dropdowns with `SelectOption` VALUES that did not match the mokosh-server backend CHECK constraints. The default Contract Type ("Managed Services") submitted `managed`, which the backend rejects with a 422, so creating a contract failed out of the box. The filter dropdown and the contract-type humanize/badge helpers used the same wrong tags, so listing/filtering and label rendering would break once any record stored a correct value. ## Change Aligned all option VALUE strings to the authoritative backend set (labels kept human-readable): - contract_type: `managed` -> `managed_services`, `time_materials` -> `time_and_materials`, added `warranty` (now: managed_services, block_hours, time_and_materials, fixed_price, warranty). Form default changed `managed` -> `managed_services`. - billing_cycle: `annual` -> `annually` (now: monthly, quarterly, annually, one_time). - line-item item_type: `recurring` -> `recurring_service`, removed bogus `usage`, added `retainer` and `product` (now: recurring_service, block_hours, retainer, product, one_time). Both hardcoded item defaults (Add Item button and submit fallback) changed `recurring` -> `recurring_service`. - Updated the filter Type dropdown and the `humanize_contract_type` / `contract_type_variant` helpers to the same values so filtering and badges match stored data. Authoritative sources confirmed by grep: `mokosh-server/src/utils/validation.rs` (CONTRACT_TYPES) and `mokosh-server/migrations/009_contracts.sql` (CHECK on billing_cycle and contract_line_items.item_type). ## Testing In `ghcr.io/niceguyit/rust-builder-glibc:v1.0.1-rust1.94-trixie`: - `cargo fmt --all --check` clean - `cargo clippy --all-targets -- -D warnings` no warnings - `cargo check --target wasm32-unknown-unknown` passes
fix(contracts): align contract dropdown values with backend CHECK constraints (MAPPS-190)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m10s
Create release / Create release from merged PR (pull_request) Has been skipped
ab7056e293
The contract Type, billing cycle, and line-item type selects sent values the backend rejects (managed, time_materials, annual, recurring, usage), so creating a contract with the default Type failed with 422. Correct the option values to the accepted set (managed_services/time_and_materials/fixed_price/warranty/block_hours; monthly/quarterly/annually/one_time; recurring_service/block_hours/retainer/product/one_time) and keep human-readable labels.

#MAPPS-190

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!178
No description provided.