mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
parse information to account owner data in mt940 file
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user