mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 23:42:29 -05:00
Add the total number of transactions in an account to AccountTransactionsList
This commit is contained in:
parent
b670e67ebb
commit
684e8defb7
@ -40,9 +40,9 @@ func (s *Split) Valid() bool {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Entered int64 = 1
|
Entered int64 = 1
|
||||||
Cleared = 2
|
Cleared = 2
|
||||||
Reconciled = 3
|
Reconciled = 3
|
||||||
Voided = 4
|
Voided = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
type Transaction struct {
|
type Transaction struct {
|
||||||
@ -59,8 +59,9 @@ type TransactionList struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AccountTransactionsList struct {
|
type AccountTransactionsList struct {
|
||||||
Account *Account `json:"account"`
|
Account *Account `json:"account"`
|
||||||
Transactions *[]Transaction `json:"transactions"`
|
Transactions *[]Transaction `json:"transactions"`
|
||||||
|
TotalTransactions int64 `json:"totaltransactions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transaction) Write(w http.ResponseWriter) error {
|
func (t *Transaction) Write(w http.ResponseWriter) error {
|
||||||
@ -574,6 +575,13 @@ func GetAccountTransactions(user *User, accountid int64, sort string, page uint6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count, err := transaction.SelectInt("SELECT count(DISTINCT transactions.TransactionId) FROM transactions INNER JOIN splits ON transactions.TransactionId = splits.TransactionId WHERE transactions.UserId=? AND splits.AccountId=?", user.UserId, accountid)
|
||||||
|
if err != nil {
|
||||||
|
transaction.Rollback()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
atl.TotalTransactions = count
|
||||||
|
|
||||||
err = transaction.Commit()
|
err = transaction.Commit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
transaction.Rollback()
|
transaction.Rollback()
|
||||||
|
Loading…
Reference in New Issue
Block a user