reg prints balance per xaction now

This commit is contained in:
Bel LaPointe
2024-12-12 22:27:44 -07:00
parent 4831914251
commit 4d484b8aa4
3 changed files with 33 additions and 13 deletions

View File

@@ -41,6 +41,13 @@ func LikeNotName(pattern string) Like {
}
}
func NotLikeName(pattern string) Like {
foo := LikeName(pattern)
return func(d Delta) bool {
return !foo(d)
}
}
func LikeName(pattern string) Like {
return func(d Delta) bool {
return like(pattern, d.Name)

View File

@@ -42,6 +42,26 @@ func (deltas Deltas) Transactions() Transactions {
return result
}
func (transactions Transactions) NotLike(like ...Like) Transactions {
result := make(Transactions, 0, len(transactions))
for _, transaction := range transactions {
if matching := (Deltas)(transaction).Like(like...); len(matching) == 0 {
result = append(result, transaction)
}
}
return result
}
func (transactions Transactions) Like(like ...Like) Transactions {
result := make(Transactions, 0, len(transactions))
for _, transaction := range transactions {
if matching := (Deltas)(transaction).Like(like...); len(matching) > 0 {
result = append(result, transaction)
}
}
return result
}
func (transaction Transaction) Payee() string {
balances := Deltas(transaction).Balances()