Documentation ¶
Index ¶
- Variables
- type Rule
- type Rules
- type Store
- func (s *Store) Accounts() []string
- func (s *Store) Add(rule Rule) (newRuleIndex int)
- func (s *Store) Apply(txn *ledger.Transaction)
- func (s *Store) ApplyAll(txns []ledger.Transaction)
- func (s *Store) Get(index int) (Rule, error)
- func (s *Store) MarshalJSON() ([]byte, error)
- func (s *Store) Matches(txn *ledger.Transaction) map[int]Rule
- func (s *Store) Remove(index int) error
- func (s *Store) Replace(newRules Rules)
- func (s *Store) String() string
- func (s *Store) Update(index int, rule Rule) error
Constants ¶
This section is empty.
Variables ¶
var ( // Default is the set of rules applied to incoming transaction, always Default = Rules{ category{Negative: true, Category: "expenses:uncategorized"}, category{ PayeeContains: containsPattern( "'s", ".*vend.*", "airport", "american", "bagels?", "bakery", "bar", "barbecue", "bbq", "bean", "beverage", "bistro", "bowl", "burger.*", "cafe", "caffe", "candy", "catering", "chicken", "coffee", "coffeehouse", "cola", "counter", "cream", "crepe", "cuisine", "custard", "deli", "diner", "donuts?", "drive", "food", "french", "gelato", "gourmet", "grill", "house", "indian", "italian", "japanese", "juice", "kitchen", "lunch.*", "market", "noodle", "pasta", "pie", "pies", "pizza", "pizzeria", "pot", "ramen", "restaurant", "rice", "sandwich", "shake", "shop", "snack", "soda", "soup", "spot", "stand", "sushi", "taco", "thai", "tortilla", ), Negative: true, Category: "expenses:shopping:food:restaurants", }, category{Positive: true, Category: "revenues:uncategorized"}, category{ PayeeContains: containsPattern( "autodiv", "dividend", "int", "interest", ), Positive: true, Category: "revenues:interest", }, category{ PayeeContains: containsPattern( "check", "deposit", ), Positive: true, Category: "revenues:deposits", }, category{ PayeeContains: containsPattern( "transfer", "wire", ), Category: "expenses:transfers", }, category{ PayeeContains: containsPattern( "irs", "us treasury", ), Positive: true, Category: "revenues:tax returns", }, category{ PayeeContains: containsPattern( "dental", "optometrist", "medical", ), Negative: true, Category: "expenses:health", }, category{ PayeeContains: containsPattern( "city", "grande", "spectrum", "comcast", ), Negative: true, Category: "expenses:home:utilities", }, category{ PayeeContains: containsPattern( ".*\\.com?", "amazon", "amzn", "barnes.*noble", "books?", "cvs", "e-commerce", "gift", "hallmark", "ikea", "photo.*", "sq \\*", "staples", "walgreens", ), Negative: true, Category: "expenses:shopping", }, category{ PayeeContains: containsPattern( "apple", "best buy", "computers?", "dell", "drop", "electronics", "fry's", "gamestop", "massdrop", "newegg.com", "software", "steamgames.com", "steampowered.com", "texas instruments", ), Negative: true, Category: "expenses:shopping:electronics", }, category{ PayeeContains: containsPattern( "apple music", "audible", "codeschool.com", "godaddy.com", "itunes.com/bill", "membership", "name-cheap.com", "pandora", "spotify", "subscriptions?", ), Negative: true, Category: "expenses:shopping:subscriptions", }, category{ PayeeContains: containsPattern( "7-eleven", "chevron", "exxon.*", "shell", ), Negative: true, Category: "expenses:car:gas", }, category{ PayeeContains: containsPattern( "vehreg", "dps", ), Negative: true, Category: "expenses:car:registration", }, category{ PayeeContains: containsPattern( "autopay", "directpay", "e-?payment", "internet payment", ), Category: "expenses:transfers:credit card payments", }, category{ PayeeContains: containsPattern( "alamo", "amc", "cinema", "cinemark", "conv center", "fandango.com", "fgt\\*", "stubhub", "ticketfly", "tickets?", ), Negative: true, Category: "expenses:concerts and shows", }, category{ PayeeContains: containsPattern( "heb", "h-e-b", "wal-mart", "supercenter", "wholefds", "mart", "market", "safeway", "grocer", "liquor", ), Negative: true, Category: "expenses:shopping:food:groceries", }, } )
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
type Rules ¶
type Rules []Rule
Rules enables transformation of transactions across multiple, sequential rules
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) Matches ¶ added in v0.8.0
func (r Rules) Matches(txn *ledger.Transaction) map[int]Rule
Matches returns matching rules
func (*Rules) UnmarshalJSON ¶ added in v0.3.0
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 (*Store) Accounts ¶ added in v0.4.0
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 and the default rules. Custom rules take precedence to default rules.
func (*Store) MarshalJSON ¶ added in v0.3.0
MarshalJSON returns JSON-encoded rules
func (*Store) Matches ¶ added in v0.8.0
func (s *Store) Matches(txn *ledger.Transaction) map[int]Rule
Matches returns matching rules