business logic out of main
This commit is contained in:
@@ -55,9 +55,7 @@ func main() {
|
||||
for k, v := range deltas.Balances() {
|
||||
results := []string{}
|
||||
for subk, subv := range v {
|
||||
if int(subv) != 0 {
|
||||
results = append(results, fmt.Sprintf("%s %.2f", subk, subv))
|
||||
}
|
||||
results = append(results, fmt.Sprintf("%s %.2f", subk, subv))
|
||||
}
|
||||
if len(results) > 0 {
|
||||
fmt.Printf("%s\t%s\n", k, strings.Join(results, " + "))
|
||||
|
||||
@@ -46,6 +46,9 @@ func (deltas Deltas) Balances() Balances {
|
||||
result[delta.Name][delta.Currency] = 0
|
||||
}
|
||||
result[delta.Name][delta.Currency] += delta.Value
|
||||
if result[delta.Name][delta.Currency] < 0.0000001 {
|
||||
delete(result[delta.Name], delta.Currency)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user