Skip to content

Commit

Permalink
Merge pull request #1476 from adamdecaf/describe-mask-ENR
Browse files Browse the repository at this point in the history
cmd/achcli/describe: accept mask flags for ENR payment related information
  • Loading branch information
adamdecaf authored Aug 26, 2024
2 parents 8ec33c3 + 35caa88 commit f5dc5b6
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions cmd/achcli/describe/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ func File(ww io.Writer, file *ach.File, opts *Opts) {
fmt.Fprintf(w, " %d %s\t%s\t%s\t%s\t%s\t%s\t%s\n", e.TransactionCode, transactionCodes[e.TransactionCode], e.RDFIIdentificationField(), accountNumber, amount, name, e.TraceNumberField(), e.Category)

dumpAddenda02(w, e.Addenda02)
for i := range e.Addenda05 {
if i == 0 {
for a := range e.Addenda05 {
if a == 0 {
fmt.Fprintln(w, "\n Addenda05")
}
dumpAddenda05(w, e.Addenda05[i])
dumpAddenda05(w, file.Batches[i], e.Addenda05[a], opts)
}
dumpAddenda98(w, opts, e.Addenda98)
dumpAddenda99(w, e.Addenda99)
Expand Down Expand Up @@ -239,13 +239,31 @@ func dumpAddenda99Contested(w *tabwriter.Writer, a *ach.Addenda99Contested) {
a.ReturnSettlementDateField(), a.ReturnReasonCodeField(), a.DishonoredReturnTraceNumberField(), a.DishonoredReturnSettlementDateField(), a.DishonoredReturnReasonCodeField(), a.TraceNumberField())
}

func dumpAddenda05(w *tabwriter.Writer, a *ach.Addenda05) {
func dumpAddenda05(w *tabwriter.Writer, batch ach.Batcher, a *ach.Addenda05, opts *Opts) {
if a == nil {
return
}

paymentRelatedInfo := a.PaymentRelatedInformationField()

switch b := batch.(type) {
case *ach.BatchENR:
paymentInfo, _ := b.ParsePaymentInformation(a)
if paymentInfo != nil {
if opts.MaskNames {
paymentInfo.IndividualName = maskName(paymentInfo.IndividualName)
}
if opts.MaskAccountNumbers {
paymentInfo.IndividualIdentification = maskNumber(paymentInfo.IndividualIdentification)
paymentInfo.DFIAccountNumber = maskNumber(paymentInfo.DFIAccountNumber)
}

paymentRelatedInfo = paymentInfo.String()
}
}

fmt.Fprintln(w, " PaymentRelatedInformation\tSequenceNumber\tEntryDetailSequenceNumber")
fmt.Fprintf(w, " %s\t%s\t%s\n", a.PaymentRelatedInformationField(), a.SequenceNumberField(), a.EntryDetailSequenceNumberField())
fmt.Fprintf(w, " %s\t%s\t%s\n", paymentRelatedInfo, a.SequenceNumberField(), a.EntryDetailSequenceNumberField())
}

func dumpAddenda98(w *tabwriter.Writer, opts *Opts, a *ach.Addenda98) {
Expand Down

0 comments on commit f5dc5b6

Please sign in to comment.