models

package
v0.0.0-...-7fd672d Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithID

func WithID[T IDable](id string, i T) T

Types

type Area

type Area struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	LocationID string `json:"location_id"`
}

func (*Area) GetID

func (a *Area) GetID() string

func (*Area) SetID

func (a *Area) SetID(id string)

func (*Area) Validate

func (a *Area) Validate() error

type AreaCommodities

type AreaCommodities map[string][]string

AreaCommodities represents an index of commodities for a given area. Map key is an AreaID and value is a slice of CommodityIDs.

type Commodity

type Commodity struct {
	EntityID
	Name                   string          `json:"name"`
	ShortName              string          `json:"short_name"`
	Type                   CommodityType   `json:"type"`
	AreaID                 string          `json:"area_id"`
	Count                  int             `json:"count"`
	OriginalPrice          decimal.Decimal `json:"original_price"`
	OriginalPriceCurrency  Currency        `json:"original_price_currency"`
	ConvertedOriginalPrice decimal.Decimal `json:"converted_original_price"`
	CurrentPrice           decimal.Decimal `json:"current_price"`
	SerialNumber           string          `json:"serial_number"`
	ExtraSerialNumbers     []string        `json:"extra_serial_numbers"`
	PartNumbers            []string        `json:"part_numbers"`
	Tags                   []string        `json:"tags"`
	Status                 CommodityStatus `json:"status"`
	PurchaseDate           PDate           `json:"purchase_date"`
	RegisteredDate         PDate           `json:"registered_date"`
	LastModifiedDate       PDate           `json:"last_modified_date"`
	URLs                   []*URL          `json:"urls" swaggertype:"string"`
	Comments               string          `json:"comments"`
	Draft                  bool            `json:"draft"`
}

func (*Commodity) MarshalJSON

func (a *Commodity) MarshalJSON() ([]byte, error)

func (*Commodity) UnmarshalJSON

func (a *Commodity) UnmarshalJSON(data []byte) error

func (*Commodity) Validate

func (a *Commodity) Validate() error

type CommodityImages

type CommodityImages map[string][]string

CommodityImages represents an index of images for a given commodity. Map key is a CommodityID and value is a slice of ImageIDs.

type CommodityInvoices

type CommodityInvoices map[string][]string

CommodityInvoices represents an index of invoices for a given commodity. Map key is a CommodityID and value is a slice of InvoiceIDs.

type CommodityManuals

type CommodityManuals map[string][]string

CommodityManuals represents an index of manuals for a given commodity. Map key is a CommodityID and value is a slice of ManualIDs.

type CommodityStatus

type CommodityStatus string
const (
	CommodityStatusInUse      CommodityStatus = "in_use"
	CommodityStatusSold       CommodityStatus = "sold"
	CommodityStatusLost       CommodityStatus = "lost"
	CommodityStatusDisposed   CommodityStatus = "disposed"
	CommodityStatusWrittenOff CommodityStatus = "written_off"
)

Commodity statuses. Adding a new status? Don't forget to update IsValid() method.

func (CommodityStatus) IsValid

func (c CommodityStatus) IsValid() bool

func (CommodityStatus) Validate

func (c CommodityStatus) Validate() error

type CommodityType

type CommodityType string
const (
	CommodityTypeWhiteGoods  CommodityType = "white_goods"
	CommodityTypeElectronics CommodityType = "electronics"
	CommodityTypeEquipment   CommodityType = "equipment"
	CommodityTypeFurniture   CommodityType = "furniture"
	CommodityTypeClothes     CommodityType = "clothes"
	CommodyTypeOther         CommodityType = "other"
)

Commodity types. Adding a new type? Don't forget to update IsValid() method.

func (CommodityType) IsValid

func (c CommodityType) IsValid() bool

func (CommodityType) Validate

func (c CommodityType) Validate() error

type Currency

type Currency string

func (Currency) IsValid

func (c Currency) IsValid() bool

func (Currency) Validate

func (c Currency) Validate() error

type Date

type Date string

func (*Date) After

func (d *Date) After(other *Date) bool

func (*Date) Before

func (d *Date) Before(other *Date) bool

func (*Date) Equal

func (d *Date) Equal(other *Date) bool

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

func (*Date) ToTime

func (d *Date) ToTime() time.Time

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

func (*Date) Validate

func (d *Date) Validate() error

type EntityID

type EntityID struct {
	ID string `json:"id"`
}

func (*EntityID) GetID

func (i *EntityID) GetID() string

func (*EntityID) SetID

func (i *EntityID) SetID(id string)

type File

type File struct {
	Path     string `json:"path"`
	Ext      string `json:"ext"`
	MIMEType string `json:"mime_type"`
}

func (*File) Validate

func (i *File) Validate() error

type IDable

type IDable interface {
	GetID() string
	SetID(string)
}

type Image

type Image struct {
	EntityID
	CommodityID string `json:"commodity_id"`
	*File
}

func (*Image) Validate

func (i *Image) Validate() error

type Invoice

type Invoice struct {
	EntityID
	CommodityID string `json:"commodity_id"`
	*File
}

func (*Invoice) Validate

func (i *Invoice) Validate() error

type Location

type Location struct {
	EntityID
	Name    string `json:"name"`
	Address string `json:"address"`
}

func (*Location) Validate

func (a *Location) Validate() error

type LocationAreas

type LocationAreas map[string][]string

LocationAreas represents an index of areas for a given location. Map key is a LocationID and value is a slice of AreaIDs.

type Manual

type Manual struct {
	EntityID
	CommodityID string `json:"commodity_id"`
	*File
}

func (*Manual) Validate

func (m *Manual) Validate() error

type PDate

type PDate = *Date

func ToPDate

func ToPDate(d Date) PDate

type URL

type URL url.URL

func URLParse

func URLParse(s string) (*URL, error)

func (*URL) MarshalJSON

func (u *URL) MarshalJSON() ([]byte, error)

func (*URL) String

func (u *URL) String() string

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

func (*URL) Validate

func (u *URL) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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