Fixes issue 0020341, 20288: Adds a Callout to warn the user
authorDavid Miguelez <david.miguelez@openbravo.com>
Wed, 25 Apr 2012 16:34:15 +0200
changeset 16214 72795668d074
parent 16213 8e05e2cd1f5b
child 16215 0e26ae8cd928
Fixes issue 0020341, 20288: Adds a Callout to warn the user
when deactivating a Warehouse or an Storage Bin.
src-db/database/sourcedata/AD_CALLOUT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
src/org/openbravo/erpCommon/ad_callouts/SE_Locator_Activate.java
--- a/src-db/database/sourcedata/AD_CALLOUT.xml	Wed Apr 25 18:28:42 2012 +0200
+++ b/src-db/database/sourcedata/AD_CALLOUT.xml	Wed Apr 25 16:34:15 2012 +0200
@@ -781,6 +781,15 @@
 <!--3585710F23F244D9B179A28D18242583-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--3585710F23F244D9B179A28D18242583--></AD_CALLOUT>
 
+<!--3C9DEC9042534CFA8C74B83D28CA777D--><AD_CALLOUT>
+<!--3C9DEC9042534CFA8C74B83D28CA777D-->  <AD_CALLOUT_ID><![CDATA[3C9DEC9042534CFA8C74B83D28CA777D]]></AD_CALLOUT_ID>
+<!--3C9DEC9042534CFA8C74B83D28CA777D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--3C9DEC9042534CFA8C74B83D28CA777D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--3C9DEC9042534CFA8C74B83D28CA777D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--3C9DEC9042534CFA8C74B83D28CA777D-->  <NAME><![CDATA[SE_Locator_Activate]]></NAME>
+<!--3C9DEC9042534CFA8C74B83D28CA777D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--3C9DEC9042534CFA8C74B83D28CA777D--></AD_CALLOUT>
+
 <!--3E7999A44EEA40FEBC71EACA93A51198--><AD_CALLOUT>
 <!--3E7999A44EEA40FEBC71EACA93A51198-->  <AD_CALLOUT_ID><![CDATA[3E7999A44EEA40FEBC71EACA93A51198]]></AD_CALLOUT_ID>
 <!--3E7999A44EEA40FEBC71EACA93A51198-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Wed Apr 25 18:28:42 2012 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Wed Apr 25 16:34:15 2012 +0200
@@ -18526,6 +18526,7 @@
 <!--1249-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--1249-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--1249-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--1249-->  <AD_CALLOUT_ID><![CDATA[3C9DEC9042534CFA8C74B83D28CA777D]]></AD_CALLOUT_ID>
 <!--1249-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--1249-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--1249-->  <POSITION><![CDATA[4]]></POSITION>
@@ -20091,6 +20092,7 @@
 <!--1392-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--1392-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--1392-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--1392-->  <AD_CALLOUT_ID><![CDATA[3C9DEC9042534CFA8C74B83D28CA777D]]></AD_CALLOUT_ID>
 <!--1392-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--1392-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--1392-->  <POSITION><![CDATA[4]]></POSITION>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Apr 25 18:28:42 2012 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Apr 25 16:34:15 2012 +0200
@@ -14805,6 +14805,17 @@
 <!--1237DD133882495FB6AF87E80A852A66-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--1237DD133882495FB6AF87E80A852A66--></AD_MESSAGE>
 
+<!--1238635F09EC446A94D17D8D86BCEE3D--><AD_MESSAGE>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <AD_MESSAGE_ID><![CDATA[1238635F09EC446A94D17D8D86BCEE3D]]></AD_MESSAGE_ID>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <VALUE><![CDATA[M_WAREHOUSE_ACTIVE_CHECK_ENTRIES]]></VALUE>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <MSGTEXT><![CDATA[There are pending Goods Shipments/Receipts for this Warehouse]]></MSGTEXT>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--1238635F09EC446A94D17D8D86BCEE3D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--1238635F09EC446A94D17D8D86BCEE3D--></AD_MESSAGE>
+
 <!--1312C32F5ECB439A8D5EE56876CC43C1--><AD_MESSAGE>
 <!--1312C32F5ECB439A8D5EE56876CC43C1-->  <AD_MESSAGE_ID><![CDATA[1312C32F5ECB439A8D5EE56876CC43C1]]></AD_MESSAGE_ID>
 <!--1312C32F5ECB439A8D5EE56876CC43C1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -15114,6 +15125,17 @@
 <!--1C3FA623333E4AE183F1F441E9F84DE9-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--1C3FA623333E4AE183F1F441E9F84DE9--></AD_MESSAGE>
 
+<!--1C68A76422C94FEC882C1E576C9F4F28--><AD_MESSAGE>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <AD_MESSAGE_ID><![CDATA[1C68A76422C94FEC882C1E576C9F4F28]]></AD_MESSAGE_ID>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <VALUE><![CDATA[M_STORAGE_ACTIVE_CHECK_FULL]]></VALUE>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <MSGTEXT><![CDATA[The Storage Bin is not empty.]]></MSGTEXT>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--1C68A76422C94FEC882C1E576C9F4F28-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--1C68A76422C94FEC882C1E576C9F4F28--></AD_MESSAGE>
+
 <!--1D9A15F68BC447C68725A544F8ED1719--><AD_MESSAGE>
 <!--1D9A15F68BC447C68725A544F8ED1719-->  <AD_MESSAGE_ID><![CDATA[1D9A15F68BC447C68725A544F8ED1719]]></AD_MESSAGE_ID>
 <!--1D9A15F68BC447C68725A544F8ED1719-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -18474,6 +18496,17 @@
 <!--ADA611B9B6E04D92A88BDB2D0B1BC0F0-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--ADA611B9B6E04D92A88BDB2D0B1BC0F0--></AD_MESSAGE>
 
+<!--ADAF53CF368D4956BDFF326A9361C750--><AD_MESSAGE>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <AD_MESSAGE_ID><![CDATA[ADAF53CF368D4956BDFF326A9361C750]]></AD_MESSAGE_ID>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <VALUE><![CDATA[M_WAREHOUSE_ACTIVE_CHECK_ACTIVES]]></VALUE>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <MSGTEXT><![CDATA[There are active Storage Bins inside this Warehouse]]></MSGTEXT>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--ADAF53CF368D4956BDFF326A9361C750-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--ADAF53CF368D4956BDFF326A9361C750--></AD_MESSAGE>
+
 <!--ADF8BF150C894C2D94A6A0AFE89E2843--><AD_MESSAGE>
 <!--ADF8BF150C894C2D94A6A0AFE89E2843-->  <AD_MESSAGE_ID><![CDATA[ADF8BF150C894C2D94A6A0AFE89E2843]]></AD_MESSAGE_ID>
 <!--ADF8BF150C894C2D94A6A0AFE89E2843-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -18773,6 +18806,17 @@
 <!--B90DAD98BE6B409FA4D10CD01397A735-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--B90DAD98BE6B409FA4D10CD01397A735--></AD_MESSAGE>
 
+<!--B9EE1302AB724B3FA76024DB096412EE--><AD_MESSAGE>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <AD_MESSAGE_ID><![CDATA[B9EE1302AB724B3FA76024DB096412EE]]></AD_MESSAGE_ID>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <VALUE><![CDATA[M_STORAGE_ACTIVE_CHECK_LAST]]></VALUE>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <MSGTEXT><![CDATA[The Storage Bin is the last one active for this Warehouse]]></MSGTEXT>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--B9EE1302AB724B3FA76024DB096412EE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--B9EE1302AB724B3FA76024DB096412EE--></AD_MESSAGE>
+
 <!--BAD33CDEBE2547A9A2FF7E87DA0B4C38--><AD_MESSAGE>
 <!--BAD33CDEBE2547A9A2FF7E87DA0B4C38-->  <AD_MESSAGE_ID><![CDATA[BAD33CDEBE2547A9A2FF7E87DA0B4C38]]></AD_MESSAGE_ID>
 <!--BAD33CDEBE2547A9A2FF7E87DA0B4C38-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Wed Apr 25 18:28:42 2012 +0200
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Wed Apr 25 16:34:15 2012 +0200
@@ -3211,6 +3211,18 @@
 <!--30D55DB2422B4CA7B7B2355E1A08EF11-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--30D55DB2422B4CA7B7B2355E1A08EF11--></AD_MODEL_OBJECT>
 
+<!--31BC8D12B955403EB8D88B85EB9BF4E4--><AD_MODEL_OBJECT>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <AD_MODEL_OBJECT_ID><![CDATA[31BC8D12B955403EB8D88B85EB9BF4E4]]></AD_MODEL_OBJECT_ID>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <ACTION><![CDATA[C]]></ACTION>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.ad_callouts.SE_Locator_Activate]]></CLASSNAME>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <AD_CALLOUT_ID><![CDATA[3C9DEC9042534CFA8C74B83D28CA777D]]></AD_CALLOUT_ID>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--31BC8D12B955403EB8D88B85EB9BF4E4--></AD_MODEL_OBJECT>
+
 <!--328EDF326D894E7D8BBA2B06FB07F1EA--><AD_MODEL_OBJECT>
 <!--328EDF326D894E7D8BBA2B06FB07F1EA-->  <AD_MODEL_OBJECT_ID><![CDATA[328EDF326D894E7D8BBA2B06FB07F1EA]]></AD_MODEL_OBJECT_ID>
 <!--328EDF326D894E7D8BBA2B06FB07F1EA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Wed Apr 25 18:28:42 2012 +0200
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Wed Apr 25 16:34:15 2012 +0200
@@ -4080,6 +4080,16 @@
 <!--887A5D8C19464BCD805726641AD05CAD-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
 <!--887A5D8C19464BCD805726641AD05CAD--></AD_MODEL_OBJECT_MAPPING>
 
+<!--8E29104FB7F742429239BCE757554EDB--><AD_MODEL_OBJECT_MAPPING>
+<!--8E29104FB7F742429239BCE757554EDB-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[8E29104FB7F742429239BCE757554EDB]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--8E29104FB7F742429239BCE757554EDB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8E29104FB7F742429239BCE757554EDB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8E29104FB7F742429239BCE757554EDB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8E29104FB7F742429239BCE757554EDB-->  <AD_MODEL_OBJECT_ID><![CDATA[31BC8D12B955403EB8D88B85EB9BF4E4]]></AD_MODEL_OBJECT_ID>
+<!--8E29104FB7F742429239BCE757554EDB-->  <MAPPINGNAME><![CDATA[/ad_callouts/SE_Locator_Activate.html]]></MAPPINGNAME>
+<!--8E29104FB7F742429239BCE757554EDB-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--8E29104FB7F742429239BCE757554EDB--></AD_MODEL_OBJECT_MAPPING>
+
 <!--8FFBEAE4CF644D3D98B19722BAE14E64--><AD_MODEL_OBJECT_MAPPING>
 <!--8FFBEAE4CF644D3D98B19722BAE14E64-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[8FFBEAE4CF644D3D98B19722BAE14E64]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--8FFBEAE4CF644D3D98B19722BAE14E64-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Locator_Activate.java	Wed Apr 25 16:34:15 2012 +0200
@@ -0,0 +1,144 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.erpCommon.ad_callouts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.advpaymentmngt.utility.FIN_Utility;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBQuery;
+import org.openbravo.model.common.enterprise.Locator;
+import org.openbravo.model.common.enterprise.Warehouse;
+import org.openbravo.model.materialmgmt.onhandquantity.StorageDetail;
+import org.openbravo.model.materialmgmt.onhandquantity.StoragePending;
+
+public class SE_Locator_Activate extends SimpleCallout {
+  private static final long serialVersionUID = 1L;
+
+  private final String STORAGEBIN_TAB = "178";
+  private final String WAREHOUSE_TAB = "177";
+
+  @Override
+  protected void execute(CalloutInfo info) throws ServletException {
+
+    VariablesSecureApp vars = info.vars;
+    String active = vars.getStringParameter("inpisactive");
+    String strLocator = vars.getStringParameter("inpmLocatorId");
+    String tab = vars.getStringParameter("inpTabId");
+    String strWarehouse = vars.getStringParameter("inpmWarehouseId");
+
+    if (active.equals("Y")) {
+      return;
+    }
+
+    OBContext.setAdminMode(true);
+    try {
+
+      if (tab.equals(STORAGEBIN_TAB)) {
+        if (storageIsNotEmpty(strLocator)) {
+          info.addResult("MESSAGE", FIN_Utility.messageBD("M_STORAGE_ACTIVE_CHECK_FULL"));
+        } else {
+          Locator locator = OBDal.getInstance().get(Locator.class, strLocator);
+          if (numberOfActiveStorageBins(locator.getWarehouse()) == 1 && locator.isActive()) {
+            // This means that the warehouse has only one active storage bin and it is this one
+            info.addResult("MESSAGE", FIN_Utility.messageBD("M_STORAGE_ACTIVE_CHECK_LAST"));
+          }
+        }
+      } else if (tab.equals(WAREHOUSE_TAB)) {
+        Warehouse warehouse = OBDal.getInstance().get(Warehouse.class, strWarehouse);
+        if (numberOfActiveStorageBins(warehouse) > 0) {
+          info.addResult("MESSAGE", FIN_Utility.messageBD("M_WAREHOUSE_ACTIVE_CHECK_ACTIVES"));
+        } else if (warehouseWithPendingReceipts(warehouse.getId())) {
+          info.addResult("MESSAGE", FIN_Utility.messageBD("M_WAREHOUSE_ACTIVE_CHECK_ENTRIES"));
+        }
+      }
+
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  /**
+   * This method returns true if the storage bin with the id passed as argument has stock inside.
+   * This means that the storage bin should not be deactivated.
+   */
+  private boolean storageIsNotEmpty(String strLocator) {
+    final StringBuilder hsqlScript = new StringBuilder();
+    final List<Object> parameters = new ArrayList<Object>();
+
+    hsqlScript.append(" as sd ");
+    hsqlScript.append(" where sd." + StorageDetail.PROPERTY_STORAGEBIN + ".id = ? and ");
+    parameters.add(strLocator);
+    hsqlScript.append(" (coalesce (sd." + StorageDetail.PROPERTY_QUANTITYONHAND + ",0) <> 0)");
+    hsqlScript.append(" or coalesce (sd." + StorageDetail.PROPERTY_ONHANDORDERQUANITY + ",0) <> 0");
+    hsqlScript.append(" or coalesce (sd." + StorageDetail.PROPERTY_QUANTITYINDRAFTTRANSACTIONS
+        + ",0) <> 0");
+    hsqlScript.append(" or coalesce (sd." + StorageDetail.PROPERTY_QUANTITYORDERINDRAFTTRANSACTIONS
+        + ",0) <> 0) ");
+
+    final OBQuery<StorageDetail> query = OBDal.getInstance().createQuery(StorageDetail.class,
+        hsqlScript.toString());
+    query.setParameters(parameters);
+    return query.list().size() > 0;
+  }
+
+  /**
+   * This method returns true if the warehouse has pending shipments or receipts.
+   */
+  private Boolean warehouseWithPendingReceipts(String warehouse) {
+    final StringBuilder hsqlScript = new StringBuilder();
+    final List<Object> parameters = new ArrayList<Object>();
+
+    hsqlScript.append(" as sp");
+    hsqlScript.append(" left join sp.warehouse as w");
+    hsqlScript.append(" where w.id = ? and");
+    parameters.add(warehouse);
+    hsqlScript.append(" (coalesce (sp." + StoragePending.PROPERTY_ORDEREDQUANTITY + ",0) <> 0");
+    hsqlScript.append(" or coalesce (sp." + StoragePending.PROPERTY_ORDEREDQUANTITYORDER
+        + ",0) <> 0");
+    hsqlScript.append(" or coalesce (sp." + StoragePending.PROPERTY_RESERVEDQUANTITY + ",0) <> 0");
+    hsqlScript.append(" or coalesce (sp." + StoragePending.PROPERTY_RESERVEDQUANTITYORDER
+        + ",0) <> 0)) ");
+
+    final OBQuery<StoragePending> query = OBDal.getInstance().createQuery(StoragePending.class,
+        hsqlScript.toString());
+    query.setParameters(parameters);
+    return query.list().size() > 0;
+  }
+
+  /**
+   * This method returns the number of Active Storage Bins a Warehouse has.
+   */
+  private int numberOfActiveStorageBins(Warehouse warehouse) {
+    int number = 0;
+    for (Locator locator : warehouse.getLocatorList()) {
+      if (locator.isActive()) {
+        number++;
+      }
+    }
+    return number;
+  }
+
+}