liveBook · Manning

Number type

As explained in Build Financial Software with Generative AI (From Scratch)

NUMERIC is a database data type for storing exact decimal numbers with specified precision and scale.

NUMERIC stores decimal amounts with a declared precision and scale. In NUMERIC(12,2), 12 is the total number of significant digits and 2 is the number of decimal digits. This fits ACH credit and debit totals, where the database structure should closely reflect the defined amount field. section 5.1

Choosing NUMERIC is also a data-quality decision. An amount stored as VARCHAR can retain spaces or other malformed characters, while a NUMERIC column makes the database enforce numeric input. That enforcement can expose existing parsing or workflow problems, so tests should identify the adjustments needed. section 7.3

Listing 7.3 ACH table for the file control record
total_debit_entry_dollar_amount NUMERIC(12, 2) NOT NULL,
total_credit_entry_dollar_amount NUMERIC(12, 2) NOT NULL,

The file-control table declares debit and credit totals as required NUMERIC(12,2) columns, making the intended monetary shape explicit at storage time. section 7.3

A reliable amount flow keeps the same meaning across layers:

  • Parse fixed-width whole and fractional portions into Decimal values before persistence. section 7.3
  • Store debit and credit totals in NOT NULL NUMERIC(12,2) columns. section 7.3
  • Return Decimal totals in the API response model and map the API field names to UI fields. section 7.3

Storing an ACH total

An ACH record can provide an amount in separate fixed-width whole-dollar and cent slices. Build a decimal value from those slices, then save it to total_debit_entry_dollar_amount or total_credit_entry_dollar_amount as NUMERIC(12,2). The API can expose the resulting debit_total and credit_total for display. section 7.3 section 5.1

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Defines precision and scale, then follows amounts through parsing, database columns, API schemas, and UI mapping.
Examples
Uses ACH file-control debit and credit totals, fixed-width amount parsing, and a files API response.
What it assumes
Introduces precision and scale from zero while using an ACH database design scenario.
What you can do after
Operate/configure numeric amount columns and trace their values from parsed ACH records to a displayed API response.
How it connects
Connects NUMERIC to VARCHAR, MONEY, Decimal, NOT NULL, referential integrity, and API response models.

Also explained in

Compare how 6 books explain number type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.