Compare commits
2 Commits
9352ca82de
...
84bbda1031
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84bbda1031 | ||
|
|
9b4accafe3 |
@@ -158,7 +158,25 @@ func FPrintBalances(w io.Writer, linePrefix string, balances, cumulatives ledger
|
|||||||
if normalized {
|
if normalized {
|
||||||
format = fmt.Sprintf("%s%%-%ds\t%%s%%.2f (%%s%%.2f (%%.2f @%%.2f (%%s%%.0f)))\n", linePrefix, max)
|
format = fmt.Sprintf("%s%%-%ds\t%%s%%.2f (%%s%%.2f (%%.2f @%%.2f (%%s%%.0f)))\n", linePrefix, max)
|
||||||
}
|
}
|
||||||
for _, key := range keys {
|
for i, key := range keys {
|
||||||
|
printableKey := key
|
||||||
|
if i > 0 {
|
||||||
|
j := 0
|
||||||
|
n := len(keys[i])
|
||||||
|
if n2 := len(keys[i-1]); n2 < n {
|
||||||
|
n = n2
|
||||||
|
}
|
||||||
|
for j = 0; j < n; j++ {
|
||||||
|
if keys[i-1][j] != keys[i][j] {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for keys[i][j] != ':' && j > 0 {
|
||||||
|
j -= 1
|
||||||
|
}
|
||||||
|
printableKey = strings.Repeat(" ", j) + keys[i][j:]
|
||||||
|
}
|
||||||
|
|
||||||
currencies := []ledger.Currency{}
|
currencies := []ledger.Currency{}
|
||||||
for currency := range balances[key] {
|
for currency := range balances[key] {
|
||||||
currencies = append(currencies, currency)
|
currencies = append(currencies, currency)
|
||||||
@@ -182,11 +200,11 @@ func FPrintBalances(w io.Writer, linePrefix string, balances, cumulatives ledger
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !normalized {
|
if !normalized {
|
||||||
fmt.Fprintf(w, format, key, printableCurrency, balances[key][currency], printableCurrency, cumulative)
|
fmt.Fprintf(w, format, printableKey, printableCurrency, balances[key][currency], printableCurrency, cumulative)
|
||||||
} else {
|
} else {
|
||||||
factor := normalizer.NormalizeFactor(ledger.Delta{Name: key, Date: date})
|
factor := normalizer.NormalizeFactor(ledger.Delta{Name: key, Date: date})
|
||||||
trailingMax := maxes[currency] - math.Abs(balances[key][currency])
|
trailingMax := maxes[currency] - math.Abs(balances[key][currency])
|
||||||
fmt.Fprintf(w, format, key, printableCurrency, balances[key][currency], printableCurrency, cumulative, cumulative*factor, factor, printableCurrency, factor*trailingMax)
|
fmt.Fprintf(w, format, printableKey, printableCurrency, balances[key][currency], printableCurrency, cumulative, cumulative*factor, factor, printableCurrency, factor*trailingMax)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,17 +46,17 @@ func buildQuery(config Config, args args) (ledger.Like, error) {
|
|||||||
switch args.peek() {
|
switch args.peek() {
|
||||||
case "and":
|
case "and":
|
||||||
args.pop()
|
args.pop()
|
||||||
var like ledger.Like
|
var and ledger.Like
|
||||||
switch args.peek() {
|
switch args.peek() {
|
||||||
case "not":
|
case "not":
|
||||||
args.pop()
|
args.pop()
|
||||||
log.Println("and not", args.peek())
|
log.Println("and not", args.peek())
|
||||||
like = notLike(likeName(args.pop()))
|
and = notLike(likeName(args.pop()))
|
||||||
default:
|
default:
|
||||||
log.Println("and ", args.peek())
|
log.Println("and ", args.peek())
|
||||||
like = likeName(args.pop())
|
and = likeName(args.pop())
|
||||||
}
|
}
|
||||||
like = andLike(like, like)
|
like = andLike(like, and)
|
||||||
case "not":
|
case "not":
|
||||||
args.pop()
|
args.pop()
|
||||||
log.Println("or not ", args.peek())
|
log.Println("or not ", args.peek())
|
||||||
|
|||||||
Reference in New Issue
Block a user