Skip to content

Commit

Permalink
Enable mapping in register
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvio Böhler committed Aug 13, 2022
1 parent 39dbbf4 commit 4910db8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func (r runner) execute(cmd *cobra.Command, args []string) error {
},
ShowCommodities: r.showCommodities,
Valuation: valuation,
Mapping: r.mapping.Value(),
}
ctx = cmd.Context()
)
Expand Down
7 changes: 5 additions & 2 deletions lib/journal/report/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Register struct {

ShowCommodities bool
Valuation *journal.Commodity
Mapping journal.Mapping
}

// Add adds another day.
Expand All @@ -47,12 +48,14 @@ func (r *Register) Add(d *ast.Day) {
}

if inCr && r.Filter.MatchAccount(b.Debit) {
ca := amounts.Key{Account: b.Debit, Commodity: commodity}
acc := b.Debit.Map(r.Mapping)
ca := amounts.Key{Account: acc, Commodity: commodity}
vals[ca] = vals[ca].Sub(value)

}
if inDr && r.Filter.MatchAccount(b.Credit) {
ca := amounts.Key{Account: b.Credit, Commodity: commodity}
acc := b.Credit.Map(r.Mapping)
ca := amounts.Key{Account: acc, Commodity: commodity}
vals[ca] = vals[ca].Add(value)
}
}
Expand Down

0 comments on commit 4910db8

Please sign in to comment.