domain

package
v3.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: OSL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrInsufficientSourceQty - use to indicate that the requested qty exceeds the available qty
	ErrInsufficientSourceQty = errors.New("Available Source Qty insufficient")
	//ErrNoSourceAvailable - use to indicate that no source for item is available at all
	ErrNoSourceAvailable = errors.New("No Available Source Qty")
)

Functions

This section is empty.

Types

type Source

type Source struct {
	//LocationCode - idendifies the warehouse or stocklocation
	LocationCode string
	//Qty - for the sources items
	Qty int
}

Source - represents the Sourceing info

type Sources

type Sources []Source

Sources - result value object containing all sources (for the request item or product)

func (Sources) MainLocation

func (s Sources) MainLocation() string

MainLocation returns first sourced location (or empty string)

func (Sources) QtySum

func (s Sources) QtySum() int

QtySum returns the sum of all sourced items

func (Sources) Reduce

func (s Sources) Reduce(reduceby Sources) Sources

Reduce returns new Source

type SourcingEngine

type SourcingEngine struct {
	SourcingService SourcingService          `inject:",optional"`
	Logger          flamingo.Logger          `inject:""`
	Cartservice     *application.CartService `inject:""`
}

SourcingEngine computes item sources

func (*SourcingEngine) SetSourcesForCartItems

func (se *SourcingEngine) SetSourcesForCartItems(ctx context.Context, session *web.Session, decoratedCart *decorator.DecoratedCart) error

SetSourcesForCartItems gets Sources and modifies the Cart Items todo move to application layer ?

type SourcingService

type SourcingService interface {
	//GetSourceID  returns one source location code where the product should be sourced
	//@todo will be Depricated in future in favor of SourcingServiceDetail interface
	GetSourceID(ctx context.Context, session *web.Session, decoratedCart *decorator.DecoratedCart, deliveryCode string, item *decorator.DecoratedCartItem) (string, error)
}

SourcingService helps in retrieving item sources

type SourcingServiceDetail

type SourcingServiceDetail interface {
	//GetSourcesForItem returns Sources for the given item in the cart
	GetSourcesForItem(ctx context.Context, session *web.Session, decoratedCart *decorator.DecoratedCart, deliveryCode string, item *decorator.DecoratedCartItem) (Sources, error)
	//GetAvailableSources returns Sources for the product - containing the maximum possible qty per source
	GetAvailableSources(ctx context.Context, session *web.Session, decoratedCart *decorator.DecoratedCart, deliveryCode string, product domain.BasicProduct) (Sources, error)
}

SourcingServiceDetail additional interface to return @todo - the methods in the interface will replace the methods in interface above (SourcingServiceDetail will be deleted then)

Jump to

Keyboard shortcuts

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