models

package
v0.0.0-...-944857f Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 3 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 {
	gorm.Model
	GarageNumber      string `validate:"required" gorm:"index:idx_garage_number,unique"`
	FullName          string `validate:"required" gorm:"not null"`
	PhoneNumber       string
	Address           string
	Debt              float32
	ElectricityNumber int
	Payments          []Payment `gorm:"foreignKey:AccountID"`
}

func (*Account) FindByGarageNumber

func (a *Account) FindByGarageNumber(n string) (*Account, error)

func (*Account) FindByID

func (a *Account) FindByID(id int) (*Account, error)

func (*Account) GetAll

func (a *Account) GetAll(orderColumn, orderDirection string) ([]Account, error)

func (*Account) Insert

func (a *Account) Insert() error

func (*Account) LastPayedYear

func (a *Account) LastPayedYear() string

func (*Account) Search

func (a *Account) Search(search string) ([]Account, error)

type Payment

type Payment struct {
	gorm.Model
	AccountID int
	Account   Account `gorm:"foreignKey:AccountID;not null"`
	RateID    int
	Rate      Rate `gorm:"foreignKey:RateID;not null"`
	Value     float32
}

func (*Payment) All

func (p *Payment) All(accountID int) ([]Payment, error)

func (*Payment) Create

func (p *Payment) Create(a *Account, r *Rate, value float32) (*Payment, error)

type Rate

type Rate struct {
	gorm.Model
	Year     string `validate:"required" gorm:"index:idx_garage_number,unique"`
	Value    float32
	Payments []Payment `gorm:"foreignKey:RateID"`
}

func (*Rate) All

func (r *Rate) All() ([]Rate, error)

func (*Rate) FindByYear

func (r *Rate) FindByYear(year string) (*Rate, error)

Jump to

Keyboard shortcuts

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