sqlite

package
v0.0.0-...-26d662e Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WITHDRAWAL = TransferType("withdrawal")
	DEPOSIT    = TransferType("deposit")
	MOVE       = TransferType("move")
)
View Source
const (
	CC_BALANCE     = CCField("balance")
	CC_LIMIT       = CCField("credit_limit")
	CC_PAID_AMOUNT = CCField("paid_amount")
	CC_PAID_DAY    = CCField("paid_day")
	CC_DUE_DAY     = CCField("due_day")
)
View Source
const (
	MONTHS               = Table("months")
	INCOME               = Table("income")
	INCOME_HISTORY       = Table("income_history")
	INCOME_AFFIXES       = Table("income_affixes")
	BANK_ACCOUNTS        = Table("bank_accounts")
	BANK_ACCOUNT_HISTORY = Table("bank_account_history")
	TRANSFERS            = Table("transfers")
	CREDIT_CARDS         = Table("credit_cards")
	CREDIT_CARD_HISTORY  = Table("credit_card_history")
	BILLS                = Table("bills")
	BILL_HISTORY         = Table("bill_history")
)
View Source
const (
	WHERE_ID = WhereFlag(1 << iota)
	WHERE_NAME
	WHERE_AMOUNT
	WHERE_BALANCE
	WHERE_YEAR
	WHERE_MONTH
	WHERE_MONTH_ID
	WHERE_BANK_ACCOUNT_ID
	WHERE_INCOME_ID
	WHERE_INCOME_HISTORY_ID
	WHERE_CREDIT_CARD_ID
	WHERE_BILL_ID
)
View Source
const (
	YEARLY   = Period("yearly")
	MONTHLY  = Period("monthly")
	WEEKLY   = Period("weekly")
	BIWEEKLY = Period("biweekly")
)

Variables

View Source
var (
	ErrForeignKey          = fmt.Errorf("foreign key failed validation")
	ErrDueDayInvalid       = fmt.Errorf("failed to validate due_day constraint")
	ErrTransferTypeInvalid = fmt.Errorf("failed to valid transfer_type constraint")
	ErrAmountInvalid       = fmt.Errorf("failed to validate amount constraint")
	ErrMonthInvalid        = fmt.Errorf("failed to validate month constraint")
	ErrUniqueName          = fmt.Errorf("failed unique 'name' constraint requirement")
)
View Source
var ErrDirtyDate = fmt.Errorf("not a clean date")
View Source
var WhereFieldMap = map[WhereFlag]string{
	WHERE_ID:                "id",
	WHERE_NAME:              "name",
	WHERE_AMOUNT:            "amount",
	WHERE_BALANCE:           "balance",
	WHERE_YEAR:              "year",
	WHERE_MONTH:             "month",
	WHERE_MONTH_ID:          "month_id",
	WHERE_BANK_ACCOUNT_ID:   "bank_account_id",
	WHERE_INCOME_ID:         "income_id",
	WHERE_INCOME_HISTORY_ID: "income_history_id",
	WHERE_CREDIT_CARD_ID:    "credit_card_id",
	WHERE_BILL_ID:           "bill_id",
}

Functions

This section is empty.

Types

type AffixIncomeRecord

type AffixIncomeRecord struct {
	ID              int
	IncomeHistoryID int
	Name            string
	Amount          lib.Currency
}

type BankAccountConfig

type BankAccountConfig struct {
	Name          string
	Password      *string
	AccountNumber *string
	Notes         *string
}

type BankHistoryConfig

type BankHistoryConfig struct {
	MonthID       int
	BankAccountID int
	Balance       lib.Currency
}

type BankHistoryRecord

type BankHistoryRecord struct {
	ID            int
	BankAccountID int
	MonthID       int
	Balance       lib.Currency
}

type BankRecord

type BankRecord struct {
	ID            int
	Name          string
	AccountNumber *string
	Notes         *string
}

type BillHistoryConfig

type BillHistoryConfig struct {
	BillID     int
	MonthID    int
	Amount     lib.Currency
	DueDay     int
	PaidAmount *lib.Currency
	PaidDate   *string
	Notes      *string
}

type BillHistoryRecord

type BillHistoryRecord struct {
	ID int
	BillHistoryConfig
}

type BillRecord

type BillRecord struct {
	ID int
	BillsConfig
}

type BillsConfig

type BillsConfig struct {
	Name   string
	Amount lib.Currency
	DueDay int
	Period Period
}

type CCField

type CCField string

type CCFieldMap

type CCFieldMap map[CCField]any

type CardHistoryRecord

type CardHistoryRecord struct {
	ID           int
	CreditCardID int
	MonthID      int
	Balance      lib.Currency
	CreditLimit  *lib.Currency
	PaidAmount   lib.Currency
	PaidDay      *int
	DueDay       int
	Period       Period
}

func (CardHistoryRecord) String

func (chr CardHistoryRecord) String() string

type CreditCardConfig

type CreditCardConfig struct {
	Name           string
	DueDay         int
	CreditLimit    *lib.Currency
	CardNumber     *string
	LastFourDigits string
	Notes          *string
	Password       *string
}

type CreditCardHistoryConfig

type CreditCardHistoryConfig struct {
	CreditCardID int
	MonthID      int
	Balance      lib.Currency
	CreditLimit  *lib.Currency
	DueDay       int
}

type CreditCardRecord

type CreditCardRecord struct {
	ID             int
	Name           string
	DueDay         int
	CreditLimit    *lib.Currency
	CardNumber     *string
	LastFourDigits string
	Notes          *string
}

func (CreditCardRecord) String

func (cr CreditCardRecord) String() string

type FieldMap

type FieldMap map[string]any

type IncomeConfig

type IncomeConfig struct {
	Name   string
	Amount lib.Currency
	Period Period
}

type IncomeHistoryConfig

type IncomeHistoryConfig struct {
	IncomeID int
	MonthID  int
	Amount   lib.Currency
}

type IncomeHistoryRecord

type IncomeHistoryRecord struct {
	ID int
	IncomeHistoryConfig
}

func (IncomeHistoryRecord) String

func (ih IncomeHistoryRecord) String() string

type IncomeRecord

type IncomeRecord struct {
	ID int
	IncomeConfig
}

type MonthRecord

type MonthRecord struct {
	ID    int
	Year  int
	Month int
}

type Period

type Period string

type QueryMap

type QueryMap map[WhereFlag]any

type SqliteDb

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

func NewSqliteDb

func NewSqliteDb(filePath string, cc lib.CurrencyCode) *SqliteDb

func (SqliteDb) AffixIncome

func (sdb SqliteDb) AffixIncome(historyID int, name string, amount lib.Currency)

AffixIncome tracks an appended amount to an existing income. This could be a bonus or overtime amount.

func (SqliteDb) Close

func (sdb SqliteDb) Close()

func (SqliteDb) CreateBankAccount

func (sdb SqliteDb) CreateBankAccount(config BankAccountConfig)

func (SqliteDb) CreateBankAccountHistory

func (sdb SqliteDb) CreateBankAccountHistory(config BankHistoryConfig)

func (SqliteDb) CreateBillHistory

func (sdb SqliteDb) CreateBillHistory(cfg BillHistoryConfig)

func (SqliteDb) CreateCreditCard

func (sdb SqliteDb) CreateCreditCard(config CreditCardConfig)

func (SqliteDb) CreateCreditCardHistory

func (sdb SqliteDb) CreateCreditCardHistory(config CreditCardHistoryConfig)

func (SqliteDb) CreateIncome

func (sdb SqliteDb) CreateIncome(config IncomeConfig) int64

func (SqliteDb) CreateIncomeHistory

func (sdb SqliteDb) CreateIncomeHistory(config IncomeHistoryConfig)

func (SqliteDb) CreateMonth

func (sdb SqliteDb) CreateMonth(t time.Time)

func (SqliteDb) CreateNewBill

func (sdb SqliteDb) CreateNewBill(cfg BillsConfig)

func (SqliteDb) CreateTransfer

func (sdb SqliteDb) CreateTransfer(td TransferConfig)

func (SqliteDb) InsertInto

func (sdb SqliteDb) InsertInto(t Table, values ...any) string

func (SqliteDb) QueryAffixIncome

func (sdb SqliteDb) QueryAffixIncome(qm QueryMap) ([]AffixIncomeRecord, error)

func (SqliteDb) QueryBankAccountHistory

func (sdb SqliteDb) QueryBankAccountHistory(qm QueryMap) ([]BankHistoryRecord, error)

func (SqliteDb) QueryBankAccounts

func (sdb SqliteDb) QueryBankAccounts(qm QueryMap, password *string) ([]BankRecord, error)

func (SqliteDb) QueryBillHistory

func (sdb SqliteDb) QueryBillHistory(qm QueryMap) ([]BillHistoryRecord, error)

func (SqliteDb) QueryBills

func (sdb SqliteDb) QueryBills(qm QueryMap) ([]BillRecord, error)

func (SqliteDb) QueryCreditCardHistory

func (sdb SqliteDb) QueryCreditCardHistory(qm QueryMap) ([]CardHistoryRecord, error)

func (SqliteDb) QueryCreditCards

func (sdb SqliteDb) QueryCreditCards(
	qm QueryMap,
	password *string,
) ([]CreditCardRecord, error)

func (SqliteDb) QueryIncome

func (sdb SqliteDb) QueryIncome(qm QueryMap) ([]IncomeRecord, error)

func (SqliteDb) QueryIncomeHistory

func (sdb SqliteDb) QueryIncomeHistory(qm QueryMap) ([]IncomeHistoryRecord, error)

func (SqliteDb) QueryMonths

func (sdb SqliteDb) QueryMonths(qm QueryMap) ([]MonthRecord, error)

func (SqliteDb) QueryTransfers

func (sdb SqliteDb) QueryTransfers(qm QueryMap) ([]TransferRecord, error)

func (SqliteDb) SetCreditCardHistory

func (sdb SqliteDb) SetCreditCardHistory(historyID int, fieldMap CCFieldMap) error

func (SqliteDb) SetIncome

func (sdb SqliteDb) SetIncome(id int, amount lib.Currency)

type Table

type Table string

type TableFields

type TableFields = map[Table][]string

type TransferConfig

type TransferConfig struct {
	HistoryID    int
	MonthID      int
	Name         string
	Amount       lib.Currency
	DueDay       int
	TransferType TransferType

	ToWhom   *string
	FromWhom *string
}

type TransferRecord

type TransferRecord struct {
	TransferConfig
	ID int
}

type TransferType

type TransferType string

type WhereFlag

type WhereFlag int

Jump to

Keyboard shortcuts

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