budgit

package
v0.0.0-...-3720d23 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package budgit is the domain package. It contains the domain objects for budgiting.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCurrency = fmt.Errorf("given currency is not valid")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID              string
	Name            string
	Balance         Balance
	ExternalAccount *ExternalAccount
}

Account is an account internal to budgit.

type Balance

type Balance struct {
	ClearedBalance   BalanceAmount
	EffectiveBalance BalanceAmount
}

Balance is a Balance, holding BalanceAmounts of the cleared and effective balances.

func (Balance) Add

func (b Balance) Add(balance Balance) Balance

func (Balance) AddAmount

func (b Balance) AddAmount(amount BalanceAmount, cleared bool) Balance

type BalanceAmount

type BalanceAmount int64

BalanceAmount stores a balance amount with no decimals, assuming the maximum number of decimal points is 2. e.g. £10 is stored as 100.

func (BalanceAmount) String

func (b BalanceAmount) String() string

type Budget

type Budget struct {
	ID       string
	Name     string
	Currency string
}

Budget is a single Budget used for tracking finances.

func NewBudget

func NewBudget(name, currency string) (*Budget, error)

NewBudget returns a Budget.

type ExternalAccount

type ExternalAccount struct {
	ID                string
	Name              string
	IntegrationID     string
	LastSyncTimestamp time.Time
	Balance           Balance
}

ExternalAccount is an Account representing some real, external Account that is attached to a budgit Account.

type Payee

type Payee struct {
	ID   string
	Name string
}

Payee is an external party involved in a payee.

type Transaction

type Transaction struct {
	ID              string
	EffectiveDate   time.Time
	AccountID       string
	PayeeID         string
	IsPayeeInternal bool
	CategoryID      string
	Amount          BalanceAmount
	Cleared         bool
}

Transaction is an Transaction, unique only within a given Budget.

func (Transaction) Mirror

func (t Transaction) Mirror(id string) *Transaction

Mirror mirrors the transaction, by returning another with the same fields but:

  • ID is replaced with given ID
  • Account and Payee IDs are swapped
  • Amount is negated

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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