func ComputeBalance(transactions Transactions) Amount {
	amount := decimal.NewFromFloat(0)
	for _, t := range transactions {
		amount = amount.Add(t.Amount)
	}
	return amount
}
ComputeBalance computes the overall balance over all transactions.
package main
import (
	"fmt"
	"log"
	"time"
	"github.com/shopspring/decimal"
)
type Transaction struct {
	Description string    `json:"description"`
	Timestamp   time.Time `json:"timestamp"`
	Amount      Amount    `json:"amount"`
}
type Budget struct {
	Balance       Amount `json:"balance"`
	Daily         Amount `json:"daily"`
	RemainingDays int    `json:"remainingDays"`
}
type Amount = decimal.Decimal
type Transactions = []Transaction
func (t Transaction) String() string {
	return fmt.Sprintf("(%v) %-10v %v",
		t.Timestamp.Format("2006-01-02 15:04:05"), t.Description, t.Amount)
}
func NewTransaction(description string, amount string) Transaction {
	log.Println("New transaction", description, amount)
	d, err := decimal.NewFromString(amount)
	if err != nil {
		log.Fatal("Unable to parse amount as decimal", err)
	}
	return Transaction{description, Time(), d}
}