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
