Class PriceGrid
- All Implemented Interfaces:
APIModifiable,Calculable,EmbeddedObject,HasCalculableObjectItems,JobNameProvider,JobSettingsProvider,NamedChangeTracker,TreeStructuredObject,UserGroupRestrictedObject
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.ListTypeNested 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
FieldsFields inherited from class AbstractCalculable
FIELD_CALCDATE, FIELD_CALCMESSAGES, FIELD_CALCSTARTDATE, FIELD_STATUS, MAX_CALCULATION_MESSAGE_LENGTH, MAX_CALCULATION_MESSAGE_THRESHOLDFields inherited from class PartitionedObject
FIELD_PARTITION, FIELD_PARTITIONID, PARTITION_FILTER_NAME, PARTITION_FILTER_PARAMFields inherited from class PersistedObject
FIELD_CREATEDATE, FIELD_CREATEDBY, FIELD_DELETEDATE, FIELD_DELETEDBY, FIELD_ID, FIELD_ISDELETED, FIELD_LASTUPDATEBY, FIELD_LASTUPDATEDATE, FIELD_VERSIONFields inherited from interface UserGroupRestrictedObject
FIELD_USERGROUPEDIT, FIELD_USERGROUPVIEWDETAILS -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty Price Grid; only the list type (SIMPLE) and the item counters (0) are initialized. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhetherusermay delete this Price Grid.booleancanEdit(User user, ValidationVisitor validationVisitor, PersistedObjectService objService, Map<String, Object> fieldsToEdit) Whetherusermay edit this Price Grid, in addition to the base checks performed by the superclass (which include thegetUserGroupEdit()restriction).voidcopyPreferencesFromSource(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 byupdateHeaderApprovalState(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 backinggetPriceGridConfiguration().The login name of the user who created this Price Grid, cached at creation time for display without an extra join.JobStatusTracker.TrackerTypeThe 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 bygetRelativeTargetDateDays()days when configured.The unique name of the Price Setting Type (PriceGridType) linked to this Price Grid, which supplies the header formula used byonSaveOrUpdate(PersistedObjectService)to keepgetPriceGridConfiguration()'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:PriceGridItemfor a plain, per-SKU Price Grid or one whose type is not yet known,MatrixPriceGridItemfor a Matrix Price Grid (seegetPriceGridType()).Equivalent togetItemListFilterFieldS(): the entity field name used to look up this Price Grid's line items.static StringThe field on a line item (PGI/XPGI) that references its Price Grid, for exampleapi.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.ListTypeEquivalent togetPriceGridType().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 byupdateHeaderApprovalState(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 byupdateHeaderApprovalState(PersistedObjectService).The number of this Price Grid's line items currently denied, part of the item-level approval rollup recomputed byupdateHeaderApprovalState(PersistedObjectService).The number of this Price Grid's line items whose approval state is notAPPROVED,AUTO_APPROVEDorDENIED.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 byupdateHeaderApprovalState(PersistedObjectService).The typed id of thePricingPlanScenariothat 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).PriceGridConfigurationThe structured configuration of this Price Grid (calculation logic selection, matrix settings, shotgun mode, and similar options), deserialized from the JSON stored ingetConfiguration()and cached: the first call parses it, later calls return the same cached instance untilsetPriceGridConfiguration(PriceGridConfiguration)orsetConfigurationString(String)replaces it.Equivalent togetId(), exposed under theidJSON property name so the Price Grid's id is always present in the API response.MatrixableCalculableObject.ListTypeWhether 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 computegetEffectiveTargetDate(PersistedObjectService)when this Price Grid has no explicit target date.intgetShotgunThreshold(PersistedObjectService objService, JobStatusTracker jst) The minimum job size (seejobSize(PersistedObjectService, JobStatusTracker, int)) above which the calculation framework switches into shotgun (distributed) mode instead of a single sequential run, whenisShotgunEnabled(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 bycanEdit(User, ValidationVisitor, PersistedObjectService, Map)andcanDelete(User, ValidationVisitor, PersistedObjectService).The User Group(s) whose members may view this Price Grid's details.booleanisMatrix()A shorthand forListType.MATRIX.equals(getPriceGridType()), useful where a full switch overgetPriceGridType()is not needed.booleanisShotgunEnabled(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 ingetPriceGridConfiguration().voiditemsStateChanged(PersistedObjectService objService) Refreshes the header counters and approval rollup viaupdateHeaderApprovalState(PersistedObjectService), after the superclass handling.intjobSize(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.voidonDelete(PersistedObjectService objService, boolean hardDelete) Called by the persistence layer when this Price Grid is deleted.booleanonPreProcessing(PersistedObjectService objService, Map<String, Object> values, LocalDateTime targetDate) Called before this Price Grid is created, updated, or deleted through the API (for exampleapi.update("PG", ...)).voidonSaveOrUpdate(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.voidsetApprovalState(ApprovalState approvalState) Sets the approval rollup.voidsetConfigurationString(String configuration) Stores the raw JSON configuration string and drops the cached configuration object, so the nextgetPriceGridConfiguration()call parses it again.voidsetCreatedByName(String createdByName) Sets the creator's login name.voidsetDescription(String description) Sets the free-text description of this Price Grid.voidsetHeaderTypeUniqueName(String headerTypeUniqueName) Links this Price Grid to a Price Setting Type.voidsetIntegrationStatus(String integrationStatus) Sets the free-text integration status (seegetIntegrationStatus()).voidsetLastUpdateByName(String lastUpdateByName) Sets the login name of the last updating user.voidSets this Price Grid's position in its tree hierarchy.voidsetParentTypedId(String parentTypedId) Sets the owningPricingPlanScenario.voidsetPartialCalculationDate(LocalDateTime lastPartialCalculation) Sets the date and time of the last partial calculation.voidsetPriceGridConfiguration(PriceGridConfiguration configuration) Stores the given configuration, serializing it to JSON, and caches the object itself so a subsequentgetPriceGridConfiguration()call returns this same instance rather than deserializing again.voidNo-op setter kept only so the JSON deserializer accepts an incomingidfield without failing; the id cannot be set directly.voidsetPriceGridType(MatrixableCalculableObject.ListType priceGridType) Sets this Price Grid's list type.voidsetRelativeTargetDateDays(Integer relativeTargetDateDays) Sets the offset in days used when this Price Grid has no explicit target date.voidsetUpdateDate(LocalDateTime updateDate) No-op setter kept only so the JSON deserializer accepts an incomingupdateDatefield; the actual last-update timestamp is maintained internally and cannot be set directly.voidsetUpdatedBy(Long updateBy) No-op setter kept only so the JSON deserializer accepts an incomingupdatedByfield; the actual last-updating user is maintained internally and cannot be set directly.voidsetUserGroupEdit(String userGroup) Sets the User Group(s) whose members may edit and delete this Price Grid (seegetUserGroupEdit()).voidsetUserGroupViewDetails(String userGroup) Sets the User Group(s) whose members may view this Price Grid's details (seegetUserGroupViewDetails()).voidupdateHeaderApprovalState(PersistedObjectService objService) Recomputes this Price Grid's header-levelgetApprovalState()from the number of line items in stateAPPROVED:NOT_APPROVEDwhen there are none (also for an empty grid),APPROVEDwhen all line items areAPPROVED,PARTIALLY_APPROVEDotherwise.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.booleanvalidate(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
anyToRecalculationMethods inherited from class CalculableObject
getKeepManualOverrides, getNumberOfItems, getWriteOnlyChangedItems, setKeepManualOverrides, setNumberOfItems, setWriteOnlyChangedItemsMethods inherited from class AbstractCalculable
calculationDate, calculationStartDate, getCalculationDate, getCalculationMessages, getCalculationMessagesAsList, getCalculationStartDate, getJobName, getLabel, getLocale, getStatus, getTargetDate, isAnonymousCalculable, setCalculationDate, setCalculationMessages, setCalculationMessages, setCalculationStartDate, setLabel, setLocale, setStatus, setTargetDateMethods inherited from class PartitionedObject
addUniqueConstraint, getLoginNameByUserId, getPartition, setPartition, toStringMethods 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, userGroupEditBulkloadFilterMethods 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
-
Field Details
-
TYPE_CODE
- See Also:
-
-
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
The raw JSON string backinggetPriceGridConfiguration(). Used for persistence.- Returns:
- The JSON-encoded configuration, or
nullif 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 subsequentgetPriceGridConfiguration()call returns this same instance rather than deserializing again.- Parameters:
configuration- The configuration to store.
-
setConfigurationString
Stores the raw JSON configuration string and drops the cached configuration object, so the nextgetPriceGridConfiguration()call parses it again. Used for persistence. To change a Price Grid's configuration from a logic, useapi.update("PG", ...)with aconfigurationmap.- 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 ingetConfiguration()and cached: the first call parses it, later calls return the same cached instance untilsetPriceGridConfiguration(PriceGridConfiguration)orsetConfigurationString(String)replaces it.- Returns:
- The parsed configuration. Never
null: an emptyPriceGridConfigurationis returned when none has been set yet. - See Also:
-
getDescription
A free-text description of this Price Grid.- Returns:
- The description. May be
null.
-
setDescription
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 (seevalidate(ValidationVisitor, PersistedObjectService)).
-
getUpdatedBy
The id of the user who last updated this Price Grid. Re-exposesgetLastUpdateBy()under theupdatedByJSON property name used by the Price Grid and price item payloads.- Returns:
- The last-updating user's id, or
nullif not yet updated.
-
getUpdateDate
The date and time this Price Grid was last updated. Re-exposesgetLastUpdateDate()under theupdateDateJSON property name used by the Price Grid and price item payloads.- Returns:
- The last-update date and time, or
nullif not yet updated.
-
setUpdateDate
No-op setter kept only so the JSON deserializer accepts an incomingupdateDatefield; the actual last-update timestamp is maintained internally and cannot be set directly.- Parameters:
updateDate- Ignored.
-
setUpdatedBy
No-op setter kept only so the JSON deserializer accepts an incomingupdatedByfield; the actual last-updating user is maintained internally and cannot be set directly.- Parameters:
updateBy- Ignored.
-
getPriceGridId
Equivalent togetId(), exposed under theidJSON property name so the Price Grid's id is always present in the API response.- Returns:
- This Price Grid's id.
-
setPriceGridIdShouldBeIgnored
No-op setter kept only so the JSON deserializer accepts an incomingidfield without failing; the id cannot be set directly.- Parameters:
id- Ignored.
-
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:
getNodeIdin interfaceTreeStructuredObject- Returns:
- The tree node id, or
nullif this Price Grid is not attached to a tree node.
-
setNodeId
Sets this Price Grid's position in its tree hierarchy. OnlyLong,Integer,ShortandBytevalues are applied; any other value,nullincluded, is ignored, so the link cannot be cleared this way.- Specified by:
setNodeIdin interfaceTreeStructuredObject- Parameters:
nodeId- The tree node id to assign.
-
getParentTypedId
The typed id of thePricingPlanScenariothat owns this Price Grid.- Specified by:
getParentTypedIdin interfaceEmbeddedObject- Returns:
- The owner's typed id, or
nullfor a standalone Price Grid.
-
setParentTypedId
Sets the owningPricingPlanScenario. Accepted only when the Price Grid is created; changing it later is rejected bycanEdit(User, ValidationVisitor, PersistedObjectService, Map).- Parameters:
parentTypedId- The typed id of an existing Pricing Plan Scenario, ornullfor a standalone Price Grid.
-
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:
getCalculationConcurrencyKeyin classAbstractCalculable- Returns:
getParentTypedId()for an owned Price Grid, the default key otherwise.
-
getApprovalState
This Price Grid's header-level approval rollup, recomputed from its line items byupdateHeaderApprovalState(PersistedObjectService). OnlyNOT_APPROVED,PARTIALLY_APPROVEDandAPPROVEDoccur; line items in stateAUTO_APPROVEDare not counted as approved. UnlikePricelist, a Price Grid has no header-level approval workflow of its own; each line item is submitted and approved individually.- Returns:
- The current
ApprovalStaterollup, ornullif it has not been computed yet. - See Also:
-
setApprovalState
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
The User Group(s) whose members may edit and delete this Price Grid; users outside them are blocked bycanEdit(User, ValidationVisitor, PersistedObjectService, Map)andcanDelete(User, ValidationVisitor, PersistedObjectService). Users with theUSERGROUP_OVERRIDEpermission bypass the restriction.- Specified by:
getUserGroupEditin interfaceUserGroupRestrictedObject- Returns:
- A User Group unique name or a comma-separated list of them, or
nullif editing is not restricted by User Group.
-
setUserGroupEdit
Sets the User Group(s) whose members may edit and delete this Price Grid (seegetUserGroupEdit()).- Specified by:
setUserGroupEditin interfaceUserGroupRestrictedObject- Parameters:
userGroup- A User Group unique name or a comma-separated list of them, ornullto remove the restriction.
-
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 theUSERGROUP_OVERRIDEpermission bypass the restriction.- Specified by:
getUserGroupViewDetailsin interfaceUserGroupRestrictedObject- Returns:
- A User Group unique name or a comma-separated list of them, or
nullif viewing is not restricted by User Group.
-
setUserGroupViewDetails
Sets the User Group(s) whose members may view this Price Grid's details (seegetUserGroupViewDetails()).- Specified by:
setUserGroupViewDetailsin interfaceUserGroupRestrictedObject- Parameters:
userGroup- A User Group unique name or a comma-separated list of them, ornullto remove the restriction.
-
getRelativeTargetDateDays
An offset, in days from the calculation date, used to computegetEffectiveTargetDate(PersistedObjectService)when this Price Grid has no explicit target date. Cleared automatically once an explicit target date is set (seevalidate(ValidationVisitor, PersistedObjectService)).- Returns:
- The offset in days, or
nullif not configured or if an explicit target date is set.
-
setRelativeTargetDateDays
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, ornullto clear it.
-
getNumberOfApprovedItems
The number of this Price Grid's line items currently approved, part of the item-level approval rollup recomputed byupdateHeaderApprovalState(PersistedObjectService).- Returns:
- The count of approved line items.
-
getNumberOfOpenItems
The number of this Price Grid's line items whose approval state is notAPPROVED,AUTO_APPROVEDorDENIED. This includes the items currently submitted for approval, which are also counted bygetNumberOfSubmittedItems(). Part of the header counters refreshed byupdatePriceGridNumbers(PersistedObjectService).- Returns:
- The count of line items not yet approved or denied.
-
getNumberOfDeniedItems
The number of this Price Grid's line items currently denied, part of the item-level approval rollup recomputed byupdateHeaderApprovalState(PersistedObjectService).- Returns:
- The count of denied line items.
-
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 byupdateHeaderApprovalState(PersistedObjectService).- Returns:
- The count of auto-approved line items.
-
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 byupdateHeaderApprovalState(PersistedObjectService).- Returns:
- The count of submitted, pending line items.
-
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
nullif this Price Grid has not had a partial calculation.
-
setPartialCalculationDate
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, ornullto clear it.
-
getIntegrationStatus
A free-text status for external integrations. The platform neither sets nor interprets it.- Returns:
- The integration status. May be
null.
-
setIntegrationStatus
Sets the free-text integration status (seegetIntegrationStatus()).- Parameters:
integrationStatus- The integration/export status to record.
-
partialCalculationDate
The last partial-calculation date and time formatted for display, using the partition's configured date-time pattern. Serialized under the JSON propertypartialCalculationDatein place of the rawgetPartialCalculationDate()value.- Returns:
- The formatted date and time, or
nullif this Price Grid has not had a partial calculation.
-
getEffectiveTargetDate
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 bygetRelativeTargetDateDays()days when configured.- Overrides:
getEffectiveTargetDatein classCalculableObject- 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 bygetItemClass(). UnlikePricelist.getPricelistType(), anullvalue is not defaulted toSIMPLE.- Returns:
- The list type, or
nullwhen the type was explicitly cleared or never stored; a later save does not repair it.
-
getListType
public MatrixableCalculableObject.ListType getListType()Equivalent togetPriceGridType().- Overrides:
getListTypein classMatrixableCalculableObject- Returns:
- The list type, or
nullwhen 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 asSIMPLE. The call is ignored when the current type isnull.- 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 agetDescription()longer than 255 characters; on create, rejects agetParentTypedId()that does not reference an existing Pricing Plan Scenario; clearsgetRelativeTargetDateDays()once an explicit target date is present; callssetPriceGridType(ListType)withSIMPLEwhen the type is unset (which the setter ignores, see there); and, for a user restricted to thePB_PRICEGRIDEDITOR_ADD_SKUrole (seecanEdit(User, ValidationVisitor, PersistedObjectService, Map)), rejects a configuration change that touches more than theinputssection. Not meant to be used directly in Groovy.- Overrides:
validatein classAbstractCalculable- Parameters:
validationVisitor- Receives a validation error when this Price Grid is invalid. May benull, in which case errors are simply not recorded.objService- Used to delegate to the superclass validation.- Returns:
trueif this Price Grid is valid,falseotherwise.
-
canEdit
public boolean canEdit(User user, ValidationVisitor validationVisitor, PersistedObjectService objService, Map<String, Object> fieldsToEdit) Whetherusermay edit this Price Grid, in addition to the base checks performed by the superclass (which include thegetUserGroupEdit()restriction). For a Price Grid owned by a Pricing Plan Scenario, any edit scoped to fields (header or configuration) is rejected; aparentTypedIdinfieldsToEditis always rejected, since the owner can be set only on create. A user who has thePB_PRICEGRIDEDITOR_ADD_SKUrole but not the broaderPB_PRICEGRIDSrole 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 sovalidate(ValidationVisitor, PersistedObjectService)can later confirm the configuration change was limited to theinputssection. Not meant to be used directly in Groovy.- Overrides:
canEditin classPersistedObject- Parameters:
user- The user attempting the edit.validationVisitor- Receives a validation error when the edit is not allowed. May benull, 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, ornullwhen the check is not scoped to specific fields (treated as a recalculation request for aPB_PRICEGRIDEDITOR_ADD_SKU-only user).- Returns:
trueif the edit is allowed,falseotherwise.
-
canDelete
public boolean canDelete(User user, ValidationVisitor validationVisitor, PersistedObjectService objService) Whetherusermay 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,canEditwith no fields scoped, and that no background job for this Price Grid is still running (anyJobStatusTrackertargeting it that has not reached a terminal status blocks the delete). Not meant to be used directly in Groovy.- Overrides:
canDeletein classPersistedObject- Parameters:
user- The user attempting the delete.validationVisitor- Receives a validation error when the delete is not allowed. May benull, 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:
trueif the delete is allowed,falseotherwise.
-
getItemClass
The concrete line item type backing this Price Grid's items:PriceGridItemfor a plain, per-SKU Price Grid or one whose type is not yet known,MatrixPriceGridItemfor a Matrix Price Grid (seegetPriceGridType()). 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:
getItemClassin interfaceHasCalculableObjectItems- Returns:
- The line item class corresponding to
getPriceGridType().
-
getItemListFilterField
Equivalent togetItemListFilterFieldS(): the entity field name used to look up this Price Grid's line items. Not meant to be used directly in Groovy.- Specified by:
getItemListFilterFieldin interfaceHasCalculableObjectItems- Returns:
"priceGridId".
-
getItemListFilterFieldS
The field on a line item (PGI/XPGI) that references its Price Grid, for exampleapi.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 forListType.MATRIX.equals(getPriceGridType()), useful where a full switch overgetPriceGridType()is not needed. UnlikegetPriceGridType()itself, this never returnsnull: an unset type is treated as not a Matrix Price Grid.- Overrides:
isMatrixin classMatrixableCalculableObject- Returns:
trueif this is a Matrix Price Grid,falseotherwise (including when the type is unset).
-
getItemAttributeMetaClass
The attribute-metadata type describing extension/attribute metadata for this Price Grid's line items.- Specified by:
getItemAttributeMetaClassin interfaceHasCalculableObjectItems- 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-levelgetApprovalState()from the number of line items in stateAPPROVED:NOT_APPROVEDwhen there are none (also for an empty grid),APPROVEDwhen all line items areAPPROVED,PARTIALLY_APPROVEDotherwise. Line items in stateAUTO_APPROVEDare 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 byapi.addorapi.updatedo not trigger it; callapi.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 viaupdatePriceGridNumbers(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:
getDefaultTrackerTypein classAbstractCalculable- Returns:
TrackerType.PRICEGRID.
-
itemsStateChanged
public void itemsStateChanged(PersistedObjectService objService) Refreshes the header counters and approval rollup viaupdateHeaderApprovalState(PersistedObjectService), after the superclass handling. Called byapi.updateCalculableObjectHeader("PG", priceGridId)(available in Calculated Field Sets, Calculation Flows and direct logic execution). Not meant to be used directly in Groovy.- Overrides:
itemsStateChangedin classCalculableObject- Parameters:
objService- Passed through to the superclass and toupdateHeaderApprovalState(PersistedObjectService).
-
getHeaderTypeUniqueName
The unique name of the Price Setting Type (PriceGridType) linked to this Price Grid, which supplies the header formula used byonSaveOrUpdate(PersistedObjectService)to keepgetPriceGridConfiguration()'s header formula in sync.- Returns:
- The linked Price Setting Type's unique name, or
nullif none is linked. - See Also:
-
setHeaderTypeUniqueName
Links this Price Grid to a Price Setting Type.- Parameters:
headerTypeUniqueName- The unique name of the Price Setting Type to link, ornullto remove the link. Takes effect on the next save (seeonSaveOrUpdate(PersistedObjectService)).
-
onSaveOrUpdate
public void onSaveOrUpdate(PersistedObjectService objService) Called by the persistence layer right before this Price Grid is saved. Keeps the header formula ingetPriceGridConfiguration()in line withgetHeaderTypeUniqueName(): 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:
onSaveOrUpdatein classPersistedObject- Parameters:
objService- Used to look up thePriceGridTypenamed bygetHeaderTypeUniqueName().
-
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 exampleapi.update("PG", ...)). A good place to normalize the incoming values before they are applied. Not meant to be used directly in Groovy.- Specified by:
onPreProcessingin interfaceAPIModifiable- Parameters:
objService-values- The field values about to be applied to this Price Grid.targetDate- The target date of the operation.- Returns:
trueto allow the operation to proceed. This implementation always returnstrue; returningfalsewould abort the operation.
-
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:
getCreatedByNamein interfaceNamedChangeTracker- Returns:
- The creator's login name, or
nullif not recorded.
-
setCreatedByName
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:
setCreatedByNamein interfaceNamedChangeTracker- Parameters:
createdByName- The login name of the user who created this Price Grid.
-
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
nullif not recorded.
-
setLastUpdateByName
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:
setLastUpdateByNamein interfaceNamedChangeTracker- Parameters:
lastUpdateByName- The login name of the user who last updated this Price Grid.
-
getJobType
The job-type discriminator used for background calculation job naming/routing. Not meant to be used directly in Groovy.- Specified by:
getJobTypein interfaceJobSettingsProvider- 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 ingetPriceGridConfiguration(). Not meant to be used directly in Groovy.- Specified by:
isShotgunEnabledin interfaceJobSettingsProvider- Parameters:
txn- Unused by this implementation; present for theJobSettingsProvidercontract.- Returns:
trueif shotgun mode is enabled in this Price Grid's configuration,falseotherwise.
-
getShotgunThreshold
public int getShotgunThreshold(PersistedObjectService objService, JobStatusTracker jst) The minimum job size (seejobSize(PersistedObjectService, JobStatusTracker, int)) above which the calculation framework switches into shotgun (distributed) mode instead of a single sequential run, whenisShotgunEnabled(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:
getShotgunThresholdin interfaceJobSettingsProvider- 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 againstgetShotgunThreshold(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:
jobSizein interfaceJobSettingsProvider- 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 benull, 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 valueapi.isFullListCalculation()returns),truewhen the job has noskusToRecalcand no tainted recalculation is requested,falsefor a run scoped to selected SKUs or to tainted items. ForTrackerType.PRICEGRID_DIRTY:truewhilerunNumberis belowMAX_DIRTY_RUNS. For any other tracker type:false.- Specified by:
getAgentOption1in interfaceJobSettingsProvider- Parameters:
objService- Unused by this implementation; present for theJobSettingsProvidercontract.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
Booleanwhose meaning depends onjst'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:
onDeletein classPersistedObject- Parameters:
objService- Used to delete the child workflows and owned Lookup Tables.hardDelete-truefor the permanent purge,falsefor 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.
-