fix
cicd / ci (push) Successful in 1m14s
Details
cicd / ci (push) Successful in 1m14s
Details
parent
0066a267a6
commit
cc546d9b2d
|
|
@ -148,17 +148,23 @@ func Main() {
|
|||
cumulatives := make(ledger.Balances)
|
||||
var sum float64
|
||||
for key := range balances {
|
||||
usd, ok := balances[key][ledger.USD]
|
||||
if ok {
|
||||
cumulatives[key] = ledger.Balance{ledger.USD: usd}
|
||||
sum += usd
|
||||
if _, ok := cumulatives[key]; !ok {
|
||||
cumulatives[key] = make(ledger.Balance)
|
||||
}
|
||||
for currency, val := range balances[key] {
|
||||
if currency == ledger.USD {
|
||||
cumulatives[key][currency] = val
|
||||
sum += val
|
||||
} else {
|
||||
cumulatives[key][currency] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
for key := range cumulatives {
|
||||
cumulatives[key][ledger.USD] = 100 * cumulatives[key][ledger.USD] / sum
|
||||
}
|
||||
|
||||
FPrintBalances(w, "", balances, cumulatives, config.Query.USDOnly, config.Query.Normalize, time.Now().Format("2006-01-02"), false, maxAccW, "%.0f%%%%")
|
||||
FPrintBalances(w, "", balances, cumulatives, config.Query.USDOnly, config.Query.Normalize, time.Now().Format("2006-01-02"), false, maxAccW, "%.0f%%")
|
||||
case "gra": // graph
|
||||
dateGrouping := "^[0-9]{4}-[0-9]{2}"
|
||||
if period := config.Query.Period; !period.Empty() {
|
||||
|
|
@ -352,9 +358,10 @@ func FPrintBalances(w io.Writer, linePrefix string, balances, cumulatives ledger
|
|||
|
||||
normalizer := ana.NewDefaultNormalizer()
|
||||
|
||||
format := fmt.Sprintf("%s%%-%ds\t%%s%%.2f (%"+cumulativeFormat+")\n", linePrefix, max)
|
||||
cumulativeFormat = strings.ReplaceAll(cumulativeFormat, "%", "%%")
|
||||
format := fmt.Sprintf("%s%%-%ds\t%%s%%.2f ("+cumulativeFormat+")\n", linePrefix, max)
|
||||
if normalized {
|
||||
format = fmt.Sprintf("%s%%-%ds\t%%s%%.2f (%%s%%.2f (%%.2f @%%.2f (%"+cumulativeFormat+")))\n", linePrefix, max)
|
||||
format = fmt.Sprintf("%s%%-%ds\t%%s%%.2f (%%s%%.2f (%%.2f @%%.2f ("+cumulativeFormat+")))\n", linePrefix, max)
|
||||
}
|
||||
for i, key := range keys {
|
||||
printableKey := key
|
||||
|
|
@ -389,12 +396,9 @@ func FPrintBalances(w io.Writer, linePrefix string, balances, cumulatives ledger
|
|||
for _, currency := range currencies {
|
||||
printableCurrency := currency
|
||||
format := format
|
||||
printPrintableCurrency := strings.Count(cumulativeFormat, "%s") > 0
|
||||
if printPrintableCurrency {
|
||||
if printableCurrency != "$" {
|
||||
printableCurrency += " "
|
||||
format = strings.ReplaceAll(format, "%.2f", "%.3f")
|
||||
}
|
||||
if printableCurrency != "$" {
|
||||
printableCurrency += " "
|
||||
format = strings.ReplaceAll(format, "%.2f", "%.3f")
|
||||
}
|
||||
if usdOnly && printableCurrency != "$" {
|
||||
continue
|
||||
|
|
@ -407,9 +411,14 @@ func FPrintBalances(w io.Writer, linePrefix string, balances, cumulatives ledger
|
|||
cumulative = value
|
||||
}
|
||||
|
||||
if printPrintableCurrency {
|
||||
printingPercents := strings.Contains(cumulativeFormat, "%%%%")
|
||||
if !printingPercents {
|
||||
if !normalized {
|
||||
fmt.Fprintf(w, format, printableKey, printableCurrency, balances[key][currency], printableCurrency, cumulative)
|
||||
fmt.Fprintf(w, format,
|
||||
printableKey,
|
||||
printableCurrency, balances[key][currency],
|
||||
printableCurrency, cumulative,
|
||||
)
|
||||
} else {
|
||||
factor := normalizer.NormalizeFactor(key, date)
|
||||
trailingMax := maxes[currency] - math.Abs(balances[key][currency])
|
||||
|
|
|
|||
Loading…
Reference in New Issue