hide zeros only in bal
parent
d093db1a2b
commit
757afa603e
|
|
@ -97,7 +97,7 @@ func Main() {
|
||||||
transactions := deltas.Transactions()
|
transactions := deltas.Transactions()
|
||||||
|
|
||||||
for i, transaction := range transactions {
|
for i, transaction := range transactions {
|
||||||
balances := ledger.Deltas(transaction).Like(q).Group(group).Balances().WithBPIs(bpis)
|
balances := ledger.Deltas(transaction).Like(q).Group(group).Balances().WithBPIs(bpis).Nonzero()
|
||||||
shouldPrint := false
|
shouldPrint := false
|
||||||
shouldPrint = shouldPrint || len(balances) > 2
|
shouldPrint = shouldPrint || len(balances) > 2
|
||||||
if config.Query.NoExchanging {
|
if config.Query.NoExchanging {
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,7 @@ func (deltas Deltas) Balances() Balances {
|
||||||
}
|
}
|
||||||
result[delta.Name][delta.Currency] += delta.Value
|
result[delta.Name][delta.Currency] += delta.Value
|
||||||
if result[delta.Name][delta.Currency] < 0.000000001 && result[delta.Name][delta.Currency] > -0.000000001 {
|
if result[delta.Name][delta.Currency] < 0.000000001 && result[delta.Name][delta.Currency] > -0.000000001 {
|
||||||
delete(result[delta.Name], delta.Currency)
|
result[delta.Name][delta.Currency] = 0
|
||||||
if len(result[delta.Name]) == 0 {
|
|
||||||
delete(result, delta.Name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,12 @@ func TestDeltas(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
balances := deltas.Balances()
|
balances := deltas.Balances()
|
||||||
if len(balances) != 1 {
|
if len(balances) != 2 {
|
||||||
t.Error(len(balances), balances)
|
t.Error(len(balances), balances)
|
||||||
}
|
}
|
||||||
|
if balances["a"][""] != 0 {
|
||||||
|
t.Error(balances["a"])
|
||||||
|
}
|
||||||
if balances["b"][""] != 1.3 {
|
if balances["b"][""] != 1.3 {
|
||||||
t.Error(balances["b"])
|
t.Error(balances["b"])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue