Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsumptionSvc ¶
type ConsumptionSvc interface {
GetConsumption(ctx context.Context, req *RetrieveConsumptionRequest) (*apiresource.Consumption, *apierror.APIError)
CreateConsumption(ctx context.Context, req *CreateConsumptionRequest) (*apiresource.Consumption, *apierror.APIError)
UpdateConsumption(ctx context.Context, req *UpdateConsumptionRequest) (*apiresource.Consumption, *apierror.APIError)
DeleteConsumption(ctx context.Context, req *DeleteConsumptionRequest) (*apiresource.Consumption, *apierror.APIError)
}
func NewConsumptionSvc ¶
func NewConsumptionSvc(config *ConsumptionSvcConfig) ConsumptionSvc
type ConsumptionSvcConfig ¶
type ConsumptionSvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type CreateConsumptionEndpoint ¶
type CreateConsumptionEndpoint struct{}
Adds a material input to a production step.
Adding a consumption recomputes the production flow: if another production step produces the consumed item, the two steps are linked upstream/downstream automatically.
func (*CreateConsumptionEndpoint) Materialize ¶
func (e *CreateConsumptionEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateConsumptionRequest, *apiresource.Consumption]
type CreateConsumptionRequest ¶
type CreateConsumptionRequest struct {
// ID of the production step that consumes the material.
ProductionStepID string `path:"production_step_id" validate:"required"`
// ID of the item to consume.
ItemID string `json:"item_id" validate:"required"`
// Amount of the item consumed, as a decimal string.
//
// Stated against the step's own output rather than a single unit, so a step producing 100 pairs that consumes 5 kg of yarn takes `5`. Material requirements for an order scale it from there.
QuantityValue string `json:"quantity_value" validate:"required"`
// ID of the unit of measure for `quantity_value`.
QuantityUnitID string `json:"quantity_unit_id" validate:"required"`
// Amount of the item expected to be lost as waste, as a decimal string.
//
// Tracked separately from the consumed quantity, but added to it when material requirements are worked out, since the waste has to be bought as well.
WasteQuantityValue string `json:"waste_quantity_value" validate:"required"`
// ID of the unit of measure for `waste_quantity_value`.
WasteQuantityUnitID string `json:"waste_quantity_unit_id" validate:"required"`
// Instructions for how this material is consumed.
Instructions field.Optional[string] `json:"instructions,omitzero"`
}
Request to create a consumption.
func (*CreateConsumptionRequest) SchemaExample ¶
func (*CreateConsumptionRequest) SchemaExample() any
type DeleteConsumptionEndpoint ¶
type DeleteConsumptionEndpoint struct{}
Removes a material input from a production step.
Any production-flow connections established through this consumption are disconnected, and the remaining consumptions are re-linked. The deleted consumption is returned; deleting it again reports that it has already been deleted.
func (*DeleteConsumptionEndpoint) Materialize ¶
func (e *DeleteConsumptionEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteConsumptionRequest, *apiresource.Consumption]
type DeleteConsumptionRequest ¶
type DeleteConsumptionRequest struct {
// Production step ID.
ProductionStepID string `path:"production_step_id" validate:"required"`
// Consumption ID.
ConsumptionID string `path:"id" validate:"required"`
}
Request to delete a consumption.
type RetrieveConsumptionEndpoint ¶
type RetrieveConsumptionEndpoint struct{}
Returns a consumption by ID within a production step.
func (*RetrieveConsumptionEndpoint) Materialize ¶
func (e *RetrieveConsumptionEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveConsumptionRequest, *apiresource.Consumption]
type RetrieveConsumptionRequest ¶
type RetrieveConsumptionRequest struct {
// Production step ID.
ProductionStepID string `path:"production_step_id" validate:"required"`
// Consumption ID.
ConsumptionID string `path:"id" validate:"required"`
}
Request to retrieve a consumption.
type UpdateConsumptionEndpoint ¶
type UpdateConsumptionEndpoint struct{}
Updates a production step's material input.
Omitted fields are left unchanged. Each quantity is only rewritten when its value and unit are sent together, and changing the consumed item recomputes the production flow around the step.
func (*UpdateConsumptionEndpoint) Materialize ¶
func (e *UpdateConsumptionEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateConsumptionRequest, *apiresource.Consumption]
type UpdateConsumptionRequest ¶
type UpdateConsumptionRequest struct {
// Production step ID.
ProductionStepID string `path:"production_step_id" validate:"required"`
// Consumption ID.
ConsumptionID string `path:"id" validate:"required"`
// ID of the item to consume.
//
// Changing the item disconnects any production-flow link based on the previous item and re-links the flow using the new item.
ItemID field.Optional[string] `json:"item_id,omitzero" validate:"omitempty"`
// Amount of the item consumed, as a decimal string.
//
// The consumed quantity only changes when this and `quantity_unit_id` are sent together; sending either one alone leaves it untouched.
QuantityValue field.Optional[string] `json:"quantity_value,omitzero"`
// ID of the unit of measure for `quantity_value`.
//
// Send it together with `quantity_value`, even when the unit is not changing.
QuantityUnitID field.Optional[string] `json:"quantity_unit_id,omitzero" validate:"omitempty"`
// Amount of the item expected to be lost as waste, as a decimal string.
//
// The waste quantity only changes when this and `waste_quantity_unit_id` are sent together; sending either one alone leaves it untouched.
WasteQuantityValue field.Optional[string] `json:"waste_quantity_value,omitzero"`
// ID of the unit of measure for `waste_quantity_value`.
//
// Send it together with `waste_quantity_value`, even when the unit is not changing.
WasteQuantityUnitID field.Optional[string] `json:"waste_quantity_unit_id,omitzero" validate:"omitempty"`
// Instructions for how this material is consumed.
Instructions field.Optional[string] `json:"instructions,omitzero"`
}
Request to partially update a consumption.
func (*UpdateConsumptionRequest) SchemaExample ¶
func (*UpdateConsumptionRequest) SchemaExample() any