{"id":19655183,"url":"https://github.com/flash-oss/aba-parser","last_synced_at":"2026-03-16T11:36:38.744Z","repository":{"id":63340601,"uuid":"567149422","full_name":"flash-oss/aba-parser","owner":"flash-oss","description":"Parse ABA (Australian Bankers Association or Cemtext) file format","archived":false,"fork":false,"pushed_at":"2023-01-31T11:33:19.000Z","size":33,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-13T11:15:42.000Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flash-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-17T07:09:00.000Z","updated_at":"2023-01-10T02:15:12.000Z","dependencies_parsed_at":"2023-02-16T18:46:18.077Z","dependency_job_id":null,"html_url":"https://github.com/flash-oss/aba-parser","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flash-oss%2Faba-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flash-oss%2Faba-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flash-oss%2Faba-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flash-oss%2Faba-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flash-oss","download_url":"https://codeload.github.com/flash-oss/aba-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224125382,"owners_count":17259869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T15:19:52.500Z","updated_at":"2026-03-16T11:36:38.690Z","avatar_url":"https://github.com/flash-oss.png","language":"TypeScript","readme":"# ABA parser\n\nNPM module to parse ABA (Australian Bankers Association) files\n\n## How to use\n\n### Install\n\n```shell\nnpm i aba-parser\n```\n\n### Usage\n\n```typescript\nconst { ABA } = require(\"aba-parser\");\n\nconst aba = new ABA();\nconst batches = aba.parse(abaString);\nfor (const { header, transactions, footer } of batches) {\n  console.log(...transactions);\n}\n```\n\n## Options\n\n### Validation\n\nAttention! Batch validation depends significantly on the default ABA structure; in order for it to function,\nyou must specify a minimum structure, as seen in the example below.\n\n```typescript\nconst minimalBatchForValidation = {\n  header: { ...otherFields },\n  transaction: [{ amount: number, transactionCode: number, ...otherFields }],\n  footer: {\n    bsb: string, // must be 999999\n    netTotal: number,\n    creditTotal: number,\n    debitTotal: number,\n    numberOfTransactions: number,\n    ...otherFileds,\n  },\n};\n```\n\nIf you want to throw an error on an invalid batch, you need to pass options `options: {validation: true}` into the ABA\nconstructor for automatic batch validation.\n\nOtherwise, you can use the manual validation method `aba.validateBatch(batch)` see examples below\n\n### Automatic batch validation\n\n```typescript\nimport { ABA } from \"aba-parser\";\n\nconst aba = new ABA({ validation: boolean });\n\ntry {\n  const batches = aba.parse(invaidAbaString);\n} catch (error) {\n  console.log(error);\n}\n```\n\n### Manual batch validation\n\nYou can validate batches manually without throwing an error, see the example below.\n\n```typescript\nconst aba = new ABA();\nconst batches = aba.parse(sourceFile);\nfor (const batch of batches) {\n  const { success, code, message } = aba.validateBatch(batch);\n}\n```\n\n### Custom transaction parsing\n\nYou can add multiple custom schemas or replace default schemas to parse non-standard ABA files or those extended by a particular bank.\n\n#### Keys description\n\n`N` - is a string key with one character, that represents the first character in the original ABA record,\nfor default schemas (\"0\" - Descriptive Record (header), \"1\" - Detail Record (transaction), and \"7\" - File Total Record (footer))\n\n`recordType` - a string that identifies the batch's record type.\nDescriptive Record -\u003e header; Detail Record -\u003e transaction; File Total Record -\u003e footer\n\n`name` - the name of a field (amount, tax, etc.).\n\n`boundaries` - array with 2 numbers, that specify the start and end of the field in the record string.\n\n`type` - type of the field, provide the desired type to reformat the field.\n\n#### Possible types:\n\n`string` – trim spaces and return the string\n\n`money` - convert cents to dollars and return the number.\n\n`integer` - trim all `0` in the start and return the number\n\n`bsb` - remove \"-\" and return the string\n\n`\"\"` – retrieve the original string\n\n```typescript\ncustomSchemas = {\n  N: {\n    recordType: \"header\" | \"transaction\" | \"footer\",\n    fields: [\n      {\n        name: \"string\",\n        boundaries: [number, number],\n        type: \"string\" | \"money\" | \"integer\" | \"bsb\" | \"\",\n      },\n    ],\n  },\n};\n\nconst aba = new ABA({ schemas: customSchmas });\n```\n\n### Custom schema use example\n\n```typescript\nconst customSchemas: RecordSchema = {\n  \"5\": {\n    recordType: \"transaction\",\n    fields: [\n      { name: \"transactionType\", boundaries: [0, 1], type: \"string\" },\n      { name: \"bsb\", boundaries: [1, 8], type: \"bsb\" },\n      { name: \"account\", boundaries: [8, 17], type: \"string\" },\n      { name: \"transactionCode\", boundaries: [18, 20], type: \"integer\" },\n      { name: \"amount\", boundaries: [20, 30], type: \"money\" },\n      { name: \"traceBsb\", boundaries: [80, 87], type: \"bsb\" },\n      { name: \"customString\", boundaries: [120, 135], type: \"string\" },\n      { name: \"customInt\", boundaries: [135, 140], type: \"integer\" },\n      { name: \"customBsb\", boundaries: [140, 145], type: \"bsb\" },\n      { name: \"custom\", boundaries: [145, 150], type: \"\" },\n      { name: \"customBsb\", boundaries: [155, 160], type: \"bsb\" },\n      { name: \"customMoney\", boundaries: [165, 170], type: \"money\" },\n    ],\n  },\n  \"6\": {\n    recordType: \"header\",\n    fields: [\n      { name: \"bsb\", boundaries: [1, 8], type: \"bsb\" },\n      { name: \"account\", boundaries: [8, 17], type: \"string\" },\n    ],\n  },\n};\n\nconst aba = new ABA({ schemas: customSchemas });\n\nconst batches = aba.parse(abaString);\nfor (const { header, transactions, footer } of batches) {\n  console.log(...transactions);\n}\n```\n\n### Default schemas\n\nHere the list of standard schemas, you can rewrite them with custom types by using the same key\n\n```typescript\nconst defaultAbaSchemas = {\n  0: {\n    recordType: \"header\",\n    fields: [\n      { name: \"bsb\", boundaries: [1, 8], type: \"bsb\" },\n      { name: \"account\", boundaries: [8, 17], type: \"string\" },\n      { name: \"sequenceNumber\", boundaries: [19, 20], type: \"integer\" },\n      { name: \"bank\", boundaries: [20, 23], type: \"string\" },\n      { name: \"user\", boundaries: [30, 56], type: \"string\" },\n      { name: \"userNumber\", boundaries: [56, 62], type: \"string\" },\n      { name: \"description\", boundaries: [62, 74], type: \"string\" },\n      { name: \"date\", boundaries: [74, 80], type: \"string\" },\n      { name: \"time\", boundaries: [80, 84], type: \"string\" },\n    ],\n  },\n\n  1: {\n    recordType: \"transaction\",\n    fields: [\n      { name: \"transactionType\", boundaries: [0, 1], type: \"string\" },\n      { name: \"bsb\", boundaries: [1, 8], type: \"bsb\" },\n      { name: \"account\", boundaries: [8, 17], type: \"string\" },\n      { name: \"tax\", boundaries: [17, 18], type: \"string\" },\n      { name: \"transactionCode\", boundaries: [18, 20], type: \"integer\" },\n      { name: \"amount\", boundaries: [20, 30], type: \"money\" },\n      { name: \"accountTitle\", boundaries: [30, 62], type: \"string\" },\n      { name: \"reference\", boundaries: [62, 80], type: \"string\" },\n      { name: \"traceBsb\", boundaries: [80, 87], type: \"bsb\" },\n      { name: \"traceAccount\", boundaries: [87, 96], type: \"string\" },\n      { name: \"remitter\", boundaries: [96, 112], type: \"string\" },\n      { name: \"taxAmount\", boundaries: [112, 120], type: \"money\" },\n    ],\n  },\n\n  7: {\n    recordType: \"footer\",\n    fields: [\n      { name: \"bsb\", boundaries: [1, 8], type: \"bsb\" },\n      { name: \"netTotal\", boundaries: [20, 30], type: \"money\" },\n      { name: \"creditTotal\", boundaries: [30, 40], type: \"money\" },\n      { name: \"debitTotal\", boundaries: [40, 50], type: \"money\" },\n      { name: \"numberOfTransactions\", boundaries: [74, 80], type: \"integer\" },\n    ],\n  },\n};\n```\n\nIn the end your code can look like this\n\n```typescript\nconst { ABA } = require(\"aba-parser\");\nconst options = {\n  validation: boolean,\n  schemas: { customSchema, customSchema },\n};\nconst aba = new ABA(options);\nconst batches = aba.parse(abaString);\nfor (const { header, transactions, footer } of batches) {\n  console.log(...transactions);\n}\n```\n\n## Reference information and links\n\n### Sibling modules\n\n[aba-generator](https://github.com/flash-oss/aba-generator) - if you need to generate an ABA string, you can use this module.\n\n### ABA file specification\n\n1. http://ddkonline.blogspot.com/2009/01/aba-bank-payment-file-format-australian.html\n2. https://www.cemtexaba.com/aba-format/cemtex-aba-file-format-details\n3. https://github.com/mjec/aba/blob/master/sample-with-comments.aba\n\n### Standard transactions codes for ABA files\n\nShortcuts that are used in ABA files and what they mean\n\n### Codes for tax in debit/credit transactions\n\nMust be a space or the letter 'N', 'T', 'W', 'X', or 'Y'.\n\n'N' - for new or varied BSB number or name details.\n'T' - for a drawing under a Transaction Negotiation Authority.\n\nWithholding Tax Indicators:\n'W' - dividend paid to a resident of a country where a double tax agreement is in force.\n'X' - dividend paid to a resident of any other country.\n'Y' - interest paid to all non-residents.\n\nWhere applicable, the amount of withholding tax is to appear in character positions 113-120.\nNote: Accounts of non-residents. Where withholding tax has been deducted, the appropriate Indicator as shown above, is to be used and will override the normal Indicator.\"\n\n### Codes for transactionCode in debit/credit transactions\n\n13 - \"externally initiated debit\"\n\n50 - \"externally initiated credit - normally what is required\"\n\n51 - \"Australian government security interest\"\n\n52 - \"Basic family payments/additional family payment\"\n\n53 - \"Payroll payment\"\n\n54 - \"Pension payment\"\n\n55 - \"Allotment\"\n\n56 - \"Dividend\"\n\n57 - \"Debenture/note interest\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflash-oss%2Faba-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflash-oss%2Faba-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflash-oss%2Faba-parser/lists"}