liveBook · Manning

Trailer record

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

A file trailer record is the final ACH-file record that terminates the file and contains file-level control totals and validation information.

A trailer record closes an ACH file and carries file-level control totals used to check whether the complete file was received correctly. The type 9 record follows all batches and is also called a file control record. section 2.3 section 2.5.3

A parser typically extracts these fixed-position fields:

  • Record type, identifying the line as type 9. section 2.5.3
  • Batch count and block count, describing file-level structure. section 2.5.3
  • Entry count and entry hash, supporting integrity checks across entries. section 2.5.3
  • Total debit and total credit amounts, supporting financial reconciliation. section 2.5.3
  • A reserved field may be retained for format completeness, even when it is not currently needed. section 2.5.3

Parsing and testing a type 9 record

A parser can slice the fixed-position record, cast numeric fields to integers, and expose values such as batch count 10, entry count 74, debit total 78.25, and credit total 1,146,114.80. A BDD test can then verify each parsed value against a representative trailer string. section 2.5.3

Listing 2.15 Parsing the file trailer record
def parse_ach_trailer_record(record):
    return {
        "record_type": record[0],
        "batch_count": int(record[1:7]),
        "block_count": int(record[7:13]),
        "entry_count": int(record[13:21]),
        "entry_hash": int(record[21:31]),
        "total_debit_amount": int(record[31:43]),
        "total_credit_amount": int(record[43:55]),
    }

Use the parsing listing to inspect the field slices and the conversion of fixed-width numeric values. section 2.5.3

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

How deep it goes
Implements fixed-position parsing and testing, while deferring deeper treatment of reserved fields and padding conventions.
Examples
Uses a type 9 sample string, parsed control totals, and a BDD scenario covering counts, hashes, and monetary totals.
What it assumes
Assumes familiarity with ACH record ordering and fixed-position fields while teaching trailer parsing incrementally from the record layout.
What you can do after
Diagnose/debug with it by parsing trailer fields, checking file totals, and testing malformed or incomplete ACH input.
How it connects
Connects ACH files with batch control records, entry records, addenda records, and fixed-width record validation.

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.