jach icon indicating copy to clipboard operation
jach copied to clipboard

Ambiguous BatchHeader types found during ACH request reading

Open skovtunenko opened this issue 6 years ago • 7 comments

Given the following ACH request file:

101 062000019B1102027371906241706P094101REGIONS BANK           MYCORP        SVCSXXXXXXXXXXXXX
52006088BCB         FV4223371           B110202737CCD6088BCB         190624   1062000190000001
6223694058211790185004       0000009999REHJXZZGF      DON 1604AF7D          R 1062000190000001
705DESCRIPT11                                                                      00010000001
6223694058211790185004       0000005091ASQSQQQQ       DON 1604AF7D          R 1062000190000002
705DESCRIPT12                                                                      00030000002
82000000040073881164            000000015090B110202737                         062000190000001
520035F0DC90        902977552           B110202737CCD35F0DC90        190624   1062000190000002
6322901649888623334396       0000008000PPPUUUU        DON 114B90FC          R 1062000190000003
705DESCRIPT21                                                                      00010000003
82000000020029016498            000000008000B110202737                         062000190000002
52003033C168        802698216           B110202737CCD3033C168        190624   1062000190000003
6228953998245558213179       0000026900CZVZVVFFF      DON 355EB790          R 1062000190000004
705DESCRIPT31                                                                      00010000004
6228953998245558213179       0000000010ZXVDSGBBB      DON 355EB790          R 1062000190000005
705DESCRIPT32                                                                      00030000005
82000000040179079964            000000026910B110202737                         062000190000003
9000003000002000000100281977626000000000000000000050000                                       
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

The ACH request reading failed for the lines:

52006088BCB         FV4223371           B110202737CCD6088BCB         190624   1062000190000001

and

520035F0DC90        902977552           B110202737CCD35F0DC90        190624   1062000190000002

and

52003033C168        802698216           B110202737CCD3033C168        190624   1062000190000003

Reading the mentioned ACH request file, there is an ambiguous java type found for the BatchHeader line: IATBatchHeader and GeneralBatchHeader.

The Java exception will be thrown:

com.afrunt.jach.exception.ACHException: More than one type found for string 52006088BCB         FV4223371           B110202737CCD6088BCB         190624   1062000190000001
 Types: GeneralBatchHeader, IATBatchHeader

skovtunenko avatar Jun 24 '19 15:06 skovtunenko

Looks like its failing because ACHRequestReader#rankTypes methods sometimes (when CompanyDiscretionaryData (in the batch header) has '1', ' 2' or '3' on the 3rd place (eg 502152229, 102727069 or 303149471) OR starts with "FV", "FF" (eg FV2152229, FF2727069 or FV3149471)) returns 2 types with the same rank IATBatchHeader and GeneralBatchHeader.

As those values are valid for FOREIGN_EXCHANGE_REFERENCE_INDICATOR so IATBatchHeader gets an extra rank up

skovtunenko avatar Jun 24 '19 15:06 skovtunenko

@skovtunenko well, you can fix it by yourself bro and prepare the PR ;)

afrunt avatar Jul 04 '19 10:07 afrunt

Just curious. Can't you determine to use the IAT batch header by simply looking at the standardEntryClassCode equal to "IAT"?

jerrybowman avatar Aug 16 '19 17:08 jerrybowman

I am having the very same issue, the ranking is broken. If a mandatory field is missing rank should be zero. Instead, IATBatchHeader and BatchHeader always tie even though sec code is not IAT. Try these files, most will fail parsing:

https://github.com/moov-io/ach/tree/master/test

dbenoff avatar Sep 05 '19 02:09 dbenoff

I actually made that change and it worked. I can send you the change. I haven’t done a pull request because I still think the right answer is to determine the record type by the class code in the batch header.

@afrunt — do you want the pull request with this fix?

jerrybowman avatar Sep 05 '19 03:09 jerrybowman

Jerry, if you would please send me the change I'd appreciate it..

On Wed, Sep 4, 2019 at 8:31 PM Jerry Bowman [email protected] wrote:

I actually made that change and it worked. I can send you the change. I haven’t done a pull request because I still think the right answer is to determine the record type by the class code in the batch header.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/afrunt/jach/issues/14?email_source=notifications&email_token=ABRKSIC5PWSV3YNA6LANYSDQIB4QVA5CNFSM4H27ZE72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD55WSUY#issuecomment-528181587, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRKSIFTQWATELRM7WOBV5TQIB4QVANCNFSM4H27ZE7Q .

dbenoff avatar Sep 05 '19 14:09 dbenoff

@jerrybowman sure, it will be very nice, because I don't have enough time right now. I will prepare the new release with your fix you can also ping me in twitter @javaguyua

afrunt avatar Sep 05 '19 18:09 afrunt