An unparsed record preserves a record in its original formatted form rather than decomposing it into database fields. In an ACH file processor, retaining it means a record can still be stored and inspected when parsing fails—for example, when a numeric field contains non-numeric data. section 5.1 section 5.9
Record order and relationships matter as well as the original content. An initial design stores the unparsed record with a sequence and links parsed records to it. A shared schema can likewise define the record string and sequence number once for each record type to inherit. section 5.1 section 5.10.1
Listing 5.1 PlantUML definition of our database
@startuml #1
object ach_file_uploads { #2
ach_files_id: UUID #3
filename: VARCHAR(255) #3
file_hash: VARCHAR(32) #3
credit_total: NUMERIC(12,2) #3
debit_total: NUMERIC(12,2) #3
}
object ach_files {
ach_files_id: UUID
record_type: VARCHAR(1)
record_id: UUID
parsed: BOOLEAN
sequence: NUMERIC
unparsed_record: VARCHAR(94)
}
object ach_file_header_records {
record_id: UUID
fields for record type
}
object ach_batch_header_records {
record_id: UUID
file_header_id: UUID
fields for record type
}
object ach_entry_detail_ppd_records {
record_id: UUID
batch_header_id: UUID
fields for record type
}
object ach_addenda_ppd_records {
record_id: UUID
entry_detail_id: UUID
fields for record type
}
object ach_batch_control_records {
record_id: UUID
batch_header_id: UUID
fields for record type
}
object ach_file_control_records {
record_id: UUID
file_header_id: UUID
fields for record type
}
ach_file_uploads::ach_files_id <-- ach_files::ach_files_id #4
#4
ach_files::record_id <-- ach_file_header_records::record_id #4
ach_files::record_id <-- ach_batch_header_records::record_id #4
ach_files::record_id <-- ach_entry_detail_ppd_records::record_id #4
ach_files::record_id <-- ach_addenda_ppd_records::record_id #4
ach_files::record_id <-- ach_batch_control_records::record_id #4
ach_files::record_id <-- ach_file_control_records::record_id #4
#4
ach_batch_header_records::file_header_id ->
ach_file_header_records::record_id #4
ach_entry_detail_ppd_records::batch_header_id ->
ach_batch_header_records::record_id #4
ach_addenda_ppd_records::entry_detail_id ->
ach_entry_detail_ppd_records::record_id #4
ach_batch_control_records::batch_header_id -->
ach_batch_header_records::record_id #4
ach_file_control_records::file_header_id -->
ach_file_header_records::record_id #4
#4
@enduml #5
The proposed database definition shows an unparsed record alongside its sequence, parsed flag, and identifiers. section 5.1
Storing only unparsed records simplifies the database, but leaves the application responsible for more integrity work. For example, deleting a batch would require application code to remove its associated records. Storing only parsed fields avoids that duplication but cannot satisfy a requirement to retain records rejected because of invalid data. section 5.9
Inspecting a parsing exception
When parsing fails, a dashboard can offer a separate request for the unparsed record associated with an exception. This lets a user inspect the problematic content without opening the file manually. Because records may contain account numbers or other nonpublic information, a separate request also provides an opportunity to control access and audit views rather than returning every record with the exception list. section 8.6.1 section 8.7.1
Listing 8.33 The updated icon button
<IconButton
onClick={(e) => {
e.preventDefault();
const fileId = params.row.file_id; #1
const exceptionId = params.row.id; #2
const apiUrl = process.env.NEXT_PUBLIC_API_URL ?? ''; #2
axios.get<AchExceptionDetailsResponse>( #3
`${apiUrl}/files/${fileId}/exceptions/
➥${exceptionId}`, {
headers: {
'Content-Type': 'application/json'
}
})
.then(response => { #4
setUnparsedRecord(response.data.unparsed_record); #4
setIsOpen(true); #4
}) #4
.catch(error => { #5
setUnparsedRecord(error.message) #5
setIsOpen(true); #5
}); #5
}} #5
color="primary">
…
</IconButton>
The dashboard’s icon button requests the selected exception’s details and displays the returned unparsed record. section 8.7.1
Regression tests can count unparsed records by type and in total after loading a file, and check that no exceptions were written for a valid file. Separate checks for parsed records help catch cases where parsing failed without an expected exception. section 11.5.1
