-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix the BAI2 grammar from forked package #1
base: master
Are you sure you want to change the base?
Conversation
@@ -90,7 +90,7 @@ | |||
"detailFundsType": "", | |||
"bankReferenceNumber": "AGN", | |||
"customerReferenceNumber": "935892", | |||
"detailText": "POINT OF SALE" | |||
"detailText": "POINT OF SALE/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I make a few changes to the test cases, because I believe the grammar was implemented incorrectly.
The specification states that
Therefore, the end of a record ending in text cannot be delimited using these characters. Instead, the logical record continues until another record that is not a continuation (88) record begins
senderIdentification = alnum + | ||
receiverIdentification = alnum + | ||
senderIdentification = alphaNumeric+ | ||
receiverIdentification = alphaNumeric+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These alterations are hardening the definition, these values cannot include , or /
@@ -74,7 +74,7 @@ BTR3 { | |||
|
|||
amountOpt = optSign digit* | |||
itemCount = digit* | |||
fundsType = alnum? | |||
fundsType = ("0".."2" | "S" | "V" | "D" | "Z") ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, hardening the definition, there is a specific set of values for this [pg. 29]
@@ -102,8 +102,10 @@ BTR3 { | |||
bankReferenceNumber = alphaNumeric* | |||
customerReferenceNumber = alphaNumeric* | |||
detailText (Text relaxed for CBA BAI2 format does not contain , / Optionally followed by /) | |||
= (~ eor any) * | |||
= & "/" // null text field | |||
| text * // normal text field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we need to do a lookahead for a /
(in the file, this would look like ,/
because detailText
is preceded by delim
. In this case, the text is null, and trying to parse it as a text
would cause the expression to be unreasonably complex
@@ -120,10 +122,17 @@ BTR3 { | |||
hh = ("0".."1" digit) | ("2" "0" .. "3") | |||
mm = "0".."5" digit | |||
|
|||
delim = "," | |||
newLine = ("\r\n" | "\n" | "\r") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should accept all kinds of newlines
delim = | ||
| "," -- comma_delimiter | ||
| "/" newLine "88," -- continuation_record_delimiter | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is big. I have added support for 88 - Continuation Record [pg. 20]. It is simplest to treat \n88, as a delimiter rather than a new record.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text = (continuationWithinTextField | ~newLine any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the specification for the file format
Cash Management Balance Reporting Specifications Version 2.pdf
I make a few changes to this code: