Fixed bug 22958: Api change. Add new parameter to m_reserve_stock_manual function
authorNaiara Martinez <naiara.martinez@openbravo.com>
Mon, 04 Feb 2013 09:18:00 +0100
changeset 19551 6fb7156c455a
parent 19550 aef37974346f
child 19552 29ce12396f33
Fixed bug 22958: Api change. Add new parameter to m_reserve_stock_manual function
Edit ReservationUtils.java to change the call to the function
src-db/database/model/functions/M_CREATE_RESERVE_FROM_SOL.xml
src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml
src-db/database/model/functions/M_RESERVE_STOCK_AUTO.xml
src-db/database/model/functions/M_RESERVE_STOCK_MANUAL.xml
src/org/openbravo/erpCommon/ad_process/MRPPurchaseCreateReservations.java
src/org/openbravo/materialmgmt/ReservationUtils.java
src/org/openbravo/materialmgmt/ReservationUtils_data.xsql
--- a/src-db/database/model/functions/M_CREATE_RESERVE_FROM_SOL.xml	Mon Feb 04 03:21:41 2013 +0100
+++ b/src-db/database/model/functions/M_CREATE_RESERVE_FROM_SOL.xml	Mon Feb 04 09:18:00 2013 +0100
@@ -90,7 +90,7 @@
       WHERE iol.c_orderline_id = p_orderline_id
         AND io.docstatus = 'CO'
   ) LOOP
-    M_RESERVE_STOCK_MANUAL(v_reservation_id, 'SD', cur_shipments.m_storage_detail_id, cur_shipments.movementqty, p_user_id, v_res_stock_id);
+    M_RESERVE_STOCK_MANUAL(v_reservation_id, 'SD', cur_shipments.m_storage_detail_id, cur_shipments.movementqty, p_user_id, 'N', v_res_stock_id);
     UPDATE m_reservation_stock
     SET releasedqty = COALESCE(releasedqty, 0) + cur_shipments.movementqty
     WHERE m_reservation_stock_id = v_res_stock_id;
--- a/src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml	Mon Feb 04 03:21:41 2013 +0100
+++ b/src-db/database/model/functions/M_RESERVATION_CONSUMPTION.xml	Mon Feb 04 09:18:00 2013 +0100
@@ -175,7 +175,7 @@
       END LOOP;
     END IF;
 
-    M_RESERVE_STOCK_MANUAL(p_reservation_id, 'SD', v_storage_detail_id, v_qtytoreserve, p_user_id, v_res_stock_id);
+    M_RESERVE_STOCK_MANUAL(p_reservation_id, 'SD', v_storage_detail_id, v_qtytoreserve, p_user_id, 'N', v_res_stock_id);
   END IF;
   
   IF (v_qtyfromother > 0) THEN
@@ -227,7 +227,7 @@
       WHERE quantity = 0
         AND m_reservation_stock_id = cur_not_allocated_stock.m_reservation_stock_id;
   
-      M_RESERVE_STOCK_MANUAL(p_reservation_id, 'SD', v_storage_detail_id, v_qtytorelease, p_user_id, v_res_stock_id);
+      M_RESERVE_STOCK_MANUAL(p_reservation_id, 'SD', v_storage_detail_id, v_qtytorelease, p_user_id, 'N', v_res_stock_id);
   
       -- Call get stock to check availability
       DECLARE
--- a/src-db/database/model/functions/M_RESERVE_STOCK_AUTO.xml	Mon Feb 04 03:21:41 2013 +0100
+++ b/src-db/database/model/functions/M_RESERVE_STOCK_AUTO.xml	Mon Feb 04 09:18:00 2013 +0100
@@ -120,7 +120,7 @@
     ORDER BY priority
   ) LOOP
     v_qty := LEAST(cur_stock.quantity, v_pendingqty);
-    M_RESERVE_STOCK_MANUAL(p_reservation_id, 'SD', cur_stock.m_storage_detail_id, v_qty, p_user_id, v_dummy);
+    M_RESERVE_STOCK_MANUAL(p_reservation_id, 'SD', cur_stock.m_storage_detail_id, v_qty, p_user_id, 'N', v_dummy);
     v_pendingqty := v_pendingqty - v_qty;
     IF (v_pendingqty <= 0) THEN
       p_reservedqty := v_reserveqty;
--- a/src-db/database/model/functions/M_RESERVE_STOCK_MANUAL.xml	Mon Feb 04 03:21:41 2013 +0100
+++ b/src-db/database/model/functions/M_RESERVE_STOCK_MANUAL.xml	Mon Feb 04 09:18:00 2013 +0100
@@ -16,6 +16,9 @@
       <parameter name="p_user_id" type="VARCHAR" mode="in">
         <default/>
       </parameter>
+      <parameter name="p_allocated" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
       <parameter name="p_reservation_stock_id" type="VARCHAR" mode="out">
         <default/>
       </parameter>
@@ -76,15 +79,15 @@
     FROM m_reservation_stock
     WHERE m_reservation_id = p_reservation_id
       AND m_locator_id = v_locator_id
-      AND m_attributesetinstance_id = v_asi_id
-      AND isallocated = 'N';
+      AND COALESCE(m_attributesetinstance_id, '0') = COALESCE(v_asi_id, '0')
+      AND isallocated = p_allocated;
   ELSIF (p_type_id = 'PO') THEN
     v_poline_id := p_stock_id;
     SELECT max(m_reservation_stock_id) INTO v_aux_rs_id
     FROM m_reservation_stock
     WHERE m_reservation_id = p_reservation_id
       AND c_orderline_id = v_poline_id
-      AND isallocated = 'N';
+      AND isallocated = p_allocated;
   ELSE
     RAISE_APPLICATION_ERROR(-20000, '@UnsupportedReservationType@');
   END IF;
@@ -105,7 +108,7 @@
     v_reservation_stock_id, v_client_id, v_org_id, 'Y',
     now(), p_user_id, now(), p_user_id,
     p_reservation_id, v_asi_id, v_locator_id, v_poline_id,
-    p_qty, 0, 'N'
+    p_qty, 0, p_allocated
   );
 
   p_reservation_stock_id := v_reservation_stock_id;
--- a/src/org/openbravo/erpCommon/ad_process/MRPPurchaseCreateReservations.java	Mon Feb 04 03:21:41 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/MRPPurchaseCreateReservations.java	Mon Feb 04 09:18:00 2013 +0100
@@ -136,7 +136,7 @@
             if (incomingLine.getTransactionType().equals("PP")
                 && incomingLine.getSalesOrderLine() != null) {
               ReservationUtils.reserveStockManual(reservation, incomingLine.getSalesOrderLine(),
-                  consumedQuantity);
+                  consumedQuantity, "N");
             }
 
             if (quantity.signum() < 1 && reservation.getRESStatus().equals("DR")) {
--- a/src/org/openbravo/materialmgmt/ReservationUtils.java	Mon Feb 04 03:21:41 2013 +0100
+++ b/src/org/openbravo/materialmgmt/ReservationUtils.java	Mon Feb 04 09:18:00 2013 +0100
@@ -100,8 +100,9 @@
    * - StorageDetail: reserves stock in the warehouse.<br>
    * - OrderLine: reserves stock pending to receipt purchase order line.
    */
+
   public static ReservationStock reserveStockManual(Reservation reservation, BaseOBObject obObject,
-      BigDecimal quantity) throws OBException {
+      BigDecimal quantity, String allocated) throws OBException {
 
     String strType = "";
 
@@ -119,7 +120,7 @@
       cs = ReservationUtilsData.reserveStockManual(OBDal.getInstance().getConnection(false),
           new DalConnectionProvider(false), reservation.getId(), strType, obObject.getId()
               .toString(), quantity.toString(), (String) DalUtil.getId(OBContext.getOBContext()
-              .getUser()));
+              .getUser()), allocated);
     } catch (ServletException e) {
       throw new OBException(DbUtility.getUnderlyingSQLException(e));
     }
--- a/src/org/openbravo/materialmgmt/ReservationUtils_data.xsql	Mon Feb 04 03:21:41 2013 +0100
+++ b/src/org/openbravo/materialmgmt/ReservationUtils_data.xsql	Mon Feb 04 09:18:00 2013 +0100
@@ -48,13 +48,15 @@
    <SqlMethod name="reserveStockManual" connection="true" type="callableStatement" return="object" object="CSResponse">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
-        CALL M_RESERVE_STOCK_MANUAL(?,?,?,to_number(?),?,?)
+        CALL M_RESERVE_STOCK_MANUAL(?,?,?,to_number(?),?,to_char(?),?)
       ]]></Sql>
       <Parameter name="mReservationId"/>
       <Parameter name="type"/>
       <Parameter name="stockId"/>
       <Parameter name="quantity"/>
       <Parameter name="adUserId"/>
+      <Parameter name="allocated"/>
       <Parameter name="returnValue" type="out"/>
    </SqlMethod>
+   
 </SqlClass>