budget

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AmountFactor is the amount by which the actual currency
	AmountFactor = 1000
	// CurrencySEK is the print string for SEK
	CurrencySEK = "SEK"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name         string
	ID           string
	Type         string
	Transactions []*Transaction
}

Account is a bank account

type Budget

type Budget struct {
	Name     string
	ID       string
	Accounts []*Account
}

Budget contains accounts

type MockYNAB

type MockYNAB struct {
	mock.Mock
}

MockYNAB is a mock implementation

func NewMockYNAB

func NewMockYNAB() *MockYNAB

NewMockYNAB is a mock implementation

func (*MockYNAB) Accounts

func (m *MockYNAB) Accounts(budgetID string) ([]*Account, error)

Accounts is a mock implementation

func (*MockYNAB) Budgets

func (m *MockYNAB) Budgets() ([]*Budget, error)

Budgets is a mock implementation

func (*MockYNAB) GetTransactions

func (m *MockYNAB) GetTransactions(budgetID string, accountID string) ([]*Transaction, error)

GetTransactions is a mock implementation

func (*MockYNAB) SendTransactions

func (m *MockYNAB) SendTransactions(budgetID string, accountID string, transactions []*Transaction) ([]string, error)

SendTransactions is a mock implementation

type Repo

type Repo interface {
	Budgets() ([]*Budget, error)
	Accounts(budgetID string) ([]*Account, error)
	GetTransactions(budgetID string, accountID string) ([]*Transaction, error)
	SendTransactions(budgetID string, accountID string, transactions []*Transaction) ([]string, error)
}

Repo is the budgets repository interface

func NewRepo

func NewRepo(accessToken string) Repo

NewRepo returns a new YNAB Repo

type Service

type Service interface {
	Get() ([]*Budget, error)
	Push(budgetID, accountID string, transactions []*Transaction, allowDuplicates bool) ([]string, error)
}

Service is the Budget service

func New

func New(repo Repo) Service

New returns a new Budget service

type Transaction

type Transaction struct {
	ID        string
	Date      time.Time
	Amount    int64
	PayeeName string
	Memo      string
	Cleared   string
	Approved  bool
}

Transaction is the Ynab Representation of a transaction

func (*Transaction) AmountPretty

func (t *Transaction) AmountPretty(currency string) string

AmountPretty returns a formatted currency string for the amount

type Ynab

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

Ynab is the YNAB Repo implementation

func (*Ynab) Accounts

func (y *Ynab) Accounts(budgetID string) ([]*Account, error)

Accounts returns a slice of Accounts for a given budget

func (*Ynab) Budgets

func (y *Ynab) Budgets() ([]*Budget, error)

Budgets returns a slice of budgets

func (*Ynab) GetTransactions

func (y *Ynab) GetTransactions(budgetID string, accountID string) ([]*Transaction, error)

GetTransactions returns all transactions from a given account

func (*Ynab) SendTransactions

func (y *Ynab) SendTransactions(budgetID string, accountID string, transactions []*Transaction) ([]string, error)

SendTransactions sends a slice of transactions to YNAB

Jump to

Keyboard shortcuts

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