Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: suport btrs (bai v3) files #118

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Moov's mission is to give developers an easy way to create and integrate bank pr

Bai2 implements a reader, writer, and validator for the [Cash Management Balance Reporting Specifications Version 2](https://en.wikipedia.org/wiki/BAI_(file_format)) developed by [Bank Administration Institute](https://www.bai.org) (BAI). This project offers a HTTP server in a [Docker image](#docker) and a Go package `github.com/moov-io/bai2`.

BTRS (BTR3/BAI3) is also supported in this library. Behavior changes are made when the BTRS Version 3 header is detected.

Specifications for [bai2](docs/specifications/Cash Management Balance Reporting Specifications Version 2.pdf) and [BTRS / BTR3](docs/specifications/ANSI-X9-121201-BTRS-Format-Guide-Version-3.pdf) are included in the repository.

## Table of contents

- [Project status](#project-status)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions pkg/lib/btrs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package lib

import (
"testing"

"github.com/stretchr/testify/require"
)

// The following samples were pulled from examples in the BTRS V3 guide
// docs/specifications/ANSI-X9-121201-BTRS-Format-Guide-Version-3.pdf
func TestBTRSParse(t *testing.T) {
input := "01,122099999,123456789,150623,0200,1,,,3/"
var header fileHeader
_, err := header.parse(input)
require.NoError(t, err)
require.Equal(t, "122099999", header.Sender)
require.Equal(t, "123456789", header.Receiver)
require.Equal(t, "150623", header.FileCreatedDate)
require.Equal(t, "0200", header.FileCreatedTime)
require.Equal(t, "1", header.FileIdNumber)
require.Equal(t, int64(0), header.PhysicalRecordLength)
require.Equal(t, int64(0), header.BlockSize)
require.Equal(t, int64(3), header.VersionNumber)
}
1 change: 1 addition & 0 deletions pkg/lib/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
func TestFileWithSampleData(t *testing.T) {
paths := []string{
"sample1.txt",
"sample1-btrs.txt",
"sample2.txt",
"sample3.txt",
"sample4-continuations-newline-delimited.txt",
Expand Down
2 changes: 1 addition & 1 deletion pkg/lib/record_file_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (h *fileHeader) validate() error {
if h.FileIdNumber == "" {
return fmt.Errorf(fmt.Sprintf(fhValidateErrorFmt, "FileIdNumber"))
}
if h.VersionNumber != 2 {
if h.VersionNumber != 2 && h.VersionNumber != 3 {
return fmt.Errorf(fmt.Sprintf(fhValidateErrorFmt, "VersionNumber"))
}

Expand Down
27 changes: 27 additions & 0 deletions test/testdata/sample1-btrs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
01,0004,12345,060321,0829,001,80,1,3/
02,12345,0004,1,060317,,CAD,/
03,10200123456,CAD,040,+000000000000,,,045,+000000000000,,/
88,100,000000000208500,00003,V,060316,,400,000000000208500,00008,V,060316,/
16,409,000000000002500,V,060316,,,,RETURNED CHEQUE /
16,409,000000000090000,V,060316,,,,RTN-UNKNOWN /
16,409,000000000000500,V,060316,,,,RTD CHQ SERVICE CHRG/
16,108,000000000203500,V,060316,,,,TFR 1020 0345678 /
16,108,000000000002500,V,060316,,,,MACLEOD MALL /
16,108,000000000002500,V,060316,,,,MASCOUCHE QUE /
16,409,000000000020000,V,060316,,,,1000 ISLANDS MALL /
16,409,000000000090000,V,060316,,,,PENHORA MALL /
16,409,000000000002000,V,060316,,,,CAPILANO MALL /
16,409,000000000002500,V,060316,,,,GALERIES LA CAPITALE/
16,409,000000000001000,V,060316,,,,PLAZA ROCK FOREST /
49,+00000000000834000,14/
03,10200123456,CAD,040,+000000000000,,,045,+000000000000,,/
88,100,000000000111500,00002,V,060317,,400,000000000111500,00004,V,060317,/
16,108,000000000011500,V,060317,,,,TFR 1020 0345678 /
16,108,000000000100000,V,060317,,,,MONTREAL /
16,409,000000000100000,V,060317,,,,GRANDFALL NB /
16,409,000000000009000,V,060317,,,,HAMILTON ON /
16,409,000000000002000,V,060317,,,,WOODSTOCK NB /
16,409,000000000000500,V,060317,,,,GALERIES RICHELIEU /
49,+00000000000446000,9/
98,+00000000001280000,2,25/
99,+00000000001280000,1,27/
Loading