-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added file structure. First specs pass
- Loading branch information
Showing
10 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require "../spec_helper" | ||
|
||
describe Nacha::FileHeader do | ||
describe "build" do | ||
it "formats the data correctly" do | ||
example = "101 021406766 8723856712212071417A094101Bank of Specialty JSTV Enterprises " | ||
|
||
current_time = Time.utc(2022, 12, 7, 14, 17, 0) | ||
|
||
io = IO::Memory.new | ||
file_header = Nacha::FileHeader.new( | ||
immediate_destination: "021406766", | ||
immediate_origin: "872385671", | ||
immediate_destination_name: "Bank of Specialty", | ||
immediate_origin_name: "JSTV Enterprises", | ||
file_creation_date: current_time, | ||
file_creation_time: current_time, | ||
) | ||
file_header.build(io) | ||
io.to_s.should eq(example) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
require "./spec_helper" | ||
|
||
describe Nacha do | ||
# TODO: Write tests | ||
|
||
it "works" do | ||
false.should eq(true) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require "./nacha/mixins/*" | ||
require "./nacha/**" | ||
|
||
module Nacha | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
module Nacha | ||
class BatchControl | ||
TYPE_CODE = 8 | ||
|
||
def initialize | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
module Nacha | ||
class BatchHeader | ||
TYPE_CODE = 5 | ||
|
||
def initialize | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
module Nacha | ||
class EntryDetail | ||
TYPE_CODE = 6 | ||
|
||
def initialize | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Nacha | ||
class EntryDetailAddenda | ||
TYPE_CODE = 7 | ||
|
||
def initialize | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
module Nacha | ||
class FileControl | ||
TYPE_CODE = 9 | ||
|
||
def initialize | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,43 @@ | ||
module Nacha | ||
# This record includes your company name and | ||
# company number. It also designates the immediate destination (LaSalle Bank | ||
# N.A. or Standard Federal Bank) of the entries contained within the file. | ||
class FileHeader | ||
def initialize | ||
include BuildableRecord | ||
|
||
TYPE_CODE = 1 # Identifies this is the FileHeader | ||
PRIORITY_CODE = 1 # lower number is higher priority (but only 01 is used) | ||
|
||
def initialize( | ||
@immediate_destination : String, # The Primary bank Routing number | ||
@immediate_origin : String, # The Primary company EIN or ABN AMRO number | ||
@immediate_destination_name : String, # The Primary bank name | ||
@immediate_origin_name : String, # The Primary company's name | ||
@file_creation_date : Time = Time.utc, # File creation date Formatted as YYMMDD | ||
@file_creation_time : Time = Time.utc, # File creation time Formatted as HHMM | ||
@file_id_modifier : Char = 'A', # Each file submitted in the same day must update this to the next consecutive letter, then 0-9 | ||
@record_size : Int32 = 94, # The number of bytes per record row | ||
@blocking_factor : String = "10", # wat | ||
@format_code : String = "1", # Placeholder for future other formats | ||
@reference_code : String? = nil # Used for your own internal accounting | ||
) | ||
end | ||
|
||
def build(io : IO) : IO | ||
io << TYPE_CODE.to_s | ||
io << PRIORITY_CODE.to_s.rjust(2, '0') | ||
io << @immediate_destination.rjust(10, ' ') | ||
io << @immediate_origin.rjust(10, ' ') | ||
io << @file_creation_date.to_s("%y%m%d") | ||
io << @file_creation_time.to_s("%H%M") | ||
io << @file_id_modifier.to_s | ||
io << @record_size.to_s.rjust(3, '0') | ||
io << @blocking_factor | ||
io << @format_code | ||
io << @immediate_destination_name[0..22].ljust(23, ' ') | ||
io << @immediate_origin_name[0..22].ljust(23, ' ') | ||
io << @reference_code.to_s.ljust(8, ' ') | ||
io | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module BuildableRecord | ||
# This turns the record in to it's data line | ||
abstract def build(io : IO) : IO | ||
end |