budgeteer/postgres/numeric.go

27 lines
399 B
Go

package postgres
import "github.com/jackc/pgtype"
type Numeric struct {
pgtype.Numeric
}
func (n Numeric) GetFloat64() float64 {
var balance float64
err := n.AssignTo(&balance)
if err != nil {
panic(err)
}
return balance
}
func (n Numeric) GetPositive() bool {
float := n.GetFloat64()
return float >= 0
}
func (n Numeric) IsZero() bool {
float := n.GetFloat64()
return float == 0
}