Class MStorageOnHand

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_M_StorageOnHand, I_Persistent, Evaluatee

public class MStorageOnHand extends X_M_StorageOnHand
Inventory On Hand Storage Model
Version:
$Id: MStorageOnHand.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
Author:
Jorg Janke
See Also:
  • Constructor Details

    • MStorageOnHand

      public MStorageOnHand(Properties ctx, String M_StorageOnHand_UU, String trxName)
      UUID based Constructor
      Parameters:
      ctx - Context
      M_StorageOnHand_UU - UUID key
      trxName - Transaction
    • MStorageOnHand

      public MStorageOnHand(Properties ctx, int ignored, String trxName)
      Parameters:
      ctx - context
      ignored - ignored
      trxName - transaction
    • MStorageOnHand

      public MStorageOnHand(Properties ctx, ResultSet rs, String trxName)
      Load Constructor
      Parameters:
      ctx - context
      rs - result set
      trxName - transaction
  • Method Details

    • get

      @Deprecated public static MStorageOnHand get(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, String trxName)
      Deprecated.
      Parameters:
      ctx -
      M_Locator_ID -
      M_Product_ID -
      M_AttributeSetInstance_ID -
      trxName -
      Returns:
      MStorageOnHand
    • get

      public static MStorageOnHand get(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp dateMPolicy, String trxName)
      Get On Hand Storage
      Parameters:
      ctx - context
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance
      dateMPolicy - optional DateMaterialPolicy filter
      trxName - transaction
      Returns:
      existing MStorageOnHand or null
    • getAllWithASI

      public static MStorageOnHand[] getAllWithASI(Properties ctx, int M_Product_ID, int M_Locator_ID, boolean FiFo, String trxName)
      Get all Storages for Product with ASI and QtyOnHand != 0
      Parameters:
      ctx - context
      M_Product_ID - product
      M_Locator_ID - locator
      FiFo - true for fifo, false for lifo
      trxName - transaction
      Returns:
      array of MStorageOnHand
    • getAll

      public static MStorageOnHand[] getAll(Properties ctx, int M_Product_ID, int M_Locator_ID, String trxName)
      Get all Storages for Product where QtyOnHand != 0
      Parameters:
      ctx - context
      M_Product_ID - product
      M_Locator_ID - locator, 0 to match all locator
      trxName - transaction
      Returns:
      array of MStorageOnHand
    • getAll

      public static MStorageOnHand[] getAll(Properties ctx, int M_Product_ID, int M_Locator_ID, String trxName, boolean forUpdate, int timeout)
      Get all Storages for Product where QtyOnHand != 0
      Parameters:
      ctx - context
      M_Product_ID - product
      M_Locator_ID - locator, 0 to match all locator
      trxName - transaction
      forUpdate - true to use For Update clause
      timeout - query timeout if forUpdate is true (0 for no timeout)
      Returns:
      array of MStorageOnHand
    • getAll

      public static MStorageOnHand[] getAll(Properties ctx, int M_Product_ID, int M_Locator_ID, boolean locatorPriority, boolean fifo, String trxName, boolean forUpdate, int timeout)
      Get all Storages for Product where QtyOnHand != 0
      Parameters:
      ctx - context
      M_Product_ID - product
      M_Locator_ID - locator, 0 to match all locator
      locatorPriority - If true, sort descending by locator Priority No
      fifo - Sort ascending(FIFO) or descending(LIFO) by date material policy, m_attributesetinstance_id
      trxName - transaction
      forUpdate - If true, acquire DB lock with FOR UPDATE clause
      timeout - query timeout if forUpdate is true (0 for no timeout)
      Returns:
      array of MStorageOnHand
    • getAll

      public static MStorageOnHand[] getAll(Properties ctx, int M_Product_ID, int M_Locator_ID, int M_AttributeSetInstance_ID, Timestamp dateMPolicy, boolean ignoreZeroQty, String trxName)
      Get On Hand Storage
      Parameters:
      ctx - context
      M_Product_ID - product
      M_Locator_ID - locator
      M_AttributeSetInstance_ID - instance
      dateMPolicy - optional DateMaterialPolicy filter
      ignoreZeroQty - if true, only get storage record with on hand != 0
      trxName - transaction
      Returns:
      array of MStorageOnHand
    • getOfProduct

      public static MStorageOnHand[] getOfProduct(Properties ctx, int M_Product_ID, String trxName)
      Get On Hand Storage for Product across warehouses
      Parameters:
      ctx - context
      M_Product_ID - product
      trxName - transaction
      Returns:
      array of MStorageOnHand
    • getWarehouse

      @Deprecated public static MStorageOnHand[] getWarehouse(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_AttributeSet_ID, boolean allAttributeInstances, Timestamp minGuaranteeDate, boolean FiFo, String trxName)
      Deprecated.
      Get On Hand Storage for Warehouse
      Parameters:
      ctx - context
      M_Warehouse_ID -
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance
      M_AttributeSet_ID - attribute set (NOT USED)
      allAttributeInstances - if true, all attribute set instances (NOT USED)
      minGuaranteeDate - optional minimum guarantee date filter. ignore if M_AttributeSetInstance_ID != 0
      FiFo - first in-first-out
      trxName - transaction
      Returns:
      existing - ordered by location priority (desc) and/or guarantee date
    • getWarehouse

      public static MStorageOnHand[] getWarehouse(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate, boolean FiFo, boolean positiveOnly, int M_Locator_ID, String trxName)
      Get On Hand Storage for Warehouse or locator
      Parameters:
      ctx - context
      M_Warehouse_ID - ignore if M_Locator_ID > 0
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance id, 0 to retrieve all instance
      minGuaranteeDate - optional minimum guarantee date filter. ignore if M_AttributeSetInstance_ID != 0
      FiFo - true first in-first-out, false for LIFO
      positiveOnly - if true, only return storage records with qtyOnHand > 0
      M_Locator_ID - optional locator id
      trxName - transaction
      Returns:
      array of MStorageOnHand - ordered by location priority (desc) and/or guarantee date
    • getWarehouse

      public static MStorageOnHand[] getWarehouse(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate, boolean FiFo, boolean positiveOnly, int M_Locator_ID, String trxName, boolean forUpdate)
      Get On Hand Storage for Warehouse or locator
      Parameters:
      ctx - context
      M_Warehouse_ID - ignore if M_Locator_ID > 0
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance id, 0 to retrieve all instance
      minGuaranteeDate - optional minimum guarantee date filter. ignore if M_AttributeSetInstance_ID != 0
      FiFo - true for first in-first-out, false for LIFO
      positiveOnly - if true, only return storage records with qtyOnHand > 0
      M_Locator_ID - optional locator id
      trxName - transaction
      forUpdate - true to acquire DB lock with FOR UPDATE clause
      Returns:
      array of MStorageOnHand - ordered by location priority (desc) and/or guarantee date
    • getWarehouse

      public static MStorageOnHand[] getWarehouse(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate, boolean FiFo, boolean positiveOnly, int M_Locator_ID, String trxName, boolean forUpdate, int timeout)
      Get On Hand Storage for Warehouse or locator
      Parameters:
      ctx - context
      M_Warehouse_ID - ignore if M_Locator_ID > 0
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance id, 0 to retrieve all instance
      minGuaranteeDate - optional minimum guarantee date filter. ignore if M_AttributeSetInstance_ID != 0
      FiFo - true for first in-first-out, false for LIFO
      positiveOnly - if true, only return storage records with qtyOnHand > 0
      M_Locator_ID - optional locator id
      trxName - transaction
      forUpdate - true to acquire DB lock with FOR UPDATE clause
      timeout - if forUpdate is true, value for query timeout (0 for no timeout).
      Returns:
      array of MStorageOnHand - ordered by location priority (desc) and/or guarantee date
    • getWarehouseNegative

      public static MStorageOnHand[] getWarehouseNegative(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate, boolean FiFo, int M_Locator_ID, String trxName)
      Get On Hand Storage for Warehouse or locator
      Parameters:
      ctx - context
      M_Warehouse_ID - ignore if M_Locator_ID > 0
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance id, 0 to retrieve all instance
      minGuaranteeDate - optional minimum guarantee date filter. ignore if M_AttributeSetInstance_ID != 0
      FiFo - true for first in-first-out, false for LIFO
      M_Locator_ID - optional locator id
      trxName - transaction
      Returns:
      array of MStorageOnHand - ordered by location priority (desc) and/or guarantee date
    • getWarehouseNegative

      public static MStorageOnHand[] getWarehouseNegative(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate, boolean FiFo, int M_Locator_ID, String trxName, boolean forUpdate)
      Get On Hand Storage for Warehouse or locator
      Parameters:
      ctx - context
      M_Warehouse_ID - ignore if M_Locator_ID > 0
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance id, 0 to retrieve storages that don't have asi, -1 to retrieve all instance
      minGuaranteeDate - optional minimum guarantee date filter. ignore if M_AttributeSetInstance_ID != 0
      FiFo - true for first in-first-out, false for LIFO
      M_Locator_ID - optional locator id
      trxName - transaction
      forUpdate - true to acquire DB lock with FOR UPDATE clause
      Returns:
      array of MStorageOnHand - ordered by location priority (desc) and/or guarantee date
    • getWarehouseNegative

      public static MStorageOnHand[] getWarehouseNegative(Properties ctx, int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp minGuaranteeDate, boolean FiFo, int M_Locator_ID, String trxName, boolean forUpdate, int timeout)
      Get On Hand Storage for Warehouse or locator
      Parameters:
      ctx - context
      M_Warehouse_ID - ignore if M_Locator_ID > 0
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance id, 0 to retrieve storages that don't have asi, -1 to retrieve all instance
      minGuaranteeDate - optional minimum guarantee date filter
      FiFo - true for first in-first-out, false for LIFO
      M_Locator_ID - optional locator id
      trxName - transaction
      forUpdate - true to acquire DB lock with FOR UPDATE clause
      timeout - if forUpdate is true, value for query timeout (0 for no timeout).
      Returns:
      array of MStorageOnHand - ordered by location priority (desc) and/or guarantee date
    • getCreate

      public static MStorageOnHand getCreate(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp dateMPolicy, String trxName)
      Create or Get On Hand Storage
      Parameters:
      ctx - context
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance
      trxName - transaction
      Returns:
      existing or new MStorageOnHand
    • getCreate

      public static MStorageOnHand getCreate(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp dateMPolicy, String trxName, boolean forUpdate)
      Create or Get On Hand Storage
      Parameters:
      ctx - context
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance
      dateMPolicy - optional DateMaterialPolicy filter
      trxName - transaction
      forUpdate - true to acquire DB lock with FOR UPDATE clause
      Returns:
      existing or new MStorageOnHand
    • getCreate

      public static MStorageOnHand getCreate(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Timestamp dateMPolicy, String trxName, boolean forUpdate, int timeout)
      Create or Get On Hand Storage
      Parameters:
      ctx - context
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - instance
      dateMPolicy - optional DateMaterialPolicy filter
      trxName - transaction
      forUpdate - true to acquire DB lock with FOR UPDATE clause
      timeout - if forUpdate is true, value for query timeout (0 for no timeout).
      Returns:
      existing or new MStorageOnHand
    • add

      @Deprecated public static boolean add(Properties ctx, int M_Warehouse_ID, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, BigDecimal diffQtyOnHand, String trxName)
      Deprecated.
      Update On Hand Storage Called from MProjectIssue
      Parameters:
      ctx - context
      M_Warehouse_ID - warehouse
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - AS Instance
      diffQtyOnHand - add on hand
      trxName - transaction
      Returns:
      true if updated
    • add

      @Deprecated public static boolean add(Properties ctx, int M_Warehouse_ID, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, BigDecimal diffQtyOnHand, Timestamp dateMPolicy, String trxName)
      Deprecated.
      Update On Hand Storage Called from MProjectIssue
      Parameters:
      ctx - context
      M_Warehouse_ID - warehouse, not use
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - AS Instance
      diffQtyOnHand - add on hand
      dateMPolicy -
      trxName - transaction
      Returns:
      true if updated
    • add

      public static boolean add(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, BigDecimal diffQtyOnHand, Timestamp dateMPolicy, String trxName)
    • add

      public static boolean add(Properties ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, BigDecimal diffQtyOnHand, Timestamp dateMPolicy, Timestamp dateLastInventory, String trxName)
      Update On Hand Storage Called from MProjectIssue
      Parameters:
      ctx - context
      M_Locator_ID - locator
      M_Product_ID - product
      M_AttributeSetInstance_ID - AS Instance
      diffQtyOnHand - difference to add to current on hand quantity
      dateMPolicy - optional DateMaterialPolicy filter
      trxName - transaction
      Returns:
      true if updated
    • addQtyOnHand

      public void addQtyOnHand(BigDecimal addition)
      Add addition to quantity on hand with direct SQL - not using cached value - solving IDEMPIERE-2629
      Parameters:
      addition -
    • updateDateLastInventory

      public void updateDateLastInventory(Timestamp dateLastInv)
      Update Date Last Inventory of this record with direct SQL
      Parameters:
      dateLastInv -
    • getM_Locator_ID

      public static int getM_Locator_ID(int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, BigDecimal Qty, String trxName)
      Get Locator with highest Locator Priority and a sufficient OnHand Qty
      Parameters:
      M_Warehouse_ID - warehouse
      M_Product_ID - product
      M_AttributeSetInstance_ID - asi id, use negative value (for e.g -1) to match all asi including 0
      Qty - qty
      trxName - transaction
      Returns:
      locator id (0 if no match found)
    • getM_Warehouse_ID

      public int getM_Warehouse_ID()
      Get M_Warehouse_ID of Locator
      Returns:
      warehouse
    • beforeSave

      protected boolean beforeSave(boolean newRecord)
      Before Save
      Overrides:
      beforeSave in class PO
      Parameters:
      newRecord - new
      Returns:
      success
    • getQtyOnHand

      public static BigDecimal getQtyOnHand(int M_Product_ID, int M_Warehouse_ID, int M_AttributeSetInstance_ID, String trxName)
      Get Quantity On Hand of Warehouse
      Parameters:
      M_Product_ID -
      M_Warehouse_ID -
      M_AttributeSetInstance_ID - M_AttributeSetInstance_ID filter, ignore if 0
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandWithASIZero

      public static BigDecimal getQtyOnHandWithASIZero(int M_Product_ID, int M_Warehouse_ID, String trxName)
      Get Quantity On Hand of Warehouse with ASI=0
      Parameters:
      M_Product_ID -
      M_Warehouse_ID -
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandForReservation

      public static BigDecimal getQtyOnHandForReservation(int M_Product_ID, int M_Warehouse_ID, int M_AttributeSetInstance_ID, String trxName)
      Get Quantity On Hand of Warehouse (only include Locator with Locator Type = Available for Reservation)
      Parameters:
      M_Product_ID -
      M_Warehouse_ID -
      M_AttributeSetInstance_ID -
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandForReservationWithASIZero

      public static BigDecimal getQtyOnHandForReservationWithASIZero(int M_Product_ID, int M_Warehouse_ID, String trxName)
      Get Quantity On Hand of Warehouse with ASI=0 (only include Locator with Locator Type = Available for Reservation)
      Parameters:
      M_Product_ID -
      M_Warehouse_ID -
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandForShipping

      public static BigDecimal getQtyOnHandForShipping(int M_Product_ID, int M_Warehouse_ID, int M_AttributeSetInstance_ID, String trxName)
      Get Quantity On Hand of Warehouse (only include Locator with Locator Type = available for shipping)
      Parameters:
      M_Product_ID -
      M_Warehouse_ID -
      M_AttributeSetInstance_ID -
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandForShippingWithASIZero

      public static BigDecimal getQtyOnHandForShippingWithASIZero(int M_Product_ID, int M_Warehouse_ID, String trxName)
      Get Quantity On Hand of Warehouse with ASI=0 (only include Locator with Locator Type = available for shipping)
      Parameters:
      M_Product_ID -
      M_Warehouse_ID -
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandForLocator

      public static BigDecimal getQtyOnHandForLocator(int M_Product_ID, int M_Locator_ID, int M_AttributeSetInstance_ID, String trxName)
      Get Quantity On Hand of Locator
      Parameters:
      M_Product_ID -
      M_Locator_ID -
      M_AttributeSetInstance_ID -
      trxName -
      Returns:
      QtyOnHand
    • getQtyOnHandForLocatorWithASIZero

      public static BigDecimal getQtyOnHandForLocatorWithASIZero(int M_Product_ID, int M_Locator_ID, String trxName)
      Get Quantity On Hand of Locator with ASI=0
      Parameters:
      M_Product_ID -
      M_Locator_ID -
      trxName -
      Returns:
      QtyOnHand
    • toString

      public String toString()
      String Representation
      Overrides:
      toString in class X_M_StorageOnHand
      Returns:
      info
    • getDateMaterialPolicy

      public static Timestamp getDateMaterialPolicy(int M_Product_ID, int M_AttributeSetInstance_ID, String trxName)
      Get DateMaterialPolicy ORDER BY QtyOnHand DESC
      Parameters:
      M_Product_ID -
      M_AttributeSetInstance_ID -
      trxName -
      Returns:
      DateMaterialPolicy time stamp
    • getDateMaterialPolicy

      public static Timestamp getDateMaterialPolicy(int M_Product_ID, int M_AttributeSetInstance_ID, int M_Locator_ID, String trxName)
      Get DateMaterialPolicy ORDER BY QtyOnHand DESC
      Parameters:
      M_Product_ID -
      M_AttributeSetInstance_ID -
      M_Locator_ID -
      trxName -
      Returns:
      DateMaterialPolicy time stamp