parse information to account owner data in mt940 file

This commit is contained in:
MaysWind
2025-06-21 00:52:08 +08:00
parent 4a6f7eb43c
commit b1349f57cd
5 changed files with 171 additions and 42 deletions
+31 -1
View File
@@ -1,5 +1,7 @@
package mt
import "strings"
type mtCreditDebitMark string
const (
@@ -9,6 +11,10 @@ const (
MT_MARK_REVERSAL_DEBIT mtCreditDebitMark = "RD"
)
const (
MT_INFORMATION_TO_ACCOUNT_OWNER_TAG_REMITTANCE string = "REMI"
)
// mt940Data defines the structure of mt940 data
type mt940Data struct {
StatementReferenceNumber string
@@ -31,7 +37,7 @@ type mtStatement struct {
TransactionTypeIdentificationCode string
ReferenceForAccountOwner string
ReferenceOfAccountServicingInstitution string
AdditionalInformation []string
InformationToAccountOwner []string
}
// mtBalance defines the structure of mt940 balance
@@ -41,3 +47,27 @@ type mtBalance struct {
Currency string
Amount string
}
// GetInformationToAccountOwnerMap returns a map of additional information
func (s *mtStatement) GetInformationToAccountOwnerMap() map[string]string {
additionalInfoMap := make(map[string]string, len(s.InformationToAccountOwner))
for _, info := range s.InformationToAccountOwner {
items := strings.Split(info, "/")
if len(items) < 3 {
continue
}
for i := 2; i < len(items); i += 2 {
key := strings.TrimSpace(items[i-1])
value := strings.TrimSpace(items[i])
if len(key) > 0 {
additionalInfoMap[key] = value
}
}
}
return additionalInfoMap
}