Skip to content

Commit

Permalink
[hledger] handle @@ total price
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Oct 4, 2023
1 parent 7c89d0f commit 5abb00a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ func execHLedgerCommand(journalPath string, prices []price.Price, flags []string
Value float64 `json:"floatingPoint"`
} `json:"aquantity"`
} `json:"contents"`
Tag string `json:"tag"`
} `json:"aprice"`
} `json:"pamount"`
} `json:"tpostings"`
Expand Down Expand Up @@ -494,7 +495,11 @@ func execHLedgerCommand(journalPath string, prices []price.Price, flags []string

if amount.Commodity != config.DefaultCurrency() {
if amount.Price.Contents.Quantity.Value != 0 {
totalAmount = decimal.NewFromFloat(amount.Price.Contents.Quantity.Value).Mul(decimal.NewFromFloat(amount.Quantity.Value))
if amount.Price.Tag == "TotalPrice" {
totalAmount = decimal.NewFromFloat(amount.Price.Contents.Quantity.Value)
} else {
totalAmount = decimal.NewFromFloat(amount.Price.Contents.Quantity.Value).Mul(decimal.NewFromFloat(amount.Quantity.Value))
}
} else {
pt := pricesTree[amount.Commodity]
if pt != nil {
Expand Down

0 comments on commit 5abb00a

Please sign in to comment.