bai2

Crates.iobai2
lib.rsbai2
version0.4.0
sourcesrc
created_at2023-10-03 16:52:50.341808
updated_at2023-12-05 16:33:46.233122
descriptionA tool to parse BAI2 files
homepagehttps://github.com/dnsbty/bai2
repositoryhttps://github.com/dnsbty/bai2
max_upload_size
id991235
size114,712
Dennis Beatty (dnsbty)

documentation

README


bai2

A tool for parsing BAI2 files


Usage

cargo install bai2

To parse a bai2 file, just provide the filename!

bai2 my_file.bai

Examples

Given a BAI2 file test.bai like below:

01,GSBI,ABC,200331,2300,1,,,2/
02,,GSBI,1,200331,2300,,,/
03,123456,USD,010,10000,,,/
16,495,1000,,I1220012,endtoendID,To: Payee account, Account: XXXXX-4454, Client Ref ID: endtoendID, GS ID:I1220012/
88,CREF: 9f4396bd-8c47-4893-8682-bd8ff006d140
49,11000,2/
98,12000,2,5/
99,22000,2,10/

View as JSON

bai2 test.bai
{
  "continuations": [],
  "file_header": {
    "sender": "GSBI",
    "receiver": "ABC",
    "creation_date": "2020-03-31",
    "creation_time": "23:00:00",
    "file_id": "1",
    "physical_record_length": "",
    "block_size": "",
    "version_number": "2"
  },
  "groups": [
    {
      "header": {
        "receiver": "",
        "sender": "GSBI",
        "status": "1",
        "as_of_date": "2020-03-31",
        "as_of_time": "23:00:00",
        "currency_code": "",
        "as_of_date_modifier": ""
      },
      "control": {
        "total": "12000",
        "number_of_accounts": "2",
        "number_of_records": "5"
      },
      "accounts": [
        {
          "header": {
            "account_number": "123456",
            "currency_code": "USD",
            "type_code": "010",
            "amount": "10000",
            "item_code": "",
            "funds_type": ""
          },
          "control": {
            "total": "11000",
            "number_of_records": "2"
          },
          "transactions": [
            {
              "type_code": "495",
              "amount": "1000",
              "funds_type": "",
              "bank_reference_number": "I1220012",
              "customer_reference_number": "endtoendID",
              "text": "To: Payee account",
              "continuations": [
                {
                  "text": "CREF: 9f4396bd-8c47-4893-8682-bd8ff006d140"
                }
              ]
            }
          ],
          "continuations": []
        }
      ],
      "continuations": []
    }
  ],
  "file_control": {
    "total": "22000",
    "number_of_groups": "2",
    "number_of_records": "10"
  },
  "last_record_type": "File"
}

Resources

I very heavily relied on documentation from these sources while writing this library:

Credits

The parser was very heavily inspired by Leejay Hsu's nacha tool.

Commit count: 24

cargo fmt