diff --git a/accountCreditedDrawdown.go b/accountCreditedDrawdown.go index 54c1faf4..14ff8bba 100644 --- a/accountCreditedDrawdown.go +++ b/accountCreditedDrawdown.go @@ -41,14 +41,13 @@ func (creditDD *AccountCreditedDrawdown) Parse(record string) error { } creditDD.tag = record[:6] - - var err error length := 6 - read := 0 - if creditDD.DrawdownCreditAccountNumber, read, err = creditDD.parseVariableStringField(record[length:], 9); err != nil { + value, read, err := creditDD.parseVariableStringField(record[length:], 9) + if err != nil { return fieldError("DrawdownCreditAccountNumber", err) } + creditDD.DrawdownCreditAccountNumber = value length += read if len(record) != length { diff --git a/accountDebitedDrawdown.go b/accountDebitedDrawdown.go index fbeae7af..10d339ba 100644 --- a/accountDebitedDrawdown.go +++ b/accountDebitedDrawdown.go @@ -47,34 +47,41 @@ func (debitDD *AccountDebitedDrawdown) Parse(record string) error { debitDD.tag = record[:6] debitDD.IdentificationCode = record[6:7] - - var err error length := 7 - read := 0 - if debitDD.Identifier, read, err = debitDD.parseVariableStringField(record[length:], 34); err != nil { + value, read, err := debitDD.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + debitDD.Identifier = value length += read - if debitDD.Name, read, err = debitDD.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = debitDD.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + debitDD.Name = value length += read - if debitDD.Address.AddressLineOne, read, err = debitDD.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = debitDD.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + debitDD.Address.AddressLineOne = value length += read - if debitDD.Address.AddressLineTwo, read, err = debitDD.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = debitDD.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + debitDD.Address.AddressLineTwo = value length += read - if debitDD.Address.AddressLineThree, read, err = debitDD.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = debitDD.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + debitDD.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/actualAmountPaid.go b/actualAmountPaid.go index dc8dea2d..fb5162f6 100644 --- a/actualAmountPaid.go +++ b/actualAmountPaid.go @@ -41,19 +41,20 @@ func (aap *ActualAmountPaid) Parse(record string) error { } aap.tag = record[:6] - - var err error length := 6 - read := 0 - if aap.RemittanceAmount.CurrencyCode, read, err = aap.parseVariableStringField(record[length:], 3); err != nil { + value, read, err := aap.parseVariableStringField(record[length:], 3) + if err != nil { return fieldError("CurrencyCode", err) } + aap.RemittanceAmount.CurrencyCode = value length += read - if aap.RemittanceAmount.Amount, read, err = aap.parseVariableStringField(record[length:], 19); err != nil { + value, read, err = aap.parseVariableStringField(record[length:], 19) + if err != nil { return fieldError("Amount", err) } + aap.RemittanceAmount.Amount = value length += read if len(record) != length { diff --git a/adjustment.go b/adjustment.go index 56f72a69..9bccfaf1 100644 --- a/adjustment.go +++ b/adjustment.go @@ -47,34 +47,41 @@ func (adj *Adjustment) Parse(record string) error { } adj.tag = record[:6] - - var err error length := 6 - read := 0 - if adj.AdjustmentReasonCode, read, err = adj.parseVariableStringField(record[length:], 2); err != nil { + value, read, err := adj.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("AdjustmentReasonCode", err) } + adj.AdjustmentReasonCode = value length += read - if adj.CreditDebitIndicator, read, err = adj.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = adj.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("CreditDebitIndicator", err) } + adj.CreditDebitIndicator = value length += read - if adj.RemittanceAmount.CurrencyCode, read, err = adj.parseVariableStringField(record[length:], 3); err != nil { + value, read, err = adj.parseVariableStringField(record[length:], 3) + if err != nil { return fieldError("CurrencyCode", err) } + adj.RemittanceAmount.CurrencyCode = value length += read - if adj.RemittanceAmount.Amount, read, err = adj.parseVariableStringField(record[length:], 19); err != nil { - return fieldError("Amount", err) + value, read, err = adj.parseVariableStringField(record[length:], 19) + if err != nil { + return fieldError("CurrencyCode", err) } + adj.RemittanceAmount.Amount = value length += read - if adj.AdditionalInfo, read, err = adj.parseVariableStringField(record[length:], 140); err != nil { + value, read, err = adj.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("AdditionalInfo", err) } + adj.AdditionalInfo = value length += read if len(record) != length { diff --git a/amountNegotiatedDiscount.go b/amountNegotiatedDiscount.go index 3eb1fe7f..8d16e4ef 100644 --- a/amountNegotiatedDiscount.go +++ b/amountNegotiatedDiscount.go @@ -41,19 +41,20 @@ func (nd *AmountNegotiatedDiscount) Parse(record string) error { } nd.tag = record[:6] - - var err error length := 6 - read := 0 - if nd.RemittanceAmount.CurrencyCode, read, err = nd.parseVariableStringField(record[length:], 3); err != nil { + value, read, err := nd.parseVariableStringField(record[length:], 3) + if err != nil { return fieldError("CurrencyCode", err) } + nd.RemittanceAmount.CurrencyCode = value length += read - if nd.RemittanceAmount.Amount, read, err = nd.parseVariableStringField(record[length:], 19); err != nil { + value, read, err = nd.parseVariableStringField(record[length:], 19) + if err != nil { return fieldError("Amount", err) } + nd.RemittanceAmount.Amount = value length += read if len(record) != length { diff --git a/beneficiary.go b/beneficiary.go index 954dbf40..1f5cd4d1 100644 --- a/beneficiary.go +++ b/beneficiary.go @@ -42,34 +42,41 @@ func (ben *Beneficiary) Parse(record string) error { ben.tag = record[:6] ben.Personal.IdentificationCode = ben.parseStringField(record[6:7]) - - var err error length := 7 - read := 0 - if ben.Personal.Identifier, read, err = ben.parseVariableStringField(record[length:], 34); err != nil { + value, read, err := ben.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + ben.Personal.Identifier = value length += read - if ben.Personal.Name, read, err = ben.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ben.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + ben.Personal.Name = value length += read - if ben.Personal.Address.AddressLineOne, read, err = ben.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ben.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + ben.Personal.Address.AddressLineOne = value length += read - if ben.Personal.Address.AddressLineTwo, read, err = ben.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ben.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + ben.Personal.Address.AddressLineTwo = value length += read - if ben.Personal.Address.AddressLineThree, read, err = ben.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ben.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + ben.Personal.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/beneficiaryCustomer.go b/beneficiaryCustomer.go index 91c29092..0edd7191 100644 --- a/beneficiaryCustomer.go +++ b/beneficiaryCustomer.go @@ -41,39 +41,48 @@ func (bc *BeneficiaryCustomer) Parse(record string) error { } bc.tag = record[:6] - - var err error length := 6 - read := 0 - if bc.CoverPayment.SwiftFieldTag, read, err = bc.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := bc.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + bc.CoverPayment.SwiftFieldTag = value length += read - if bc.CoverPayment.SwiftLineOne, read, err = bc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + bc.CoverPayment.SwiftLineOne = value length += read - if bc.CoverPayment.SwiftLineTwo, read, err = bc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + bc.CoverPayment.SwiftLineTwo = value length += read - if bc.CoverPayment.SwiftLineThree, read, err = bc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + bc.CoverPayment.SwiftLineThree = value length += read - if bc.CoverPayment.SwiftLineFour, read, err = bc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + bc.CoverPayment.SwiftLineFour = value length += read - if bc.CoverPayment.SwiftLineFive, read, err = bc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFive", err) } + bc.CoverPayment.SwiftLineFive = value length += read if len(record) != length { diff --git a/beneficiaryFI.go b/beneficiaryFI.go index d2656059..b229b572 100644 --- a/beneficiaryFI.go +++ b/beneficiaryFI.go @@ -42,34 +42,41 @@ func (bfi *BeneficiaryFI) Parse(record string) error { bfi.tag = record[:6] bfi.FinancialInstitution.IdentificationCode = bfi.parseStringField(record[6:7]) - - var err error length := 7 - read := 0 - if bfi.FinancialInstitution.Identifier, read, err = bfi.parseVariableStringField(record[length:], 34); err != nil { + value, read, err := bfi.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + bfi.FinancialInstitution.Identifier = value length += read - if bfi.FinancialInstitution.Name, read, err = bfi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bfi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + bfi.FinancialInstitution.Name = value length += read - if bfi.FinancialInstitution.Address.AddressLineOne, read, err = bfi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bfi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + bfi.FinancialInstitution.Address.AddressLineOne = value length += read - if bfi.FinancialInstitution.Address.AddressLineTwo, read, err = bfi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bfi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + bfi.FinancialInstitution.Address.AddressLineTwo = value length += read - if bfi.FinancialInstitution.Address.AddressLineThree, read, err = bfi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bfi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + bfi.FinancialInstitution.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/beneficiaryIntermediaryFI.go b/beneficiaryIntermediaryFI.go index 76ab1015..d33ed342 100644 --- a/beneficiaryIntermediaryFI.go +++ b/beneficiaryIntermediaryFI.go @@ -42,34 +42,41 @@ func (bifi *BeneficiaryIntermediaryFI) Parse(record string) error { bifi.tag = record[:6] bifi.FinancialInstitution.IdentificationCode = bifi.parseStringField(record[6:7]) - - var err error length := 7 - read := 0 - if bifi.FinancialInstitution.Identifier, read, err = bifi.parseVariableStringField(record[length:], 34); err != nil { + value, read, err := bifi.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + bifi.FinancialInstitution.Identifier = value length += read - if bifi.FinancialInstitution.Name, read, err = bifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + bifi.FinancialInstitution.Name = value length += read - if bifi.FinancialInstitution.Address.AddressLineOne, read, err = bifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + bifi.FinancialInstitution.Address.AddressLineOne = value length += read - if bifi.FinancialInstitution.Address.AddressLineTwo, read, err = bifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + bifi.FinancialInstitution.Address.AddressLineTwo = value length += read - if bifi.FinancialInstitution.Address.AddressLineThree, read, err = bifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = bifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + bifi.FinancialInstitution.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/beneficiaryReference.go b/beneficiaryReference.go index 543a32d9..a5b48b10 100644 --- a/beneficiaryReference.go +++ b/beneficiaryReference.go @@ -41,14 +41,13 @@ func (br *BeneficiaryReference) Parse(record string) error { } br.tag = record[:6] - - var err error length := 6 - read := 0 - if br.BeneficiaryReference, read, err = br.parseVariableStringField(record[length:], 16); err != nil { + value, read, err := br.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("BeneficiaryReference", err) } + br.BeneficiaryReference = value length += read if len(record) != length { diff --git a/businessFunctionCode.go b/businessFunctionCode.go index 17c4a685..0b9eca0a 100644 --- a/businessFunctionCode.go +++ b/businessFunctionCode.go @@ -44,14 +44,13 @@ func (bfc *BusinessFunctionCode) Parse(record string) error { bfc.tag = record[:6] bfc.BusinessFunctionCode = bfc.parseStringField(record[6:9]) - - var err error length := 9 - read := 0 - if bfc.TransactionTypeCode, read, err = bfc.parseVariableStringField(record[length:], 3); err != nil { - return fieldError("BeneficiaryReference", err) + value, read, err := bfc.parseVariableStringField(record[length:], 3) + if err != nil { + return fieldError("TransactionTypeCode", err) } + bfc.TransactionTypeCode = value length += read if len(record) != length { diff --git a/charges.go b/charges.go index 3c70a9d6..27e1d8a7 100644 --- a/charges.go +++ b/charges.go @@ -58,29 +58,34 @@ func (c *Charges) Parse(record string) error { c.tag = record[:6] c.ChargeDetails = c.parseStringField(record[6:7]) - - var err error length := 7 - read := 0 - if c.SendersChargesOne, read, err = c.parseVariableStringField(record[length:], 15); err != nil { + value, read, err := c.parseVariableStringField(record[length:], 15) + if err != nil { return fieldError("SendersChargesOne", err) } + c.SendersChargesOne = value length += read - if c.SendersChargesTwo, read, err = c.parseVariableStringField(record[length:], 15); err != nil { + value, read, err = c.parseVariableStringField(record[length:], 15) + if err != nil { return fieldError("SendersChargesTwo", err) } + c.SendersChargesTwo = value length += read - if c.SendersChargesThree, read, err = c.parseVariableStringField(record[length:], 15); err != nil { + value, read, err = c.parseVariableStringField(record[length:], 15) + if err != nil { return fieldError("SendersChargesThree", err) } + c.SendersChargesThree = value length += read - if c.SendersChargesFour, read, err = c.parseVariableStringField(record[length:], 15); err != nil { + value, read, err = c.parseVariableStringField(record[length:], 15) + if err != nil { return fieldError("SendersChargesFour", err) } + c.SendersChargesFour = value length += read if len(record) != length { diff --git a/currencyInstructedAmount.go b/currencyInstructedAmount.go index f40dc149..63a5537b 100644 --- a/currencyInstructedAmount.go +++ b/currencyInstructedAmount.go @@ -44,21 +44,20 @@ func (cia *CurrencyInstructedAmount) Parse(record string) error { } cia.tag = record[:6] - - var err error length := 6 - read := 0 - if cia.SwiftFieldTag, read, err = cia.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := cia.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + cia.SwiftFieldTag = value length += read if len(record) < length+18 { return fieldError("Amount", ErrValidLengthSize) } - cia.Amount = cia.parseStringField(record[length:length+18]) + cia.Amount = cia.parseStringField(record[length : length+18]) length += 18 if len(record) != length { diff --git a/errorWire.go b/errorWire.go index 1e740c85..bde0046d 100644 --- a/errorWire.go +++ b/errorWire.go @@ -45,24 +45,27 @@ func (ew *ErrorWire) Parse(record string) error { } ew.tag = record[:6] - - var err error length := 6 - read := 0 - if ew.ErrorCategory, read, err = ew.parseVariableStringField(record[length:], 1); err != nil { + value, read, err := ew.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("ErrorCategory", err) } + ew.ErrorCategory = value length += read - if ew.ErrorCode, read, err = ew.parseVariableStringField(record[length:], 3); err != nil { + value, read, err = ew.parseVariableStringField(record[length:], 3) + if err != nil { return fieldError("ErrorCode", err) } + ew.ErrorCode = value length += read - if ew.ErrorDescription, read, err = ew.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ew.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ErrorDescription", err) } + ew.ErrorDescription = value length += read if len(record) != length { diff --git a/exchangeRate.go b/exchangeRate.go index 9bf6e283..2b20d7b0 100644 --- a/exchangeRate.go +++ b/exchangeRate.go @@ -42,14 +42,13 @@ func (eRate *ExchangeRate) Parse(record string) error { } eRate.tag = record[:6] - - var err error length := 6 - read := 0 - if eRate.ExchangeRate, read, err = eRate.parseVariableStringField(record[length:], 12); err != nil { + value, read, err := eRate.parseVariableStringField(record[length:], 12) + if err != nil { return fieldError("ExchangeRate", err) } + eRate.ExchangeRate = value length += read if len(record) != length { diff --git a/fIBeneficiaryFIAdvice.go b/fIBeneficiaryFIAdvice.go index 1237603b..45763b39 100644 --- a/fIBeneficiaryFIAdvice.go +++ b/fIBeneficiaryFIAdvice.go @@ -42,39 +42,48 @@ func (fibfia *FIBeneficiaryFIAdvice) Parse(record string) error { fibfia.tag = record[:6] fibfia.Advice.AdviceCode = fibfia.parseStringField(record[6:9]) - - var err error length := 9 - read := 0 - if fibfia.Advice.LineOne, read, err = fibfia.parseVariableStringField(record[length:], 26); err != nil { + value, read, err := fibfia.parseVariableStringField(record[length:], 26) + if err != nil { return fieldError("LineOne", err) } + fibfia.Advice.LineOne = value length += read - if fibfia.Advice.LineTwo, read, err = fibfia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + fibfia.Advice.LineTwo = value length += read - if fibfia.Advice.LineThree, read, err = fibfia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + fibfia.Advice.LineThree = value length += read - if fibfia.Advice.LineFour, read, err = fibfia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + fibfia.Advice.LineFour = value length += read - if fibfia.Advice.LineFive, read, err = fibfia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + fibfia.Advice.LineFive = value length += read - if fibfia.Advice.LineSix, read, err = fibfia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + fibfia.Advice.LineSix = value length += read if len(record) != length { diff --git a/fiAdditionalFIToFI.go b/fiAdditionalFIToFI.go index 5f1c719e..f38f7631 100644 --- a/fiAdditionalFIToFI.go +++ b/fiAdditionalFIToFI.go @@ -41,39 +41,48 @@ func (fifi *FIAdditionalFIToFI) Parse(record string) error { } fifi.tag = record[:6] - - var err error length := 6 - read := 0 - if fifi.AdditionalFIToFI.LineOne, read, err = fifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err := fifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineOne", err) } + fifi.AdditionalFIToFI.LineOne = value length += read - if fifi.AdditionalFIToFI.LineTwo, read, err = fifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = fifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineTwo", err) } + fifi.AdditionalFIToFI.LineTwo = value length += read - if fifi.AdditionalFIToFI.LineThree, read, err = fifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = fifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineThree", err) } + fifi.AdditionalFIToFI.LineThree = value length += read - if fifi.AdditionalFIToFI.LineFour, read, err = fifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = fifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineFour", err) } + fifi.AdditionalFIToFI.LineFour = value length += read - if fifi.AdditionalFIToFI.LineFive, read, err = fifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = fifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineFive", err) } + fifi.AdditionalFIToFI.LineFive = value length += read - if fifi.AdditionalFIToFI.LineSix, read, err = fifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = fifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineSix", err) } + fifi.AdditionalFIToFI.LineSix = value length += read if len(record) != length { diff --git a/fiBeneficiary.go b/fiBeneficiary.go index beeaa32c..10a9902e 100644 --- a/fiBeneficiary.go +++ b/fiBeneficiary.go @@ -41,39 +41,48 @@ func (fib *FIBeneficiary) Parse(record string) error { } fib.tag = record[:6] - - var err error length := 6 - read := 0 - if fib.FIToFI.LineOne, read, err = fib.parseVariableStringField(record[length:], 30); err != nil { + value, read, err := fib.parseVariableStringField(record[length:], 30) + if err != nil { return fieldError("LineOne", err) } + fib.FIToFI.LineOne = value length += read - if fib.FIToFI.LineTwo, read, err = fib.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fib.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + fib.FIToFI.LineTwo = value length += read - if fib.FIToFI.LineThree, read, err = fib.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fib.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + fib.FIToFI.LineThree = value length += read - if fib.FIToFI.LineFour, read, err = fib.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fib.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + fib.FIToFI.LineFour = value length += read - if fib.FIToFI.LineFive, read, err = fib.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fib.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + fib.FIToFI.LineFive = value length += read - if fib.FIToFI.LineSix, read, err = fib.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fib.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + fib.FIToFI.LineSix = value length += read if len(record) != length { diff --git a/fiBeneficiaryAdvice.go b/fiBeneficiaryAdvice.go index 3897e03f..bcb41f18 100644 --- a/fiBeneficiaryAdvice.go +++ b/fiBeneficiaryAdvice.go @@ -42,39 +42,48 @@ func (fiba *FIBeneficiaryAdvice) Parse(record string) error { fiba.tag = record[:6] fiba.Advice.AdviceCode = fiba.parseStringField(record[6:9]) - - var err error length := 9 - read := 0 - if fiba.Advice.LineOne, read, err = fiba.parseVariableStringField(record[length:], 26); err != nil { + value, read, err := fiba.parseVariableStringField(record[length:], 26) + if err != nil { return fieldError("LineOne", err) } + fiba.Advice.LineOne = value length += read - if fiba.Advice.LineTwo, read, err = fiba.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiba.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + fiba.Advice.LineTwo = value length += read - if fiba.Advice.LineThree, read, err = fiba.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiba.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + fiba.Advice.LineThree = value length += read - if fiba.Advice.LineFour, read, err = fiba.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiba.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + fiba.Advice.LineFour = value length += read - if fiba.Advice.LineFive, read, err = fiba.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiba.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + fiba.Advice.LineFive = value length += read - if fiba.Advice.LineSix, read, err = fiba.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiba.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + fiba.Advice.LineSix = value length += read if len(record) != length { diff --git a/fiBeneficiaryFI.go b/fiBeneficiaryFI.go index 95f93919..7ca8fab5 100644 --- a/fiBeneficiaryFI.go +++ b/fiBeneficiaryFI.go @@ -41,39 +41,48 @@ func (fibfi *FIBeneficiaryFI) Parse(record string) error { } fibfi.tag = record[:6] - - var err error length := 6 - read := 0 - if fibfi.FIToFI.LineOne, read, err = fibfi.parseVariableStringField(record[length:], 30); err != nil { + value, read, err := fibfi.parseVariableStringField(record[length:], 30) + if err != nil { return fieldError("LineOne", err) } + fibfi.FIToFI.LineOne = value length += read - if fibfi.FIToFI.LineTwo, read, err = fibfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + fibfi.FIToFI.LineTwo = value length += read - if fibfi.FIToFI.LineThree, read, err = fibfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + fibfi.FIToFI.LineThree = value length += read - if fibfi.FIToFI.LineFour, read, err = fibfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + fibfi.FIToFI.LineFour = value length += read - if fibfi.FIToFI.LineFive, read, err = fibfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + fibfi.FIToFI.LineFive = value length += read - if fibfi.FIToFI.LineSix, read, err = fibfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fibfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + fibfi.FIToFI.LineSix = value length += read if len(record) != length { diff --git a/fiDrawdownDebitAccountAdvice.go b/fiDrawdownDebitAccountAdvice.go index eeb9358e..16244201 100644 --- a/fiDrawdownDebitAccountAdvice.go +++ b/fiDrawdownDebitAccountAdvice.go @@ -42,39 +42,48 @@ func (debitDDAdvice *FIDrawdownDebitAccountAdvice) Parse(record string) error { debitDDAdvice.tag = record[:6] debitDDAdvice.Advice.AdviceCode = debitDDAdvice.parseStringField(record[6:9]) - - var err error length := 9 - read := 0 - if debitDDAdvice.Advice.LineOne, read, err = debitDDAdvice.parseVariableStringField(record[length:], 26); err != nil { + value, read, err := debitDDAdvice.parseVariableStringField(record[length:], 26) + if err != nil { return fieldError("LineOne", err) } + debitDDAdvice.Advice.LineOne = value length += read - if debitDDAdvice.Advice.LineTwo, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + debitDDAdvice.Advice.LineTwo = value length += read - if debitDDAdvice.Advice.LineThree, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + debitDDAdvice.Advice.LineThree = value length += read - if debitDDAdvice.Advice.LineFour, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + debitDDAdvice.Advice.LineFour = value length += read - if debitDDAdvice.Advice.LineFive, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + debitDDAdvice.Advice.LineFive = value length += read - if debitDDAdvice.Advice.LineSix, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = debitDDAdvice.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + debitDDAdvice.Advice.LineSix = value length += read if len(record) != length { diff --git a/fiIntermediaryFI.go b/fiIntermediaryFI.go index 1c61bfaa..ba68fb17 100644 --- a/fiIntermediaryFI.go +++ b/fiIntermediaryFI.go @@ -41,39 +41,48 @@ func (fiifi *FIIntermediaryFI) Parse(record string) error { } fiifi.tag = record[:6] - - var err error length := 6 - read := 0 - if fiifi.FIToFI.LineOne, read, err = fiifi.parseVariableStringField(record[length:], 30); err != nil { + value, read, err := fiifi.parseVariableStringField(record[length:], 30) + if err != nil { return fieldError("LineOne", err) } + fiifi.FIToFI.LineOne = value length += read - if fiifi.FIToFI.LineTwo, read, err = fiifi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + fiifi.FIToFI.LineTwo = value length += read - if fiifi.FIToFI.LineThree, read, err = fiifi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + fiifi.FIToFI.LineThree = value length += read - if fiifi.FIToFI.LineFour, read, err = fiifi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + fiifi.FIToFI.LineFour = value length += read - if fiifi.FIToFI.LineFive, read, err = fiifi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + fiifi.FIToFI.LineFive = value length += read - if fiifi.FIToFI.LineSix, read, err = fiifi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + fiifi.FIToFI.LineSix = value length += read if len(record) != length { diff --git a/fiIntermediaryFIAdvice.go b/fiIntermediaryFIAdvice.go index 0aa1650d..6625624a 100644 --- a/fiIntermediaryFIAdvice.go +++ b/fiIntermediaryFIAdvice.go @@ -42,39 +42,48 @@ func (fiifia *FIIntermediaryFIAdvice) Parse(record string) error { fiifia.tag = record[:6] fiifia.Advice.AdviceCode = fiifia.parseStringField(record[6:9]) - - var err error length := 9 - read := 0 - if fiifia.Advice.LineOne, read, err = fiifia.parseVariableStringField(record[length:], 26); err != nil { + value, read, err := fiifia.parseVariableStringField(record[length:], 26) + if err != nil { return fieldError("LineOne", err) } + fiifia.Advice.LineOne = value length += read - if fiifia.Advice.LineTwo, read, err = fiifia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + fiifia.Advice.LineTwo = value length += read - if fiifia.Advice.LineThree, read, err = fiifia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + fiifia.Advice.LineThree = value length += read - if fiifia.Advice.LineFour, read, err = fiifia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + fiifia.Advice.LineFour = value length += read - if fiifia.Advice.LineFive, read, err = fiifia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + fiifia.Advice.LineFive = value length += read - if fiifia.Advice.LineSix, read, err = fiifia.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = fiifia.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + fiifia.Advice.LineSix = value length += read if len(record) != length { diff --git a/fiPaymentMethodToBeneficiary.go b/fiPaymentMethodToBeneficiary.go index 26d3940b..d20c2067 100644 --- a/fiPaymentMethodToBeneficiary.go +++ b/fiPaymentMethodToBeneficiary.go @@ -45,14 +45,13 @@ func (pm *FIPaymentMethodToBeneficiary) Parse(record string) error { pm.tag = record[:6] pm.PaymentMethod = pm.parseStringField(record[6:11]) - - var err error length := 11 - read := 0 - if pm.AdditionalInformation, read, err = pm.parseVariableStringField(record[length:], 30); err != nil { + value, read, err := pm.parseVariableStringField(record[length:], 30) + if err != nil { return fieldError("AdditionalInformation", err) } + pm.AdditionalInformation = value length += read if len(record) != length { diff --git a/fiReceiverFI.go b/fiReceiverFI.go index 96cc321a..b0b13c14 100644 --- a/fiReceiverFI.go +++ b/fiReceiverFI.go @@ -41,39 +41,48 @@ func (firfi *FIReceiverFI) Parse(record string) error { } firfi.tag = record[:6] - - var err error length := 6 - read := 0 - if firfi.FIToFI.LineOne, read, err = firfi.parseVariableStringField(record[length:], 30); err != nil { + value, read, err := firfi.parseVariableStringField(record[length:], 30) + if err != nil { return fieldError("LineOne", err) } + firfi.FIToFI.LineOne = value length += read - if firfi.FIToFI.LineTwo, read, err = firfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = firfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineTwo", err) } + firfi.FIToFI.LineTwo = value length += read - if firfi.FIToFI.LineThree, read, err = firfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = firfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineThree", err) } + firfi.FIToFI.LineThree = value length += read - if firfi.FIToFI.LineFour, read, err = firfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = firfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFour", err) } + firfi.FIToFI.LineFour = value length += read - if firfi.FIToFI.LineFive, read, err = firfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = firfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineFive", err) } + firfi.FIToFI.LineFive = value length += read - if firfi.FIToFI.LineSix, read, err = firfi.parseVariableStringField(record[length:], 33); err != nil { + value, read, err = firfi.parseVariableStringField(record[length:], 33) + if err != nil { return fieldError("LineSix", err) } + firfi.FIToFI.LineSix = value length += read if len(record) != length { diff --git a/grossAmountRemittanceDocument.go b/grossAmountRemittanceDocument.go index f7730024..36f8f30a 100644 --- a/grossAmountRemittanceDocument.go +++ b/grossAmountRemittanceDocument.go @@ -41,19 +41,20 @@ func (gard *GrossAmountRemittanceDocument) Parse(record string) error { } gard.tag = record[:6] - - var err error length := 6 - read := 0 - if gard.RemittanceAmount.CurrencyCode, read, err = gard.parseVariableStringField(record[length:], 3); err != nil { + value, read, err := gard.parseVariableStringField(record[length:], 3) + if err != nil { return fieldError("CurrencyCode", err) } + gard.RemittanceAmount.CurrencyCode = value length += read - if gard.RemittanceAmount.Amount, read, err = gard.parseVariableStringField(record[length:], 19); err != nil { + value, read, err = gard.parseVariableStringField(record[length:], 19) + if err != nil { return fieldError("Amount", err) } + gard.RemittanceAmount.Amount = value length += read if len(record) != length { diff --git a/institutionAccount.go b/institutionAccount.go index 64ad9bae..8be06ad8 100644 --- a/institutionAccount.go +++ b/institutionAccount.go @@ -41,39 +41,48 @@ func (iAccount *InstitutionAccount) Parse(record string) error { } iAccount.tag = record[:6] - - var err error length := 6 - read := 0 - if iAccount.CoverPayment.SwiftFieldTag, read, err = iAccount.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := iAccount.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + iAccount.CoverPayment.SwiftFieldTag = value length += read - if iAccount.CoverPayment.SwiftLineOne, read, err = iAccount.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = iAccount.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + iAccount.CoverPayment.SwiftLineOne = value length += read - if iAccount.CoverPayment.SwiftLineTwo, read, err = iAccount.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = iAccount.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + iAccount.CoverPayment.SwiftLineTwo = value length += read - if iAccount.CoverPayment.SwiftLineThree, read, err = iAccount.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = iAccount.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + iAccount.CoverPayment.SwiftLineThree = value length += read - if iAccount.CoverPayment.SwiftLineFour, read, err = iAccount.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = iAccount.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + iAccount.CoverPayment.SwiftLineFour = value length += read - if iAccount.CoverPayment.SwiftLineFive, read, err = iAccount.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = iAccount.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFive", err) } + iAccount.CoverPayment.SwiftLineFive = value length += read if len(record) != length { diff --git a/instructedAmount.go b/instructedAmount.go index 64f4ee8b..ab13396b 100644 --- a/instructedAmount.go +++ b/instructedAmount.go @@ -44,19 +44,20 @@ func (ia *InstructedAmount) Parse(record string) error { } ia.tag = record[:6] - - var err error length := 6 - read := 0 - if ia.CurrencyCode, read, err = ia.parseVariableStringField(record[length:], 3); err != nil { - return fieldError("CurrencyCode", err) + value, read, err := ia.parseVariableStringField(record[length:], 3) + if err != nil { + return fieldError("SwiftFieldTag", err) } + ia.CurrencyCode = value length += read - if ia.Amount, read, err = ia.parseVariableStringField(record[length:], 15); err != nil { + value, read, err = ia.parseVariableStringField(record[length:], 15) + if err != nil { return fieldError("Amount", err) } + ia.Amount = value length += read if len(record) != length { diff --git a/instructingFI.go b/instructingFI.go index 306bd575..37d9579c 100644 --- a/instructingFI.go +++ b/instructingFI.go @@ -42,34 +42,41 @@ func (ifi *InstructingFI) Parse(record string) error { ifi.tag = record[:6] ifi.FinancialInstitution.IdentificationCode = ifi.parseStringField(record[6:7]) - - var err error length := 7 - read := 0 - if ifi.FinancialInstitution.Identifier, read, err = ifi.parseVariableStringField(record[length:], 34); err != nil { + value, read, err := ifi.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + ifi.FinancialInstitution.Identifier = value length += read - if ifi.FinancialInstitution.Name, read, err = ifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + ifi.FinancialInstitution.Name = value length += read - if ifi.FinancialInstitution.Address.AddressLineOne, read, err = ifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + ifi.FinancialInstitution.Address.AddressLineOne = value length += read - if ifi.FinancialInstitution.Address.AddressLineTwo, read, err = ifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + ifi.FinancialInstitution.Address.AddressLineTwo = value length += read - if ifi.FinancialInstitution.Address.AddressLineThree, read, err = ifi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ifi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + ifi.FinancialInstitution.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/intermediaryInstitution.go b/intermediaryInstitution.go index 63ba432c..fc5cad86 100644 --- a/intermediaryInstitution.go +++ b/intermediaryInstitution.go @@ -41,39 +41,48 @@ func (ii *IntermediaryInstitution) Parse(record string) error { } ii.tag = record[:6] - - var err error length := 6 - read := 0 - if ii.CoverPayment.SwiftFieldTag, read, err = ii.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := ii.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + ii.CoverPayment.SwiftFieldTag = value length += read - if ii.CoverPayment.SwiftLineOne, read, err = ii.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ii.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + ii.CoverPayment.SwiftLineOne = value length += read - if ii.CoverPayment.SwiftLineTwo, read, err = ii.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ii.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + ii.CoverPayment.SwiftLineTwo = value length += read - if ii.CoverPayment.SwiftLineThree, read, err = ii.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ii.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + ii.CoverPayment.SwiftLineThree = value length += read - if ii.CoverPayment.SwiftLineFour, read, err = ii.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ii.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + ii.CoverPayment.SwiftLineFour = value length += read - if ii.CoverPayment.SwiftLineFive, read, err = ii.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ii.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFive", err) } + ii.CoverPayment.SwiftLineFive = value length += read if len(record) != length { diff --git a/localInstrument.go b/localInstrument.go index c0bc385d..eee40dcb 100644 --- a/localInstrument.go +++ b/localInstrument.go @@ -43,19 +43,20 @@ func (li *LocalInstrument) Parse(record string) error { } li.tag = record[:6] - - var err error length := 6 - read := 0 - if li.LocalInstrumentCode, read, err = li.parseVariableStringField(record[length:], 4); err != nil { - return fieldError("LocalInstrumentCode", err) + value, read, err := li.parseVariableStringField(record[length:], 4) + if err != nil { + return fieldError("SwiftFieldTag", err) } + li.LocalInstrumentCode = value length += read - if li.ProprietaryCode, read, err = li.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = li.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ProprietaryCode", err) } + li.ProprietaryCode = value length += read if len(record) != length { diff --git a/messageDisposition.go b/messageDisposition.go index 814199c8..03fb37cb 100644 --- a/messageDisposition.go +++ b/messageDisposition.go @@ -50,29 +50,34 @@ func (md *MessageDisposition) Parse(record string) error { } md.tag = record[:6] - - var err error length := 6 - read := 0 - if md.FormatVersion, read, err = md.parseVariableStringField(record[length:], 2); err != nil { + value, read, err := md.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("FormatVersion", err) } + md.FormatVersion = value length += read - if md.TestProductionCode, read, err = md.parseVariableStringField(record[length:], 1); err != nil { + value, read, err = md.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("TestProductionCode", err) } + md.TestProductionCode = value length += read - if md.MessageDuplicationCode, read, err = md.parseVariableStringField(record[length:], 1); err != nil { + value, read, err = md.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("MessageDuplicationCode", err) } + md.MessageDuplicationCode = value length += read - if md.MessageStatusIndicator, read, err = md.parseVariableStringField(record[length:], 1); err != nil { + value, read, err = md.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("MessageStatusIndicator", err) } + md.MessageStatusIndicator = value length += read if len(record) != length { diff --git a/orderingCustomer.go b/orderingCustomer.go index 17894c01..1c5d5813 100644 --- a/orderingCustomer.go +++ b/orderingCustomer.go @@ -41,39 +41,48 @@ func (oc *OrderingCustomer) Parse(record string) error { } oc.tag = record[:6] - - var err error length := 6 - read := 0 - if oc.CoverPayment.SwiftFieldTag, read, err = oc.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := oc.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + oc.CoverPayment.SwiftFieldTag = value length += read - if oc.CoverPayment.SwiftLineOne, read, err = oc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + oc.CoverPayment.SwiftLineOne = value length += read - if oc.CoverPayment.SwiftLineTwo, read, err = oc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + oc.CoverPayment.SwiftLineTwo = value length += read - if oc.CoverPayment.SwiftLineThree, read, err = oc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + oc.CoverPayment.SwiftLineThree = value length += read - if oc.CoverPayment.SwiftLineFour, read, err = oc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + oc.CoverPayment.SwiftLineFour = value length += read - if oc.CoverPayment.SwiftLineFive, read, err = oc.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oc.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFive", err) } + oc.CoverPayment.SwiftLineFive = value length += read if len(record) != length { diff --git a/orderingInstitution.go b/orderingInstitution.go index 4434bbfe..f95247c9 100644 --- a/orderingInstitution.go +++ b/orderingInstitution.go @@ -41,39 +41,48 @@ func (oi *OrderingInstitution) Parse(record string) error { } oi.tag = record[:6] - - var err error length := 6 - read := 0 - if oi.CoverPayment.SwiftFieldTag, read, err = oi.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := oi.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + oi.CoverPayment.SwiftFieldTag = value length += read - if oi.CoverPayment.SwiftLineOne, read, err = oi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + oi.CoverPayment.SwiftLineOne = value length += read - if oi.CoverPayment.SwiftLineTwo, read, err = oi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + oi.CoverPayment.SwiftLineTwo = value length += read - if oi.CoverPayment.SwiftLineThree, read, err = oi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + oi.CoverPayment.SwiftLineThree = value length += read - if oi.CoverPayment.SwiftLineFour, read, err = oi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + oi.CoverPayment.SwiftLineFour = value length += read - if oi.CoverPayment.SwiftLineFive, read, err = oi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFive", err) } + oi.CoverPayment.SwiftLineFive = value length += read if len(record) != length { diff --git a/originator.go b/originator.go index e14123d0..6ebcd86b 100644 --- a/originator.go +++ b/originator.go @@ -42,34 +42,41 @@ func (o *Originator) Parse(record string) error { o.tag = record[:6] o.Personal.IdentificationCode = o.parseStringField(record[6:7]) - - var err error length := 7 - read := 0 - if o.Personal.Identifier, read, err = o.parseVariableStringField(record[length:], 34); err != nil { + value, read, err := o.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + o.Personal.Identifier = value length += read - if o.Personal.Name, read, err = o.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = o.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + o.Personal.Name = value length += read - if o.Personal.Address.AddressLineOne, read, err = o.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = o.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + o.Personal.Address.AddressLineOne = value length += read - if o.Personal.Address.AddressLineTwo, read, err = o.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = o.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + o.Personal.Address.AddressLineTwo = value length += read - if o.Personal.Address.AddressLineThree, read, err = o.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = o.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + o.Personal.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/originatorFI.go b/originatorFI.go index ebc64c1e..ee83785e 100644 --- a/originatorFI.go +++ b/originatorFI.go @@ -41,39 +41,48 @@ func (ofi *OriginatorFI) Parse(record string) error { } ofi.tag = record[:6] - - var err error length := 6 - read := 0 - if ofi.FinancialInstitution.IdentificationCode, read, err = ofi.parseVariableStringField(record[length:], 1); err != nil { + value, read, err := ofi.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("IdentificationCode", err) } + ofi.FinancialInstitution.IdentificationCode = value length += read - if ofi.FinancialInstitution.Identifier, read, err = ofi.parseVariableStringField(record[length:], 34); err != nil { + value, read, err = ofi.parseVariableStringField(record[length:], 34) + if err != nil { return fieldError("Identifier", err) } + ofi.FinancialInstitution.Identifier = value length += read - if ofi.FinancialInstitution.Name, read, err = ofi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ofi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + ofi.FinancialInstitution.Name = value length += read - if ofi.FinancialInstitution.Address.AddressLineOne, read, err = ofi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ofi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineOne", err) } + ofi.FinancialInstitution.Address.AddressLineOne = value length += read - if ofi.FinancialInstitution.Address.AddressLineTwo, read, err = ofi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ofi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineTwo", err) } + ofi.FinancialInstitution.Address.AddressLineTwo = value length += read - if ofi.FinancialInstitution.Address.AddressLineThree, read, err = ofi.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ofi.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("AddressLineThree", err) } + ofi.FinancialInstitution.Address.AddressLineThree = value length += read if len(record) != length { diff --git a/originatorOptionF.go b/originatorOptionF.go index 5f0cac23..aff29214 100644 --- a/originatorOptionF.go +++ b/originatorOptionF.go @@ -105,34 +105,41 @@ func (oof *OriginatorOptionF) Parse(record string) error { } oof.tag = oof.parseStringField(record[:6]) - - var err error length := 6 - read := 0 - if oof.PartyIdentifier, read, err = oof.parseVariableStringField(record[length:], 35); err != nil { + value, read, err := oof.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("PartyIdentifier", err) } + oof.PartyIdentifier = value length += read - if oof.Name, read, err = oof.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oof.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Name", err) } + oof.Name = value length += read - if oof.LineOne, read, err = oof.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oof.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineOne", err) } + oof.LineOne = value length += read - if oof.LineTwo, read, err = oof.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oof.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineTwo", err) } + oof.LineTwo = value length += read - if oof.LineThree, read, err = oof.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = oof.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineThree", err) } + oof.LineThree = value length += read if len(record) != length { diff --git a/originatorToBeneficiary.go b/originatorToBeneficiary.go index f334c64b..517fd6d3 100644 --- a/originatorToBeneficiary.go +++ b/originatorToBeneficiary.go @@ -47,29 +47,34 @@ func (ob *OriginatorToBeneficiary) Parse(record string) error { } ob.tag = record[:6] - - var err error length := 6 - read := 0 - if ob.LineOne, read, err = ob.parseVariableStringField(record[length:], 35); err != nil { + value, read, err := ob.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineOne", err) } + ob.LineOne = value length += read - if ob.LineTwo, read, err = ob.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ob.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineTwo", err) } + ob.LineTwo = value length += read - if ob.LineThree, read, err = ob.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ob.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineThree", err) } + ob.LineThree = value length += read - if ob.LineFour, read, err = ob.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ob.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineFour", err) } + ob.LineFour = value length += read if len(record) != length { diff --git a/outputMessageAccountabilityData.go b/outputMessageAccountabilityData.go index b81452f7..484ca2d2 100644 --- a/outputMessageAccountabilityData.go +++ b/outputMessageAccountabilityData.go @@ -51,41 +51,48 @@ func (omad *OutputMessageAccountabilityData) Parse(record string) error { } omad.tag = record[:6] - - var err error length := 6 - read := 0 - if omad.OutputCycleDate, read, err = omad.parseVariableStringField(record[length:], 8); err != nil { + value, read, err := omad.parseVariableStringField(record[length:], 8) + if err != nil { return fieldError("OutputCycleDate", err) } + omad.OutputCycleDate = value length += read - if omad.OutputDestinationID, read, err = omad.parseVariableStringField(record[length:], 8); err != nil { + value, read, err = omad.parseVariableStringField(record[length:], 8) + if err != nil { return fieldError("OutputDestinationID", err) } + omad.OutputDestinationID = value length += read if len(record) < length+6 { return fieldError("OutputSequenceNumber", ErrValidLengthSize) } - omad.OutputSequenceNumber = record[length:length+6] + omad.OutputSequenceNumber = record[length : length+6] length += 6 - if omad.OutputDate, read, err = omad.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = omad.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("OutputDate", err) } + omad.OutputDate = value length += read - if omad.OutputTime, read, err = omad.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = omad.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("OutputTime", err) } + omad.OutputTime = value length += read - if omad.OutputFRBApplicationIdentification, read, err = omad.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = omad.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("OutputFRBApplicationIdentification", err) } + omad.OutputFRBApplicationIdentification = value length += read if len(record) != length { diff --git a/paymentNotification.go b/paymentNotification.go index 220d1b9b..cc60dcf3 100644 --- a/paymentNotification.go +++ b/paymentNotification.go @@ -55,44 +55,55 @@ func (pn *PaymentNotification) Parse(record string) error { } pn.tag = record[:6] - - var err error length := 6 - read := 0 - if pn.PaymentNotificationIndicator, read, err = pn.parseVariableStringField(record[length:], 1); err != nil { + value, read, err := pn.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("PaymentNotificationIndicator", err) } + pn.PaymentNotificationIndicator = value length += read - if pn.ContactNotificationElectronicAddress, read, err = pn.parseVariableStringField(record[length:], 2048); err != nil { + value, read, err = pn.parseVariableStringField(record[length:], 2048) + if err != nil { return fieldError("ContactNotificationElectronicAddress", err) } + pn.ContactNotificationElectronicAddress = value length += read - if pn.ContactName, read, err = pn.parseVariableStringField(record[length:], 140); err != nil { + value, read, err = pn.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("ContactName", err) } + pn.ContactName = value length += read - if pn.ContactPhoneNumber, read, err = pn.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = pn.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactPhoneNumber", err) } + pn.ContactPhoneNumber = value length += read - if pn.ContactMobileNumber, read, err = pn.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = pn.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactMobileNumber", err) } + pn.ContactMobileNumber = value length += read - if pn.ContactFaxNumber, read, err = pn.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = pn.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactFaxNumber", err) } + pn.ContactFaxNumber = value length += read - if pn.EndToEndIdentification, read, err = pn.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = pn.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("EndToEndIdentification", err) } + pn.EndToEndIdentification = value length += read if len(record) != length { diff --git a/previousMessageIdentifier.go b/previousMessageIdentifier.go index 084ad927..ded20e2a 100644 --- a/previousMessageIdentifier.go +++ b/previousMessageIdentifier.go @@ -41,14 +41,13 @@ func (pmi *PreviousMessageIdentifier) Parse(record string) error { } pmi.tag = record[:6] - - var err error length := 6 - read := 0 - if pmi.PreviousMessageIdentifier, read, err = pmi.parseVariableStringField(record[length:], 22); err != nil { + value, read, err := pmi.parseVariableStringField(record[length:], 22) + if err != nil { return fieldError("PreviousMessageIdentifier", err) } + pmi.PreviousMessageIdentifier = value length += read if len(record) != length { diff --git a/primaryRemittanceDocument.go b/primaryRemittanceDocument.go index a3f6158d..cd1b3951 100644 --- a/primaryRemittanceDocument.go +++ b/primaryRemittanceDocument.go @@ -48,24 +48,27 @@ func (prd *PrimaryRemittanceDocument) Parse(record string) error { prd.tag = record[:6] prd.DocumentTypeCode = record[6:10] - - var err error length := 10 - read := 0 - if prd.ProprietaryDocumentTypeCode, read, err = prd.parseVariableStringField(record[length:], 35); err != nil { + value, read, err := prd.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ProprietaryDocumentTypeCode", err) } + prd.ProprietaryDocumentTypeCode = value length += read - if prd.DocumentIdentificationNumber, read, err = prd.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = prd.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("DocumentIdentificationNumber", err) } + prd.DocumentIdentificationNumber = value length += read - if prd.Issuer, read, err = prd.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = prd.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Issuer", err) } + prd.Issuer = value length += read if len(record) != length { diff --git a/receiptTimeStamp.go b/receiptTimeStamp.go index e04532d4..c4b42e8b 100644 --- a/receiptTimeStamp.go +++ b/receiptTimeStamp.go @@ -45,24 +45,27 @@ func (rts *ReceiptTimeStamp) Parse(record string) error { } rts.tag = record[:6] - - var err error length := 6 - read := 0 - if rts.ReceiptDate, read, err = rts.parseVariableStringField(record[length:], 4); err != nil { + value, read, err := rts.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("ReceiptDate", err) } + rts.ReceiptDate = value length += read - if rts.ReceiptTime, read, err = rts.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = rts.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("ReceiptTime", err) } + rts.ReceiptTime = value length += read - if rts.ReceiptApplicationIdentification, read, err = rts.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = rts.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("ReceiptApplicationIdentification", err) } + rts.ReceiptApplicationIdentification = value length += read if len(record) != length { diff --git a/receiverDepositoryInstitution.go b/receiverDepositoryInstitution.go index d9780c04..af53cb24 100644 --- a/receiverDepositoryInstitution.go +++ b/receiverDepositoryInstitution.go @@ -43,19 +43,20 @@ func (rdi *ReceiverDepositoryInstitution) Parse(record string) error { } rdi.tag = record[:6] - - var err error length := 6 - read := 0 - if rdi.ReceiverABANumber, read, err = rdi.parseVariableStringField(record[length:], 9); err != nil { + value, read, err := rdi.parseVariableStringField(record[length:], 9) + if err != nil { return fieldError("ReceiverABANumber", err) } + rdi.ReceiverABANumber = value length += read - if rdi.ReceiverShortName, read, err = rdi.parseVariableStringField(record[length:], 18); err != nil { + value, read, err = rdi.parseVariableStringField(record[length:], 18) + if err != nil { return fieldError("ReceiverShortName", err) } + rdi.ReceiverShortName = value length += read if len(record) != length { diff --git a/relatedRemittance.go b/relatedRemittance.go index d9d9a2c0..29861ee2 100644 --- a/relatedRemittance.go +++ b/relatedRemittance.go @@ -47,109 +47,146 @@ func (rr *RelatedRemittance) Parse(record string) error { } rr.tag = record[:6] - - var err error length := 6 - read := 0 - if rr.RemittanceIdentification, read, err = rr.parseVariableStringField(record[length:], 35); err != nil { + value, read, err := rr.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("RemittanceIdentification", err) } + rr.RemittanceIdentification = value length += read - if rr.RemittanceLocationMethod, read, err = rr.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("RemittanceLocationMethod", err) } + rr.RemittanceLocationMethod = value length += read - if rr.RemittanceLocationElectronicAddress, read, err = rr.parseVariableStringField(record[length:], 2048); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 2048) + if err != nil { return fieldError("RemittanceLocationElectronicAddress", err) } + rr.RemittanceLocationElectronicAddress = value length += read - if rr.RemittanceData.Name, read, err = rr.parseVariableStringField(record[length:], 140); err != nil { - return fieldError("Name", err) + value, read, err = rr.parseVariableStringField(record[length:], 140) + if err != nil { + return fieldError("RemittanceData", err) } + rr.RemittanceData.Name = value length += read - if rr.RemittanceData.AddressType, read, err = rr.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("AddressType", err) } + rr.RemittanceData.AddressType = value length += read - if rr.RemittanceData.Department, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("Department", err) } + rr.RemittanceData.Department = value length += read - if rr.RemittanceData.SubDepartment, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("SubDepartment", err) } + rr.RemittanceData.SubDepartment = value length += read - if rr.RemittanceData.StreetName, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("StreetName", err) } + rr.RemittanceData.StreetName = value length += read - if rr.RemittanceData.BuildingNumber, read, err = rr.parseVariableStringField(record[length:], 16); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("BuildingNumber", err) } + rr.RemittanceData.BuildingNumber = value length += read - if rr.RemittanceData.PostCode, read, err = rr.parseVariableStringField(record[length:], 16); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("PostCode", err) } + rr.RemittanceData.PostCode = value length += read - if rr.RemittanceData.TownName, read, err = rr.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("TownName", err) } + rr.RemittanceData.TownName = value length += read - if rr.RemittanceData.CountrySubDivisionState, read, err = rr.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("CountrySubDivisionState", err) } + rr.RemittanceData.CountrySubDivisionState = value length += read - if rr.RemittanceData.Country, read, err = rr.parseVariableStringField(record[length:], 2); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("Country", err) } + rr.RemittanceData.Country = value length += read - if rr.RemittanceData.AddressLineOne, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineOne", err) } + rr.RemittanceData.AddressLineOne = value length += read - if rr.RemittanceData.AddressLineTwo, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineTwo", err) } + rr.RemittanceData.AddressLineTwo = value length += read - if rr.RemittanceData.AddressLineThree, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineThree", err) } + rr.RemittanceData.AddressLineThree = value length += read - if rr.RemittanceData.AddressLineFour, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineFour", err) } + rr.RemittanceData.AddressLineFour = value length += read - if rr.RemittanceData.AddressLineFive, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineFive", err) } + rr.RemittanceData.AddressLineFive = value length += read - if rr.RemittanceData.AddressLineSix, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineSix", err) } + rr.RemittanceData.AddressLineSix = value length += read - if rr.RemittanceData.AddressLineSeven, read, err = rr.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rr.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineSeven", err) } + rr.RemittanceData.AddressLineSeven = value length += read if len(record) != length { diff --git a/remittance.go b/remittance.go index ee31b918..85a22e2a 100644 --- a/remittance.go +++ b/remittance.go @@ -41,34 +41,41 @@ func (ri *Remittance) Parse(record string) error { } ri.tag = record[:6] - - var err error length := 6 - read := 0 - if ri.CoverPayment.SwiftFieldTag, read, err = ri.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := ri.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + ri.CoverPayment.SwiftFieldTag = value length += read - if ri.CoverPayment.SwiftLineOne, read, err = ri.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ri.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + ri.CoverPayment.SwiftLineOne = value length += read - if ri.CoverPayment.SwiftLineTwo, read, err = ri.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ri.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + ri.CoverPayment.SwiftLineTwo = value length += read - if ri.CoverPayment.SwiftLineThree, read, err = ri.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ri.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + ri.CoverPayment.SwiftLineThree = value length += read - if ri.CoverPayment.SwiftLineFour, read, err = ri.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ri.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + ri.CoverPayment.SwiftLineFour = value length += read if len(record) != length { diff --git a/remittanceBeneficiary.go b/remittanceBeneficiary.go index f9930b4f..525003a7 100644 --- a/remittanceBeneficiary.go +++ b/remittanceBeneficiary.go @@ -49,124 +49,167 @@ func (rb *RemittanceBeneficiary) Parse(record string) error { } rb.tag = record[:6] - - var err error length := 6 - read := 0 - if rb.RemittanceData.Name, read, err = rb.parseVariableStringField(record[length:], 140); err != nil { + value, read, err := rb.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("Name", err) } + rb.RemittanceData.Name = value length += read - if rb.IdentificationType, read, err = rb.parseVariableStringField(record[length:], 2); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("IdentificationType", err) } + rb.IdentificationType = value length += read - if rb.IdentificationCode, read, err = rb.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("IdentificationCode", err) } + rb.IdentificationCode = value length += read - if rb.IdentificationNumber, read, err = rb.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("IdentificationNumber", err) } + rb.IdentificationNumber = value length += read - if rb.IdentificationNumberIssuer, read, err = rb.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("IdentificationNumberIssuer", err) } + rb.IdentificationNumberIssuer = value length += read - if rb.RemittanceData.DateBirthPlace, read, err = rb.parseVariableStringField(record[length:], 82); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 82) + if err != nil { return fieldError("DateBirthPlace", err) } + rb.RemittanceData.DateBirthPlace = value length += read - if rb.RemittanceData.AddressType, read, err = rb.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("AddressType", err) } + rb.RemittanceData.AddressType = value length += read - if rb.RemittanceData.Department, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("Department", err) } + rb.RemittanceData.Department = value length += read - if rb.RemittanceData.SubDepartment, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("SubDepartment", err) } + rb.RemittanceData.SubDepartment = value length += read - if rb.RemittanceData.StreetName, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("StreetName", err) } + rb.RemittanceData.StreetName = value length += read - if rb.RemittanceData.BuildingNumber, read, err = rb.parseVariableStringField(record[length:], 16); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("BuildingNumber", err) } + rb.RemittanceData.BuildingNumber = value length += read - if rb.RemittanceData.PostCode, read, err = rb.parseVariableStringField(record[length:], 16); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("PostCode", err) } + rb.RemittanceData.PostCode = value length += read - if rb.RemittanceData.TownName, read, err = rb.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("TownName", err) } + rb.RemittanceData.TownName = value length += read - if rb.RemittanceData.CountrySubDivisionState, read, err = rb.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("CountrySubDivisionState", err) } + rb.RemittanceData.CountrySubDivisionState = value length += read - if rb.RemittanceData.Country, read, err = rb.parseVariableStringField(record[length:], 2); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("Country", err) } + rb.RemittanceData.Country = value length += read - if rb.RemittanceData.AddressLineOne, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineOne", err) } + rb.RemittanceData.AddressLineOne = value length += read - if rb.RemittanceData.AddressLineTwo, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineTwo", err) } + rb.RemittanceData.AddressLineTwo = value length += read - if rb.RemittanceData.AddressLineThree, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineThree", err) } + rb.RemittanceData.AddressLineThree = value length += read - if rb.RemittanceData.AddressLineFour, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineFour", err) } + rb.RemittanceData.AddressLineFour = value length += read - if rb.RemittanceData.AddressLineFive, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineFive", err) } + rb.RemittanceData.AddressLineFive = value length += read - if rb.RemittanceData.AddressLineSix, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineSix", err) } + rb.RemittanceData.AddressLineSix = value length += read - if rb.RemittanceData.AddressLineSeven, read, err = rb.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineSeven", err) } + rb.RemittanceData.AddressLineSeven = value length += read - if rb.RemittanceData.CountryOfResidence, read, err = rb.parseVariableStringField(record[length:], 2); err != nil { + value, read, err = rb.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("CountryOfResidence", err) } + rb.RemittanceData.CountryOfResidence = value length += read if len(record) != length { diff --git a/remittanceFreeText.go b/remittanceFreeText.go index f04983c9..f6b0f2e1 100644 --- a/remittanceFreeText.go +++ b/remittanceFreeText.go @@ -45,24 +45,27 @@ func (rft *RemittanceFreeText) Parse(record string) error { } rft.tag = record[:6] - - var err error length := 6 - read := 0 - if rft.LineOne, read, err = rft.parseVariableStringField(record[length:], 140); err != nil { + value, read, err := rft.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("LineOne", err) } + rft.LineOne = value length += read - if rft.LineTwo, read, err = rft.parseVariableStringField(record[length:], 140); err != nil { + value, read, err = rft.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("LineTwo", err) } + rft.LineTwo = value length += read - if rft.LineThree, read, err = rft.parseVariableStringField(record[length:], 140); err != nil { + value, read, err = rft.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("LineThree", err) } + rft.LineThree = value length += read if len(record) != length { diff --git a/remittanceOriginator.go b/remittanceOriginator.go index fc87127f..1af87081 100644 --- a/remittanceOriginator.go +++ b/remittanceOriginator.go @@ -61,154 +61,209 @@ func (ro *RemittanceOriginator) Parse(record string) error { } ro.tag = record[:6] - - var err error length := 6 - read := 0 - if ro.IdentificationType, read, err = ro.parseVariableStringField(record[length:], 2); err != nil { + value, read, err := ro.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("IdentificationType", err) } + ro.IdentificationType = value length += read - if ro.IdentificationCode, read, err = ro.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("IdentificationCode", err) } + ro.IdentificationCode = value length += read - if ro.RemittanceData.Name, read, err = ro.parseVariableStringField(record[length:], 140); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("Name", err) } + ro.RemittanceData.Name = value length += read - if ro.IdentificationNumber, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("IdentificationNumber", err) } + ro.IdentificationNumber = value length += read - if ro.IdentificationNumberIssuer, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("IdentificationNumberIssuer", err) } + ro.IdentificationNumberIssuer = value length += read - if ro.RemittanceData.DateBirthPlace, read, err = ro.parseVariableStringField(record[length:], 82); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 82) + if err != nil { return fieldError("DateBirthPlace", err) } + ro.RemittanceData.DateBirthPlace = value length += read - if ro.RemittanceData.AddressType, read, err = ro.parseVariableStringField(record[length:], 4); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("AddressType", err) } + ro.RemittanceData.AddressType = value length += read - if ro.RemittanceData.Department, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("Department", err) } + ro.RemittanceData.Department = value length += read - if ro.RemittanceData.SubDepartment, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("SubDepartment", err) } + ro.RemittanceData.SubDepartment = value length += read - if ro.RemittanceData.StreetName, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("StreetName", err) } + ro.RemittanceData.StreetName = value length += read - if ro.RemittanceData.BuildingNumber, read, err = ro.parseVariableStringField(record[length:], 16); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("BuildingNumber", err) } + ro.RemittanceData.BuildingNumber = value length += read - if ro.RemittanceData.PostCode, read, err = ro.parseVariableStringField(record[length:], 16); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("PostCode", err) } + ro.RemittanceData.PostCode = value length += read - if ro.RemittanceData.TownName, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("TownName", err) } + ro.RemittanceData.TownName = value length += read - if ro.RemittanceData.CountrySubDivisionState, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("CountrySubDivisionState", err) } + ro.RemittanceData.CountrySubDivisionState = value length += read - if ro.RemittanceData.Country, read, err = ro.parseVariableStringField(record[length:], 2); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("Country", err) } + ro.RemittanceData.Country = value length += read - if ro.RemittanceData.AddressLineOne, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineOne", err) } + ro.RemittanceData.AddressLineOne = value length += read - if ro.RemittanceData.AddressLineTwo, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineTwo", err) } + ro.RemittanceData.AddressLineTwo = value length += read - if ro.RemittanceData.AddressLineThree, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineThree", err) } + ro.RemittanceData.AddressLineThree = value length += read - if ro.RemittanceData.AddressLineFour, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineFour", err) } + ro.RemittanceData.AddressLineFour = value length += read - if ro.RemittanceData.AddressLineFive, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineFive", err) } + ro.RemittanceData.AddressLineFive = value length += read - if ro.RemittanceData.AddressLineSix, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineSix", err) } + ro.RemittanceData.AddressLineSix = value length += read - if ro.RemittanceData.AddressLineSeven, read, err = ro.parseVariableStringField(record[length:], 70); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 70) + if err != nil { return fieldError("AddressLineSeven", err) } + ro.RemittanceData.AddressLineSeven = value length += read - if ro.RemittanceData.CountryOfResidence, read, err = ro.parseVariableStringField(record[length:], 2); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 2) + if err != nil { return fieldError("CountryOfResidence", err) } + ro.RemittanceData.CountryOfResidence = value length += read - if ro.ContactName, read, err = ro.parseVariableStringField(record[length:], 140); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 140) + if err != nil { return fieldError("ContactName", err) } + ro.ContactName = value length += read - if ro.ContactPhoneNumber, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactPhoneNumber", err) } + ro.ContactPhoneNumber = value length += read - if ro.ContactMobileNumber, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactMobileNumber", err) } + ro.ContactMobileNumber = value length += read - if ro.ContactFaxNumber, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactFaxNumber", err) } + ro.ContactFaxNumber = value length += read - if ro.ContactElectronicAddress, read, err = ro.parseVariableStringField(record[length:], 2048); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 2048) + if err != nil { return fieldError("ContactElectronicAddress", err) } + ro.ContactElectronicAddress = value length += read - if ro.ContactOther, read, err = ro.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = ro.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ContactOther", err) } + ro.ContactOther = value length += read if len(record) != length { diff --git a/remittance_test.go b/remittance_test.go index e1821372..6c088705 100644 --- a/remittance_test.go +++ b/remittance_test.go @@ -129,7 +129,6 @@ func TestRemittanceTagError(t *testing.T) { require.EqualError(t, ri.Validate(), fieldError("tag", ErrValidTagForType, ri.tag).Error()) } - // TestStringRemittanceVariableLength parses using variable length func TestStringRemittanceVariableLength(t *testing.T) { var line = "{7070}" diff --git a/secondaryRemittanceDocument.go b/secondaryRemittanceDocument.go index 23085d07..4f2b91c4 100644 --- a/secondaryRemittanceDocument.go +++ b/secondaryRemittanceDocument.go @@ -47,29 +47,34 @@ func (srd *SecondaryRemittanceDocument) Parse(record string) error { } srd.tag = record[:6] - - var err error length := 6 - read := 0 - if srd.DocumentTypeCode, read, err = srd.parseVariableStringField(record[length:], 4); err != nil { + value, read, err := srd.parseVariableStringField(record[length:], 4) + if err != nil { return fieldError("DocumentTypeCode", err) } + srd.DocumentTypeCode = value length += read - if srd.ProprietaryDocumentTypeCode, read, err = srd.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = srd.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("ProprietaryDocumentTypeCode", err) } + srd.ProprietaryDocumentTypeCode = value length += read - if srd.DocumentIdentificationNumber, read, err = srd.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = srd.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("DocumentIdentificationNumber", err) } + srd.DocumentIdentificationNumber = value length += read - if srd.Issuer, read, err = srd.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = srd.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("Issuer", err) } + srd.Issuer = value length += read if len(record) != length { diff --git a/senderDepositoryInstitution.go b/senderDepositoryInstitution.go index 3187ffef..e495df4c 100644 --- a/senderDepositoryInstitution.go +++ b/senderDepositoryInstitution.go @@ -43,19 +43,20 @@ func (sdi *SenderDepositoryInstitution) Parse(record string) error { } sdi.tag = record[:6] - - var err error length := 6 - read := 0 - if sdi.SenderABANumber, read, err = sdi.parseVariableStringField(record[length:], 9); err != nil { + value, read, err := sdi.parseVariableStringField(record[length:], 9) + if err != nil { return fieldError("SenderABANumber", err) } + sdi.SenderABANumber = value length += read - if sdi.SenderShortName, read, err = sdi.parseVariableStringField(record[length:], 18); err != nil { + value, read, err = sdi.parseVariableStringField(record[length:], 18) + if err != nil { return fieldError("SenderShortName", err) } + sdi.SenderShortName = value length += read if len(record) != length { diff --git a/senderReference.go b/senderReference.go index 1407217d..866da008 100644 --- a/senderReference.go +++ b/senderReference.go @@ -41,14 +41,13 @@ func (sr *SenderReference) Parse(record string) error { } sr.tag = record[:6] - - var err error length := 6 - read := 0 - if sr.SenderReference, read, err = sr.parseVariableStringField(record[length:], 16); err != nil { + value, read, err := sr.parseVariableStringField(record[length:], 16) + if err != nil { return fieldError("SenderReference", err) } + sr.SenderReference = value length += read if len(record) != length { diff --git a/senderSupplied.go b/senderSupplied.go index 50e1b0e3..ea69b478 100644 --- a/senderSupplied.go +++ b/senderSupplied.go @@ -51,14 +51,13 @@ func (ss *SenderSupplied) Parse(record string) error { ss.tag = record[0:6] ss.FormatVersion = ss.parseStringField(record[6:8]) - - var err error length := 8 - read := 0 - if ss.UserRequestCorrelation, read, err = ss.parseVariableStringField(record[length:], 8); err != nil { + value, read, err := ss.parseVariableStringField(record[length:], 8) + if err != nil { return fieldError("UserRequestCorrelation", err) } + ss.UserRequestCorrelation = value length += read if len(record) < length+1 { @@ -68,10 +67,13 @@ func (ss *SenderSupplied) Parse(record string) error { ss.TestProductionCode = ss.parseStringField(record[length : length+1]) length += 1 - if ss.MessageDuplicationCode, read, err = ss.parseVariableStringField(record[length:], 1); err != nil { + value, read, err = ss.parseVariableStringField(record[length:], 1) + if err != nil { return fieldError("MessageDuplicationCode", err) } + ss.MessageDuplicationCode = value length += read + ss.MessageDuplicationCode = ss.parseStringField(ss.MessageDuplicationCode) if len(record) != length { diff --git a/senderToReceiver.go b/senderToReceiver.go index 199c561c..87e733f5 100644 --- a/senderToReceiver.go +++ b/senderToReceiver.go @@ -41,44 +41,55 @@ func (str *SenderToReceiver) Parse(record string) error { } str.tag = record[:6] - - var err error length := 6 - read := 0 - if str.CoverPayment.SwiftFieldTag, read, err = str.parseVariableStringField(record[length:], 5); err != nil { + value, read, err := str.parseVariableStringField(record[length:], 5) + if err != nil { return fieldError("SwiftFieldTag", err) } + str.CoverPayment.SwiftFieldTag = value length += read - if str.CoverPayment.SwiftLineOne, read, err = str.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = str.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineOne", err) } + str.CoverPayment.SwiftLineOne = value length += read - if str.CoverPayment.SwiftLineTwo, read, err = str.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = str.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineTwo", err) } + str.CoverPayment.SwiftLineTwo = value length += read - if str.CoverPayment.SwiftLineThree, read, err = str.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = str.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineThree", err) } + str.CoverPayment.SwiftLineThree = value length += read - if str.CoverPayment.SwiftLineFour, read, err = str.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = str.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFour", err) } + str.CoverPayment.SwiftLineFour = value length += read - if str.CoverPayment.SwiftLineFive, read, err = str.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = str.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineFive", err) } + str.CoverPayment.SwiftLineFive = value length += read - if str.CoverPayment.SwiftLineSix, read, err = str.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = str.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("SwiftLineSix", err) } + str.CoverPayment.SwiftLineSix = value length += read if len(record) != length { diff --git a/serviceMessage.go b/serviceMessage.go index 48473a18..7a5970d9 100644 --- a/serviceMessage.go +++ b/serviceMessage.go @@ -63,69 +63,90 @@ func (sm *ServiceMessage) Parse(record string) error { } sm.tag = record[:6] - - var err error length := 6 - read := 0 - if sm.LineOne, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err := sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineOne", err) } + sm.LineOne = value length += read - if sm.LineTwo, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineTwo", err) } + sm.LineTwo = value length += read - if sm.LineThree, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineThree", err) } + sm.LineThree = value length += read - if sm.LineFour, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineFour", err) } + sm.LineFour = value length += read - if sm.LineFive, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineFive", err) } + sm.LineFive = value length += read - if sm.LineSix, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineSix", err) } + sm.LineSix = value length += read - if sm.LineSeven, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineSeven", err) } + sm.LineSeven = value length += read - if sm.LineEight, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineEight", err) } + sm.LineEight = value length += read - if sm.LineNine, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineNine", err) } + sm.LineNine = value length += read - if sm.LineTen, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineTen", err) } + sm.LineTen = value length += read - if sm.LineEleven, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineEleven", err) } + sm.LineEleven = value length += read - if sm.LineTwelve, read, err = sm.parseVariableStringField(record[length:], 35); err != nil { + value, read, err = sm.parseVariableStringField(record[length:], 35) + if err != nil { return fieldError("LineTwelve", err) } + sm.LineTwelve = value length += read if len(record) != length {