[Issue]: PO History Search Options #121
Labels
No labels
bug
claude-failed
claude-pr
claude-queue
claude-working
epic
feature
interactive
portal
triaged
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: shad0w/pelagia-portal#121
Loading…
Add table
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?
Raised by
Kaushal Pal Singh (kps@pelagiamarine.com, MANAGER) — via portal Report Issue button
Description
In PO History, there is no search option with Accounting Code Search
Priority
P2 — Medium
Context
/historyClaude triage
Triage — Issue #121: PO History Search Options (Accounting Code Search)
Type: feature · Priority: P2 · Page:
/history· Reporter: Kaushal Pal Singh (MANAGER)Interpretation
The PO History page (
/history) currently offers filters for From/To (created date),Approved From/To, Cost Centre (vessel) and Status. The manager wants an additional
filter to narrow PO History by Accounting Code — the same "Accounting Code" construct already
modelled by the
Accounttree (6-digit codes, leaf items selectable on a PO). This is anadditive new filter, not a broken behaviour, so it is a feature/enhancement.
Each
PurchaseOrderalready carries a PO-levelaccountId(accountrelation), which is alreadyincluded in the History query — so the data is present; only a filter control + awhereclauseare missing.
Action items
app/(portal)/history/page.tsx(Server Component)accountId?: stringto thesearchParamstype.Accounts — those with no children, matching what a POcan reference;
isActiveand ordered bycode) and pass them toHistoryFilters.if (accountId) where.accountId = accountId;to the Prismawhere.accountIdinto bothpageParams(pagination links) andexportParams(CSV/PDF export).app/(portal)/history/history-filters.tsx(Client Component)components/ui/searchable-select.tsxcombobox (already used for accounting-code selection in thePO line-items editor) so a manager can type-to-search the 6-digit code/name; include an
"All accounting codes" empty option.
buildParams/apply/clear/hasFiltersexactly like the existingvesselIdselect.app/api/reports/export/route.ts(CSV + PDF export)accountIdfrom the query string and apply the samewhere.accountIdfilter so theExport CSV/PDF respect the on-screen filter (it already mirrors the other history filters).
?accountId=narrowsthe result set (mirror the existing
tests/staging/issue-31-history-multi-status.spec.ts/issue-104-history-pagination.spec.tspattern). Optionally surface the Account column in thetable for context (the CSV already has an "Account" column).
Files / areas involved
App/app/(portal)/history/page.tsx— querywhere, params threading, fetch codes.App/app/(portal)/history/history-filters.tsx— new filter control.App/app/api/reports/export/route.ts— keep export in sync.App/components/ui/searchable-select.tsx— reused (no change expected).App/prisma/schema.prisma—Accountmodel (reference only; no migration).Open questions
accountIdonly (simplest, matches displayed account)vs. also matching POs whose line items carry the code (
lineItems: { some: { accountId } }).Recommended default: PO-level account for v1 (consistent, cheap), note line-item match as a
possible follow-up.
exactly. If selecting a parent (heading/sub-heading) should include all descendant leaves, that
needs a roll-up (
accountId: { in: leavesUnder(parent) }). Default: leaf-only select (exactmatch) to keep it localized; roll-up is a nice-to-have.
Cost Centre control and keep acceptance crisp.
Routing rationale
Routing rationale: Localized, additive filter following an existing in-file pattern with reusable components, no DB migration / auth / payments / external systems, and verifiable by type-check + lint + a history filter test — safe for an unattended claude-queue run with a sensible PO-level leaf-match default.
Routing:
claude-queue| Type:feature[Claude] Started working on this issue on branch
claude/issue-121.[Claude] Opened PR #123 with a proposed fix. Review and merge it, then create a release tag to deploy.