src-db/database/model/functions/M_RESERVATION_POST.xml
changeset 24152 bae6b944d95a
parent 21157 2e9ce78cf1e3
child 24270 e414f3f0e298
equal deleted inserted replaced
24151:4f31d2d162f9 24152:bae6b944d95a
    23 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    23 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    24 * License for the specific  language  governing  rights  and  limitations
    24 * License for the specific  language  governing  rights  and  limitations
    25 * under the License.
    25 * under the License.
    26 * The Original Code is Openbravo ERP.
    26 * The Original Code is Openbravo ERP.
    27 * The Initial Developer of the Original Code is Openbravo SLU
    27 * The Initial Developer of the Original Code is Openbravo SLU
    28 * All portions are Copyright (C) 2012-2013 Openbravo SLU
    28 * All portions are Copyright (C) 2012-2014 Openbravo SLU
    29 * All Rights Reserved.
    29 * All Rights Reserved.
    30 * Contributor(s):  ______________________________________.
    30 * Contributor(s):  ______________________________________.
    31 ************************************************************************/
    31 ************************************************************************/
    32   v_ResultStr       VARCHAR2(2000):='';
    32   v_ResultStr       VARCHAR2(2000):='';
    33   v_Message         VARCHAR2(2000):='';
    33   v_Message         VARCHAR2(2000):='';
   230                              ELSE rs2.quantity END) as qty, rs2.c_orderline_id
   230                              ELSE rs2.quantity END) as qty, rs2.c_orderline_id
   231                   FROM m_reservation_stock rs2
   231                   FROM m_reservation_stock rs2
   232                       JOIN m_reservation r ON rs2.m_reservation_id = r.m_reservation_id
   232                       JOIN m_reservation r ON rs2.m_reservation_id = r.m_reservation_id
   233                   WHERE rs2.c_orderline_id IS NOT NULL
   233                   WHERE rs2.c_orderline_id IS NOT NULL
   234                     AND r.res_status NOT IN ('DR')
   234                     AND r.res_status NOT IN ('DR')
       
   235                     AND r.m_product_id = v_product_id
       
   236                     AND r.c_uom_id = v_uom_id
   235                   GROUP BY rs2.c_orderline_id
   237                   GROUP BY rs2.c_orderline_id
   236                 ) pre ON rs.c_orderline_id = pre.c_orderline_id
   238                 ) pre ON rs.c_orderline_id = pre.c_orderline_id
   237           WHERE rs.m_reservation_id = v_reservation_id
   239           WHERE rs.m_reservation_id = v_reservation_id
   238             AND rs.c_orderline_id IS NOT NULL
   240             AND rs.c_orderline_id IS NOT NULL
   239             AND ol.qtyordered < rs.quantity + COALESCE(pre.qty, 0)
   241             AND ol.qtyordered < rs.quantity + COALESCE(pre.qty, 0)