Skip to content

Commit

Permalink
Support acknowledgment entries - ACK & ATX #327
Browse files Browse the repository at this point in the history
ACk and AXT testing adjustments
  • Loading branch information
bkmoovio committed Oct 26, 2018
1 parent 5d63140 commit 3c3b14c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 65 deletions.
12 changes: 2 additions & 10 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,18 @@ func NewBatch(bh *BatchHeader) (Batcher, error) {
switch bh.StandardEntryClassCode {
case "ACK":
return NewBatchACK(bh), nil
case "ATX":
return NewBatchATX(bh), nil
case "ARC":
return NewBatchARC(bh), nil
case "ATX":
return NewBatchATX(bh), nil
case "BOC":
return NewBatchBOC(bh), nil
/* case "CCD", "ACK":
return NewBatchCCD(bh), nil
ToDo: Should we do it this way and slash up batchCCD?
*/
case "CCD":
return NewBatchCCD(bh), nil
case "CIE":
return NewBatchCIE(bh), nil
case "COR":
return NewBatchCOR(bh), nil
/* case "CTX", ATX:
return NewBatchCTX(bh), nil
ToDo: Should we do it this way and slash up batchCTX
*/
case "CTX":
return NewBatchCTX(bh), nil
case "IAT":
Expand Down
7 changes: 3 additions & 4 deletions batchACK_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func mockBatchACKHeader() *BatchHeader {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ACK"
bh.CompanyName = "Your Company, inc"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "Vndr Pay"
bh.ODFIIdentification = "231380104"
bh.ODFIIdentification = "23138010"
return bh
}

Expand All @@ -28,8 +28,7 @@ func mockACKEntryDetail() *EntryDetail {
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 0
// ToDo: In EntryDetail Change To Proper Name
entry.IdentificationNumber = "121042880000001"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetReceivingCompany("Best Co. #23")
entry.SetTraceNumber(mockBatchACKHeader().ODFIIdentification, 1)
entry.DiscretionaryData = "S"
Expand Down
48 changes: 24 additions & 24 deletions batchATX_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ func mockBatchATXHeader() *BatchHeader {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ATX"
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "ACH ATX"
bh.ODFIIdentification = "12104288"
bh.ODFIIdentification = "23138010"
return bh
}

// mockATXEntryDetail creates a BatchATX EntryDetail
func mockATXEntryDetail() *EntryDetail {
entry := NewEntryDetail()
entry.TransactionCode = 24
entry.SetRDFI("231380104")
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 0
entry.IdentificationNumber = "45689033"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetCATXAddendaRecords(1)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchATXHeader().ODFIIdentification, 1)
Expand Down Expand Up @@ -300,16 +300,16 @@ func testBatchATXAddenda10000(t testing.TB) {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ATX"
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "ACH ATX"
bh.ODFIIdentification = "12104288"
bh.ODFIIdentification = "23138010"

entry := NewEntryDetail()
entry.TransactionCode = 24
entry.SetRDFI("231380104")
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 0
entry.IdentificationNumber = "45689033"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetCATXAddendaRecords(9999)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchATXHeader().ODFIIdentification, 1)
Expand Down Expand Up @@ -353,16 +353,16 @@ func testBatchATXAddendaRecords(t testing.TB) {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ATX"
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "ACH ATX"
bh.ODFIIdentification = "12104288"
bh.ODFIIdentification = "23138010"

entry := NewEntryDetail()
entry.TransactionCode = 24
entry.SetRDFI("231380104")
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 0
entry.IdentificationNumber = "45689033"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetCATXAddendaRecords(500)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchATXHeader().ODFIIdentification, 1)
Expand Down Expand Up @@ -451,16 +451,16 @@ func testBatchATXZeroAddendaRecords(t testing.TB) {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ATX"
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "ACH ATX"
bh.ODFIIdentification = "12104288"
bh.ODFIIdentification = "23138010"

entry := NewEntryDetail()
entry.TransactionCode = 24
entry.SetRDFI("231380104")
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 0
entry.IdentificationNumber = "45689033"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetCATXAddendaRecords(1)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchATXHeader().ODFIIdentification, 1)
Expand Down Expand Up @@ -500,17 +500,17 @@ func testBatchATXTransactionCode(t testing.TB) {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ATX"
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "ACH ATX"
bh.ODFIIdentification = "12104288"
bh.ODFIIdentification = "23138010"
bh.OriginatorStatusCode = 2

entry := NewEntryDetail()
entry.TransactionCode = 23
entry.SetRDFI("231380104")
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 0
entry.IdentificationNumber = "45689033"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetCATXAddendaRecords(1)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchATXHeader().ODFIIdentification, 1)
Expand Down Expand Up @@ -551,17 +551,17 @@ func TestBatchATXAmount(t *testing.T) {
bh.ServiceClassCode = 220
bh.StandardEntryClassCode = "ATX"
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyIdentification = "231380104"
bh.CompanyEntryDescription = "ACH ATX"
bh.ODFIIdentification = "12104288"
bh.ODFIIdentification = "23138010"
bh.OriginatorStatusCode = 2

entry := NewEntryDetail()
entry.TransactionCode = 23
entry.SetRDFI("231380104")
entry.SetRDFI("121042882")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.IdentificationNumber = "45689033"
entry.SetOriginalTraceNumber(121042880000001)
entry.SetCATXAddendaRecords(1)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchATXHeader().ODFIIdentification, 1)
Expand Down
35 changes: 8 additions & 27 deletions entryDetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,35 +400,16 @@ func (ed *EntryDetail) SetReceivingCompany(s string) {
ed.IndividualName = s
}

// ToDo: Deprecate
// SetCTXAddendaRecords setter for CTX AddendaRecords characters 1-4 of underlying IndividualName
func (ed *EntryDetail) SetCTXAddendaRecords(i int) {
ed.IndividualName = ed.numericField(i, 4)
}

// ToDo: Deprecate
// SetCTXReceivingCompany setter for CTX ReceivingCompany characters 5-20 underlying IndividualName
// Position 21-22 of underlying Individual Name are reserved blank space for ATX " "
func (ed *EntryDetail) SetCTXReceivingCompany(s string) {
ed.IndividualName = ed.IndividualName + ed.alphaField(s, 16) + " "
}

// ToDo: Deprecate
// CTXAddendaRecordsField is used in CTX files, characters 1-4 of underlying IndividualName field
func (ed *EntryDetail) CTXAddendaRecordsField() string {
return ed.parseStringField(ed.IndividualName[0:4])
}

// ToDo: Deprecate
// CTXReceivingCompanyField is used in CTX files, characters 5-20 of underlying IndividualName field
func (ed *EntryDetail) CTXReceivingCompanyField() string {
return ed.parseStringField(ed.IndividualName[4:20])
// OriginalTraceNumberField is used in ACK and ATX files but returns the underlying IdentificationNumber field
func (ed *EntryDetail) OriginalTraceNumberField() string {
return ed.IdentificationNumberField()
}

// ToDo: Deprecate
// CTXReservedField is used in CTX files, characters 21-22 of underlying IndividualName field
func (ed *EntryDetail) CTXReservedField() string {
return ed.IndividualName[20:22]
// SetOriginalTraceNumber setter for ACK and ATX OriginalTraceNumber which is underlying IdentificationNumber
func (ed *EntryDetail) SetOriginalTraceNumber(i int) {
s := strconv.Itoa(i)
//ed.IdentificationNumber = ed.numericField(i, 15)
ed.IdentificationNumber = s
}

// SetCATXAddendaRecords setter for CTX and ATX AddendaRecords characters 1-4 of underlying IndividualName
Expand Down

0 comments on commit 3c3b14c

Please sign in to comment.