fix(dashboard): exclude services from modal tertahan table and calculations #191

Merged
yuris merged 2 commits from fix/190-exclude-services-modal-tertahan into main 2026-10-02 10:18:45 +00:00
Owner

Closes #190.

What changed

  • apps/management/lib/inventory/queries.ts: Exclude services (type != 'Service') from agedQty, agedCostValue, oldestAgedDate, agedDays, and totalCostValue in getDashboardInventory.
  • apps/management/app/(dashboard)/page.tsx: Filter type !== 'Service' in stockValue, agedItems, agedTotalValue, agedSkuCount, and agedPercent.
  • apps/management/app/(dashboard)/aging-inventory-table.tsx: Filter type !== 'Service' from initialData in AgingInventoryTable.

Verified

  • pnpm verify:management passed (vitest 531 tests, tsc, biome lint).

Deviations

none

Closes #190. ## What changed - `apps/management/lib/inventory/queries.ts`: Exclude services (`type != 'Service'`) from `agedQty`, `agedCostValue`, `oldestAgedDate`, `agedDays`, and `totalCostValue` in `getDashboardInventory`. - `apps/management/app/(dashboard)/page.tsx`: Filter `type !== 'Service'` in `stockValue`, `agedItems`, `agedTotalValue`, `agedSkuCount`, and `agedPercent`. - `apps/management/app/(dashboard)/aging-inventory-table.tsx`: Filter `type !== 'Service'` from `initialData` in `AgingInventoryTable`. ## Verified - `pnpm verify:management` passed (vitest 531 tests, tsc, biome lint). ## Deviations none
fix(dashboard): exclude services from modal tertahan table and calculations
All checks were successful
Checks / test @garage/catalog (pull_request) Successful in 1m16s
Checks / test garage (pull_request) Successful in 1m26s
Checks / test garage-store (pull_request) Successful in 1m20s
Checks / typecheck apps/management (pull_request) Successful in 1m36s
Checks / lint (biome) (pull_request) Successful in 11s
Checks / typecheck apps/store (pull_request) Successful in 1m23s
b54dba9206
yuris left a comment

VERDICT: request-changes

[P2] Include null-typed inventory in physical stock aggregates (apps/management/lib/inventory/queries.ts:239-257). inventory.type is nullable, and the page/table explicitly include every type other than Service. PostgreSQL evaluates NULL != 'Service' as unknown, so the new SQL filters erase the cost and aging values of valid null-typed items with lots. These physical items vanish from Modal Mengendap and their stock value is understated. Use IS DISTINCT FROM 'Service' in each aggregate filter (and cover a null-typed row in a behavior test).

The page KPI and table filters otherwise meet the requested service exclusion. The added test checks generated SQL text using mocked rows rather than executing aggregates, so it misses this mismatch. Forgejo reports the management test job passing; management typecheck and Biome lint were pending at review time. I did not run pnpm verify:management in this read-only review.

VERDICT: request-changes [P2] Include null-typed inventory in physical stock aggregates (`apps/management/lib/inventory/queries.ts:239-257`). `inventory.type` is nullable, and the page/table explicitly include every type other than `Service`. PostgreSQL evaluates `NULL != 'Service'` as unknown, so the new SQL filters erase the cost and aging values of valid null-typed items with lots. These physical items vanish from Modal Mengendap and their stock value is understated. Use `IS DISTINCT FROM 'Service'` in each aggregate filter (and cover a null-typed row in a behavior test). The page KPI and table filters otherwise meet the requested service exclusion. The added test checks generated SQL text using mocked rows rather than executing aggregates, so it misses this mismatch. Forgejo reports the management test job passing; management typecheck and Biome lint were pending at review time. I did not run `pnpm verify:management` in this read-only review.
fix(dashboard): use is distinct from for service exclusion in inventory queries
All checks were successful
Checks / test @garage/catalog (pull_request) Successful in 1m15s
Checks / test garage (pull_request) Successful in 1m26s
Checks / test garage-store (pull_request) Successful in 1m17s
Checks / typecheck apps/management (pull_request) Successful in 1m40s
Checks / lint (biome) (pull_request) Successful in 12s
Checks / typecheck apps/store (pull_request) Successful in 1m20s
cf8ec0d33b
Author
Owner

Round 1 addressed

  • Switched service exclusion in getDashboardInventory SQL query filters to use is distinct from 'Service' instead of != 'Service' across totalCostValue, agedQty, agedCostValue, oldestAgedDate, and agedDays to correctly retain null-typed physical inventory items.
  • Updated queries.test.ts to assert is distinct from 'Service' on all aggregate projections and added test coverage for null-typed inventory items.
  • Verified with pnpm verify:management (all 532 tests pass, typecheck clean, biome lint clean).
### Round 1 addressed - Switched service exclusion in `getDashboardInventory` SQL query filters to use `is distinct from 'Service'` instead of `!= 'Service'` across `totalCostValue`, `agedQty`, `agedCostValue`, `oldestAgedDate`, and `agedDays` to correctly retain null-typed physical inventory items. - Updated `queries.test.ts` to assert `is distinct from 'Service'` on all aggregate projections and added test coverage for null-typed inventory items. - Verified with `pnpm verify:management` (all 532 tests pass, typecheck clean, biome lint clean).
yuris left a comment

VERDICT: approve-with-nits
Round 2: The nullable-type finding is resolved. The dashboard query now uses IS DISTINCT FROM for all four aging aggregates and totalCostValue, retaining null-typed physical inventory while zeroing service valuations. The page excludes services from aging KPIs and stockValue; the table excludes service rows. No correctness blockers found.
Nit: The new tests assert SQL fragments and feed precomputed Service/null rows through a mocked DB; they do not execute the query against mixed-type lots, so the Service/null behavioral cases are not actually exercised.
Verification: I did not run pnpm verify:management in this read-only review; its result is not confirmed here.

VERDICT: approve-with-nits Round 2: The nullable-type finding is resolved. The dashboard query now uses IS DISTINCT FROM for all four aging aggregates and totalCostValue, retaining null-typed physical inventory while zeroing service valuations. The page excludes services from aging KPIs and stockValue; the table excludes service rows. No correctness blockers found. Nit: The new tests assert SQL fragments and feed precomputed Service/null rows through a mocked DB; they do not execute the query against mixed-type lots, so the Service/null behavioral cases are not actually exercised. Verification: I did not run pnpm verify:management in this read-only review; its result is not confirmed here.
yuris merged commit dbf949c436 into main 2026-10-02 10:18:45 +00:00
yuris deleted branch fix/190-exclude-services-modal-tertahan 2026-10-02 10:18:45 +00:00
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
yuris/garage!191
No description provided.