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

Should not allow to create File with different SCC codes in Batch Header and Batch Control #1076

Open
nazeer1100126 opened this issue Aug 30, 2022 · 3 comments
Labels

Comments

@nazeer1100126
Copy link

nazeer1100126 commented Aug 30, 2022

Looks like there is no validation on Batch Control SCC code. Even I can pass some random integer.
But NACHA file is created having Batch Control SCC code equal to Batch Header SCC code

ACH Version: master

What were you trying to do?

What did you expect to see?

What did you see?

How can we reproduce the problem?

@nazeer1100126 nazeer1100126 changed the title Should not allow to create File with different SEC codes in Batch Header and Batch Control Should not allow to create File with different SCC codes in Batch Header and Batch Control Aug 30, 2022
@adamdecaf
Copy link
Member

But NACHA file is created having Batch Control SCC code equal to Batch Header SCC code

It sounds like the SCC code is correctly fixed. I'm not sure what the bug is here. We're creating a valid file from invalid input, which is good.

@nazeer1100126
Copy link
Author

nazeer1100126 commented Aug 30, 2022

I see the below logic in batch.go, I assume it is mandating the both SCC codes should be equal. But actually it is not mandating as mentioned in this ticket.

if !batch.IsADV() {
		// validate batch header and control codes are the same
		if (batch.validateOpts == nil || !batch.validateOpts.UnequalServiceClassCode) &&
			**batch.Header.ServiceClassCode != batch.Control.ServiceClassCode {
			return batch.Error("ServiceClassCode",
				NewErrBatchHeaderControlEquality(batch.Header.ServiceClassCode, batch.Control.ServiceClassCode))
		}**
		// Company Identification in the batch header and control must match if bypassCompanyIdentificationMatch is not enabled.
		if batch.Header.CompanyIdentification != batch.Control.CompanyIdentification &&
			!(batch.validateOpts != nil && batch.validateOpts.BypassCompanyIdentificationMatch) {
			return batch.Error("CompanyIdentification",
				NewErrBatchHeaderControlEquality(batch.Header.CompanyIdentification, batch.Control.CompanyIdentification))
		}

		// Control ODFIIdentification must be the same as batch header
		if batch.Header.ODFIIdentification != batch.Control.ODFIIdentification {
			return batch.Error("ODFIIdentification",
				NewErrBatchHeaderControlEquality(batch.Header.ODFIIdentification, batch.Control.ODFIIdentification))
		}
		// batch number header and control must match
		if batch.Header.BatchNumber != batch.Control.BatchNumber {
			return batch.Error("BatchNumber",
				NewErrBatchHeaderControlEquality(batch.Header.BatchNumber, batch.Control.BatchNumber))
		}
	} 

@adamdecaf
Copy link
Member

Does setting UnequalServiceClassCode: true fix your issue?

https://pkg.go.dev/github.com/moov-io/ach?utm_source=godoc#ValidateOpts.UnequalServiceClassCode

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

No branches or pull requests

2 participants