37 lines
517 B
Go
37 lines
517 B
Go
package ledger
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type Currency string
|
|
|
|
const (
|
|
USD = Currency("$")
|
|
)
|
|
|
|
type Delta struct {
|
|
Date time.Time
|
|
Account string
|
|
Value float64
|
|
Currency Currency
|
|
}
|
|
|
|
func newDelta(d time.Time, a string, v float64) Delta {
|
|
return Delta{
|
|
Date: d,
|
|
Account: a,
|
|
Value: v,
|
|
Currency: USD, // TODO
|
|
}
|
|
}
|
|
|
|
func (delta Delta) Plus(other Delta) Delta {
|
|
return Delta{
|
|
Date: other.Date,
|
|
Account: delta.Account,
|
|
Value: delta.Value + other.Value,
|
|
Currency: other.Currency,
|
|
}
|
|
}
|