models

package
v0.0.0-...-0ad7c06 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bank       AccountType = 1 // start at 1 so that the default (0) is invalid
	Cash                   = 2
	Asset                  = 3
	Liability              = 4
	Investment             = 5
	Income                 = 6
	Expense                = 7
	Trading                = 8
	Equity                 = 9
	Receivable             = 10
	Payable                = 11
)
View Source
const (
	Imported   int64 = 1
	Entered          = 2
	Cleared          = 3
	Reconciled       = 4
	Voided           = 5
)

Split.Status

View Source
const (
	Default         int64 = 0
	ImportAccount         = 1 // This split belongs to the main account being imported
	SubAccount            = 2 // This split belongs to a sub-account of that being imported
	ExternalAccount       = 3
	TradingAccount        = 4
	Commission            = 5
	Taxes                 = 6
	Fees                  = 7
	Load                  = 8
	IncomeAccount         = 9
	ExpenseAccount        = 10
)

Split.ImportSplitType

View Source
const BogusPassword = "password"
View Source
const LuaMaxLength int = 65536

The maximum length (in bytes) the Lua code may be. This is used to set the max size of the database columns (with an added fudge factor)

View Source
const MaxPrecision uint64 = 15

MaxPrexision denotes the maximum valid value for Security.Precision

Variables

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountId         int64
	ExternalAccountId string
	UserId            int64
	SecurityId        int64
	ParentAccountId   int64 // -1 if this account is at the root
	Type              AccountType
	Name              string

	// monotonically-increasing account transaction version number. Used for
	// allowing a client to ensure they have a consistent version when paging
	// through transactions.
	AccountVersion int64 `json:"Version"`

	// Optional fields specifying how to fetch transactions from a bank via OFX
	OFXURL       string
	OFXORG       string
	OFXFID       string
	OFXUser      string
	OFXBankID    string // OFX BankID (BrokerID if AcctType == Investment)
	OFXAcctID    string
	OFXAcctType  string // ofxgo.acctType
	OFXClientUID string
	OFXAppID     string
	OFXAppVer    string
	OFXVersion   string
	OFXNoIndent  bool
}

func (*Account) Read

func (a *Account) Read(json_str string) error

func (*Account) Write

func (a *Account) Write(w http.ResponseWriter) error

type AccountList

type AccountList struct {
	Accounts *[]*Account `json:"accounts"`
}

func (*AccountList) Read

func (al *AccountList) Read(json_str string) error

func (*AccountList) Write

func (al *AccountList) Write(w http.ResponseWriter) error

type AccountTransactionsList

type AccountTransactionsList struct {
	Account           *Account
	Transactions      *[]*Transaction
	TotalTransactions int64
	BeginningBalance  Amount
	EndingBalance     Amount
}

func (*AccountTransactionsList) Read

func (atl *AccountTransactionsList) Read(json_str string) error

func (*AccountTransactionsList) Write

type AccountType

type AccountType int64

func (AccountType) String

func (t AccountType) String() string

type Amount

type Amount struct {
	big.Rat
}

func (Amount) Fractional

func (amount Amount) Fractional(precision uint64) (int64, error)

Fractional returns the fractional portion of the Amount, multiplied by 10^precision

func (*Amount) FromParts

func (amount *Amount) FromParts(whole, fractional int64, precision uint64)

FromParts re-assembles an Amount from the results from previous calls to Whole and Fractional

func (Amount) MarshalJSON

func (amount Amount) MarshalJSON() ([]byte, error)

func (Amount) Precision

func (amount Amount) Precision() uint64

Precision returns the minimum positive integer p such that if you multiplied this Amount by 10^p, it would become an integer

func (*Amount) Round

func (amount *Amount) Round(precision uint64)

Round rounds the given Amount to the given precision

func (Amount) String

func (amount Amount) String() string

func (*Amount) UnmarshalJSON

func (amount *Amount) UnmarshalJSON(bytes []byte) error

func (Amount) Whole

func (amount Amount) Whole() (int64, error)

Whole returns the integral portion of the Amount

type PrecisionError

type PrecisionError struct {
	// contains filtered or unexported fields
}

func (PrecisionError) Error

func (p PrecisionError) Error() string

type Price

type Price struct {
	PriceId    int64
	SecurityId int64
	CurrencyId int64
	Date       time.Time
	Value      Amount // price of Security in Currency units
	RemoteId   string // unique ID from source, for detecting duplicates
}

func (*Price) Read

func (p *Price) Read(json_str string) error

func (*Price) Write

func (p *Price) Write(w http.ResponseWriter) error

type PriceList

type PriceList struct {
	Prices *[]*Price `json:"prices"`
}

func (*PriceList) Read

func (pl *PriceList) Read(json_str string) error

func (*PriceList) Write

func (pl *PriceList) Write(w http.ResponseWriter) error

type Report

type Report struct {
	ReportId int64
	UserId   int64
	Name     string
	Lua      string
}

func (*Report) Read

func (r *Report) Read(json_str string) error

func (*Report) Write

func (r *Report) Write(w http.ResponseWriter) error

type ReportList

type ReportList struct {
	Reports *[]*Report `json:"reports"`
}

func (*ReportList) Read

func (rl *ReportList) Read(json_str string) error

func (*ReportList) Write

func (rl *ReportList) Write(w http.ResponseWriter) error

type Security

type Security struct {
	SecurityId  int64
	UserId      int64
	Name        string
	Description string
	Symbol      string
	// Number of decimal digits (to the right of the decimal point) this
	// security is precise to
	Precision uint64 `db:"Preciseness"`
	Type      SecurityType
	// AlternateId is CUSIP for Type=Stock, ISO4217 for Type=Currency
	AlternateId string
}

func (*Security) Read

func (s *Security) Read(json_str string) error

func (*Security) Write

func (s *Security) Write(w http.ResponseWriter) error

type SecurityList

type SecurityList struct {
	Securities *[]*Security `json:"securities"`
}

func (*SecurityList) Read

func (sl *SecurityList) Read(json_str string) error

func (*SecurityList) Write

func (sl *SecurityList) Write(w http.ResponseWriter) error

type SecurityType

type SecurityType int64
const (
	Currency SecurityType = 1
	Stock                 = 2
)

func GetSecurityType

func GetSecurityType(typestring string) SecurityType

type Series

type Series struct {
	Values []float64
	Series map[string]*Series
}

type Session

type Session struct {
	SessionId     int64
	SessionSecret string `json:"-"`
	UserId        int64
	Created       time.Time
	Expires       time.Time
}

func NewSession

func NewSession(userid int64) (*Session, error)

func (*Session) Cookie

func (s *Session) Cookie(domain string) *http.Cookie

func (*Session) Read

func (s *Session) Read(json_str string) error

func (*Session) Write

func (s *Session) Write(w http.ResponseWriter) error

type Split

type Split struct {
	SplitId         int64
	TransactionId   int64
	Status          int64
	ImportSplitType int64

	// One of AccountId and SecurityId must be -1
	// In normal splits, AccountId will be valid and SecurityId will be -1. The
	// only case where this is reversed is for transactions that have been
	// imported and not yet associated with an account.
	AccountId  int64
	SecurityId int64

	RemoteId string // unique ID from server, for detecting duplicates
	Number   string // Check or reference number
	Memo     string
	Amount   Amount
}

func (*Split) Valid

func (s *Split) Valid() bool

type Tabulation

type Tabulation struct {
	ReportId int64
	Title    string
	Subtitle string
	Units    string
	Labels   []string
	Series   map[string]*Series
}

func (*Tabulation) Read

func (t *Tabulation) Read(json_str string) error

func (*Tabulation) Write

func (t *Tabulation) Write(w http.ResponseWriter) error

type Transaction

type Transaction struct {
	TransactionId int64
	UserId        int64
	Description   string
	Date          time.Time
	Splits        []*Split `db:"-"`
}

func (*Transaction) Read

func (t *Transaction) Read(json_str string) error

func (*Transaction) Valid

func (t *Transaction) Valid() bool

func (*Transaction) Write

func (t *Transaction) Write(w http.ResponseWriter) error

type TransactionList

type TransactionList struct {
	Transactions *[]*Transaction `json:"transactions"`
}

func (*TransactionList) Read

func (tl *TransactionList) Read(json_str string) error

func (*TransactionList) Write

type User

type User struct {
	UserId          int64
	DefaultCurrency int64 // SecurityId of default currency, or ISO4217 code for it if creating new user
	Name            string
	Username        string
	Password        string `db:"-"`
	PasswordHash    string `json:"-"`
	Email           string
}

func (*User) HashPassword

func (u *User) HashPassword()

func (*User) Read

func (u *User) Read(json_str string) error

func (*User) Write

func (u *User) Write(w http.ResponseWriter) error

Jump to

Keyboard shortcuts

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