Repository: moov-io/ach
Pull request #1030 (2022-06-07 19:21:23)

Export the settlementDate field in batchHeader and iatBatchHeader
https://github.com/moov-io/ach/issues/1029


Patch:
diff --git a/batchHeader.go b/batchHeader.go
index 5297d29b..15b323b5 100644
--- a/batchHeader.go
+++ b/batchHeader.go
@@ -97,7 +97,7 @@ type BatchHeader struct {
 	EffectiveEntryDate string `json:"effectiveEntryDate,omitempty"`
 
 	// SettlementDate Leave blank, this field is inserted by the ACH operator
-	settlementDate string
+	SettlementDate string `json:"settlementDate,omitempty"`
 
 	// OriginatorStatusCode refers to the ODFI initiating the Entry.
 	// 0 ADV File prepared by an ACH Operator.
@@ -181,7 +181,7 @@ func (bh *BatchHeader) Parse(record string) {
 	bh.EffectiveEntryDate = bh.validateSimpleDate(record[69:75])
 	// 76-78 Always blank if creating batches (just fill with spaces).
 	// Set to file value when parsing. Julian day format.
-	bh.settlementDate = bh.validateSettlementDate(record[75:78])
+	bh.SettlementDate = bh.validateSettlementDate(record[75:78])
 	// 79-79 Always 1
 	bh.OriginatorStatusCode = bh.parseNumField(record[78:79])
 	// 80-87 Your ODFI's routing number without the last digit. The last digit is simply a
@@ -360,7 +360,7 @@ func (bh *BatchHeader) BatchNumberField() string {
 }
 
 func (bh *BatchHeader) SettlementDateField() string {
-	return bh.alphaField(bh.settlementDate, 3)
+	return bh.alphaField(bh.SettlementDate, 3)
 }
 
 func (bh *BatchHeader) LiftEffectiveEntryDate() (time.Time, error) {
diff --git a/file.go b/file.go
index 26864716..77a44d83 100644
--- a/file.go
+++ b/file.go
@@ -1097,7 +1097,7 @@ func createSegmentFileBatchHeader(serviceClassCode int, bh *BatchHeader) *BatchH
 	nbh.CompanyEntryDescription = bh.CompanyEntryDescription
 	nbh.CompanyDescriptiveDate = bh.CompanyDescriptiveDate
 	nbh.EffectiveEntryDate = bh.EffectiveEntryDate
-	nbh.settlementDate = bh.settlementDate
+	nbh.SettlementDate = bh.SettlementDate
 	if serviceClassCode == AutomatedAccountingAdvices {
 		nbh.OriginatorStatusCode = 0 // ADV requires this be 0
 	} else {
diff --git a/iatBatchHeader.go b/iatBatchHeader.go
index e225aa57..cf6a6252 100644
--- a/iatBatchHeader.go
+++ b/iatBatchHeader.go
@@ -143,7 +143,7 @@ type IATBatchHeader struct {
 	EffectiveEntryDate string `json:"effectiveEntryDate,omitempty"`
 
 	// SettlementDate Leave blank, this field is inserted by the ACH operator
-	settlementDate string
+	SettlementDate string `json:"settlementDate,omitempty"`
 
 	// OriginatorStatusCode refers to the ODFI initiating the Entry.
 	// 0 ADV File prepared by an ACH Operator.
@@ -236,7 +236,7 @@ func (iatBh *IATBatchHeader) Parse(record string) {
 	// You almost always want the transaction to post as soon as possible, so put tomorrow's date in YYMMDD format
 	iatBh.EffectiveEntryDate = iatBh.validateSimpleDate(record[69:75])
 	// 76-78 Always blank (just fill with spaces)
-	iatBh.settlementDate = iatBh.validateSettlementDate(record[75:78])
+	iatBh.SettlementDate = iatBh.validateSettlementDate(record[75:78])
 	// 79-79 Always 1
 	iatBh.OriginatorStatusCode = iatBh.parseNumField(record[78:79])
 	// 80-87 Your ODFI's routing number without the last digit. The last digit is simply a
@@ -264,7 +264,7 @@ func (iatBh *IATBatchHeader) String() string {
 	buf.WriteString(iatBh.ISOOriginatingCurrencyCodeField())
 	buf.WriteString(iatBh.ISODestinationCurrencyCodeField())
 	buf.WriteString(iatBh.EffectiveEntryDateField())
-	buf.WriteString(iatBh.settlementDateField())
+	buf.WriteString(iatBh.SettlementDateField())
 	buf.WriteString(fmt.Sprintf("%v", iatBh.OriginatorStatusCode))
 	buf.WriteString(iatBh.ODFIIdentificationField())
 	buf.WriteString(iatBh.BatchNumberField())
@@ -419,7 +419,7 @@ func (iatBh *IATBatchHeader) BatchNumberField() string {
 	return iatBh.numericField(iatBh.BatchNumber, 7)
 }
 
-// settlementDateField gets the settlementDate
-func (iatBh *IATBatchHeader) settlementDateField() string {
-	return iatBh.alphaField(iatBh.settlementDate, 3)
+// SettlementDateField gets the SettlementDate
+func (iatBh *IATBatchHeader) SettlementDateField() string {
+	return iatBh.alphaField(iatBh.SettlementDate, 3)
 }


Test patch:
diff --git a/iatBatchHeader_test.go b/iatBatchHeader_test.go
index 740096ae..f16d4256 100644
--- a/iatBatchHeader_test.go
+++ b/iatBatchHeader_test.go
@@ -165,8 +165,8 @@ func testParseIATBatchHeader(t testing.TB) {
 	if record.EffectiveEntryDateField() != "180621" {
 		t.Errorf("EffectiveEntryDate Expected '180621' got: %v", record.EffectiveEntryDateField())
 	}
-	if record.settlementDate != "   " {
-		t.Errorf("SettlementDate Expected '   ' got: %v", record.settlementDate)
+	if record.SettlementDate != "   " {
+		t.Errorf("SettlementDate Expected '   ' got: %v", record.SettlementDate)
 	}
 	if record.OriginatorStatusCode != 1 {
 		t.Errorf("OriginatorStatusCode Expected 1 got: %v", record.OriginatorStatusCode)