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
1 changed files with 17 additions and 0 deletions

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
}