splitcore

package
v0.0.0-...-d5421df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DistributionStrategyEqual = distributionStrategyEqual{}
View Source
var RoundingDigitCount = 4

Functions

This section is empty.

Types

type Amount

type Amount float64

func Round

func Round(amount Amount) Amount

func (Amount) Equals

func (a Amount) Equals(b Amount) bool

type Balances

type Balances map[ID]Amount

type Bill

type Bill struct {
	ID
	DistributionStrategy
	Date   time.Time
	PaidBy map[ID]Amount
}

func (Bill) TotalAmount

func (bill Bill) TotalAmount() Amount

type Bills

type Bills []Bill

type DistributionStrategy

type DistributionStrategy interface {
	GetBalances(group *Group, bill Bill) Balances
}

type DistributionStrategyPercentage

type DistributionStrategyPercentage map[ID]float64

func (DistributionStrategyPercentage) GetBalances

func (d DistributionStrategyPercentage) GetBalances(group *Group, bill Bill) Balances

type DistributionStrategyShares

type DistributionStrategyShares map[ID]int

func (DistributionStrategyShares) GetBalances

func (d DistributionStrategyShares) GetBalances(group *Group, bill Bill) Balances

type Group

type Group struct {
	Bills
	Members
	Transactions
	Balances
}

func NewGroup

func NewGroup(members Members) *Group

func (*Group) AddBill

func (grp *Group) AddBill(bill Bill)

func (*Group) AddMember

func (grp *Group) AddMember(member Member)

func (*Group) AddPayment

func (grp *Group) AddPayment(transaction Transaction)

func (*Group) CalculateTransactions

func (grp *Group) CalculateTransactions() Transactions

func (*Group) GetBalancesForBill

func (grp *Group) GetBalancesForBill(bill Bill) Balances

func (*Group) RemoveBill

func (grp *Group) RemoveBill(billID ID)

func (*Group) RemoveMember

func (grp *Group) RemoveMember(memberID ID)

func (*Group) RemovePayment

func (grp *Group) RemovePayment(paymentID ID)

type History

type History struct {
	Received Transactions
	Sent     Transactions
}

type ID

type ID string

type IDs

type IDs []ID

type Member

type Member struct {
	ID
	History
}

type Members

type Members []Member

type Transaction

type Transaction struct {
	ID
	By ID
	To ID
	Amount
}

func (Transaction) String

func (t Transaction) String() string

type Transactions

type Transactions []Transaction

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL