model

package
v0.0.0-...-f47859d Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OutOfStockErr = errors.New("out of stock")

Functions

func OrderLinesEqual

func OrderLinesEqual(first, second []OrderLine) bool

Types

type Batch

type Batch struct {
	ID                int64
	Reference         string
	SKU               string
	PurchasedQuantity int
	ETA               time.Time
	// contains filtered or unexported fields
}

func Allocate

func Allocate(line OrderLine, batches []*Batch) (*Batch, error)

Allocate TODO: remove this function Allocate deprecate

func NewBatch

func NewBatch(reference string, sku string, qty int, eta time.Time) *Batch

func (*Batch) Allocate

func (b *Batch) Allocate(line OrderLine)

func (*Batch) AllocatedQuantity

func (b *Batch) AllocatedQuantity() int

func (*Batch) Allocations

func (b *Batch) Allocations() []OrderLine

func (*Batch) AvailableQuantity

func (b *Batch) AvailableQuantity() int

func (*Batch) CanAllocate

func (b *Batch) CanAllocate(line OrderLine) bool

func (*Batch) Contain

func (b *Batch) Contain(line OrderLine) (bool, int)

func (*Batch) Deallocate

func (b *Batch) Deallocate(line OrderLine)

func (*Batch) DeallocateOne

func (b *Batch) DeallocateOne() *OrderLine

func (*Batch) EqualTo

func (b *Batch) EqualTo(other Batch) bool

type OrderLine

type OrderLine struct {
	ID      int64
	OrderID string
	SKU     string
	Qty     int
}

func NewOrderLine

func NewOrderLine(orderID string, SKU string, qty int) OrderLine

func (OrderLine) Any

func (line OrderLine) Any(lines []OrderLine) bool

func (OrderLine) EqualTo

func (line OrderLine) EqualTo(orderLine OrderLine) bool

type Product

type Product struct {
	*domain.BaseEntity
	SKU           string
	VersionNumber int
	Batches       []*Batch
}

func NewProduct

func NewProduct(SKU string, batches []*Batch) *Product

func (*Product) Allocate

func (p *Product) Allocate(line OrderLine)

func (*Product) AllocateDeprecated

func (p *Product) AllocateDeprecated(line OrderLine) (*Batch, error)

func (*Product) ChangeBatchQuantity

func (p *Product) ChangeBatchQuantity(ref string, qty int)

func (*Product) HasOutOfStockEventAsLast

func (p *Product) HasOutOfStockEventAsLast() bool

Jump to

Keyboard shortcuts

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