@rationalthinker1/eft-generator
v8.0.5
Published
Formats Electronic Funds Transfer (EFT) data into the CPA 005 standard.
Downloads
1,332
Maintainers
Readme
EFT Generator for Node
Forked from cityssm/node-eft-generator.
Formats Electronic Funds Transfer (EFT) data into the CPA 005 standard.
Supports credit (C) and debit (D) record types. Other logical record types are not supported.
✔️ Output parsed successfully by BMO.
Installation
npm install @rationalthinker1/eft-generator
# or
yarn add @rationalthinker1/eft-generatorUsage
import fs from 'node:fs'
import { BankPADInformation, EFTFileBuilder } from '@rationalthinker1/eft-generator'
const { bankInstitution, bankTransit, bankAccount } = BankPADInformation
const eftFile = new EFTFileBuilder({
originatorId: '0123456789',
originatorShortName: 'SSM',
originatorLongName: 'The City of Sault Ste. Marie',
fileCreationNumber: '0001'
})
eftFile.addDebitTransaction({
bankInstitutionNumber: bankInstitution('003'), // RBC
bankTransitNumber: bankTransit('22222'),
bankAccountNumber: bankAccount('333333333'),
cpaCode: '385', // Property Taxes
amount: 1234.56,
payeeName: 'Test Property Owner'
})
// `generate()` runs the strict validator first; any spec violation
// throws before any output is written.
const output = eftFile.generate()
fs.writeFileSync('cpa005.txt', output)The validator can also be invoked directly:
eftFile.validate() // returns void; throws on any violationMigrating from 2.x to 3.x
- Digit fields (
bankInstitutionNumber,bankTransitNumber,bankAccountNumber, and thereturn*Numberconfig fields) are now branded types. Construct them viaBankPADInformation.bankInstitution(...),.bankTransit(...),.bankAccount(...). Bank institution numbers are validated against the Payments Canada FI list. cpaCodeis the literal string unionCPATransactionCode; only known codes type-check.
Migrating from 3.x to 4.x
EFTFileBuilder.validate()now returnsvoidand throws on any spec violation. Catch the thrownErrorif you need a boolean.- The validator is strict: prohibited characters, oversized names, duplicate
cross-reference numbers, empty transactions, segments-per-record overflow,
and out-of-range payment dates (more than 173 days from
fileCreationDate) all throw instead of warn. originatorShortNameis no longer auto-defaulted tooriginatorLongName.
Migrating from 1.x to 2.x
The top-level class was renamed from EFTGenerator to EFTFileBuilder to make
room for an internal EFTGenerator class that owns CPA-005 formatting. Two
methods on the public class were also renamed for clarity:
- import { EFTGenerator } from '@rationalthinker1/eft-generator'
- const eft = new EFTGenerator(config)
+ import { EFTFileBuilder } from '@rationalthinker1/eft-generator'
+ const eft = new EFTFileBuilder(config)
- eft.toCPA005()
- eft.validateCPA005()
+ eft.generate()
+ eft.validate()addTransaction, addCreditTransaction, addDebitTransaction,
getConfiguration, and getTransactions are unchanged.
Resources
- Canadian Payments Association Standard 005
- Royal Bank CPA-005 Reference (RBC source)
- BMO Electronic Funds Transfer Client Manual
Related Projects
CPA Codes for Node Lookups, validations, and utility functions for Canadian Payments Association (CPA) Standard 007 transaction and return codes.
