Class PriceGrid

Object
DomainObject
PersistedObject
PartitionedObject
AbstractCalculable
CalculableObject
MatrixableCalculableObject
PriceGrid
All Implemented Interfaces:
APIModifiable, Calculable, EmbeddedObject, HasCalculableObjectItems, JobNameProvider, JobSettingsProvider, NamedChangeTracker, TreeStructuredObject, UserGroupRestrictedObject

@Entity public class PriceGrid extends MatrixableCalculableObject implements TreeStructuredObject, UserGroupRestrictedObject, APIModifiable, NamedChangeTracker, JobSettingsProvider, EmbeddedObject
A Live Price Grid (LPG, type code PG) is a continuously maintained set of calculated prices, one line item per SKU (or per SKU and secondary key for a Matrix grid). Unlike a Pricelist, which is a frozen snapshot approved as a whole and replaced by a new revision, a Price Grid can be recalculated partially for selected SKUs, and its line items are approved one by one.

A calculation logic (Nature generic/default) calculates one line item at a time; the Price Grid header is not passed to it as an object. api.currentItem() returns the line item (PGI or XPGI), and a Price Grid is not one of the contexts supported by api.currentContext().

To read a Price Grid from a logic, use api.findPriceGrids(targetDate, name). Related calls: api.triggerPriceGridCalculation, api.recalculatePriceGridItems and api.updateCalculableObjectHeader("PG", id). Line items have the type code PGI (XPGI for a Matrix Price Grid, see getPriceGridType()) and reference their Price Grid by the priceGridId field.

A Matrix Price Grid's line items are generated at calculation time: before the items are calculated, a matrix-nature logic runs once per SKU and returns its secondary keys (key2), and each SKU and key2 pair becomes a line item. The items themselves are calculated by the default-nature logic. The matrix phase runs in every calculation that is not limited to given line items, SKU-scoped recalculations included; a dirty-items pass skips it.

A Price Grid has no single header-level approval workflow (it does not implement an approval lifecycle the way Pricelist does); instead, each line item is submitted and approved on its own (one by one or with mass actions), and getApprovalState() together with getNumberOfApprovedItems(), getNumberOfOpenItems(), getNumberOfDeniedItems(), getNumberOfSubmittedItems() and getNumberOfAutoApprovedItems() report the current rollup of item-level approval across the grid. Approving a line item can start a Condition Record job for it; the CONDITION_RECORD_CREATION_FINISHED event then carries this Price Grid's typed id as sourceObjectId. Do follow-up actions there, not in the Condition Record logic. Access to a Price Grid's detail view and edit actions can be restricted to specific User Groups via getUserGroupViewDetails() and getUserGroupEdit().

A Price Grid can be owned by a PricingPlanScenario (see getParentTypedId()). The owner manages the header, the configuration and the full calculation of an owned Price Grid: they cannot be edited directly, the Price Grid cannot be deleted directly, and api.triggerPriceGridCalculation without skusToRecalc does not start a job for it (returns null). Its product filter is changed through the owning Pricing Plan Scenario. Line items of an owned Price Grid can be edited, approved, denied and partially recalculated only while the owner's Pricing Plan Revision is not locked, no calculation of the owner is running and the Price Grid itself is calculated. Otherwise these requests are rejected, and api.recalculatePriceGridItems and a partial api.triggerPriceGridCalculation silently do nothing.

Example, looking up a Price Grid by name and reading its item-approval rollup:


 def pg = api.findPriceGrids(api.targetDate(), "EMEA Q3 Grid")?.find()
 if (pg?.numberOfOpenItems > 0) {
   // ...
 }
 
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class MatrixableCalculableObject

    MatrixableCalculableObject.ListType

    Nested classes/interfaces inherited from class PersistedObject

    PersistedObject.BatchDelete, PersistedObject.BulkloadFilterCheckCallback, PersistedObject.ComputedFieldMapping, PersistedObject.ComputedFields, PersistedObject.HardDelete, PersistedObject.ImportManagerEnabled, PersistedObject.PersistedObjectMeta, PersistedObject.VirtualField, PersistedObject.VirtualFieldMapping, PersistedObject.VirtualFields, PersistedObject.VirtualSearchFields, PersistedObject.VirtualSortFields
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class AbstractCalculable

    FIELD_CALCDATE, FIELD_CALCMESSAGES, FIELD_CALCSTARTDATE, FIELD_STATUS, MAX_CALCULATION_MESSAGE_LENGTH, MAX_CALCULATION_MESSAGE_THRESHOLD

    Fields inherited from class PartitionedObject

    FIELD_PARTITION, FIELD_PARTITIONID, PARTITION_FILTER_NAME, PARTITION_FILTER_PARAM

    Fields inherited from class PersistedObject

    FIELD_CREATEDATE, FIELD_CREATEDBY, FIELD_DELETEDATE, FIELD_DELETEDBY, FIELD_ID, FIELD_ISDELETED, FIELD_LASTUPDATEBY, FIELD_LASTUPDATEDATE, FIELD_VERSION

    Fields inherited from interface UserGroupRestrictedObject

    FIELD_USERGROUPEDIT, FIELD_USERGROUPVIEWDETAILS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty Price Grid; only the list type (SIMPLE) and the item counters (0) are initialized.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canDelete(User user, ValidationVisitor validationVisitor, PersistedObjectService objService)
    Whether user may delete this Price Grid.
    boolean
    canEdit(User user, ValidationVisitor validationVisitor, PersistedObjectService objService, Map<String,Object> fieldsToEdit)
    Whether user may edit this Price Grid, in addition to the base checks performed by the superclass (which include the getUserGroupEdit() restriction).
    void
    copyPreferencesFromSource(PersistedObjectService objService)
    Copies the line item grid-view and portlet preferences from the source Price Grid named in the configuration's preferences source, unless this Price Grid already has its own line item preferences.
    getAgentOption1(PersistedObjectService objService, JobStatusTracker jst, int runNumber)
    A flag passed to the calculation agent.
    This Price Grid's header-level approval rollup, recomputed from its line items by updateHeaderApprovalState(PersistedObjectService).
    The concurrency key of the calculation jobs started for this Price Grid: an owned Price Grid uses its owner's typed id, so these jobs of all Price Grids with the same owner share one key.
    The raw JSON string backing getPriceGridConfiguration().
    The login name of the user who created this Price Grid, cached at creation time for display without an extra join.
    JobStatusTracker.TrackerType
    The kind of background job tracker used by default when this Price Grid's calculation runs.
    A free-text description of this Price Grid.
    getEffectiveTargetDate(PersistedObjectService objService)
    The target date this Price Grid's calculation runs against: its own target date if one is set, otherwise the current date and time (adjusted for the partition's time zone) shifted by getRelativeTargetDateDays() days when configured.
    The unique name of the Price Setting Type (PriceGridType) linked to this Price Grid, which supplies the header formula used by onSaveOrUpdate(PersistedObjectService) to keep getPriceGridConfiguration()'s header formula in sync.
    A free-text status for external integrations.
    Class<? extends ElementAttributeMeta>
    The attribute-metadata type describing extension/attribute metadata for this Price Grid's line items.
    Class<? extends AbstractPriceGridItem>
    The concrete line item type backing this Price Grid's items: PriceGridItem for a plain, per-SKU Price Grid or one whose type is not yet known, MatrixPriceGridItem for a Matrix Price Grid (see getPriceGridType()).
    Equivalent to getItemListFilterFieldS(): the entity field name used to look up this Price Grid's line items.
    static String
    The field on a line item (PGI / XPGI) that references its Price Grid, for example api.find("PGI", 0, 0, null, ["sku"], Filter.equal("priceGridId", priceGridId)).
    The job-type discriminator used for background calculation job naming/routing.
    The login name of the user who last updated this Price Grid, cached at update time for display without an extra join.
    MatrixableCalculableObject.ListType
    Equivalent to getPriceGridType().
    This Price Grid's position in its containing tree hierarchy, used for tree-based navigation.
    The number of this Price Grid's line items currently approved, part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
    The number of this Price Grid's line items approved automatically (without an explicit approval action), part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
    The number of this Price Grid's line items currently denied, part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
    The number of this Price Grid's line items whose approval state is not APPROVED, AUTO_APPROVED or DENIED.
    The number of this Price Grid's line items currently submitted for approval but not yet decided, part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
    The typed id of the PricingPlanScenario that owns this Price Grid.
    The date and time this Price Grid was last partially recalculated (for example a dirty-items or SKU-restricted run, as opposed to a full recalculation).
    PriceGridConfiguration
    The structured configuration of this Price Grid (calculation logic selection, matrix settings, shotgun mode, and similar options), deserialized from the JSON stored in getConfiguration() and cached: the first call parses it, later calls return the same cached instance until setPriceGridConfiguration(PriceGridConfiguration) or setConfigurationString(String) replaces it.
    Equivalent to getId(), exposed under the id JSON property name so the Price Grid's id is always present in the API response.
    MatrixableCalculableObject.ListType
    Whether this is a plain, per-SKU Price Grid or a Matrix Price Grid with a secondary key.
    An offset, in days from the calculation date, used to compute getEffectiveTargetDate(PersistedObjectService) when this Price Grid has no explicit target date.
    int
    getShotgunThreshold(PersistedObjectService objService, JobStatusTracker jst)
    The minimum job size (see jobSize(PersistedObjectService, JobStatusTracker, int)) above which the calculation framework switches into shotgun (distributed) mode instead of a single sequential run, when isShotgunEnabled(PersistedObjectService) allows it.
    The date and time this Price Grid was last updated.
    The id of the user who last updated this Price Grid.
    The User Group(s) whose members may edit and delete this Price Grid; users outside them are blocked by canEdit(User, ValidationVisitor, PersistedObjectService, Map) and canDelete(User, ValidationVisitor, PersistedObjectService).
    The User Group(s) whose members may view this Price Grid's details.
    boolean
    A shorthand for ListType.MATRIX.equals(getPriceGridType()), useful where a full switch over getPriceGridType() is not needed.
    boolean
    isShotgunEnabled(PersistedObjectService txn)
    Whether "shotgun mode" (distributed calculation spread across multiple worker agents/pods rather than run sequentially) is allowed for this Price Grid at all, controlled by the shotgun mode setting in getPriceGridConfiguration().
    void
    itemsStateChanged(PersistedObjectService objService)
    Refreshes the header counters and approval rollup via updateHeaderApprovalState(PersistedObjectService), after the superclass handling.
    int
    jobSize(PersistedObjectService objectService, JobStatusTracker jst, int runNumber)
    The size of this Price Grid's current calculation run: the number of line items the run is expected to process.
    void
    onDelete(PersistedObjectService objService, boolean hardDelete)
    Called by the persistence layer when this Price Grid is deleted.
    boolean
    onPreProcessing(PersistedObjectService objService, Map<String,Object> values, LocalDateTime targetDate)
    Called before this Price Grid is created, updated, or deleted through the API (for example api.update("PG", ...)).
    void
    onSaveOrUpdate(PersistedObjectService objService)
    Called by the persistence layer right before this Price Grid is saved.
    The last partial-calculation date and time formatted for display, using the partition's configured date-time pattern.
    void
    Sets the approval rollup.
    void
    Stores the raw JSON configuration string and drops the cached configuration object, so the next getPriceGridConfiguration() call parses it again.
    void
    setCreatedByName(String createdByName)
    Sets the creator's login name.
    void
    setDescription(String description)
    Sets the free-text description of this Price Grid.
    void
    setHeaderTypeUniqueName(String headerTypeUniqueName)
    Links this Price Grid to a Price Setting Type.
    void
    setIntegrationStatus(String integrationStatus)
    Sets the free-text integration status (see getIntegrationStatus()).
    void
    setLastUpdateByName(String lastUpdateByName)
    Sets the login name of the last updating user.
    void
    setNodeId(Number nodeId)
    Sets this Price Grid's position in its tree hierarchy.
    void
    setParentTypedId(String parentTypedId)
    Sets the owning PricingPlanScenario.
    void
    setPartialCalculationDate(LocalDateTime lastPartialCalculation)
    Sets the date and time of the last partial calculation.
    void
    setPriceGridConfiguration(PriceGridConfiguration configuration)
    Stores the given configuration, serializing it to JSON, and caches the object itself so a subsequent getPriceGridConfiguration() call returns this same instance rather than deserializing again.
    void
    No-op setter kept only so the JSON deserializer accepts an incoming id field without failing; the id cannot be set directly.
    void
    setPriceGridType(MatrixableCalculableObject.ListType priceGridType)
    Sets this Price Grid's list type.
    void
    setRelativeTargetDateDays(Integer relativeTargetDateDays)
    Sets the offset in days used when this Price Grid has no explicit target date.
    void
    No-op setter kept only so the JSON deserializer accepts an incoming updateDate field; the actual last-update timestamp is maintained internally and cannot be set directly.
    void
    setUpdatedBy(Long updateBy)
    No-op setter kept only so the JSON deserializer accepts an incoming updatedBy field; the actual last-updating user is maintained internally and cannot be set directly.
    void
    Sets the User Group(s) whose members may edit and delete this Price Grid (see getUserGroupEdit()).
    void
    Sets the User Group(s) whose members may view this Price Grid's details (see getUserGroupViewDetails()).
    void
    updateHeaderApprovalState(PersistedObjectService objService)
    Recomputes this Price Grid's header-level getApprovalState() from the number of line items in state APPROVED: NOT_APPROVED when there are none (also for an empty grid), APPROVED when all line items are APPROVED, PARTIALLY_APPROVED otherwise.
    int[]
    updatePriceGridNumbers(PersistedObjectService objService)
    Recounts this Price Grid's line items and stores the header counters (total, approved, auto-approved, denied, submitted and open items) directly in the database, without a version bump; the getters of this in-memory instance are not refreshed.
    boolean
    validate(ValidationVisitor validationVisitor, PersistedObjectService objService)
    Validates this Price Grid before it is saved, in addition to the base validation performed by the superclass.

    Methods inherited from class MatrixableCalculableObject

    anyToRecalculation

    Methods inherited from class CalculableObject

    getKeepManualOverrides, getNumberOfItems, getWriteOnlyChangedItems, setKeepManualOverrides, setNumberOfItems, setWriteOnlyChangedItems

    Methods inherited from class AbstractCalculable

    calculationDate, calculationStartDate, getCalculationDate, getCalculationMessages, getCalculationMessagesAsList, getCalculationStartDate, getJobName, getLabel, getLocale, getStatus, getTargetDate, isAnonymousCalculable, setCalculationDate, setCalculationMessages, setCalculationMessages, setCalculationStartDate, setLabel, setLocale, setStatus, setTargetDate

    Methods inherited from class PartitionedObject

    addUniqueConstraint, getLoginNameByUserId, getPartition, setPartition, toString

    Methods inherited from class PersistedObject

    auditOperation, bumpVersion, canAdd, canEdit, canRead, canReadElements, createDate, entityIsHardDeleted, entityIsMassDeletable, entityIsSafeInserted, entityIsSafeInserted, getBulkloadMap, getBusinessKey, getCreateDate, getCreatedBy, getDbColumnNameForField, getDeleteDate, getDeletedBy, getId, getLastUpdateBy, getLastUpdateDate, getSensitiveFields, getSignificantFields, getTypeCode, getTypedId, getVersion, getVirtualSearchFieldMappings, getVirtualSortFieldMappings, isAudited, isDeleted, isHardDeleted, isVirtualSearchField, lastUpdateDate, notifyOnBusinessKeyChange, onBusinessKeyChange, onRefreshed, onSavedOrUpdated, setCreateDate, setCreateDateShouldBeIgnored, setCreateDateTime, setCreatedBy, setDeleted, setDeleteDate, setDeletedBy, setId, setLastUpdateBy, setLastUpdateDate, setLastUpdateDateTime, setTypedId, setVersion, userGroupEditBulkloadFilter, userGroupEditBulkloadFilter

    Methods inherited from class DomainObject

    deepCopy, getNewMidnightDate, getNewMidnightDateTime, isMidnight, isMidnight, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerializedSizeOK, jsonSerializeToBytes, jsonSerializeToBytes, setToDayEnd, setToDayEnd, setToMidnight, setToMidnight, setToMidnightAsLocalDateTime, toPropertyMap, truncatedToString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • PriceGrid

      public PriceGrid()
      Creates an empty Price Grid; only the list type (SIMPLE) and the item counters (0) are initialized.
  • Method Details

    • getConfiguration

      public String getConfiguration()
      The raw JSON string backing getPriceGridConfiguration(). Used for persistence.
      Returns:
      The JSON-encoded configuration, or null if none has been set yet.
      See Also:
    • setPriceGridConfiguration

      public void setPriceGridConfiguration(PriceGridConfiguration configuration)
      Stores the given configuration, serializing it to JSON, and caches the object itself so a subsequent getPriceGridConfiguration() call returns this same instance rather than deserializing again.
      Parameters:
      configuration - The configuration to store.
    • setConfigurationString

      public void setConfigurationString(String configuration)
      Stores the raw JSON configuration string and drops the cached configuration object, so the next getPriceGridConfiguration() call parses it again. Used for persistence. To change a Price Grid's configuration from a logic, use api.update("PG", ...) with a configuration map.
      Parameters:
      configuration - The JSON-encoded configuration to store.
    • getPriceGridConfiguration

      public PriceGridConfiguration getPriceGridConfiguration()
      The structured configuration of this Price Grid (calculation logic selection, matrix settings, shotgun mode, and similar options), deserialized from the JSON stored in getConfiguration() and cached: the first call parses it, later calls return the same cached instance until setPriceGridConfiguration(PriceGridConfiguration) or setConfigurationString(String) replaces it.
      Returns:
      The parsed configuration. Never null: an empty PriceGridConfiguration is returned when none has been set yet.
      See Also:
    • getDescription

      public String getDescription()
      A free-text description of this Price Grid.
      Returns:
      The description. May be null.
    • setDescription

      public void setDescription(String description)
      Sets the free-text description of this Price Grid.
      Parameters:
      description - A free-text description of this Price Grid. A value longer than 255 characters fails validation on save (see validate(ValidationVisitor, PersistedObjectService)).
    • getUpdatedBy

      public Long getUpdatedBy()
      The id of the user who last updated this Price Grid. Re-exposes getLastUpdateBy() under the updatedBy JSON property name used by the Price Grid and price item payloads.
      Returns:
      The last-updating user's id, or null if not yet updated.
    • getUpdateDate

      public LocalDateTime getUpdateDate()
      The date and time this Price Grid was last updated. Re-exposes getLastUpdateDate() under the updateDate JSON property name used by the Price Grid and price item payloads.
      Returns:
      The last-update date and time, or null if not yet updated.
    • setUpdateDate

      public void setUpdateDate(LocalDateTime updateDate)
      No-op setter kept only so the JSON deserializer accepts an incoming updateDate field; the actual last-update timestamp is maintained internally and cannot be set directly.
      Parameters:
      updateDate - Ignored.
    • setUpdatedBy

      public void setUpdatedBy(Long updateBy)
      No-op setter kept only so the JSON deserializer accepts an incoming updatedBy field; the actual last-updating user is maintained internally and cannot be set directly.
      Parameters:
      updateBy - Ignored.
    • getPriceGridId

      public Long getPriceGridId()
      Equivalent to getId(), exposed under the id JSON property name so the Price Grid's id is always present in the API response.
      Returns:
      This Price Grid's id.
    • setPriceGridIdShouldBeIgnored

      public void setPriceGridIdShouldBeIgnored(Long id)
      No-op setter kept only so the JSON deserializer accepts an incoming id field without failing; the id cannot be set directly.
      Parameters:
      id - Ignored.
    • getNodeId

      public Long getNodeId()
      This Price Grid's position in its containing tree hierarchy, used for tree-based navigation. Not related to line items or calculation.
      Specified by:
      getNodeId in interface TreeStructuredObject
      Returns:
      The tree node id, or null if this Price Grid is not attached to a tree node.
    • setNodeId

      public void setNodeId(Number nodeId)
      Sets this Price Grid's position in its tree hierarchy. Only Long, Integer, Short and Byte values are applied; any other value, null included, is ignored, so the link cannot be cleared this way.
      Specified by:
      setNodeId in interface TreeStructuredObject
      Parameters:
      nodeId - The tree node id to assign.
    • getParentTypedId

      public String getParentTypedId()
      The typed id of the PricingPlanScenario that owns this Price Grid.
      Specified by:
      getParentTypedId in interface EmbeddedObject
      Returns:
      The owner's typed id, or null for a standalone Price Grid.
    • setParentTypedId

      public void setParentTypedId(String parentTypedId)
      Sets the owning PricingPlanScenario. Accepted only when the Price Grid is created; changing it later is rejected by canEdit(User, ValidationVisitor, PersistedObjectService, Map).
      Parameters:
      parentTypedId - The typed id of an existing Pricing Plan Scenario, or null for a standalone Price Grid.
    • getCalculationConcurrencyKey

      public String getCalculationConcurrencyKey()
      The concurrency key of the calculation jobs started for this Price Grid: an owned Price Grid uses its owner's typed id, so these jobs of all Price Grids with the same owner share one key. Dirty-item passes and distributed re-runs keep the key of the job that spawned them. Not meant to be used directly in Groovy.
      Overrides:
      getCalculationConcurrencyKey in class AbstractCalculable
      Returns:
      getParentTypedId() for an owned Price Grid, the default key otherwise.
    • getApprovalState

      public ApprovalState getApprovalState()
      This Price Grid's header-level approval rollup, recomputed from its line items by updateHeaderApprovalState(PersistedObjectService). Only NOT_APPROVED, PARTIALLY_APPROVED and APPROVED occur; line items in state AUTO_APPROVED are not counted as approved. Unlike Pricelist, a Price Grid has no header-level approval workflow of its own; each line item is submitted and approved individually.
      Returns:
      The current ApprovalState rollup, or null if it has not been computed yet.
      See Also:
    • setApprovalState

      public void setApprovalState(ApprovalState approvalState)
      Sets the approval rollup. The framework overwrites it whenever the rollup is recomputed. Not meant to be used directly in Groovy.
      Parameters:
      approvalState - The approval state rollup to assign.
    • getUserGroupEdit

      public String getUserGroupEdit()
      The User Group(s) whose members may edit and delete this Price Grid; users outside them are blocked by canEdit(User, ValidationVisitor, PersistedObjectService, Map) and canDelete(User, ValidationVisitor, PersistedObjectService). Users with the USERGROUP_OVERRIDE permission bypass the restriction.
      Specified by:
      getUserGroupEdit in interface UserGroupRestrictedObject
      Returns:
      A User Group unique name or a comma-separated list of them, or null if editing is not restricted by User Group.
    • setUserGroupEdit

      public void setUserGroupEdit(String userGroup)
      Sets the User Group(s) whose members may edit and delete this Price Grid (see getUserGroupEdit()).
      Specified by:
      setUserGroupEdit in interface UserGroupRestrictedObject
      Parameters:
      userGroup - A User Group unique name or a comma-separated list of them, or null to remove the restriction.
    • getUserGroupViewDetails

      public String getUserGroupViewDetails()
      The User Group(s) whose members may view this Price Grid's details. Members of the edit User Group(s) (getUserGroupEdit()) may view the details too, and users with the USERGROUP_OVERRIDE permission bypass the restriction.
      Specified by:
      getUserGroupViewDetails in interface UserGroupRestrictedObject
      Returns:
      A User Group unique name or a comma-separated list of them, or null if viewing is not restricted by User Group.
    • setUserGroupViewDetails

      public void setUserGroupViewDetails(String userGroup)
      Sets the User Group(s) whose members may view this Price Grid's details (see getUserGroupViewDetails()).
      Specified by:
      setUserGroupViewDetails in interface UserGroupRestrictedObject
      Parameters:
      userGroup - A User Group unique name or a comma-separated list of them, or null to remove the restriction.
    • getRelativeTargetDateDays

      public Integer getRelativeTargetDateDays()
      An offset, in days from the calculation date, used to compute getEffectiveTargetDate(PersistedObjectService) when this Price Grid has no explicit target date. Cleared automatically once an explicit target date is set (see validate(ValidationVisitor, PersistedObjectService)).
      Returns:
      The offset in days, or null if not configured or if an explicit target date is set.
    • setRelativeTargetDateDays

      public void setRelativeTargetDateDays(Integer relativeTargetDateDays)
      Sets the offset in days used when this Price Grid has no explicit target date.
      Parameters:
      relativeTargetDateDays - The offset in days from the calculation date to use as this Price Grid's effective target date, or null to clear it.
    • getNumberOfApprovedItems

      public Integer getNumberOfApprovedItems()
      The number of this Price Grid's line items currently approved, part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
      Returns:
      The count of approved line items.
    • getNumberOfOpenItems

      public Integer getNumberOfOpenItems()
      The number of this Price Grid's line items whose approval state is not APPROVED, AUTO_APPROVED or DENIED. This includes the items currently submitted for approval, which are also counted by getNumberOfSubmittedItems(). Part of the header counters refreshed by updatePriceGridNumbers(PersistedObjectService).
      Returns:
      The count of line items not yet approved or denied.
    • getNumberOfDeniedItems

      public Integer getNumberOfDeniedItems()
      The number of this Price Grid's line items currently denied, part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
      Returns:
      The count of denied line items.
    • getNumberOfAutoApprovedItems

      public Integer getNumberOfAutoApprovedItems()
      The number of this Price Grid's line items approved automatically (without an explicit approval action), part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
      Returns:
      The count of auto-approved line items.
    • getNumberOfSubmittedItems

      public Integer getNumberOfSubmittedItems()
      The number of this Price Grid's line items currently submitted for approval but not yet decided, part of the item-level approval rollup recomputed by updateHeaderApprovalState(PersistedObjectService).
      Returns:
      The count of submitted, pending line items.
    • getPartialCalculationDate

      public LocalDateTime getPartialCalculationDate()
      The date and time this Price Grid was last partially recalculated (for example a dirty-items or SKU-restricted run, as opposed to a full recalculation).
      Returns:
      The last partial-calculation date and time, or null if this Price Grid has not had a partial calculation.
    • setPartialCalculationDate

      public void setPartialCalculationDate(LocalDateTime lastPartialCalculation)
      Sets the date and time of the last partial calculation. Set by the calculation. Not meant to be used directly in Groovy.
      Parameters:
      lastPartialCalculation - The date and time of this Price Grid's last partial calculation, or null to clear it.
    • getIntegrationStatus

      public String getIntegrationStatus()
      A free-text status for external integrations. The platform neither sets nor interprets it.
      Returns:
      The integration status. May be null.
    • setIntegrationStatus

      public void setIntegrationStatus(String integrationStatus)
      Sets the free-text integration status (see getIntegrationStatus()).
      Parameters:
      integrationStatus - The integration/export status to record.
    • partialCalculationDate

      public String partialCalculationDate()
      The last partial-calculation date and time formatted for display, using the partition's configured date-time pattern. Serialized under the JSON property partialCalculationDate in place of the raw getPartialCalculationDate() value.
      Returns:
      The formatted date and time, or null if this Price Grid has not had a partial calculation.
    • getEffectiveTargetDate

      public LocalDateTime getEffectiveTargetDate(PersistedObjectService objService)
      The target date this Price Grid's calculation runs against: its own target date if one is set, otherwise the current date and time (adjusted for the partition's time zone) shifted by getRelativeTargetDateDays() days when configured.
      Overrides:
      getEffectiveTargetDate in class CalculableObject
      Parameters:
      objService - Used to resolve the partition's time zone offset when no explicit target date is set.
      Returns:
      The effective target date and time for calculation.
    • getPriceGridType

      public MatrixableCalculableObject.ListType getPriceGridType()
      Whether this is a plain, per-SKU Price Grid or a Matrix Price Grid with a secondary key. This also determines the line item type returned by getItemClass(). Unlike Pricelist.getPricelistType(), a null value is not defaulted to SIMPLE.
      Returns:
      The list type, or null when the type was explicitly cleared or never stored; a later save does not repair it.
    • getListType

      public MatrixableCalculableObject.ListType getListType()
      Equivalent to getPriceGridType().
      Overrides:
      getListType in class MatrixableCalculableObject
      Returns:
      The list type, or null when the type was explicitly cleared or never stored; a later save does not repair it.
    • setPriceGridType

      public void setPriceGridType(MatrixableCalculableObject.ListType priceGridType)
      Sets this Price Grid's list type. New Price Grids start as SIMPLE. The call is ignored when the current type is null.
      Parameters:
      priceGridType - The list type to assign.
    • validate

      public boolean validate(ValidationVisitor validationVisitor, PersistedObjectService objService)
      Validates this Price Grid before it is saved, in addition to the base validation performed by the superclass. Rejects a getDescription() longer than 255 characters; on create, rejects a getParentTypedId() that does not reference an existing Pricing Plan Scenario; clears getRelativeTargetDateDays() once an explicit target date is present; calls setPriceGridType(ListType) with SIMPLE when the type is unset (which the setter ignores, see there); and, for a user restricted to the PB_PRICEGRIDEDITOR_ADD_SKU role (see canEdit(User, ValidationVisitor, PersistedObjectService, Map)), rejects a configuration change that touches more than the inputs section. Not meant to be used directly in Groovy.
      Overrides:
      validate in class AbstractCalculable
      Parameters:
      validationVisitor - Receives a validation error when this Price Grid is invalid. May be null, in which case errors are simply not recorded.
      objService - Used to delegate to the superclass validation.
      Returns:
      true if this Price Grid is valid, false otherwise.
    • canEdit

      public boolean canEdit(User user, ValidationVisitor validationVisitor, PersistedObjectService objService, Map<String,Object> fieldsToEdit)
      Whether user may edit this Price Grid, in addition to the base checks performed by the superclass (which include the getUserGroupEdit() restriction). For a Price Grid owned by a Pricing Plan Scenario, any edit scoped to fields (header or configuration) is rejected; a parentTypedId in fieldsToEdit is always rejected, since the owner can be set only on create. A user who has the PB_PRICEGRIDEDITOR_ADD_SKU role but not the broader PB_PRICEGRIDS role is restricted further: with no specific fields scoped (a recalculation request) the edit is allowed, but an edit that touches more than the typed id, version, and configuration fields is rejected, and one that touches exactly those three is allowed only provisionally, recording the prior configuration so validate(ValidationVisitor, PersistedObjectService) can later confirm the configuration change was limited to the inputs section. Not meant to be used directly in Groovy.
      Overrides:
      canEdit in class PersistedObject
      Parameters:
      user - The user attempting the edit.
      validationVisitor - Receives a validation error when the edit is not allowed. May be null, in which case errors are simply not recorded.
      objService - Used to delegate to the superclass check.
      fieldsToEdit - The fields the caller intends to change, keyed by field name, or null when the check is not scoped to specific fields (treated as a recalculation request for a PB_PRICEGRIDEDITOR_ADD_SKU-only user).
      Returns:
      true if the edit is allowed, false otherwise.
    • canDelete

      public boolean canDelete(User user, ValidationVisitor validationVisitor, PersistedObjectService objService)
      Whether user may delete this Price Grid. A Price Grid owned by a Pricing Plan Scenario is never deleted directly; it is deleted through its owner. Otherwise, the delete requires the base delete check, canEdit with no fields scoped, and that no background job for this Price Grid is still running (any JobStatusTracker targeting it that has not reached a terminal status blocks the delete). Not meant to be used directly in Groovy.
      Overrides:
      canDelete in class PersistedObject
      Parameters:
      user - The user attempting the delete.
      validationVisitor - Receives a validation error when the delete is not allowed. May be null, in which case errors are simply not recorded.
      objService - Used to check for non-terminated background jobs and to delegate to the superclass and edit checks.
      Returns:
      true if the delete is allowed, false otherwise.
    • getItemClass

      public Class<? extends AbstractPriceGridItem> getItemClass()
      The concrete line item type backing this Price Grid's items: PriceGridItem for a plain, per-SKU Price Grid or one whose type is not yet known, MatrixPriceGridItem for a Matrix Price Grid (see getPriceGridType()). Used generically by item-management code to instantiate and query this Price Grid's line items. Not meant to be used directly in Groovy.
      Specified by:
      getItemClass in interface HasCalculableObjectItems
      Returns:
      The line item class corresponding to getPriceGridType().
    • getItemListFilterField

      public String getItemListFilterField()
      Equivalent to getItemListFilterFieldS(): the entity field name used to look up this Price Grid's line items. Not meant to be used directly in Groovy.
      Specified by:
      getItemListFilterField in interface HasCalculableObjectItems
      Returns:
      "priceGridId".
    • getItemListFilterFieldS

      public static String getItemListFilterFieldS()
      The field on a line item (PGI / XPGI) that references its Price Grid, for example api.find("PGI", 0, 0, null, ["sku"], Filter.equal("priceGridId", priceGridId)). The method itself is not meant to be used directly in Groovy; use the field name "priceGridId" instead.
      Returns:
      "priceGridId".
    • isMatrix

      public boolean isMatrix()
      A shorthand for ListType.MATRIX.equals(getPriceGridType()), useful where a full switch over getPriceGridType() is not needed. Unlike getPriceGridType() itself, this never returns null: an unset type is treated as not a Matrix Price Grid.
      Overrides:
      isMatrix in class MatrixableCalculableObject
      Returns:
      true if this is a Matrix Price Grid, false otherwise (including when the type is unset).
    • getItemAttributeMetaClass

      public Class<? extends ElementAttributeMeta> getItemAttributeMetaClass()
      The attribute-metadata type describing extension/attribute metadata for this Price Grid's line items.
      Specified by:
      getItemAttributeMetaClass in interface HasCalculableObjectItems
      Returns:
      PriceGridItemAttributeMeta.class.
    • updatePriceGridNumbers

      public int[] updatePriceGridNumbers(PersistedObjectService objService)
      Recounts this Price Grid's line items and stores the header counters (total, approved, auto-approved, denied, submitted and open items) directly in the database, without a version bump; the getters of this in-memory instance are not refreshed. Not meant to be used directly in Groovy.
      Parameters:
      objService - Used to recount and store the header counters.
      Returns:
      A two-element array: the total item count at index 0, the approved item count at index 1.
    • updateHeaderApprovalState

      public void updateHeaderApprovalState(PersistedObjectService objService)
      Recomputes this Price Grid's header-level getApprovalState() from the number of line items in state APPROVED: NOT_APPROVED when there are none (also for an empty grid), APPROVED when all line items are APPROVED, PARTIALLY_APPROVED otherwise. Line items in state AUTO_APPROVED are not counted as approved. Runs at the end of a calculation or dirty-items pass and after a line item is approved or denied. Line items changed by api.add or api.update do not trigger it; call api.updateCalculableObjectHeader("PG", priceGridId) to refresh the counters from a script. Not meant to be used directly in Groovy.
      Parameters:
      objService - Used to recompute the item counts via updatePriceGridNumbers(PersistedObjectService) and to persist the resulting approval state.
    • getDefaultTrackerType

      public JobStatusTracker.TrackerType getDefaultTrackerType()
      The kind of background job tracker used by default when this Price Grid's calculation runs. Not meant to be used directly in Groovy.
      Specified by:
      getDefaultTrackerType in class AbstractCalculable
      Returns:
      TrackerType.PRICEGRID.
    • itemsStateChanged

      public void itemsStateChanged(PersistedObjectService objService)
      Refreshes the header counters and approval rollup via updateHeaderApprovalState(PersistedObjectService), after the superclass handling. Called by api.updateCalculableObjectHeader("PG", priceGridId) (available in Calculated Field Sets, Calculation Flows and direct logic execution). Not meant to be used directly in Groovy.
      Overrides:
      itemsStateChanged in class CalculableObject
      Parameters:
      objService - Passed through to the superclass and to updateHeaderApprovalState(PersistedObjectService).
    • getHeaderTypeUniqueName

      public String getHeaderTypeUniqueName()
      The unique name of the Price Setting Type (PriceGridType) linked to this Price Grid, which supplies the header formula used by onSaveOrUpdate(PersistedObjectService) to keep getPriceGridConfiguration()'s header formula in sync.
      Returns:
      The linked Price Setting Type's unique name, or null if none is linked.
      See Also:
    • setHeaderTypeUniqueName

      public void setHeaderTypeUniqueName(String headerTypeUniqueName)
      Links this Price Grid to a Price Setting Type.
      Parameters:
      headerTypeUniqueName - The unique name of the Price Setting Type to link, or null to remove the link. Takes effect on the next save (see onSaveOrUpdate(PersistedObjectService)).
    • onSaveOrUpdate

      public void onSaveOrUpdate(PersistedObjectService objService)
      Called by the persistence layer right before this Price Grid is saved. Keeps the header formula in getPriceGridConfiguration() in line with getHeaderTypeUniqueName(): on a new Price Grid with a header type and no configuration, it creates the configuration with that type's header formula; while a header type is linked, every save copies that type's header formula into the configuration; when the header type is cleared, it clears the header formula. Not meant to be used directly in Groovy.
      Overrides:
      onSaveOrUpdate in class PersistedObject
      Parameters:
      objService - Used to look up the PriceGridType named by getHeaderTypeUniqueName().
    • onPreProcessing

      public boolean onPreProcessing(PersistedObjectService objService, Map<String,Object> values, LocalDateTime targetDate)
      Called before this Price Grid is created, updated, or deleted through the API (for example api.update("PG", ...)). A good place to normalize the incoming values before they are applied. Not meant to be used directly in Groovy.
      Specified by:
      onPreProcessing in interface APIModifiable
      Parameters:
      objService -
      values - The field values about to be applied to this Price Grid.
      targetDate - The target date of the operation.
      Returns:
      true to allow the operation to proceed. This implementation always returns true; returning false would abort the operation.
    • getCreatedByName

      public String getCreatedByName()
      The login name of the user who created this Price Grid, cached at creation time for display without an extra join. May become stale if the referenced user's login name later changes.
      Specified by:
      getCreatedByName in interface NamedChangeTracker
      Returns:
      The creator's login name, or null if not recorded.
    • setCreatedByName

      public void setCreatedByName(String createdByName)
      Sets the creator's login name. The framework sets it when the Price Grid is created. Not meant to be used directly in Groovy.
      Specified by:
      setCreatedByName in interface NamedChangeTracker
      Parameters:
      createdByName - The login name of the user who created this Price Grid.
    • getLastUpdateByName

      public String getLastUpdateByName()
      The login name of the user who last updated this Price Grid, cached at update time for display without an extra join. May become stale if the referenced user's login name later changes.
      Returns:
      The last-updating user's login name, or null if not recorded.
    • setLastUpdateByName

      public void setLastUpdateByName(String lastUpdateByName)
      Sets the login name of the last updating user. The framework overwrites it on every update. Not meant to be used directly in Groovy.
      Specified by:
      setLastUpdateByName in interface NamedChangeTracker
      Parameters:
      lastUpdateByName - The login name of the user who last updated this Price Grid.
    • getJobType

      public String getJobType()
      The job-type discriminator used for background calculation job naming/routing. Not meant to be used directly in Groovy.
      Specified by:
      getJobType in interface JobSettingsProvider
      Returns:
      This Price Grid's type code, TYPE_CODE.
    • isShotgunEnabled

      public boolean isShotgunEnabled(PersistedObjectService txn)
      Whether "shotgun mode" (distributed calculation spread across multiple worker agents/pods rather than run sequentially) is allowed for this Price Grid at all, controlled by the shotgun mode setting in getPriceGridConfiguration(). Not meant to be used directly in Groovy.
      Specified by:
      isShotgunEnabled in interface JobSettingsProvider
      Parameters:
      txn - Unused by this implementation; present for the JobSettingsProvider contract.
      Returns:
      true if shotgun mode is enabled in this Price Grid's configuration, false otherwise.
    • getShotgunThreshold

      public int getShotgunThreshold(PersistedObjectService objService, JobStatusTracker jst)
      The minimum job size (see jobSize(PersistedObjectService, JobStatusTracker, int)) above which the calculation framework switches into shotgun (distributed) mode instead of a single sequential run, when isShotgunEnabled(PersistedObjectService) allows it. The threshold is set for the whole instance (default 5000) and can be overridden per partition by an application property. Not meant to be used directly in Groovy.
      Specified by:
      getShotgunThreshold in interface JobSettingsProvider
      Parameters:
      objService - Used to resolve the configured threshold.
      jst - The job status tracker for the current calculation run.
      Returns:
      The shotgun mode threshold for this run.
    • jobSize

      public int jobSize(PersistedObjectService objectService, JobStatusTracker jst, int runNumber)
      The size of this Price Grid's current calculation run: the number of line items the run is expected to process. Used by the calculation framework both to decide whether to switch into shotgun (distributed) mode (compared against getShotgunThreshold(PersistedObjectService, JobStatusTracker)) and, once in shotgun mode, to size the number of worker pods. Not meant to be used directly in Groovy.

      Resolution order: an explicit distributed job size job parameter, then the count of SKUs already marked for recalculation (matrix secondary keys are not counted here), then, for a follow-up pass (runNumber > 0), the count of dirty line items, then the already-known item count, and finally a fresh count derived from the configured product selection.

      Specified by:
      jobSize in interface JobSettingsProvider
      Parameters:
      objectService - Used to count line items when the size cannot be resolved from the tracker or from the already-known item count.
      jst - The job status tracker for the current calculation run, supplying job parameters. May be null, in which case resolution falls straight through to the item-count-based fallbacks.
      runNumber - The current pass number of a multi-pass calculation (0 for the first pass).
      Returns:
      The number of line items this run is expected to process.
    • getAgentOption1

      public Object getAgentOption1(PersistedObjectService objService, JobStatusTracker jst, int runNumber)
      A flag passed to the calculation agent. Not meant to be used directly in Groovy.

      For TrackerType.PRICEGRID: the full-list flag (the value api.isFullListCalculation() returns), true when the job has no skusToRecalc and no tainted recalculation is requested, false for a run scoped to selected SKUs or to tainted items. For TrackerType.PRICEGRID_DIRTY: true while runNumber is below MAX_DIRTY_RUNS. For any other tracker type: false.

      Specified by:
      getAgentOption1 in interface JobSettingsProvider
      Parameters:
      objService - Unused by this implementation; present for the JobSettingsProvider contract.
      jst - The job status tracker for the current calculation run, supplying job parameters and the tracker type.
      runNumber - The current pass number, used for the dirty-items tracker case.
      Returns:
      A Boolean whose meaning depends on jst's tracker type, as described above.
    • onDelete

      public void onDelete(PersistedObjectService objService, boolean hardDelete)
      Called by the persistence layer when this Price Grid is deleted. Always removes the workflows whose parent is this Price Grid; on the hard delete (done later by the deleted-lists purge job) it also deletes the Lookup Tables owned by this Price Grid. Not meant to be used directly in Groovy.
      Overrides:
      onDelete in class PersistedObject
      Parameters:
      objService - Used to delete the child workflows and owned Lookup Tables.
      hardDelete - true for the permanent purge, false for the initial soft delete.
    • copyPreferencesFromSource

      public void copyPreferencesFromSource(PersistedObjectService objService)
      Copies the line item grid-view and portlet preferences from the source Price Grid named in the configuration's preferences source, unless this Price Grid already has its own line item preferences. Does nothing when no preferences source is set. Not meant to be used directly in Groovy.
      Parameters:
      objService - Used to look up existing preferences and to perform the copy.