model

package
v0.0.0-...-dabee0d Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncomeTypeName  = "income"
	ExpenseTypeName = "expense"
)

Variables

View Source
var EntryClassTypeNames = map[int]string{
	0: ExpenseTypeName,
	1: IncomeTypeName,
}

Functions

func RegisterModels

func RegisterModels()

Types

type Budget

type Budget struct {
	ID              int
	UID             string
	Balance         float32
	TotalIncome     float32
	TotalExpenses   float32
	EntryCount      int
	IncomeCount     int
	ExpenseCount    int
	BudgetAccountID int
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

func (*Budget) Insert

func (b *Budget) Insert(budgetAccountID int) error

func (*Budget) SelectByUID

func (b *Budget) SelectByUID(uid string) error

func (*Budget) SelectCurrent

func (b *Budget) SelectCurrent(budgetAccountID int) error

func (*Budget) UpdateOnEntry

func (b *Budget) UpdateOnEntry(credit float32, debit float32, count int) error

func (*Budget) UpdateOnExpense

func (b *Budget) UpdateOnExpense(credit float32, debit float32, count int) error

func (*Budget) UpdateOnIncome

func (b *Budget) UpdateOnIncome(credit float32, debit float32, count int) error

func (*Budget) Validate

func (b *Budget) Validate() error

type BudgetAccount

type BudgetAccount struct {
	ID        int
	UserID    int
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*BudgetAccount) Insert

func (b *BudgetAccount) Insert(userID int) error

func (*BudgetAccount) SelectByUserID

func (b *BudgetAccount) SelectByUserID(userID int) error

type Budgets

type Budgets []Budget

func (*Budgets) Index

func (bs *Budgets) Index(budgetAccountID int) error

type EntryClass

type EntryClass struct {
	ID        int    `json:"id"`
	UID       string `json:"uid"`
	Name      string `json:"name"`
	Type      int
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*EntryClass) Insert

func (e *EntryClass) Insert() error

func (*EntryClass) InsertIfNotExists

func (e *EntryClass) InsertIfNotExists() error

func (*EntryClass) SelectByID

func (e *EntryClass) SelectByID(id int) error

func (*EntryClass) TypeName

func (e *EntryClass) TypeName() string

type EntryClasses

type EntryClasses []EntryClass

type ErrIncompleteQuery

type ErrIncompleteQuery struct{}

func (ErrIncompleteQuery) Error

func (e ErrIncompleteQuery) Error() string

type Expense

type Expense struct {
	ID           int       `json:"id"`
	Amount       float32   `json:"amount"`
	Description  string    `json:"description"`
	BudgetID     int       `json:"budgetId"`
	EntryClassID int       `json:"entryClassId"`
	CreatedAt    time.Time `json:"createAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

func (*Expense) Delete

func (e *Expense) Delete() error

func (*Expense) FindLast

func (e *Expense) FindLast(budgetID int) error

func (*Expense) Insert

func (e *Expense) Insert(expenseFormData ExpenseFormData, budgetID int) error

func (*Expense) SelectByID

func (e *Expense) SelectByID(id int) error

func (*Expense) Update

func (e *Expense) Update(expenseFormData ExpenseFormData) error

type ExpenseFormData

type ExpenseFormData struct {
	Amount       float32 `json:"amount"`
	Description  string  `json:"description"`
	EntryClassID int     `json:"entryClassId"`
}

func (ExpenseFormData) Validate

func (e ExpenseFormData) Validate() error

type Expenses

type Expenses []Expense

func (*Expenses) Index

func (es *Expenses) Index(budgetID int) error

type Income

type Income struct {
	ID           int       `json:"id"`
	Amount       float32   `json:"amount"`
	Description  string    `json:"description"`
	BudgetID     int       `json:"budgetId"`
	EntryClassID int       `json:"entryClassId"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

func (*Income) Delete

func (i *Income) Delete() error

func (*Income) FindLast

func (i *Income) FindLast(budgetID int) error

func (*Income) Insert

func (i *Income) Insert(incomeFormData IncomeFormData, budgetID int) error

func (*Income) SelectByID

func (i *Income) SelectByID(id int) error

func (*Income) Update

func (i *Income) Update(incomeFormData IncomeFormData) error

type IncomeFormData

type IncomeFormData struct {
	Amount       float32 `json:"amount"`
	Description  string  `json:"description"`
	EntryClassID int     `json:"entryClassId"`
}

func (IncomeFormData) Validate

func (i IncomeFormData) Validate() error

type IncomeList

type IncomeList []Income

func (*IncomeList) Index

func (il *IncomeList) Index(budgetID int) error

type SafeUser

type SafeUser struct {
	Username string
	Name     string
	Email    string
	Image    sql.NullString
}

type SignInData

type SignInData struct {
	Email    string
	Password string
}

type SignUpData

type SignUpData struct {
	Username             string
	Name                 string
	Email                string
	Password             string
	PasswordConfirmation string
}

func (*SignUpData) Validate

func (s *SignUpData) Validate() error

type User

type User struct {
	ID        int
	Username  string
	Name      string
	Email     string
	Password  string
	Image     sql.NullString
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*User) GetSafeUser

func (u *User) GetSafeUser() SafeUser

func (*User) Insert

func (u *User) Insert(signUpData SignUpData) error

func (*User) SelectByEmail

func (u *User) SelectByEmail(email string) error

func (*User) SelectByID

func (u *User) SelectByID(userID int) error

Jump to

Keyboard shortcuts

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