un-break shared
cicd / ci (push) Successful in 3m5s
Details
cicd / ci (push) Successful in 3m5s
Details
parent
cc546d9b2d
commit
b1cf639f39
|
|
@ -17,4 +17,5 @@ type Config struct {
|
||||||
}
|
}
|
||||||
Compact bool
|
Compact bool
|
||||||
GroupDate string
|
GroupDate string
|
||||||
|
NoPercent bool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ func Main() {
|
||||||
fs.StringVar(&config.CPI, "cpi", "", "path to cpi")
|
fs.StringVar(&config.CPI, "cpi", "", "path to cpi")
|
||||||
fs.StringVar(&config.GroupDate, "group-date", "^....-..-..", "date grouping")
|
fs.StringVar(&config.GroupDate, "group-date", "^....-..-..", "date grouping")
|
||||||
fs.IntVar(&config.CPIYear, "cpiy", 0, "use cpi to convert usd to this year's value")
|
fs.IntVar(&config.CPIYear, "cpiy", 0, "use cpi to convert usd to this year's value")
|
||||||
|
fs.BoolVar(&config.NoPercent, "no-percent", false, "compute percent")
|
||||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -146,25 +147,29 @@ func Main() {
|
||||||
Normalize(cpiNormalizer, "9")
|
Normalize(cpiNormalizer, "9")
|
||||||
|
|
||||||
cumulatives := make(ledger.Balances)
|
cumulatives := make(ledger.Balances)
|
||||||
var sum float64
|
cumulativesFormat := "%s%.2f"
|
||||||
for key := range balances {
|
if !config.NoPercent {
|
||||||
if _, ok := cumulatives[key]; !ok {
|
var sum float64
|
||||||
cumulatives[key] = make(ledger.Balance)
|
for key := range balances {
|
||||||
}
|
if _, ok := cumulatives[key]; !ok {
|
||||||
for currency, val := range balances[key] {
|
cumulatives[key] = make(ledger.Balance)
|
||||||
if currency == ledger.USD {
|
}
|
||||||
cumulatives[key][currency] = val
|
for currency, val := range balances[key] {
|
||||||
sum += val
|
if currency == ledger.USD {
|
||||||
} else {
|
cumulatives[key][currency] = val
|
||||||
cumulatives[key][currency] = 0
|
sum += val
|
||||||
|
} else {
|
||||||
|
cumulatives[key][currency] = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for key := range cumulatives {
|
||||||
for key := range cumulatives {
|
cumulatives[key][ledger.USD] = 100 * cumulatives[key][ledger.USD] / sum
|
||||||
cumulatives[key][ledger.USD] = 100 * cumulatives[key][ledger.USD] / sum
|
}
|
||||||
|
cumulativesFormat = "%.0f%%"
|
||||||
}
|
}
|
||||||
|
|
||||||
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, cumulativesFormat)
|
||||||
case "gra": // graph
|
case "gra": // graph
|
||||||
dateGrouping := "^[0-9]{4}-[0-9]{2}"
|
dateGrouping := "^[0-9]{4}-[0-9]{2}"
|
||||||
if period := config.Query.Period; !period.Empty() {
|
if period := config.Query.Period; !period.Empty() {
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ func main() {
|
||||||
"--depth=1",
|
"--depth=1",
|
||||||
"--usd",
|
"--usd",
|
||||||
"-n",
|
"-n",
|
||||||
|
"--no-percent",
|
||||||
"bal", "^Bel", "^Zach",
|
"bal", "^Bel", "^Zach",
|
||||||
)
|
)
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue