From 5abb00a4fd6ff0e9ba48298dc01b616d99d931f0 Mon Sep 17 00:00:00 2001 From: Anantha Kumaran Date: Wed, 4 Oct 2023 08:26:53 +0530 Subject: [PATCH] [hledger] handle @@ total price --- internal/ledger/ledger.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/ledger/ledger.go b/internal/ledger/ledger.go index 6780e1b8..496e772c 100644 --- a/internal/ledger/ledger.go +++ b/internal/ledger/ledger.go @@ -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"` @@ -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 {