midata

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 8 Imported by: 0

README

midata Go Reference GitHub tag license Go Report Card codecov

A simple midata library for Go (golang)

Can be used for importing midata CSV files and doing some financial analysis.

Tested only with official spec and Lloyds Bank midata export.

Usage

See godoc.org/github.com/bbrks/midata for reference.

Contributing

Anonymised examples from different banks via issue/PR are much appreciated!

Feature requests/improvements welcome.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMidata is returned when data
	// does not match the expected midata format.
	ErrInvalidMidata = errors.New("invalid midata format")
)

Functions

This section is empty.

Types

type Midata

type Midata struct {
	Transactions Transactions
	Overdraft    Overdraft
}

Midata holds midata information

func Marshal

func Marshal(r io.Reader) (*Midata, error)

Marshal takes an io.Reader and attempts to parse it into a midata struct.

func (*Midata) DaysInOverdraft

func (md *Midata) DaysInOverdraft() int

DaysInOverdraft will return the total number of days with a negative balance.

func (*Midata) TotalExpenses

func (md *Midata) TotalExpenses() decimal.Decimal

TotalExpenses will return the total amount of debit for the account.

func (*Midata) TotalIncome

func (md *Midata) TotalIncome() decimal.Decimal

TotalIncome will return the sum of credit for the account.

func (*Midata) TotalNet

func (md *Midata) TotalNet() decimal.Decimal

TotalNet will return the total net amount for the account.

type Overdraft

type Overdraft struct {
	Date   time.Time
	Amount decimal.Decimal
}

Overdraft information is appended to the midata file

type Transaction

type Transaction struct {
	Date     time.Time
	Type     string
	Merchant string

	Debit   decimal.Decimal
	Balance decimal.Decimal
}

Transaction is a single entry in a midata file

type Transactions

type Transactions []*Transaction

Transactions are held in a midata file

func (Transactions) Len

func (t Transactions) Len() int

func (Transactions) Less

func (t Transactions) Less(i, j int) bool

func (Transactions) Swap

func (t Transactions) Swap(i, j int)

Jump to

Keyboard shortcuts

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