Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type Bill
- func (b *Bill) BalanceByUser() map[UserID]MoneyRat
- func (b *Bill) CreditByUser() map[UserID]MoneyRat
- func (b *Bill) DebitByUser() map[UserID]MoneyRat
- func (b *Bill) GetSchemaVersion() int
- func (b *Bill) ToInvoices() ([]Invoice, error)
- func (b *Bill) TotalPayment() Money
- func (b *Bill) TotalPrice() Money
- func (b *Bill) Validate() error
- type BillID
- type BillItem
- type BillPayment
- type BillShare
- type Invoice
- type Money
- type MoneyRat
- type NetKind
- type User
- type UserID
Constants ¶
View Source
const (
CurrentBillSchemaVersion = 1
)
View Source
const (
MoneyPrecision = 2
)
Variables ¶
View Source
var ( ErrDiscrepancy = errors.New("total price and total payments must be equal") ErrInternalAssertion = errors.New("internal assertion") )
View Source
var ( ErrZeroQuantity = errors.New("quantity is zero") )
View Source
var (
ErrBalanceNotZero = errors.New("balance isn't zero")
)
View Source
var (
ErrMoneyPrecision = errors.Errorf("target's exponent greater then %d", MoneyPrecision)
)
Functions ¶
This section is empty.
Types ¶
type Bill ¶
type Bill struct { ID BillID `json:"-"` Items []BillItem `json:",omitempty"` Payments []BillPayment `json:",omitempty"` }
func (*Bill) BalanceByUser ¶
func (*Bill) CreditByUser ¶
func (*Bill) DebitByUser ¶
func (*Bill) GetSchemaVersion ¶
func (*Bill) ToInvoices ¶
func (*Bill) TotalPayment ¶
func (*Bill) TotalPrice ¶
type BillItem ¶
func (*BillItem) SharePricesByUser ¶
func (*BillItem) SimplifyShares ¶
func (bi *BillItem) SimplifyShares()
func (*BillItem) TotalPrice ¶
func (*BillItem) TotalShare ¶
type BillPayment ¶
func (*BillPayment) Validate ¶
func (bp *BillPayment) Validate() error
type Invoice ¶
func FixInvocesTotal ¶
type Money ¶
Деньги для БД. Конечный результат цепочки вычислений. То, сколько нужно пересести. Рациональное число может быть не выразимо в десятичной системе счисления. Если требуется отдать 100/3 рублей, то в decimal это 33.33 и 0.00(3) - невязка.
func InvoicesTotal ¶
func NewMoneyFromBig ¶
type MoneyRat ¶
Тип для вычисления с деньгами. Абсолютная точность в операциях. https://github.com/nethruster/go-fraction
func NewMoneyRat ¶
func NewMoneyRat() MoneyRat
Click to show internal directories.
Click to hide internal directories.