Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnitFromQuantityInfo ¶
func UnitFromQuantityInfo(q *pb.QuantityInfo) *apiresource.Unit
UnitFromQuantityInfo returns the fully-resolved Unit when the proto carries complete unit detail, or nil otherwise. It never fabricates a placeholder — when only a unit id is available, callers stash the id so the unit is loaded with real data via LoadUnits when ?include= is requested.
Types ¶
type QuantitySvc ¶
type QuantitySvc interface {
UpdateQuantity(ctx context.Context, req *UpdateQuantityRequest) (*apiresource.Quantity, *apierror.APIError)
}
func NewQuantitySvc ¶
func NewQuantitySvc(config *QuantitySvcConfig) QuantitySvc
type QuantitySvcConfig ¶
type QuantitySvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type UpdateQuantityEndpoint ¶
type UpdateQuantityEndpoint struct{}
Updates the value or unit of a quantity in place.
A quantity belongs to the resource that reports it — a material's order point, the amount a production step consumes, and so on — so this changes that resource's stored measure directly.
func (*UpdateQuantityEndpoint) Materialize ¶
func (e *UpdateQuantityEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateQuantityRequest, *apiresource.Quantity]
type UpdateQuantityRequest ¶
type UpdateQuantityRequest struct {
// Quantity ID.
QuantityID string `path:"id" validate:"required"`
// New decimal value for the quantity, as a string to preserve precision.
Value field.Optional[string] `json:"value,omitzero"`
// ID of the new unit of measure for the quantity.
//
// The stored value is kept as-is and is not converted into the new unit, so send `value` alongside this when the amount should change too.
UnitID field.Optional[string] `json:"unit_id,omitzero" validate:"omitempty"`
// ID of the resource that owns this quantity.
//
// Used together with `object_type` to verify the owning resource exists; it does not reassign the quantity.
ObjectID field.Optional[string] `json:"object_id,omitzero" validate:"omitempty"`
// Type of the resource that owns this quantity.
//
// Determines the permission required for the update. Must be `item`, `production_step`, or `department`.
ObjectType field.Optional[string] `json:"object_type,omitzero" validate:"omitempty,max=255"`
}
Request to partially update a quantity.
func (*UpdateQuantityRequest) SchemaExample ¶
func (*UpdateQuantityRequest) SchemaExample() any
Click to show internal directories.
Click to hide internal directories.