Skip to content

Generating US routing number (ABA RTN) in Finance provider. - #821

Merged
bodiam merged 1 commit into
datafaker-net:mainfrom
polarfish:finance-usRoutingNumber
May 6, 2023
Merged

Generating US routing number (ABA RTN) in Finance provider.#821
bodiam merged 1 commit into
datafaker-net:mainfrom
polarfish:finance-usRoutingNumber

Conversation

@polarfish

@polarfish polarfish commented May 5, 2023

Copy link
Copy Markdown
Contributor

ABA RTN Format

XXXXYYYYC
where XXXX is Federal Reserve Routing Symbol, YYYY is ABA Institution Identifier, and C is the check digit.
...
The first two digits of the nine digit RTN must be in the ranges 00 through 12, 21 through 32, 61 through 72, or 80.
- 00 is used by the [United States Government](https://en.wikipedia.org/wiki/Federal_government_of_the_United_States)
- 01 through 12 are the "normal" routing numbers, and correspond to the 12 [Federal Reserve Banks](https://en.wikipedia.org/wiki/Federal_Reserve_Bank). For example, 0260-0959-3 is the routing number for Bank of America incoming wires in New York, with the initial "02" indicating the [Federal Reserve Bank of New York](https://en.wikipedia.org/wiki/Federal_Reserve_Bank_of_New_York).
- 21 through 32 were assigned only to [thrift institutions](https://en.wikipedia.org/wiki/Cooperative_banking) (e.g. [credit unions](https://en.wikipedia.org/wiki/Credit_union) and savings banks) through 1985, but are no longer assigned (thrifts are assigned normal 01–12 numbers). Currently they are still used by the thrift institutions, or their successors, and correspond to the normal routing number, plus 20. (For example, 2260-7352-3 is the routing number for Grand Adirondack Federal Credit Union in New York, with the initial "22" corresponding to "02" (New York Fed) plus "20" (thrift).)
- 61 through 72 are special purpose routing numbers designated for use by non-bank payment processors and clearinghouses and are termed Electronic Transaction Identifiers (ETIs), and correspond to the normal routing number, plus 60.
- 80 is used for [traveler's checks](https://en.wikipedia.org/wiki/Traveler%27s_check)
...
Check digit
The ninth, check digit provides a checksum test using a position-weighted sum of each of the digits. High-speed check-sorting equipment will typically verify the checksum and if it fails, route the item to a reject pocket for manual examination, repair, and re-sorting. Mis-routings to an incorrect bank are thus greatly reduced.
The following condition must hold:
(3*(d1 + d4 + d7) + 7*(d2 + d5 + d8) + 1*(d3 + d6 + d9)) mod 10 = 0

References

@snuyanzin

snuyanzin commented May 5, 2023

Copy link
Copy Markdown
Collaborator

Can you please provide more info about rules of generation for US routing number (ABA RTN) in Finance with some ref to official source of truth

@polarfish

polarfish commented May 5, 2023

Copy link
Copy Markdown
Contributor Author

Can you please provide more info about rules of generation for US routing number (ABA RTN) in Finance with some ref to official source of truth

I added description with links.
The motivation of adding this logic to datafaker is to be able to generate ABA RTN with correct check digit, otherwise we could just run faker.numerify("#".repeat(9))

@bodiam

bodiam commented May 5, 2023

Copy link
Copy Markdown
Contributor

Looks great to me! Thanks for your contribution @polarfish

@bodiam
bodiam merged commit d827105 into datafaker-net:main May 6, 2023
@polarfish

Copy link
Copy Markdown
Contributor Author

@bodiam Shall I create [Backport-1.x] PR to have my changes in the coming 1.x version?

@bodiam

bodiam commented May 7, 2023

Copy link
Copy Markdown
Contributor

@polarfish That is up to you; if you want it in the 1.x version, then we would welcome a PR, otherwise it will most likely only end up in the 2.x release.

@polarfish

polarfish commented May 7, 2023

Copy link
Copy Markdown
Contributor Author

#823 ([Backport-1.x] Generating US routing number (ABA RTN) in Finance provider (datafaker-net#821).)

@polarfish
polarfish deleted the finance-usRoutingNumber branch May 7, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants