package ledger import "errors" // ErrShortBalance is returned when a posting would drive the balance negative. var ErrShortBalance = errors.New("ledger: insufficient balance") // Apply posts one delta against the running balance and returns the new total. func Apply(balance, delta int64) (int64, error) { if balance+delta < 0 { return balance, ErrShortBalance } return balance + delta, nil }