Skip to content

feat: ordering update - #40

Merged
CPrutean merged 5 commits into
mainfrom
feat/ordering-update
Aug 21, 2026
Merged

feat: ordering update#40
CPrutean merged 5 commits into
mainfrom
feat/ordering-update

Conversation

@CPrutean

@CPrutean CPrutean commented Aug 21, 2026

Copy link
Copy Markdown
Member

Rewrote ordering system for clarity.

CPrutean and others added 5 commits August 20, 2026 19:36
Snapshots 0010 and 0011 both recorded 0009 as prevId, so drizzle-kit
refused to diff the schema and no new migration could be generated.

Only the lineage pointer was wrong: 0011's snapshot already contained
both 0010's `name_changed_at` column and its own `sim_export_cache`
table, and the two migrations touch unrelated tables. No applied SQL
changes, so no environment needs re-migrating.

Claude-Session: https://claude.ai/code/session_01GvXPAmtJMzagwAWdiEeWiH
Both "Back" buttons passed a next/link into `render` while `nativeButton`
still defaulted to true, so Base UI warned that a non-<button> was
dropping native button semantics, which affects forms and accessibility.

Matches the pattern already used in OrderTable and the orders index.

Claude-Session: https://claude.ai/code/session_01GvXPAmtJMzagwAWdiEeWiH
Ordering took six clicks and a full page round-trip per item, and every
item re-asked for the fund type and STF bucket. Members also had to know
the finance model to file a request at all.

Members now submit items only. The form drops fund type and bucket, and
one submission can carry up to 50 items: "Add another item" grows the
single-item form into a full-width grid, and "Paste a list" ingests rows
copied out of a spreadsheet. Items submitted together share a batchId.
Vendor is guessed from the link's domain when left blank.

Officers own the finance model instead. The queue splits pending orders
into "Needs triage" and "Ready to review", and acts on a multi-select:
POST /api/orders/assign sets fund, bucket and quarter, and
POST /api/orders/bulk-action approves or denies.

Balance checks move from submit time to assign/approve time. A member has
no bucket to check against, and a balance checked at submit is stale by
review. Two consequences:

- Approving a selection checks each fund/bucket group's total at once.
  Checking one at a time would let a batch overdraw a bucket that every
  individual order fits inside.
- Assigning counts the selection plus everything already queued against
  that bucket. Pending orders don't reduce a bucket's remaining balance,
  so otherwise an officer could park more there than could be approved.

fund_type is now nullable, which forces a SQLite table rebuild. The
generated INSERT selected the three new columns from the old table;
SQLite's double-quoted-identifier fallback turned them into string
literals rather than erroring, writing assigned_by='assigned_by' into
every existing row. The migration selects NULL for those columns instead.

Claude-Session: https://claude.ai/code/session_01GvXPAmtJMzagwAWdiEeWiH
Adds an ordering-workflow section to the architecture overview covering
the member/officer split, the two triage endpoints, and why balance
checks run at assign and approve time rather than at submission.

The forms guide used OrderForm as its cross-field superRefine example,
which no longer applies now that the form validates an array of items;
it points at orderAssignSchema instead and gains a repeatable-rows
section for useFieldArray and the paste panel.

Claude-Session: https://claude.ai/code/session_01GvXPAmtJMzagwAWdiEeWiH
@matejstastny matejstastny changed the title Feat/ordering update feat: ordering update Aug 21, 2026
@matejstastny
matejstastny self-requested a review August 21, 2026 06:12
@matejstastny matejstastny added the enhancement New feature or request label Aug 21, 2026

@matejstastny matejstastny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works well, good change.

@CPrutean
CPrutean merged commit 9344d50 into main Aug 21, 2026
2 checks passed
@matejstastny
matejstastny deleted the feat/ordering-update branch August 21, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants