inventory

package
v0.0.0-...-cbab839 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ByName sorts items by name.
	ByName sortBy = (1 << iota)
	// ByDate sorts items by update date.
	ByDate
	// ByPrice sorts items by price.
	ByPrice
)

Variables

View Source
var (
	// CustomPath sets a custom directory to store the inventory.
	CustomPath string
	// ReturnLocation sets the return location of the inventory (default:
	// returned).
	ReturnLocation = "returned"
)

Functions

func Delete

func Delete(id string) error

Delete deletes an item from the inventory.

func Path

func Path() string

Path returns the path of the inventory.

func Sort

func Sort(element sortBy, items []*Item, reversed bool)

Sort sorts a slice of items by the speciafied element.

Types

type Item

type Item struct {
	ID       string    `yaml:"id"`
	SKU      string    `yaml:"sku"`
	Name     string    `yaml:"name"`
	Type     string    `yaml:"itemtype"`
	Value    string    `yaml:"value"`
	Size     string    `yaml:"size"`
	Quantity string    `yaml:"quantity"`
	Price    string    `yaml:"price"`
	Location string    `yaml:"location"`
	Updated  time.Time `yaml:"update"`
}

Item is the item in the inventory.

func Add

func Add(sku, name, itemtype, value, size, quantity, price, location string) (*Item, error)

Add adds a new named item to the inventory. It will auto-generate a unique ID for the item based on the name.

func Items

func Items() ([]*Item, error)

Items returns the list of items in the inventory.

func SortedItems

func SortedItems(by sortBy, reversed bool) ([]*Item, error)

SortedItems returns a sorted slice of items in the inventory.

func Update

func Update(id, sku, name, itemtype, value, size, quantity, price, location string) (*Item, error)

Update updates an item in the inventory by ID.

func (*Item) Delete

func (i *Item) Delete() error

Delete deletes the item from the disk

func (*Item) LocationPicture

func (i *Item) LocationPicture() (image.Image, error)

LocationPicture returns the picture of the location associated with the item.

func (*Item) Picture

func (i *Item) Picture() (image.Image, error)

Picture returns the picture associated with the item.

func (*Item) SetLocationPicture

func (i *Item) SetLocationPicture(r io.ReadSeeker) error

SetLocationPicture sets the thumbnail picture of the item. To save space, the image is resized within 1000x1000 pixels and encoded as jpeg.

func (*Item) SetPicture

func (i *Item) SetPicture(r io.ReadSeeker) error

SetPicture sets the thumbnail picture of the item. To save space, the image is resized within 1000x1000 pixels and encoded as jpeg.

func (*Item) Update

func (i *Item) Update() error

Update updates the information of the item on disk.

Jump to

Keyboard shortcuts

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