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
454 stars 150 forks source link

The DFIAccountNumber field on EntryDetails should trim value after parsing ach file #631

Closed rayjlinden closed 1 year ago

rayjlinden commented 4 years ago

What were you trying to do?

View the field entry.DFIAccountNumber after parsing an ACH file.

What did you expect to see?

The string value to have white space trimmed.

What did you see?

The string value had white space padded to the right of the account number.

How can we reproduce the problem?

Parse and ACH file and print the value of the DFIAccountNumber field.

adamdecaf commented 4 years ago

Do you have the 2019 NACHA rules? This copy I'm reading from is a bit old (2013), but they state:

Screen Shot 2019-09-25 at 9 55 05 AM

Looking at that description "81967038518 " makes sense to left justify and pad with spaces, but that's only on a receiver's account number.

In the event of a DFI's account number it looks like we should return "81967038518" (and handle placing -'s in where 's are within the account number).

adamdecaf commented 4 years ago

If you're comparing against non-MICR account numbers I can see where having to trim the returned number is an extra step.

All we specify on DFIAccountNumberField() is:

// DFIAccountNumberField gets the DFIAccountNumber with space padding

This doesn't really help as we don't perform ` (space) for-` substitution in that method either.

adamdecaf commented 4 years ago

We could add a helper ach.MICRNumber(string) string which would convert "1234 5678" into "1234-5678 " (padded to 17 characters).

adamdecaf commented 4 years ago

cc @wadearnold I'm a bit confused what to do here

adamdecaf commented 4 years ago

Thoughts @wadearnold ?