aggregators

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package aggregators contains aggregators of fin.Entry and fin.CatPayment values. Each aggregator has an Include method and can be easily converted to a consumer via the appropriate method in the consumers package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoCompleteAggregator

type AutoCompleteAggregator struct {
	str_util.AutoComplete
	// The field on which to find auto complete candidates
	Field func(e *fin.Entry) string
}

AutoCompleteAggregator makes list of auto complete candidates.

func (*AutoCompleteAggregator) Include

func (a *AutoCompleteAggregator) Include(e *fin.Entry)

type ByNameCategorizerBuilder

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

ByNameCategorizerBuilder builds a Categorizer that assigns categories based on the name in the entry. Feed a ByNameCategorizerBuilder entries from most recent to least recent to train it to create a Categorizer.

func NewByNameCategorizerBuilder

func NewByNameCategorizerBuilder(n, k int) *ByNameCategorizerBuilder

The created object looks at the latest n entries with a similar name. If k of those entries have the same category then new entries with similar name get assigned that category. NewByNameCategorizerBuilder panics if n < k or k < 1.

func (*ByNameCategorizerBuilder) Build

Build returns a Categorizer based on Entries it has observed so far.

func (*ByNameCategorizerBuilder) Include

func (b *ByNameCategorizerBuilder) Include(entry *fin.Entry)

Include trains this instance with a particular entry.

type ByPeriodTotaler

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

ByPeriodTotaler sums totals by period

func NewByPeriodTotaler

func NewByPeriodTotaler(start, end time.Time, recurring Recurring) *ByPeriodTotaler

NewByPeriodTotaler creates a new ByPeriodTotaler that collects statistics for transactions happening between start inclusive and end exclusive. The recurring perameter indicates the recurring period such as monthly or yearly.

func (*ByPeriodTotaler) Include

func (b *ByPeriodTotaler) Include(entry *fin.Entry)

func (*ByPeriodTotaler) Iterator

func (b *ByPeriodTotaler) Iterator() *PeriodTotalIterator

Iterator is used to get the totals by period.

type Categorizer

type Categorizer interface {
	// Assigns a category to entry modifying it in-place.
	// If it can't pick a category for entry, it sets the category to
	// fin.Expense. Returns true if it set the category or false otherwise.
	Categorize(entry *fin.Entry) bool
}

Interface Categorizer assigns categories to entries just added from a bank statement.

type PeriodTotal

type PeriodTotal struct {
	// The start of the period
	PeriodStart time.Time
	// The actual start inclusive. May differ from PeriodStart if this record
	// covers a partial period
	Start time.Time
	// The end exclusive. May differ from start of next period if this record
	// covers a partial period.
	End time.Time
	// The total for the period.
	Total int64
}

PeriodTotal contains the total of all transactions for a given period.

type PeriodTotalIterator

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

PeriodTotalIterator iterates over period totals.

func (*PeriodTotalIterator) Next

func (pti *PeriodTotalIterator) Next(p *PeriodTotal) bool

Next stores the next period total at p and returns true. If there is no next period total, Next returns false.

type Recurring

type Recurring interface {
	// Normalize returns the beginning of a time period for a given time
	Normalize(t time.Time) time.Time
	// Add returns the result of adding numPeriods time periods to a start time
	Add(t time.Time, numPeriods int) time.Time
}

Recurring is the interface for recurring time periods. e.g monthly, yearly.

func Monthly

func Monthly() Recurring

func Yearly

func Yearly() Recurring

type Totaler

type Totaler struct {
	// Total is the total so far
	Total int64
}

Totaler sums up the total in each fin.CatPayment instance.

func (*Totaler) Include

func (t *Totaler) Include(cp *fin.CatPayment)

Jump to

Keyboard shortcuts

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