ach

package
v0.53.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ach provides bidirectional conversion between ACH files and TableData.

This package bridges the moov-io/ach library with parser.TableData, enabling SQL queries on ACH file data via filesql.

Security Note

TableData structures expose sensitive banking information including account numbers, routing numbers, names, and transaction amounts. Avoid logging or exporting TableData contents verbatim in production environments.

Supported Addenda Types

Standard entries (EntryDetail):

  • Addenda02: Point-of-Sale (POS), Machine Transfer Entry (MTE), Shared Network Entry (SHR)
  • Addenda05: Payment Related Information (PPD, CCD, CTX, WEB, etc.)
  • Addenda98: Notification of Change (NOC)
  • Addenda98Refused: Refused Notification of Change
  • Addenda99: Return entries
  • Addenda99Dishonored: Dishonored Returns
  • Addenda99Contested: Contested Dishonored Returns

IAT entries (IATEntryDetail) - International ACH Transactions:

  • Addenda10: Transaction information (receiving company, foreign payment amount)
  • Addenda11: Originator name and address
  • Addenda12: Originator city, state/province, country, postal code
  • Addenda13: Originating DFI information
  • Addenda14: Receiving DFI information
  • Addenda15: Receiver identification number and street address
  • Addenda16: Receiver city, state/province, country, postal code
  • Addenda17: Payment related information (up to 2 per entry)
  • Addenda18: Foreign correspondent bank information (up to 5 per entry)
  • Addenda98/99: Same as standard entries

Limitations

Only UPDATE operations on existing rows are supported for round-trip editing. INSERT/DELETE operations in SQL are not reflected in the output ACH file. This is because ACH file structure requires careful coordination between related records (entry counts, hash totals, addenda indicators).

This package uses github.com/tiendc/go-deepcopy for deep copying ACH files. If moov-io/ach adds new fields (especially interfaces or unexported fields), the deep copy may not capture them correctly. Monitor moov-io/ach releases.

Usage

import (
    "os"

    "github.com/nao1215/filesql/parser/ach"
)

// Read an ACH file into TableData for SQL queries
f, _ := os.Open("payment.ach")
defer f.Close()
tables, _ := ach.ParseReader(f)

// After SQL modifications, write the file back out
out, _ := os.Create("modified.ach")
defer out.Close()
tables.WriteToWriter(out)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TableSet

type TableSet struct {
	// contains filtered or unexported fields
}

TableSet contains multiple TableData representing different aspects of an ACH file. This structure preserves the hierarchical nature of ACH files while enabling flat table-based queries.

func ParseReader

func ParseReader(reader io.Reader) (*TableSet, error)

ParseReader parses an ACH file from an io.Reader and returns a TableSet. This function encapsulates the moov-io/ach dependency so that callers don't need to import moov-io/ach directly.

Example
package main

import (
	"fmt"
	"os"

	"github.com/nao1215/filesql/parser/ach"
)

func main() {
	file, err := os.Open("testdata/ppd-debit.ach")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer file.Close()

	tableSet, err := ach.ParseReader(file)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	// One ACH file becomes several tables, one per record kind.
	fmt.Println("file_header rows:", len(tableSet.GetFileHeaderTable().Records))
	fmt.Println("batches rows:", len(tableSet.GetBatchesTable().Records))
	fmt.Println("entries rows:", len(tableSet.GetEntriesTable().Records))
	fmt.Println("addenda rows:", len(tableSet.GetAddendaTable().Records))
	fmt.Println("entry columns:", len(tableSet.GetEntriesTable().Headers))
}
Output:
file_header rows: 1
batches rows: 1
entries rows: 1
addenda rows: 0
entry columns: 13

func (*TableSet) GetAddendaTable

func (ts *TableSet) GetAddendaTable() *parser.TableData

GetAddendaTable returns the addenda TableData for use with filesql.

func (*TableSet) GetBatchesTable

func (ts *TableSet) GetBatchesTable() *parser.TableData

GetBatchesTable returns the batches TableData for use with filesql.

func (*TableSet) GetEntriesTable

func (ts *TableSet) GetEntriesTable() *parser.TableData

GetEntriesTable returns the entries TableData for use with filesql. This is the most commonly used table for transaction analysis.

func (*TableSet) GetFileHeaderTable

func (ts *TableSet) GetFileHeaderTable() *parser.TableData

GetFileHeaderTable returns the file header TableData for use with filesql.

func (*TableSet) GetIATAddendaTable added in v0.49.0

func (ts *TableSet) GetIATAddendaTable() *parser.TableData

GetIATAddendaTable returns the IAT addenda TableData for use with filesql.

func (*TableSet) GetIATBatchesTable added in v0.49.0

func (ts *TableSet) GetIATBatchesTable() *parser.TableData

GetIATBatchesTable returns the IAT batches TableData for use with filesql.

func (*TableSet) GetIATEntriesTable added in v0.49.0

func (ts *TableSet) GetIATEntriesTable() *parser.TableData

GetIATEntriesTable returns the IAT entries TableData for use with filesql.

func (*TableSet) UpdateAddendaFromTableData

func (ts *TableSet) UpdateAddendaFromTableData(addenda *parser.TableData)

UpdateAddendaFromTableData updates the internal addenda data from modified TableData.

func (*TableSet) UpdateBatchesFromTableData

func (ts *TableSet) UpdateBatchesFromTableData(batches *parser.TableData)

UpdateBatchesFromTableData updates the internal batches data from modified TableData.

func (*TableSet) UpdateEntriesFromTableData

func (ts *TableSet) UpdateEntriesFromTableData(entries *parser.TableData)

UpdateEntriesFromTableData updates the internal entries data from modified TableData. Call this after making SQL modifications to prepare for WriteToWriter.

func (*TableSet) UpdateFileHeaderFromTableData

func (ts *TableSet) UpdateFileHeaderFromTableData(fileHeader *parser.TableData)

UpdateFileHeaderFromTableData updates the internal file header data from modified TableData.

func (*TableSet) UpdateIATAddendaFromTableData

func (ts *TableSet) UpdateIATAddendaFromTableData(iatAddenda *parser.TableData)

UpdateIATAddendaFromTableData updates the internal IAT addenda data from modified TableData.

func (*TableSet) UpdateIATBatchesFromTableData

func (ts *TableSet) UpdateIATBatchesFromTableData(iatBatches *parser.TableData)

UpdateIATBatchesFromTableData updates the internal IAT batches data from modified TableData.

func (*TableSet) UpdateIATEntriesFromTableData

func (ts *TableSet) UpdateIATEntriesFromTableData(iatEntries *parser.TableData)

UpdateIATEntriesFromTableData updates the internal IAT entries data from modified TableData.

func (*TableSet) WriteToWriter

func (ts *TableSet) WriteToWriter(writer io.Writer) error

WriteToWriter writes the ACH file from a TableSet to an io.Writer. This function encapsulates the moov-io/ach dependency so that callers don't need to import moov-io/ach directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL