implement transaction.go:Transactions:expenses to return a new slice of only the expense transactions
This commit is contained in:
@@ -50,6 +50,16 @@ func (trn Transaction) isRefund() bool {
|
||||
// Transactions represents a list of Transaction
|
||||
type Transactions []Transaction
|
||||
|
||||
func (trns Transactions) expenses() Transactions {
|
||||
result := make(Transactions, 0, len(trns))
|
||||
for i := range trns {
|
||||
if !trns[i].isRefund() {
|
||||
result = append(result, trns[i])
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Sum adds all transactions together.
|
||||
func (trns Transactions) Sum() Amount {
|
||||
result := Amount(0.0)
|
||||
|
||||
Reference in New Issue
Block a user