mirror of
				https://github.com/aclindsa/moneygo.git
				synced 2025-11-01 02:03:26 -04:00 
			
		
		
		
	Add the total number of transactions in an account to AccountTransactionsList
This commit is contained in:
		| @@ -40,9 +40,9 @@ func (s *Split) Valid() bool { | ||||
|  | ||||
| const ( | ||||
| 	Entered    int64 = 1 | ||||
| 	Cleared                      = 2 | ||||
| 	Reconciled                   = 3 | ||||
| 	Voided                       = 4 | ||||
| 	Cleared          = 2 | ||||
| 	Reconciled       = 3 | ||||
| 	Voided           = 4 | ||||
| ) | ||||
|  | ||||
| type Transaction struct { | ||||
| @@ -59,8 +59,9 @@ type TransactionList struct { | ||||
| } | ||||
|  | ||||
| type AccountTransactionsList struct { | ||||
| 	Account      *Account       `json:"account"` | ||||
| 	Transactions *[]Transaction `json:"transactions"` | ||||
| 	Account           *Account       `json:"account"` | ||||
| 	Transactions      *[]Transaction `json:"transactions"` | ||||
| 	TotalTransactions int64          `json:"totaltransactions"` | ||||
| } | ||||
|  | ||||
| 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() | ||||
| 	if err != nil { | ||||
| 		transaction.Rollback() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user