From 15b9bc8314fae78f2b0b64ee4d92d7694580bf3f Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Thu, 21 Sep 2017 21:16:23 -0400 Subject: [PATCH] OFX imports: Create sub-accounts for sub-account splits --- imports.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/imports.go b/imports.go index 5ff30a7..fd57dc4 100644 --- a/imports.go +++ b/imports.go @@ -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 }