models

package
v0.0.0-...-aee05de Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB is the application business database
	DB *gorm.DB
)

Functions

func CreateAdmin

func CreateAdmin(siteName string) *admin.Admin

CreateAdmin creates an admin based on the models

Types

type Batch

type Batch struct {
	gorm.Model
	Recipe        Recipe `gorm:"foreignkey:RecipeID;not null"`
	RecipeID      uint   `gorm:"not null"`
	Date          time.Time
	Step          string
	StartVolume   int
	CurrentVolume int
	Events        []Event
	Transfers     []Transfer
	Sales         []Sale
	Stock         string
}

Batch is made from a recipe and has a list of events altering (or not) it's volume

func (*Batch) AfterFind

func (b *Batch) AfterFind() (err error)

AfterFind calculates the batch volumes according to the events

type Container

type Container struct {
	gorm.Model
	Name   string
	Volume int
}

Container is where the beer is stored

type Event

type Event struct {
	gorm.Model
	BatchID uint
	Name    string
	Date    time.Time
	Volume  int
}

Event is attached to a batch and can alter its volume

type Recipe

type Recipe struct {
	gorm.Model
	Name string
}

Recipe is a beer recipe

type Sale

type Sale struct {
	gorm.Model
	BatchID uint
	Date    time.Time
	From    Container `gorm:"foreignkey:FromID"`
	FromID  uint
	Volume  int
}

Sale is a special event attached to a batch and can alter its stock

type Transfer

type Transfer struct {
	gorm.Model
	BatchID uint
	Date    time.Time
	From    Container `gorm:"foreignkey:FromID"`
	FromID  uint
	To      Container `gorm:"foreignkey:ToID"`
	ToID    uint
	Volume  int
}

Transfer is a special event attached to a batch and can alter its stock

Jump to

Keyboard shortcuts

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