model

package
v0.0.0-...-1fcc497 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvMarketConverter

func InvMarketConverter(market, typ string) (string, string)

func MarketConverter

func MarketConverter(market, typ string) (string, string)

Types

type Account

type Account struct {
	Name         string
	Balance      float64
	CostBase     float64
	Transactions []LineItem
}

func NewAccount

func NewAccount(name string) *Account

func (*Account) Credit

func (a *Account) Credit(date time.Time, amount float64, w io.Writer) (float64, float64, float64)

Takes a date and an amount to credit, returns the total cost base, the units sold that were over a year old and the cost base amount of those units

func (*Account) Debit

func (a *Account) Debit(date time.Time, amount, unitprice, costbase float64)

Amount of commodity to add to account and the total AUD cost of the

func (*Account) Recalculate

func (a *Account) Recalculate()

func (*Account) Revalue

func (a *Account) Revalue(price float64) float64

func (*Account) SortTxns

func (a *Account) SortTxns()

type LineItem

type LineItem struct {
	Date      time.Time
	Amount    float64
	UnitPrice float64
	CostBase  float64
}

type Model

type Model struct {
	GainsDB cgtdb.Database
	Pricer  prices.Pricer
	Config  *config.Config

	Nonce int
	Txns  []Transaction
	Files []string

	Accounts map[string]*Account

	CapitalGains             float64
	DiscountAvailableCGTGain float64
	TradingGains             float64
	UnrealisedGains          float64
	StartDate                time.Time
	EndDate                  time.Time
}

func NewModel

func NewModel(gainsDB, priceDB cgtdb.Database, cfg *config.Config) *Model

func (*Model) AddSingleTxn

func (m *Model) AddSingleTxn(txn Transaction) error

func (*Model) AddTxns

func (m *Model) AddTxns(txns []Transaction) error

func (*Model) Checksum

func (m *Model) Checksum(filename string) bool

func (*Model) Close

func (m *Model) Close() error

func (*Model) Commit

func (m *Model) Commit() error

func (*Model) GetNonce

func (m *Model) GetNonce() int

func (*Model) ProcessModel

func (m *Model) ProcessModel()

func (*Model) Revalue

func (m *Model) Revalue(date time.Time) float64

func (*Model) SortTxns

func (m *Model) SortTxns()

func (*Model) UpdateNonces

func (m *Model) UpdateNonces()

type Transaction

type Transaction struct {
	Date                     time.Time
	Exchange                 string
	ExchangeID               string
	BaseCurrency             string
	BaseSpent                float64
	QuoteCurrency            string
	QuoteReceived            float64
	Proceeds                 float64
	CostBase                 float64
	TradingCostBase          float64
	Gain                     float64
	TradingGain              float64
	DiscountAvailableCGTGain float64
	Trace                    []byte
	Nonce                    int
}

func NewTransaction

func NewTransaction(date, buycurrency, buyamount, sellcurrency, sellamount string) *Transaction

func NewTransactionShortDate

func NewTransactionShortDate(date, buycurrency, buyamount, sellcurrency, sellamount string) *Transaction

Jump to

Keyboard shortcuts

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