rules

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rule

type Rule interface {
	Match(ledger.Transaction) bool
	Apply(*ledger.Transaction)
}

Rule can match a transaction and apply a transformation to it

func NewCSVRule

func NewCSVRule(account1, account2, comment string, conditions ...string) (Rule, error)

type Rules

type Rules []Rule

Rules enables transformation of transactions across multiple, sequential rules

func NewCSVRulesFromReader

func NewCSVRulesFromReader(reader io.Reader) (Rules, error)

func (Rules) Apply

func (r Rules) Apply(txn *ledger.Transaction)

Apply runs a match and subsequent apply for each rule on the given transaction

func (Rules) String

func (r Rules) String() string

func (*Rules) UnmarshalJSON added in v0.3.0

func (r *Rules) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the given bytes into rules

type Store added in v0.3.0

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

Store enables manipulation of rules in memory

func NewStore added in v0.3.0

func NewStore(rules Rules) *Store

NewStore creates a rules store from the given rules

func (*Store) Accounts added in v0.4.0

func (s *Store) Accounts() []string

Accounts returns account names (account2) for any CSV rules

func (*Store) Apply added in v0.3.0

func (s *Store) Apply(txn *ledger.Transaction)

Apply transforms the given transaction based on the current rules

func (*Store) ApplyAll added in v0.3.0

func (s *Store) ApplyAll(txns []ledger.Transaction)

ApplyAll transforms the given transactions based on the current rules

func (*Store) MarshalJSON added in v0.3.0

func (s *Store) MarshalJSON() ([]byte, error)

MarshalJSON returns JSON-encoded rules

func (*Store) Replace added in v0.3.0

func (s *Store) Replace(newRules Rules)

Replace replaces the current rules with newRules

func (*Store) String added in v0.3.0

func (s *Store) String() string

Jump to

Keyboard shortcuts

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