Skip to content

invoicejob: injbAmount accepts Infinity/-Infinity — DOUBLE column stores them as inf #179

@CryptoJones

Description

@CryptoJones

Problem

app/schemas/invoicejob.schema.js declares injbAmount as
z.coerce.number(). zod's .number() rejects NaN by default but
allows Infinity and -Infinity through.

JSON has no literal for Infinity, but z.coerce.number() happily
turns the string "Infinity" into the float, and the underlying
Sequelize DOUBLE column accepts the value and stores it as inf.
Any downstream consumer doing arithmetic on the column (invoice
totals, aging buckets, CSV exports) then gets contaminated.

This mirrors the cpayAmount bug fixed in #172, on the invoice-line
side. Unlike the payment field, injbAmount legitimately accepts
zero (reference / courtesy lines) and negatives (credits, discounts),
so the appropriate refinement is .finite() only — not a non-zero
gate.

Fix

Acceptance

  • Schema rejects Infinity / -Infinity (post coerce)
  • Schema still accepts zero
  • Schema still accepts negatives
  • Tests cover all four cases

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions