repository

package
v0.0.0-...-c061cf9 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        string
	ParentID  string
	Name      string
	Type      string
	Basis     string
	CreatedAt time.Time
}

type Amount

type Amount struct {
	Value    int64  `validate:"gte=0"`
	Currency string `validate:"len=3,alpha"`
}

type Entry

type Entry struct {
	ID            string
	TransactionID string
	Description   string
	DebitAccount  string
	CreditAccount string
	Amount        Amount
	CreatedAt     time.Time
}

type Repository

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

func NewRepository

func NewRepository(database *pgxpool.Pool) *Repository

func (*Repository) CreateAccount

func (r *Repository) CreateAccount(ctx context.Context, create Account) (Account, error)

CreateAccount creates an account record in the database and returns the created record

func (*Repository) CreateTransaction

func (r *Repository) CreateTransaction(ctx context.Context, create Transaction) (Transaction, error)

CreateTransaction creates a transaction and associated entries in a single transaction

func (*Repository) GetAccount

func (r *Repository) GetAccount(ctx context.Context, accountID string) (Account, error)

GetAccount gets an account from the database

func (*Repository) GetTransaction

func (r *Repository) GetTransaction(ctx context.Context, transactionID string) (Transaction, error)

GetTransaction get's a transaction record, without it's entries, by the transaction ID

func (*Repository) ListAccounts

func (r *Repository) ListAccounts(ctx context.Context, accountID string, createdAt time.Time, limit uint64) ([]Account, error)

ListAccounts get accounts paginated based on a cursor and limit

func (*Repository) ListTransactions

func (r *Repository) ListTransactions(ctx context.Context, transactionID string, createdAt time.Time, limit uint64) ([]Transaction, error)

ListTransactions get's transactions paginated by cursor and limit

type Transaction

type Transaction struct {
	ID          string
	Description string
	Entries     []Entry
	CreatedAt   time.Time
}

func (Transaction) IsZero

func (t Transaction) IsZero() bool

Jump to

Keyboard shortcuts

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