Skip to content

Commit

Permalink
handle quoted commodity
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Aug 19, 2023
1 parent 2863e54 commit 60723b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (HLedgerCLI) Prices(journalPath string) ([]price.Price, error) {

func parseLedgerPrices(output string, defaultCurrency string) ([]price.Price, error) {
var prices []price.Price
re := regexp.MustCompile(`P (\d{4}\/\d{2}\/\d{2}) (?:\d{2}:\d{2}:\d{2}) ([^\s\d.-]+) (.+)\n`)
re := regexp.MustCompile(`P (\d{4}\/\d{2}\/\d{2}) (?:\d{2}:\d{2}:\d{2}) ([^\s\d.-]+|"[^"]+") (.+)\n`)
matches := re.FindAllStringSubmatch(output, -1)

for _, match := range matches {
Expand Down
3 changes: 2 additions & 1 deletion internal/server/assets/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/samber/lo"

"github.com/ananthakumaran/paisa/internal/accounting"
"github.com/ananthakumaran/paisa/internal/model/posting"
"github.com/ananthakumaran/paisa/internal/query"
"github.com/ananthakumaran/paisa/internal/service"
Expand Down Expand Up @@ -60,7 +61,7 @@ func computeBreakdown(db *gorm.DB, postings []posting.Posting) map[string]AssetB
return acc + -p.Amount
}
}, 0.0)
marketAmount := lo.Reduce(ps, func(acc float64, p posting.Posting, _ int) float64 { return acc + p.MarketAmount }, 0.0)
marketAmount := accounting.CurrentBalance(ps)
var balanceUnits float64
if leaf {
balanceUnits = lo.Reduce(ps, func(acc float64, p posting.Posting, _ int) float64 {
Expand Down

0 comments on commit 60723b7

Please sign in to comment.