Class MStorageOnHand

    • Constructor Detail

      • MStorageOnHand

        public MStorageOnHand​(Properties ctx,
                              int ignored,
                              String trxName)
        Persistency Constructor
        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 Detail

      • get

        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 Storage Info
        Parameters:
        ctx - context
        M_Locator_ID - locator
        M_Product_ID - product
        M_AttributeSetInstance_ID - instance
        dateMPolicy -
        trxName - transaction
        Returns:
        existing 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 - first in-first-out
        trxName - transaction
        Returns:
        existing or null
      • 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:
        existing or null
      • 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 -
        timeout -
        Returns:
        existing or null
      • 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 for update
        timeout - timeout for the acquisition of db update lock
        Returns:
        existing or null
      • getOfProduct

        public static MStorageOnHand[] getOfProduct​(Properties ctx,
                                                    int M_Product_ID,
                                                    String trxName)
        Get Storage Info for Product across warehouses
        Parameters:
        ctx - context
        M_Product_ID - product
        trxName - transaction
        Returns:
        existing or null
      • getWarehouse

        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 Storage Info 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 if all attribute instances
        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 Storage Info 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 if all attribute instances
        FiFo - first in-first-out
        positiveOnly - if true, only return storage records with qtyOnHand > 0
        M_Locator_ID - optional locator id
        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,
                                                    boolean forUpdate)
        Get Storage Info 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 if all attribute instances
        FiFo - first in-first-out
        positiveOnly - if true, only return storage records with qtyOnHand > 0
        M_Locator_ID - optional locator id
        trxName - transaction
        forUpdate -
        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,
                                                    boolean forUpdate,
                                                    int timeout)
        Get Storage Info 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 if all attribute instances
        FiFo - first in-first-out
        positiveOnly - if true, only return storage records with qtyOnHand > 0
        M_Locator_ID - optional locator id
        trxName - transaction
        forUpdate -
        timeout -
        Returns:
        existing - 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 Storage Info 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 if all attribute instances
        FiFo - first in-first-out
        M_Locator_ID - optional locator id
        trxName - transaction
        Returns:
        existing - 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 Storage Info 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 if all attribute instances
        FiFo - first in-first-out
        M_Locator_ID - optional locator id
        trxName - transaction
        forUpdate -
        Returns:
        existing - 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 Storage Info 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 if all attribute instances
        FiFo - first in-first-out
        M_Locator_ID - optional locator id
        trxName - transaction
        forUpdate -
        timeout -
        Returns:
        existing - 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 Storage Info
        Parameters:
        ctx - context
        M_Locator_ID - locator
        M_Product_ID - product
        M_AttributeSetInstance_ID - instance
        trxName - transaction
        Returns:
        existing/new or null
      • 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 Storage Info
        Parameters:
        ctx - context
        M_Locator_ID - locator
        M_Product_ID - product
        M_AttributeSetInstance_ID - instance
        trxName - transaction
        forUpdate -
        Returns:
        existing/new or null
      • 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 Storage Info
        Parameters:
        ctx - context
        M_Locator_ID - locator
        M_Product_ID - product
        M_AttributeSetInstance_ID - instance
        trxName - transaction
        forUpdate -
        timeout -
        Returns:
        existing/new or null
      • 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 Storage Info add. 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

        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 Storage Info add. 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)
        Update Storage Info add. Called from MProjectIssue
        Parameters:
        ctx - context
        M_Locator_ID - locator
        M_Product_ID - product
        M_AttributeSetInstance_ID - AS Instance
        diffQtyOnHand - add on hand
        dateMPolicy -
        trxName - transaction
        Returns:
        true if updated
      • addQtyOnHand

        public void addQtyOnHand​(BigDecimal addition)
        Add quantity on hand directly - not using cached value - solving IDEMPIERE-2629
        Parameters:
        addition -
      • 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 Location 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 -
        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 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 Available for Reservation with ASI=0
        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 that's 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 that's available for shipping with ASI=0
        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 wtih ASI=0
        Parameters:
        M_Product_ID -
        M_Locator_ID -
        trxName -
        Returns:
        QtyOnHand
      • getDateMaterialPolicy

        public static Timestamp getDateMaterialPolicy​(int M_Product_ID,
                                                      int M_AttributeSetInstance_ID,
                                                      String trxName)
        Parameters:
        M_Product_ID -
        M_AttributeSetInstance_ID -
        trxName -
        Returns:
        datempolicy timestamp
      • getDateMaterialPolicy

        public static Timestamp getDateMaterialPolicy​(int M_Product_ID,
                                                      int M_AttributeSetInstance_ID,
                                                      int M_Locator_ID,
                                                      String trxName)
        Parameters:
        M_Product_ID -
        M_AttributeSetInstance_ID -
        M_Locator_ID -
        trxName -
        Returns:
        datempolicy timestamp