Record Class MCost.CostingKey

java.lang.Object
java.lang.Record
org.compiere.model.MCost.CostingKey
Record Components:
AD_Org_ID - the resolved org ID (zeroed for Client and BatchLot costing levels)
M_AttributeSetInstance_ID - the resolved ASI ID (zeroed for Client and Organization costing levels)
Enclosing class:
MCost

public static record MCost.CostingKey(int AD_Org_ID, int M_AttributeSetInstance_ID) extends Record
Represents a resolved (AD_Org_ID, M_AttributeSetInstance_ID) key pair, derived by applying costing-level normalization rules, used to look up or create MCost/MCostHistory records. Depending on the product's costing level (X_C_AcctSchema.COSTINGLEVEL_Client, X_C_AcctSchema.COSTINGLEVEL_Organization, or X_C_AcctSchema.COSTINGLEVEL_BatchLot), one or both of the raw org/ASI values supplied by the caller are zeroed out to match the granularity at which cost is tracked.

Callers should always obtain instances via resolve(int, int, String) rather than constructing this record directly, to ensure the normalization rules are applied consistently.

  • Constructor Summary

    Constructors
    Constructor
    Description
    CostingKey(int AD_Org_ID, int M_AttributeSetInstance_ID)
    Creates an instance of a CostingKey record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the AD_Org_ID record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Indicates whether cost lookup/processing should be skipped entirely for this key, because BatchLot-level costing requires a specific attribute set instance (lot) to associate cost with, and none could be resolved (M_AttributeSetInstance_ID is 0).
    int
    Returns the value of the M_AttributeSetInstance_ID record component.
    resolve(int AD_Org_ID, int M_AttributeSetInstance_ID, String costingLevel)
    Resolves the org/ASI key pair for the given costing level, zeroing out whichever fields are not significant at that costing granularity: Client - both AD_Org_ID and M_AttributeSetInstance_ID are zeroed Organization - only M_AttributeSetInstance_ID is zeroed BatchLot - only AD_Org_ID is zeroed; ASI is preserved since cost is tracked per lot Any other costing level is passed through unchanged.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CostingKey

      public CostingKey(int AD_Org_ID, int M_AttributeSetInstance_ID)
      Creates an instance of a CostingKey record class.
      Parameters:
      AD_Org_ID - the value for the AD_Org_ID record component
      M_AttributeSetInstance_ID - the value for the M_AttributeSetInstance_ID record component
  • Method Details

    • resolve

      public static MCost.CostingKey resolve(int AD_Org_ID, int M_AttributeSetInstance_ID, String costingLevel)
      Resolves the org/ASI key pair for the given costing level, zeroing out whichever fields are not significant at that costing granularity:
      • Client - both AD_Org_ID and M_AttributeSetInstance_ID are zeroed
      • Organization - only M_AttributeSetInstance_ID is zeroed
      • BatchLot - only AD_Org_ID is zeroed; ASI is preserved since cost is tracked per lot
      Any other costing level is passed through unchanged.
      Parameters:
      AD_Org_ID - the raw org ID before normalization
      M_AttributeSetInstance_ID - the raw ASI ID before normalization
      costingLevel - one of the MAcctSchema.COSTINGLEVEL_* constants
      Returns:
      a new CostingKey with fields normalized per the costing level
    • isSkipCostingProcessing

      public boolean isSkipCostingProcessing(String costingLevel)
      Indicates whether cost lookup/processing should be skipped entirely for this key, because BatchLot-level costing requires a specific attribute set instance (lot) to associate cost with, and none could be resolved (M_AttributeSetInstance_ID is 0).

      When this returns true, callers should abort the current cost lookup or costing-record retrieval and return null (or otherwise skip processing), rather than falling back to a client- or organization-level cost record — no BatchLot-level cost record can exist without a lot to key it against.

      Used by MProduct.getCostInfo(MAcctSchema, int, int, String, Timestamp) and MProduct.getCostingRecord(MAcctSchema, int, int, String) as an early-exit guard before resolving cost elements or cost records.

      Parameters:
      costingLevel - one of the MAcctSchema.COSTINGLEVEL_* constants
      Returns:
      true if costingLevel is BatchLot and no ASI (lot) could be resolved, meaning the caller should skip cost processing and return null
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • AD_Org_ID

      public int AD_Org_ID()
      Returns the value of the AD_Org_ID record component.
      Returns:
      the value of the AD_Org_ID record component
    • M_AttributeSetInstance_ID

      public int M_AttributeSetInstance_ID()
      Returns the value of the M_AttributeSetInstance_ID record component.
      Returns:
      the value of the M_AttributeSetInstance_ID record component