Related to issue 42295: Avoid API change in CancelAndReplaceUtils
authorÁlvaro Ferraz <alvaro.ferraz@openbravo.com>
Mon, 18 Nov 2019 12:47:40 +0100
changeset 36814 5a1554f3b7a1
parent 36813 9aa4940cd2b3
child 36815 0e5e02a7ff59
child 36817 fbd6f128b3f9
child 36837 0b8a0558c384
Related to issue 42295: Avoid API change in CancelAndReplaceUtils
src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java
src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java
--- a/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java	Mon Nov 18 12:45:39 2019 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java	Mon Nov 18 12:47:40 2019 +0100
@@ -29,6 +29,7 @@
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.LockOptions;
 import org.hibernate.ScrollMode;
@@ -243,6 +244,49 @@
     return newDocNo.toString();
   }
 
+  /**
+   * Method to check if a netting shipment must be generated during the C&amp;R and CL process.
+   * 
+   * @param order
+   *          The order that is being canceled.
+   * @return True if is necessary to create the netting shipment.
+   */
+  public static boolean getCreateNettingGoodsShipmentPreferenceValue(Order order) {
+    boolean createNettingGoodsShipment = false;
+    try {
+      createNettingGoodsShipment = Preferences
+          .getPreferenceValue(CREATE_NETTING_SHIPMENT, true,
+              OBContext.getOBContext().getCurrentClient(), order.getOrganization(),
+              OBContext.getOBContext().getUser(), null, null)
+          .equals("Y");
+    } catch (PropertyException e1) {
+      createNettingGoodsShipment = false;
+    }
+    return createNettingGoodsShipment;
+  }
+
+  /**
+   * Method to check if during the C&amp;R process the shipment lines must be moved from the old
+   * order to the new order.
+   * 
+   * @param order
+   *          The order that is being canceled.
+   * @return True if the shipment lines must be moved to the new order.
+   */
+  public static boolean getAssociateGoodsShipmentToNewSalesOrderPreferenceValue(Order order) {
+    boolean associateShipmentToNewReceipt = false;
+    try {
+      associateShipmentToNewReceipt = Preferences
+          .getPreferenceValue(ASSOCIATE_SHIPMENT_TO_REPLACE_TICKET, true,
+              OBContext.getOBContext().getCurrentClient(), order.getOrganization(),
+              OBContext.getOBContext().getUser(), null, null)
+          .equals("Y");
+    } catch (PropertyException e1) {
+      associateShipmentToNewReceipt = false;
+    }
+    return associateShipmentToNewReceipt;
+  }
+
   static void throwExceptionIfOrderIsCanceled(Order order) {
     if (order.isCancelled().booleanValue()) {
       throw new OBException(
@@ -341,7 +385,7 @@
   // Pay original order and inverse order.
   static FIN_Payment payOriginalAndInverseOrder(JSONObject jsonOrder, Order oldOrder,
       Order inverseOrder, Organization paymentOrganization, BigDecimal outstandingAmount,
-      BigDecimal negativeAmount, boolean useOrderDocumentNoForRelatedDocs) throws Exception {
+      BigDecimal negativeAmount, boolean useOrderDocumentNoForRelatedDocs) throws JSONException {
     FIN_Payment nettingPayment = null;
     String paymentDocumentNo = null;
     FIN_PaymentMethod paymentPaymentMethod = null;
--- a/src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java	Mon Nov 18 12:45:39 2019 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java	Mon Nov 18 12:47:40 2019 +0100
@@ -49,7 +49,6 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.erpCommon.utility.OBDateUtils;
-import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.materialmgmt.ReservationUtils;
 import org.openbravo.model.ad.access.OrderLineTax;
 import org.openbravo.model.common.enterprise.DocumentType;
@@ -905,49 +904,6 @@
     }
   }
 
-  /**
-   * Method to check if a netting shipment must be generated during the C&amp;R and CL process.
-   * 
-   * @param order
-   *          The order that is being canceled.
-   * @return True if is necessary to create the netting shipment.
-   */
-  private boolean getCreateNettingGoodsShipmentPreferenceValue(Order order) {
-    boolean createNettingGoodsShipment = false;
-    try {
-      createNettingGoodsShipment = Preferences
-          .getPreferenceValue(CREATE_NETTING_SHIPMENT, true,
-              OBContext.getOBContext().getCurrentClient(), order.getOrganization(),
-              OBContext.getOBContext().getUser(), null, null)
-          .equals("Y");
-    } catch (PropertyException e1) {
-      createNettingGoodsShipment = false;
-    }
-    return createNettingGoodsShipment;
-  }
-
-  /**
-   * Method to check if during the C&amp;R process the shipment lines must be moved from the old
-   * order to the new order.
-   * 
-   * @param order
-   *          The order that is being canceled.
-   * @return True if the shipment lines must be moved to the new order.
-   */
-  public boolean getAssociateGoodsShipmentToNewSalesOrderPreferenceValue(Order order) {
-    boolean associateShipmentToNewReceipt = false;
-    try {
-      associateShipmentToNewReceipt = Preferences
-          .getPreferenceValue(ASSOCIATE_SHIPMENT_TO_REPLACE_TICKET, true,
-              OBContext.getOBContext().getCurrentClient(), order.getOrganization(),
-              OBContext.getOBContext().getUser(), null, null)
-          .equals("Y");
-    } catch (PropertyException e1) {
-      associateShipmentToNewReceipt = false;
-    }
-    return associateShipmentToNewReceipt;
-  }
-
   private OrderLine getReplacementOrderLine(String oldOrderLineId) {
     return (OrderLine) OBDal.getInstance()
         .createCriteria(OrderLine.class)