financesgrpc

package
v0.0.0-...-d0ef0bd Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(gRPCServer *grpc.Server, finances Finances)

Types

type Category

type Category struct {
	ID   int64
	Name string // "food", "groceries", "transport", "misc"
}

type CategoryReport

type CategoryReport struct {
	Category string
	Color    string
	Amount   int64
	Percent  float64
}

type Expense

type Expense struct {
	ID          int64
	Description string
	Amount      int64  // in cents
	Date        string // YYYY-MM-DD
	Category    string // "food", "groceries", "transport", "misc"
	Color       string
}

type Finances

type Finances interface {
	Expense(
		ctx context.Context,
		Description string,
		Amount int64,
		Date string,
		Category string,
		Id int64,
	) (err error)

	// ExpenseEdit(
	// 	ctx context.Context,
	// 	ID int64, // expense ID in the database, not the ID in the gRPC request
	// 	Description string,
	// 	Amount int64, // in cents
	// 	Date string, // YYYY-MM-DD
	// 	Category string, // "food", "groceries", "transport", "misc"
	// ) (err error)
	ExpensesList(
		ctx context.Context,
		category string,
		month int64,
		year int64,
	) (list []Expense, totalAmount int64, err error)

	CreateCategory(context.Context, string) (string, error)
	CategoriesList(context.Context) ([]Category, error)
	Report(context.Context, ReportFilter, int, int) (int64, int64, int64, []CategoryReport, error)
}

type ReportFilter

type ReportFilter string
const (
	Week  ReportFilter = "week"
	Month ReportFilter = "month"
	Year  ReportFilter = "year" // TODO: make this an enum?
)

func (ReportFilter) String

func (f ReportFilter) String() string

Jump to

Keyboard shortcuts

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