mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 15:42:27 -05:00
Use default currency for top-level 'Trading' account
Also add missing transaction.Rollback() calls on early returns in GetAccountTransactions()
This commit is contained in:
parent
d0d6ea3a78
commit
e38c49a556
@ -189,10 +189,15 @@ func GetTradingAccount(transaction *gorp.Transaction, userid int64, securityid i
|
|||||||
var tradingAccount Account
|
var tradingAccount Account
|
||||||
var account Account
|
var account Account
|
||||||
|
|
||||||
|
user, err := GetUserTx(transaction, userid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
tradingAccount.UserId = userid
|
tradingAccount.UserId = userid
|
||||||
tradingAccount.Type = Trading
|
tradingAccount.Type = Trading
|
||||||
tradingAccount.Name = "Trading"
|
tradingAccount.Name = "Trading"
|
||||||
tradingAccount.SecurityId = 840 /*USD*/ //FIXME SecurityId shouldn't matter for top-level trading account, but maybe we should grab the user's default
|
tradingAccount.SecurityId = user.DefaultCurrency
|
||||||
tradingAccount.ParentAccountId = -1
|
tradingAccount.ParentAccountId = -1
|
||||||
|
|
||||||
// Find/create the top-level trading account
|
// Find/create the top-level trading account
|
||||||
|
@ -834,11 +834,13 @@ func GetAccountTransactions(user *User, accountid int64, sort string, page uint6
|
|||||||
}
|
}
|
||||||
atl.TotalTransactions = count
|
atl.TotalTransactions = count
|
||||||
|
|
||||||
security, err := GetSecurity(atl.Account.SecurityId, user.UserId)
|
security, err := GetSecurityTx(transaction, atl.Account.SecurityId, user.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
transaction.Rollback()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if security == nil {
|
if security == nil {
|
||||||
|
transaction.Rollback()
|
||||||
return nil, errors.New("Security not found")
|
return nil, errors.New("Security not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user