1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-25 23:23:21 -05:00

OFX imports: Create sub-accounts for sub-account splits

This commit is contained in:
Aaron Lindsay 2017-09-21 21:16:23 -04:00
parent e38c49a556
commit 15b9bc8314

View File

@ -132,6 +132,23 @@ func ofxImportHelper(r io.Reader, w http.ResponseWriter, user *User, accountid i
}
split.AccountId = trading_account.AccountId
split.SecurityId = -1
} else if split.ImportSplitType == SubAccount {
subaccount := &Account{
UserId: user.UserId,
Name: sec.Name,
ParentAccountId: account.AccountId,
SecurityId: sec.SecurityId,
Type: account.Type,
}
subaccount, err := GetCreateAccountTx(sqltransaction, *subaccount)
if err != nil {
sqltransaction.Rollback()
WriteError(w, 999 /*Internal Error*/)
log.Print(err)
return
}
split.AccountId = subaccount.AccountId
split.SecurityId = -1
} else {
split.SecurityId = sec.SecurityId
}