spendings

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Uncategorized = &categories.Category{
		Model: datastore.Model{UUID: uuid.NewV5(uuid.Nil, "Uncategorized")},
	}
	Unaccounted = &categories.Category{
		Model: datastore.Model{UUID: uuid.NewV5(uuid.Nil, "Unaccounted")},
	}
)

Service categories.

Functions

This section is empty.

Types

type CapitalService

type CapitalService interface {
	GetCapital(ctx context.Context, u *users.User, month string) (*capital.Capital, error)
}

type CategoryService added in v0.2.0

type CategoryService interface {
	GetUserCategories(ctx context.Context, u *users.User) ([]*categories.Category, error)
}

type Service

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

Service is a service responsible for calculating spendings.

func NewService

func NewService(capSrv CapitalService, transSrv TransactionsService, catSrv CategoryService) *Service

NewService initializes the spendings service.

func (*Service) GetMonthSpendings

func (s *Service) GetMonthSpendings(ctx context.Context, u *users.User, month string) (Spendings, error)

GetMonthSpendings calculates funds spent during specified month.

type Spendings added in v0.2.0

type Spendings interface {
	AddAmount(cat *categories.Category, currency accounts.Currency, amount float64)
	AddAmounts(cat *categories.Category, amounts accounts.CurrencyAmounts)
	GetAmount(cat *categories.Category, currency accounts.Currency) float64
	GetAmounts(cat *categories.Category) accounts.CurrencyAmounts
	GetUncategorized() accounts.CurrencyAmounts
	GetUnaccounted() accounts.CurrencyAmounts
	GetTotal() accounts.CurrencyAmounts
	AddTransaction(tx *transactions.Transaction)
}

func NewSpendings added in v0.4.0

func NewSpendings(cats []*categories.Category) Spendings

NewSpendings initializes new spendings structure.

type TransactionsService added in v0.2.0

type TransactionsService interface {
	GetUserTransactions(ctx context.Context, u *users.User, month string) (transactions.TransactionCollection, error)
}

Jump to

Keyboard shortcuts

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