Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/achcli/describe: accept mask flags for ENR payment related information #1476

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading