Skip to content

Commit 95bde90

Browse files
committed
feat: add one piece nacha
1 parent 99e8614 commit 95bde90

File tree

233 files changed

+37585
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+37585
-2
lines changed

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
elixir 1.13.2
2-
erlang 24.2.1
1+
elixir 1.14.0
2+
erlang 24.3.4
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

apps/one_piece_nacha/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
one_piece_nacha-*.tar
24+
25+
# Temporary files, for example, from tests.
26+
/tmp/

apps/one_piece_nacha/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# OnePieceNacha
2+
3+
**TODO: Add description**
4+
5+
## Installation
6+
7+
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
8+
by adding `one_piece_nacha` to your list of dependencies in `mix.exs`:
9+
10+
```elixir
11+
def deps do
12+
[
13+
{:one_piece_nacha, "~> 0.1.0"}
14+
]
15+
end
16+
```
17+
18+
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
19+
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
20+
be found at <https://hexdocs.pm/one_piece_nacha>.
21+
22+
Supports for 2022` Nacha Operating Rules.
23+
24+
## Supported Formats
25+
26+
- [x] File Header
27+
- [x] File Control
28+
- [x] Batch Header
29+
- [x] Batch Control
30+
31+
- [x] IAT Batch Header
32+
- [x] IAT Entry Detail
33+
- [x] First IAT Addenda
34+
- [x] Second IAT Addenda
35+
- [x] Third IAT Addenda
36+
- [x] Fourth IAT Addenda
37+
- [x] Fifth IAT Addenda
38+
- [x] Sixth IAT Addenda
39+
- [x] Seventh IAT Addenda
40+
- [x] IAT Addenda for Remittance Information
41+
- [x] IAT Addenda Record for Foreign Correspondent Bank Information
42+
43+
- [x] ADV File Header
44+
- [x] ADV File Control
45+
- [x] ADV Batch Control
46+
- [x] ADV Entry Detail
47+
48+
- [x] ARC Entry Detail
49+
- [x] BOC Entry Detail
50+
- [x] CCD Entry Detail
51+
- [x] CCD Addenda
52+
- [x] CIE Entry Detail
53+
- [x] CIE Addenda
54+
- [x] CTX Entry Detail
55+
- [x] CTX Addenda
56+
- [x] DNE Entry Detail
57+
- [x] DNE Addenda
58+
- [x] ENR Entry Detail
59+
- [x] ENR Addenda
60+
- [x] MTE Entry Detail
61+
- [x] MTE Addenda
62+
- [x] POP Entry Detail
63+
- [x] POS Entry Detail
64+
- [x] POS Addenda
65+
- [x] PPD Entry Detail
66+
- [x] PPD Addenda
67+
- [x] RCK Entry Detail
68+
- [x] SHR Entry Detail
69+
- [x] SHR Addenda
70+
- [x] TEL Entry Detail
71+
- [x] TRC Entry Detail
72+
- [x] TRX Entry Detail
73+
- [x] TRX Addenda
74+
- [x] Web Entry Detail
75+
- [x] Web Addenda
76+
- [x] XCK Entry Detail
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3.8'
2+
3+
services:
4+
moov_ach:
5+
image: moov/ach:v1.21.1
6+
ports:
7+
- "7080:8080"
8+
- "7091:9090"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
defmodule OnePiece.Nacha.AdvBatchControl do
2+
import NimbleParsec
3+
import OnePiece.Nacha.Helpers
4+
5+
@enforce_keys [
6+
:record_type_code,
7+
:service_class_code,
8+
:entry_and_addenda_count,
9+
:entry_hash,
10+
:total_debit_entry_dollar_amount,
11+
:total_credit_entry_dollar_amount,
12+
:ach_operator_data,
13+
:originating_dfi_identification,
14+
:batch_number,
15+
:__parsing_info__
16+
]
17+
18+
defstruct @enforce_keys
19+
20+
def post_traverse(rest, parsed_line, context, line, byte_offset) do
21+
{rest,
22+
[
23+
%__MODULE__{
24+
record_type_code: Enum.at(parsed_line, 8),
25+
service_class_code: Enum.at(parsed_line, 7),
26+
entry_and_addenda_count: Enum.at(parsed_line, 6),
27+
entry_hash: Enum.at(parsed_line, 5),
28+
total_debit_entry_dollar_amount: Enum.at(parsed_line, 4),
29+
total_credit_entry_dollar_amount: Enum.at(parsed_line, 3),
30+
ach_operator_data: Enum.at(parsed_line, 2),
31+
originating_dfi_identification: Enum.at(parsed_line, 1),
32+
batch_number: Enum.at(parsed_line, 0),
33+
__parsing_info__: OnePiece.Nacha.ParsingInfo.new(line, byte_offset)
34+
}
35+
], context}
36+
end
37+
38+
def batch_control do
39+
string("8")
40+
|> label("Record Type Code")
41+
|> ascii_string([], 3)
42+
|> label("Service Class Code")
43+
|> ascii_string([], 6)
44+
|> label("Entry/Addenda Count")
45+
|> ascii_string([], 10)
46+
|> label("Entry Hash")
47+
|> ascii_string([], 20)
48+
|> label("Total Debit Entry Dollar Amount")
49+
|> ascii_string([], 20)
50+
|> label("Total Credit Entry Dollar Amount")
51+
|> ascii_string([], 19)
52+
|> label("Ach Operator Data")
53+
|> ascii_string([], 8)
54+
|> label("Originating DFI Identification")
55+
|> ascii_string([], 7)
56+
|> label("Batch Number")
57+
|> eol()
58+
|> post_traverse({__MODULE__, :post_traverse, []})
59+
|> unwrap_and_tag(:batch_control)
60+
|> label("ADV Batch Control")
61+
end
62+
end
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
defmodule OnePiece.Nacha.AdvEntryDetail do
2+
import NimbleParsec
3+
import OnePiece.Nacha.Helpers
4+
5+
@enforce_keys [
6+
:record_type_code,
7+
:transaction_code,
8+
:receiving_dfi_identification,
9+
:check_digit,
10+
:dfi_account_number,
11+
:amount,
12+
:check_serial_number,
13+
:individual_name_receiving_company_name,
14+
:discretionary_data,
15+
:addenda_record_indicator,
16+
:trace_number,
17+
:__parsing_info__
18+
]
19+
20+
defstruct @enforce_keys
21+
22+
def post_traverse(rest, parsed_line, context, line, byte_offset) do
23+
{rest,
24+
[
25+
%__MODULE__{
26+
record_type_code: Enum.at(parsed_line, 10),
27+
transaction_code: Enum.at(parsed_line, 9),
28+
receiving_dfi_identification: Enum.at(parsed_line, 8),
29+
check_digit: Enum.at(parsed_line, 7),
30+
dfi_account_number: Enum.at(parsed_line, 6),
31+
amount: Enum.at(parsed_line, 5),
32+
check_serial_number: Enum.at(parsed_line, 4),
33+
individual_name_receiving_company_name: Enum.at(parsed_line, 3),
34+
discretionary_data: Enum.at(parsed_line, 2),
35+
addenda_record_indicator: Enum.at(parsed_line, 1),
36+
trace_number: Enum.at(parsed_line, 0),
37+
__parsing_info__: OnePiece.Nacha.ParsingInfo.new(line, byte_offset)
38+
}
39+
], context}
40+
end
41+
42+
def adv_entry_detail do
43+
record_type_code_entry_detail()
44+
|> ascii_string([], 2)
45+
|> label("Transaction Code")
46+
|> ascii_string([], 8)
47+
|> label("Receiving DFI Identification")
48+
|> ascii_string([], 1)
49+
|> label("Check Digit")
50+
|> ascii_string([], 17)
51+
|> label("DFI Account Number")
52+
|> ascii_string([], 10)
53+
|> label("Amount")
54+
|> ascii_string([], 15)
55+
|> label("Check Serial Number")
56+
|> ascii_string([], 22)
57+
|> label("Individual Name/Receiving Company Name")
58+
|> ascii_string([], 2)
59+
|> label("Discretionary Data")
60+
|> ascii_string([], 1)
61+
|> label("Addenda Record Indicator")
62+
|> ascii_string([], 15)
63+
|> label("Trace Number")
64+
|> eol()
65+
|> post_traverse({__MODULE__, :post_traverse, []})
66+
|> label("ADV Entry Detail")
67+
end
68+
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
defmodule OnePiece.Nacha.AdvFileControl do
2+
import NimbleParsec
3+
import OnePiece.Nacha.Helpers
4+
5+
@enforce_keys [
6+
:record_type_code,
7+
:batch_count,
8+
:block_count,
9+
:entry_and_addenda_count,
10+
:entry_hash,
11+
:total_debit_entry_dollar_amount_in_file,
12+
:total_credit_entry_dollar_amount_in_file,
13+
:reserved,
14+
:__parsing_info__
15+
]
16+
17+
defstruct @enforce_keys
18+
19+
def post_traverse(rest, parsed_line, context, line, byte_offset) do
20+
{rest,
21+
[
22+
%__MODULE__{
23+
record_type_code: Enum.at(parsed_line, 7),
24+
batch_count: Enum.at(parsed_line, 6),
25+
block_count: Enum.at(parsed_line, 5),
26+
entry_and_addenda_count: Enum.at(parsed_line, 4),
27+
entry_hash: Enum.at(parsed_line, 3),
28+
total_debit_entry_dollar_amount_in_file: Enum.at(parsed_line, 2),
29+
total_credit_entry_dollar_amount_in_file: Enum.at(parsed_line, 1),
30+
reserved: Enum.at(parsed_line, 0),
31+
__parsing_info__: OnePiece.Nacha.ParsingInfo.new(line, byte_offset)
32+
}
33+
], context}
34+
end
35+
36+
def file_control do
37+
string("9")
38+
|> label("Record Type Code")
39+
|> ascii_string([], 6)
40+
|> label("Batch Count")
41+
|> ascii_string([], 6)
42+
|> label("Block Count")
43+
|> ascii_string([], 8)
44+
|> label("Entry/Addenda Count")
45+
|> ascii_string([], 10)
46+
|> label("Entry Hash")
47+
|> ascii_string([], 20)
48+
|> label("Total Debit Entry Dollar Amount In File")
49+
|> ascii_string([], 20)
50+
|> label("Total Credit Entry Dollar Amount In File")
51+
|> ascii_string([], 23)
52+
|> label("Reserved")
53+
|> eol()
54+
|> post_traverse({__MODULE__, :post_traverse, []})
55+
|> unwrap_and_tag(:file_control)
56+
|> label("ADV File Control")
57+
end
58+
end
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
defmodule OnePiece.Nacha.AdvFileHeader do
2+
import NimbleParsec
3+
import OnePiece.Nacha.Helpers
4+
5+
@enforce_keys [
6+
:record_type_code,
7+
:priority_code,
8+
:immediate_destination,
9+
:immediate_origin,
10+
:file_creation_date,
11+
:file_creation_time,
12+
:file_id_modifier,
13+
:record_size,
14+
:blocking_factor,
15+
:format_code,
16+
:immediate_destination_name,
17+
:immediate_origin_name,
18+
:reference_code,
19+
:__parsing_info__
20+
]
21+
22+
defstruct @enforce_keys
23+
24+
def post_traverse(rest, parsed_line, context, line, byte_offset) do
25+
{rest,
26+
[
27+
%__MODULE__{
28+
record_type_code: Enum.at(parsed_line, 12),
29+
priority_code: Enum.at(parsed_line, 11),
30+
immediate_destination: Enum.at(parsed_line, 10),
31+
immediate_origin: Enum.at(parsed_line, 9),
32+
file_creation_date: Enum.at(parsed_line, 8),
33+
file_creation_time: Enum.at(parsed_line, 7),
34+
file_id_modifier: Enum.at(parsed_line, 6),
35+
record_size: Enum.at(parsed_line, 5),
36+
blocking_factor: Enum.at(parsed_line, 4),
37+
format_code: Enum.at(parsed_line, 3),
38+
immediate_destination_name: Enum.at(parsed_line, 2),
39+
immediate_origin_name: Enum.at(parsed_line, 1),
40+
reference_code: Enum.at(parsed_line, 0),
41+
__parsing_info__: OnePiece.Nacha.ParsingInfo.new(line, byte_offset)
42+
}
43+
], context}
44+
end
45+
46+
def file_header do
47+
string("1")
48+
|> label("Record Type Code")
49+
|> ascii_string([], 2)
50+
|> label("Priority Code")
51+
|> ascii_string([], 10)
52+
|> label("Immediate Destination")
53+
|> ascii_string([], 10)
54+
|> label("Immediate Origin")
55+
|> ascii_string([], 6)
56+
|> label("File Creation Date")
57+
|> ascii_string([], 4)
58+
|> label("File Creation Time")
59+
|> ascii_string([], 1)
60+
|> label("File ID Modifier")
61+
|> ascii_string([], 3)
62+
|> label("Record Size")
63+
|> ascii_string([], 2)
64+
|> label("Blocking Factor")
65+
|> ascii_string([], 1)
66+
|> label("Format Code")
67+
|> ascii_string([], 23)
68+
|> label("Immediate Destination Name")
69+
|> ascii_string([], 23)
70+
|> label("Immediate Origin Name")
71+
|> ascii_string([], 8)
72+
|> label("Reference Code")
73+
|> eol()
74+
|> post_traverse({__MODULE__, :post_traverse, []})
75+
|> unwrap_and_tag(:file_header)
76+
|> label("ADV File Header")
77+
end
78+
end

0 commit comments

Comments
 (0)