Skip to content

feat(inventoryitem): reject non-finite invitQty at the schema layer#212

Merged
CryptoJones merged 1 commit into
masterfrom
feat/inventoryitem-reject-non-finite-qty
May 19, 2026
Merged

feat(inventoryitem): reject non-finite invitQty at the schema layer#212
CryptoJones merged 1 commit into
masterfrom
feat/inventoryitem-reject-non-finite-qty

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #211.

Summary

invitQty was z.coerce.number() — accepts the infinities. "Infinity" from JSON coerces to the float, lands inf in the DOUBLE column, contaminates PO receiving / inventory-rollup arithmetic.

.finite() via shared invitQtyField. Mirrors polQty/polPrice (#194), btHourlyRate (#206). Zero + negatives remain valid (out-of-stock, backorders).

Test plan

  • npm run lint clean
  • npm test — 659 → 663 (+4)

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

`invitQty` was typed `z.coerce.number()`, which accepts the
infinities and the coerce path turns the string `"Infinity"` into
the float. An `inf` qty in the DOUBLE column silently corrupts
every downstream consumer that does arithmetic against it —
PO line receiving, inventory-transaction net-position rollups,
valuation reports.

Pin `.finite()` at the boundary via a shared `invitQtyField`. Zero
and negatives remain valid: a 0 on-hand qty for an out-of-stock
item is legitimate, and negative qtys cover backorders and
historical reconciliation entries that some accounting flows allow.

Mirrors polQtyField / polPriceField (#194) and btHourlyRateField
(#206). Pinned in `tests/api/inventoryitem.test.js` with 4 new
tests: non-finite rejection (POST + PATCH), zero accepted,
negative accepted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 3f725de into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the feat/inventoryitem-reject-non-finite-qty branch May 19, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inventoryitem: invitQty accepts Infinity/-Infinity — DOUBLE column stores them as inf

1 participant