account

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Types is an array with the ordered accont types.

Functions

func Compare

func Compare(a1, a2 *Account) compare.Order

func Remap

func Remap(reg *Registry, rs regex.Regexes) mapper.Mapper[*Account]

func Shorten

func Shorten(reg *Registry, m Mapping) mapper.Mapper[*Account]

Types

type Account

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

Account represents an account which can be used in bookings.

func (Account) IsAL

func (a Account) IsAL() bool

IsAL returns whether this account is an asset or liability account.

func (Account) IsIE

func (a Account) IsIE() bool

IsIE returns whether this account is an income or expense account.

func (Account) Level

func (a Account) Level() int

func (Account) Name

func (a Account) Name() string

Name returns the name of this account.

func (*Account) Segments

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

Segments returns the account name split into segments.

func (Account) String

func (a Account) String() string

func (Account) Type

func (a Account) Type() Type

Type returns the account type.

type Mapping

type Mapping []Rule

Mapping is a set of mapping rules.

func (Mapping) Level

func (m Mapping) Level(s string) (int, int, bool)

Level returns the Level to which an account should be shortened.

func (Mapping) String

func (m Mapping) String() string

type Registry

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

Registry is a thread-safe collection of accounts.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new thread-safe collection of accounts.

func (*Registry) Create

func (as *Registry) Create(a syntax.Account) (*Account, error)

func (*Registry) Get

func (as *Registry) Get(name string) (*Account, error)

Get returns an account.

func (*Registry) GetPath

func (as *Registry) GetPath(segments []string) (*Account, error)

Get returns an account.

func (*Registry) MustGet

func (as *Registry) MustGet(name string) *Account

func (*Registry) MustGetPath

func (as *Registry) MustGetPath(ss []string) *Account

func (*Registry) SwapType

func (as *Registry) SwapType(a *Account) *Account

func (*Registry) TBDAccount

func (as *Registry) TBDAccount() *Account

TBDAccount returns the TBD account.

func (*Registry) ValuationAccountFor

func (as *Registry) ValuationAccountFor(a *Account) *Account

ValuationAccountFor returns the valuation account which corresponds to the given Asset or Liability account.

type Rule

type Rule struct {
	Level  int
	Suffix int
	Regex  *regexp.Regexp
}

Rule is a rule to shorten accounts which match the given regex.

func (Rule) Match

func (rule Rule) Match(s string) (int, int, bool)

func (Rule) String

func (rule Rule) String() string

type Type

type Type int

Type is the type of an account.

const (
	// ASSETS represents an asset account.
	ASSETS Type = iota
	// LIABILITIES represents a liability account.
	LIABILITIES
	// EQUITY represents an equity account.
	EQUITY
	// INCOME represents an income account.
	INCOME
	// EXPENSES represents an expenses account.
	EXPENSES
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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