demandoverridesep

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DemandOverrideFromProto

func DemandOverrideFromProto(info *pb.DemandOverrideInfo) apiresource.DemandOverride

DemandOverrideFromProto maps a core DemandOverrideInfo to the API resource. The scope, unit and created_by expandables are left nil; pair with StashDemandOverrideMeta so they resolve on ?include=.

func DemandOverrideTypeFromProto

func DemandOverrideTypeFromProto(info *pb.DemandOverrideTypeInfo) apiresource.DemandOverrideType

DemandOverrideTypeFromProto maps a core DemandOverrideTypeInfo to the API resource.

func StashDemandOverrideMeta

func StashDemandOverrideMeta(ctx context.Context, meta *resourcekit.LoadMeta, info *pb.DemandOverrideInfo) *apiresource.Actor

StashDemandOverrideMeta stashes the reference data for the expandable sub-resources. The scope is polymorphic, so it resolves to an Entity rather than to a typed sub-resource: an include that can only ever populate for half the rows is not an include. The creator is stored as a bare identity-actor id, so its Actor is built from the id's prefix and preheated — LoadActors has no backing store. The built actor is returned (nil when absent) so the caller can batch-hydrate display names.

Types

type CreateDemandOverrideEndpoint

type CreateDemandOverrideEndpoint struct{}

Creates a demand override, telling the planner about demand the sales history cannot see.

The scope reference is validated against the account's items and product lines, so an override can never silently match nothing. An `account`-scoped override takes no scope reference and must be a delta rather than an absolute value, since one number fanned out across every item would flatten the whole plan.

Schedules that have already been generated are unaffected; the override is picked up by the next one.

type CreateDemandOverrideRequest

type CreateDemandOverrideRequest struct {
	// What the override targets.
	//
	// - `item`: a single item.
	// - `product_line`: every item sold under one product line.
	// - `account`: every item in the plan, which is how a blanket assumption such as "plan for double demand" is expressed.
	ScopeType constants.DemandOverrideScope `json:"scope_type" validate:"required"`
	// ID of the item or product line the override targets.
	//
	// Omit it for an `account`-wide override, which targets every planned item rather than one thing. The ID is checked against the account's items and product lines, so an override cannot be created against something that does not exist.
	ScopeRefID string `json:"scope_ref_id,omitzero" validate:"omitempty"`
	// First day of the demand period the override applies to.
	//
	// Overrides are applied month by month, so every calendar month the period touches is adjusted and any time of day is ignored.
	PeriodStartsAt time.Time `json:"period_starts_at" validate:"required"`
	// Last day of the demand period the override applies to.
	//
	// Must fall on or after `period_starts_at`.
	PeriodEndsAt time.Time `json:"period_ends_at" validate:"required"`
	// How the value adjusts the forecast.
	//
	// - `absolute`: replaces the forecast for each month in the period.
	// - `delta_units`: adds the value to each month in the period.
	// - `delta_percent`: scales each month in the period by the value as a percentage.
	//
	// When several overrides land on the same month they are applied in that order, so a percentage always acts on the already-adjusted number.
	Adjustment constants.DemandOverrideAdjustment `json:"adjustment" validate:"required"`
	// The amount of the adjustment, interpreted according to `adjustment`.
	//
	// A `delta_percent` value is a number of percent, so `-25` plans a quarter less than the forecast; it cannot go below `-100`. An `absolute` value cannot be negative, while a `delta_units` value can, so that a cancelled program removes demand.
	Value float64 `json:"value" validate:"required"`
	// ID of the unit the value is expressed in.
	//
	// Recorded for context only: the value is applied to the planned demand without unit conversion, so a unit adjustment should be stated in the unit the item is planned in.
	UnitID field.Optional[string] `json:"unit_id,omitzero"`
	// Why the adjustment was made.
	//
	// The reason is carried into each schedule the override changes, so a plan can explain why a month departs from history.
	Reason field.Optional[constants.DemandOverrideReason] `json:"reason,omitzero"`
	// Free-form notes about the adjustment.
	//
	// This is the text the free-text search on the list endpoint matches against.
	Note field.Optional[string] `json:"note,omitzero" validate:"omitempty,max=2000"`
	// When the override starts being applied to newly generated schedules.
	//
	// When omitted, the override starts applying straight away.
	EffectiveAt field.Optional[time.Time] `json:"effective_at,omitzero"`
	// When the override stops being applied to newly generated schedules.
	//
	// When omitted, the override keeps applying until it is deactivated or deleted.
	ExpiresAt field.Optional[time.Time] `json:"expires_at,omitzero"`
	// Whether the override is taken into account when a schedule is generated.
	//
	// Send `false` to stage an adjustment that should not affect schedules yet; an override is otherwise created ready to apply.
	Active field.Optional[bool] `json:"active,omitzero"`
}

Request to create a demand override.

func (*CreateDemandOverrideRequest) SchemaExample

func (*CreateDemandOverrideRequest) SchemaExample() any

type DeleteDemandOverrideEndpoint

type DeleteDemandOverrideEndpoint struct{}

Deletes a demand override permanently.

Schedules that have already been generated are unaffected: each one records the overrides it applied, so deleting an override changes only schedules generated from now on. To stop an override applying while keeping it on file, deactivate it instead.

type DeleteDemandOverrideRequest

type DeleteDemandOverrideRequest struct {
	// ID of the demand override.
	DemandOverrideID string `path:"id" validate:"required"`
}

Request to delete a demand override.

type DemandOverridesSvcConfig

type DemandOverridesSvcConfig struct {
	// CoreClient (required) is the core-service demand-override gRPC client.
	CoreClient pb.CoreDemandOverrideServiceClient
}

type ListDemandOverrideTypesEndpoint

type ListDemandOverrideTypesEndpoint struct{}

Returns the demand override types, which describe how an override's value adjusts the forecast.

The taxonomy is platform-provided and identical for every account; each type's `code` is a value accepted as an override's `adjustment`.

type ListDemandOverrideTypesRequest

type ListDemandOverrideTypesRequest struct{}

Request to list demand override types.

type ListDemandOverridesEndpoint

type ListDemandOverridesEndpoint struct{}

Returns a paginated list of demand overrides, most recently created first.

The period filters match on overlap rather than containment, so an override spanning a quarter is returned when querying a single month inside it. The `q` search term matches the override's note.

type ListDemandOverridesRequest

type ListDemandOverridesRequest struct {
	apiresource.PaginationRequest
	// Only return overrides with these kinds of target.
	ScopeTypes []constants.DemandOverrideScope `query:"scope_types"`
	// Only return overrides targeting these items or product lines.
	ScopeRefIDs []string `query:"scope_ref_ids"`
	// Only return overrides making these kinds of adjustment.
	Adjustments []constants.DemandOverrideAdjustment `query:"adjustments"`
	// Only return overrides in these activation states.
	Statuses []constants.ActivationStatus `query:"statuses"`
	// The start of the window to match against. Only return overrides whose period ends on or after this timestamp, formatted as RFC3339.
	PeriodStart *string `query:"starts_at"`
	// The end of the window to match against. Only return overrides whose period starts on or before this timestamp, formatted as RFC3339.
	PeriodEnd *string `query:"ends_at"`
}

Request to list demand overrides.

type RetrieveDemandOverrideEndpoint

type RetrieveDemandOverrideEndpoint struct{}

Retrieves a single demand override by ID.

type RetrieveDemandOverrideRequest

type RetrieveDemandOverrideRequest struct {
	// ID of the demand override.
	DemandOverrideID string `path:"id" validate:"required"`
}

Request to retrieve a demand override.

type UpdateDemandOverrideEndpoint

type UpdateDemandOverrideEndpoint struct{}

Updates a demand override.

Only the fields sent are changed. The adjustment and value are validated as a pair against the resulting override, so switching a stored unit adjustment to `delta_percent` is checked as a percentage even when only the adjustment is sent; the period is checked the same way.

What an override targets cannot be changed — create a new override to adjust a different item, product line, or the account as a whole. Schedules that have already been generated are unaffected; the change is picked up by the next one.

type UpdateDemandOverrideRequest

type UpdateDemandOverrideRequest struct {
	// ID of the demand override.
	DemandOverrideID string `path:"id" validate:"required"`
	// First day of the demand period the override applies to.
	//
	// Overrides are applied month by month, so every calendar month the period touches is adjusted and any time of day is ignored.
	PeriodStartsAt field.Optional[time.Time] `json:"period_starts_at,omitzero"`
	// Last day of the demand period the override applies to.
	//
	// Must fall on or after the override's start, whether that is sent here or already stored.
	PeriodEndsAt field.Optional[time.Time] `json:"period_ends_at,omitzero"`
	// How the value adjusts the forecast.
	//
	// - `absolute`: replaces the forecast for each month in the period.
	// - `delta_units`: adds the value to each month in the period.
	// - `delta_percent`: scales each month in the period by the value as a percentage.
	Adjustment field.Optional[constants.DemandOverrideAdjustment] `json:"adjustment,omitzero"`
	// The amount of the adjustment, interpreted according to `adjustment`.
	//
	// It is validated against the adjustment the override ends up with, so switching a stored unit delta to `delta_percent` without sending a new value requires the existing value to be a legal percentage.
	Value field.Optional[float64] `json:"value,omitzero"`
	// ID of the unit the value is expressed in.
	//
	// Recorded for context only: the value is applied to the planned demand without unit conversion.
	UnitID field.Clearable[string] `json:"unit_id,omitzero"`
	// Why the adjustment was made.
	//
	// The reason is carried into each schedule the override changes, so a plan can explain why a month departs from history.
	Reason field.Clearable[constants.DemandOverrideReason] `json:"reason,omitzero"`
	// Free-form notes about the adjustment.
	Note field.Clearable[string] `json:"note,omitzero" validate:"omitempty,max=2000"`
	// When the override stops being applied to newly generated schedules.
	//
	// Clear it to keep the override applying until it is deactivated or deleted.
	ExpiresAt field.Clearable[time.Time] `json:"expires_at,omitzero"`
	// Whether the override is taken into account when a schedule is generated.
	//
	// Deactivating parks the override without losing it; it is skipped whatever its effective window says, and can be reactivated later.
	Active field.Optional[bool] `json:"active,omitzero"`
}

Request to update a demand override.

func (*UpdateDemandOverrideRequest) SchemaExample

func (*UpdateDemandOverrideRequest) SchemaExample() any

Jump to

Keyboard shortcuts

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