core

package
v0.0.0-...-45cad10 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLotName = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name         string
	CreationDate Date
	ClosingDate  Date
	Commodities  map[string]*Commodity
	Lots         map[string]map[string]*Lot // lot name -> commodity name -> *Lot
	Tags         map[string]bool
	Notes        map[string]string
}

func NewAccount

func NewAccount(name string, creationDate Date) *Account

func (*Account) AddTag

func (a *Account) AddTag(tag string)

func (*Account) GetTags

func (a *Account) GetTags() []string

func (*Account) HasTag

func (a *Account) HasTag(tag string) bool

func (*Account) IsClosed

func (a *Account) IsClosed(date Date) bool

func (*Account) RemoveTag

func (a *Account) RemoveTag(tag string)

type Commodity

type Commodity struct {
	Name         string
	Description  string
	CreationDate Date
	Tags         map[string]bool
}

func NewCommodity

func NewCommodity(name, description string, creationDate Date) *Commodity

func (*Commodity) AddTag

func (c *Commodity) AddTag(tag string)

func (*Commodity) GetTags

func (c *Commodity) GetTags() []string

func (*Commodity) HasTag

func (c *Commodity) HasTag(tag string) bool

func (*Commodity) RemoveTag

func (c *Commodity) RemoveTag(tag string)

func (Commodity) String

func (c Commodity) String() string

type Context

type Context struct {
	Date        Date
	Accounts    map[string]*Account
	Commodities map[string]*Commodity
	Tags        map[string][]TagTarget
}

func NewContext

func NewContext() *Context

type Date

type Date struct {
	Year  int
	Month int
	Day   int
}

func FromTime

func FromTime(t time.Time) Date

func ParseDate

func ParseDate(s string) (Date, error)

func (Date) After

func (d Date) After(u Date) bool

func (Date) Before

func (d Date) Before(u Date) bool

func (Date) BeforeOrEqual

func (d Date) BeforeOrEqual(u Date) bool

func (Date) Equal

func (d Date) Equal(u Date) bool

func (Date) EqualOrAfter

func (d Date) EqualOrAfter(u Date) bool

func (Date) IsZero

func (d Date) IsZero() bool

func (Date) String

func (d Date) String() string

func (Date) ToTime

func (d Date) ToTime() time.Time

type ExchangeRate

type ExchangeRate struct {
	UnitPrice  Quantity
	TotalPrice Quantity
}

func NewExchangeRateFromTotalPrice

func NewExchangeRateFromTotalPrice(balance, totalPrice Quantity) ExchangeRate

func NewExchangeRateFromUnitPrice

func NewExchangeRateFromUnitPrice(balance, unitPrice Quantity) ExchangeRate

type Lot

type Lot struct {
	Name         string
	CreationDate Date
	Balance      Quantity
	ExchangeRate *ExchangeRate
}

type Quantity

type Quantity struct {
	Commodity *Commodity
	Amount    decimal.Decimal
}

func (Quantity) String

func (q Quantity) String() string

type TagTarget

type TagTarget interface {
	AddTag(string)
	GetTags() []string
	HasTag(string) bool
	RemoveTag(string)
}

Jump to

Keyboard shortcuts

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