business logic out of main

This commit is contained in:
Bel LaPointe
2023-10-25 07:55:59 -06:00
parent 9e613f3a1b
commit e80721ee91
2 changed files with 4 additions and 3 deletions

View File

@@ -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, " + "))

View File

@@ -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