pfin – git.sr.ht/~mendelmaleh/pfin Index | Files | Directories

package pfin

import "git.sr.ht/~mendelmaleh/pfin"

Index

Functions

func Filetype

func Filetype(parser string) (string, error)

func Register

func Register(name string, parser Parser)

Types

type Account

type Account struct {
	Name string

	// parser type, inherited from account name if unset
	Type string

	// folder path from root, inherited from account name if unset
	Path string

	// default user, inherited from config.Pfin.User if unset
	DefaultUser string `toml:"user"`

	// map of users to card identifier
	Users map[string][]string

	// generated
	Cards map[string]string
}

func (Account) User

func (a Account) User(card string) string

type Config

type Config struct {
	Pfin struct {
		User string
		Root string
	}

	// the map is nice in the toml config, but not that nice for usability
	Account  map[string]Account
	Accounts []string
}

func ParseConfig

func ParseConfig(path string) (config Config, err error)

ParseConfig will use default config location if path is empty

type ErrUnregisteredParser

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

func (ErrUnregisteredParser) Error

func (e ErrUnregisteredParser) Error() string

type Parser

type Parser interface {
	Filetype() string
	Parse(acc Account, filename string, data []byte) ([]Transaction, error)
}

type Transaction

type Transaction interface {
	Date() time.Time
	Amount() float64 // positive for debit, negative for credit
	Name() string

	Category() string

	Card() string // may be empty
	User() string
	Account() string

	// should be util.FormatTx
	String() string
}

func Parse

func Parse(acc Account, filename string, data []byte) ([]Transaction, error)

Source Files

parser.go transaction.go types.go

Directories

PathSynopsis
cmd
cmd/capitalone
cmd/csvsum
cmd/main
cmd/pfin
cmd/statements
cmd/status
cmd/sum
cmd/unpaid
parser
parser/all
parser/amex
parser/amex/checking
parser/bofa
parser/capitalone
parser/chase
parser/citi
parser/personal
parser/util
util
Version
v0.0.0-20240211185340-c44b6515a97b (latest)
Published
Feb 11, 2024
Platform
linux/amd64
Imports
6 packages
Last checked
3 weeks ago

Tools for package owners.