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

Addenda 99 Dishonored ReturnTraceNumberField method returns truncated value when a file is read #1537

Open
sunnygill-stash opened this issue Jan 23, 2025 · 2 comments

Comments

@sunnygill-stash
Copy link

sunnygill-stash commented Jan 23, 2025

ACH Version

v1.45.3

What were you trying to do?

The project I work on reads ACH files and then converts them to CSV. When an Addenda 99 Dishonor is parsed, the value is truncated. This is happening because the parser is grabbing the 3 blank spaces that proceed the Return Trace Number. The ReturnTraceNumberField method takes the first 15 characters of the ReturnTraceNumber value, which drops off the last 3 characters.

The problem appears to be with the Parse method

func (Addenda99Dishonored *Addenda99Dishonored) Parse(record string) {
	runeCount := utf8.RuneCountInString(record)
	if runeCount != 94 {
		return
	}

	buf := getBuffer()
	defer saveBuffer(buf)

	reset := func() string {
		out := buf.String()
		buf.Reset()
		return out
	}

	// We're going to process the record rune-by-rune and at each field cutoff save the value.
	var idx int
	for _, r := range record {
		idx++

		// Append rune to buffer
		buf.WriteRune(r)

		// At each cutoff save the buffer and reset
		switch idx {
		case 0, 1:
			// 1-1 Always 7
			reset()
		case 3:
			Addenda99Dishonored.TypeCode = reset()
		case 6:
			Addenda99Dishonored.DishonoredReturnReasonCode = reset()
		case 21:
			Addenda99Dishonored.OriginalEntryTraceNumber = reset()
		case 35:
			Addenda99Dishonored.OriginalReceivingDFIIdentification = reset()
		case 53:
			Addenda99Dishonored.ReturnTraceNumber = reset()
		case 56:
			Addenda99Dishonored.ReturnSettlementDate = reset()
		case 58:
			Addenda99Dishonored.ReturnReasonCode = reset()
		case 79:
			Addenda99Dishonored.AddendaInformation = reset()
		case 94:
			Addenda99Dishonored.TraceNumber = reset()
		}
	}
}

The blank spaces between the Original Receiving DFI Identification and Return Trace Number are unaccounted. Adding the following fixes the issue

		case 38:
			// 36-38 reserved - Leave blank
			reset()

What did you expect to see?

The ReturnTraceNumberField method would return all 15 digits of the Trace Number

What did you see?

A string with 3 leading blank spaces and missing the last 3 digits was returned.

How can we reproduce the problem?

Read an ACH file that has an Addenda 99 Dishonor. Then call the ReturnTraceNumberField method on the field. The value will be wrong. Using ReturnTraceNumber works, so there is a workaround.

@adamdecaf
Copy link
Member

Do you have a sample (can be masked) record we can use as a test case for this? I can get this fixed and released today.

@adamdecaf
Copy link
Member

I double checked the Nacha standards book and don't see any issues with our parsing logic. We have that 38 case already (it was out of order).

456deff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants