Skip to content

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

Open
@sunnygill-stash

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions