moov-io / ach

ACH implements a reader, writer, and validator for Automated Clearing House (ACH) files. The HTTP server is available in a Docker image and the Go package is available.
https://moov-io.github.io/ach/
Apache License 2.0
452 stars 150 forks source link

Offset batch missing when using API #1340

Closed DennyWeinberg closed 8 months ago

DennyWeinberg commented 8 months ago

ACH Version

v1.32.0

What were you trying to do?

I try to generate balanced files with the library https://moov-io.github.io/ach/balanced-offset/ (by API)

Here is what I did:

  1. I created an ACH JSON structure as expected by the ACH API
  2. I added the offset instructions
  3. I called the "create" API endpoint
  4. I called the "contents" API endpoint which gives me the raw ACH file

What did you expect to see?

I expected that I see at least two batches, so the offset would be resolved and transformed into batches.

What did you see?

The problem is that the offset information are not in the resulting ACH file. I searched for the routing/account number and the description but none of them are included in the list of the ACH file, I can only see the original batch I included in my JSON file.

Is that a bug in the lib? In the doc I read: On each batch.Create() call the offset record will be re-tabulated Might that be missing when using the API?

How can we reproduce the problem?

JSON:

{
    "fileHeader": {
        "immediateOrigin": "123456780",
        "immediateOriginName": "Anonymous Bank",
        "immediateDestination": "123456780",
        "immediateDestinationName": "Anonymous Bank"
    },
    "batches": [
        {
            "batchHeader": {
                "serviceClassCode": 200,
                "companyName": "Anonymous Bank",
                "companyIdentification": "123456780",
                "standardEntryClassCode": "CCD",
                "companyEntryDescription": "Anonymous Bank",
                "ODFIIdentification": "123456780"
            },
            "entryDetails": [
                {
                    "amount": 50000,
                    "DFIAccountNumber": "12345"
                }
            ],
            "offset": {
                "routingNumber": "123456780",
                "accountNumber": "12345",
                "accountType": "checking",
                "description": "For offset"
            }
        }
    ]
}

Resulting ACH (where I miss the offset information):

101 123456780 1234567802312130849A094101Anonymous Bank         Anonymous Bank                 
5200Anonymous Bank                      123456780 CCDAnonymous       000000   1123456780000001
600000000012345            0000050000                                       0123456780000001
82000000010000000000000000000000000000000000123456780                          123456780000001
9000001000001000000010000000000000000000000000000000000                                       
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
adamdecaf commented 8 months ago

I'm not able to reproduce the issue you're seeing. I can create a file with an offset following these steps https://github.com/moov-io/ach/pull/1345

DennyWeinberg commented 8 months ago

Hi, thanks! I checked your test and see that you are doing more things than I did. I simply called the create endoint with a json that contains "offset" from the beginning on, and expected to see the offset when calling "contents". However, in your test, you called "balance" and "build" in addition. Is that always needed? In my opinion "balance" wouldn't be needed as the original json already contains all needed information, but I would accept that "build" was needed (to transform the offset information to separate batches).

Update: I tried to call "build" between "create" and "contents", but that doesn't help. I'm still getting only one batch. I just realize you add the OFFSET duringthe balance call, but the original json already contains the offset infos.

adamdecaf commented 8 months ago

After removing the balance and build calls I can still see OFFSET in the result of "/contents" so I'm not quite sure how you're running into an issue. My issue1340.json is a bit different from yours as I had to add a couple fields, so maybe you're ignoring an error in your code?

DennyWeinberg commented 8 months ago

Wow yeah now it works after adding some missing fields. I don't know yet which one is important, but now I'm getting the OFFSET line.

image

Thanks for your help!

DennyWeinberg commented 8 months ago

I pass skipAll in my code, as I had some other issues with client files. That might be the reason why it doesn't work without error. Were you getting specific issues and added the needed fields because of that?

Update: I see, there are some errors raised. Thanks for all!

adamdecaf commented 8 months ago

Yep I was getting errors when SkipAll: false which is helpful to tell you what fields are needed. The API docs also mention what's required https://moov-io.github.io/ach/api/#post-/files/-fileID-

If you have more issues feel free to reach out in the #ach room on slack.