ledger

package module
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: ISC Imports: 16 Imported by: 16

README

license GitHub releases GitHub downloads Chat on Libera Go Report Card Go Reference Coverage Status

ledger-logo

Purpose

Ledger is a command line application for plain text accounting. Providing commands to view balances, register of transactions, importing of CSV files, exporting of CSV files, and a web interface to view reports, and track investments.

Documentation

Head over to https://howeyc.github.io/ledger/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLedgerReader deprecated added in v0.2.0

func NewLedgerReader(filename string) (io.Reader, error)

NewLedgerReader reads a file and includes any files with include directives and returns the whole combined ledger as a buffer for parsing.

Deprecated: use ParseLedgerFile

func ParseLedgerAsync

func ParseLedgerAsync(ledgerReader io.Reader) (c chan *Transaction, e chan error)

ParseLedgerAsync parses a ledger file and returns a Transaction and error channels .

Types

type Account

type Account struct {
	Name    string
	Balance decimal.Decimal
	Comment string
}

Account holds the name and balance

func GetBalances

func GetBalances(generalLedger []*Transaction, filterArr []string) []*Account

GetBalances provided a list of transactions and filter strings, returns account balances of all accounts that have any filter as a substring of the account name. Also returns balances for each account level depth as a separate record.

Accounts are sorted by name.

type Period

type Period string

Period is used to specify the length of a date range or frequency

const (
	PeriodDay      Period = "Daily"
	PeriodWeek     Period = "Weekly"
	Period2Week    Period = "BiWeekly"
	PeriodMonth    Period = "Monthly"
	Period2Month   Period = "BiMonthly"
	PeriodQuarter  Period = "Quarterly"
	PeriodSemiYear Period = "SemiYearly"
	PeriodYear     Period = "Yearly"
)

Periods supported by ledger

type RangeBalance

type RangeBalance struct {
	Start, End time.Time
	Balances   []*Account
}

RangeBalance contains the account balances and the start and end time of the date range

func BalancesByPeriod

func BalancesByPeriod(trans []*Transaction, per Period, rType RangeType) []*RangeBalance

BalancesByPeriod will return the account balances for each period.

type RangeTransactions

type RangeTransactions struct {
	Start, End   time.Time
	Transactions []*Transaction
}

RangeTransactions contains the transactions and the start and end time of the date range

func TransactionsByPeriod

func TransactionsByPeriod(trans []*Transaction, per Period) []*RangeTransactions

TransactionsByPeriod will return the transactions for each period.

type RangeType

type RangeType string

RangeType is used to specify how the data is "split" into sections

const (
	// RangeSnapshot will have each section be the running total at the time of the snapshot
	RangeSnapshot RangeType = "Snapshot"

	// RangePartition will have each section be the accumulated value of the transactions within that partition's date range
	RangePartition RangeType = "Partition"
)

type Transaction

type Transaction struct {
	Date           time.Time
	Payee          string
	PayeeComment   string
	AccountChanges []Account
	Comments       []string
}

Transaction is the basis of a ledger. The ledger holds a list of transactions. A Transaction has a Payee, Date (with no time, or to put another way, with hours,minutes,seconds values that probably doesn't make sense), and a list of Account values that hold the value of the transaction for each account.

func ParseLedger

func ParseLedger(ledgerReader io.Reader) (generalLedger []*Transaction, err error)

ParseLedger parses a ledger file and returns a list of Transactions.

func ParseLedgerFile added in v1.7.0

func ParseLedgerFile(filename string) (generalLedger []*Transaction, err error)

ParseLedgerFile parses a ledger file and returns a list of Transactions.

func TransactionsInDateRange

func TransactionsInDateRange(trans []*Transaction, start, end time.Time) []*Transaction

TransactionsInDateRange returns a new array of transactions that are in the date range specified by start and end. The returned list contains transactions on the same day as start but does not include any transactions on the day of end.

Directories

Path Synopsis
Package decimal implements fixed-point decimal with accuracy to 3 digits of precision after the decimal point.
Package decimal implements fixed-point decimal with accuracy to 3 digits of precision after the decimal point.
cmd
cmd/internal/pdr
Package pdr parses date range as string Uses pointlander/peg
Package pdr parses date range as string Uses pointlander/peg

Jump to

Keyboard shortcuts

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