src-db/database/model/functions/M_INOUT_POST.xml
changeset 21751 d7f5fe16e748
parent 21373 e3a359452601
child 21838 304b13b3a917
equal deleted inserted replaced
21750:e7bddfad3ae2 21751:d7f5fe16e748
    20   * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
    20   * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
    21   * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
    21   * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
    22   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
    22   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
    23   * All Rights Reserved.
    23   * All Rights Reserved.
    24   * Contributor(s): Openbravo SLU
    24   * Contributor(s): Openbravo SLU
    25   * Contributions are Copyright (C) 2001-2013 Openbravo, S.L.U.
    25   * Contributions are Copyright (C) 2001-2014 Openbravo, S.L.U.
    26   *
    26   *
    27   * Specifically, this derivative work is based upon the following Compiere
    27   * Specifically, this derivative work is based upon the following Compiere
    28   * file and version.
    28   * file and version.
    29   *************************************************************************
    29   *************************************************************************
    30   * $Id: M_InOut_Post.sql,v 1.8 2003/09/05 04:58:06 jjanke Exp $
    30   * $Id: M_InOut_Post.sql,v 1.8 2003/09/05 04:58:06 jjanke Exp $
    64     Cur_Parameter RECORD;
    64     Cur_Parameter RECORD;
    65     --
    65     --
    66     Cur_InOut RECORD;
    66     Cur_InOut RECORD;
    67     Cur_InOutLine RECORD;
    67     Cur_InOutLine RECORD;
    68     Cur_Order RECORD;
    68     Cur_Order RECORD;
       
    69     Cur_OrderLine RECORD;
    69     --
    70     --
    70     v_Result NUMBER:=1;
    71     v_Result NUMBER:=1;
    71     v_AD_Org_ID VARCHAR2(32);
    72     v_AD_Org_ID VARCHAR2(32);
    72     v_Warehouse_Org VARCHAR2(32);
    73     v_Warehouse_Org VARCHAR2(32);
    73     v_AD_Client_ID VARCHAR2(32);
    74     v_AD_Client_ID VARCHAR2(32);
   174           AND AD_IsOrgIncluded(m.AD_ORG_ID, bp.AD_ORG_ID, bp.AD_CLIENT_ID)=-1;
   175           AND AD_IsOrgIncluded(m.AD_ORG_ID, bp.AD_ORG_ID, bp.AD_CLIENT_ID)=-1;
   175         IF v_Count>0 THEN
   176         IF v_Count>0 THEN
   176           RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgBpartnerInout@') ;
   177           RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgBpartnerInout@') ;
   177         END IF;
   178         END IF;
   178       END IF;
   179       END IF;
       
   180 
       
   181       if(v_isreturndoctype = 'N' AND v_isSoTrx = 'Y') then
       
   182         v_message := null;
       
   183         for Cur_OrderLine in (
       
   184           select c_orderline_id, line
       
   185           from m_inoutline
       
   186           where m_inout_id = v_Record_ID
       
   187           order by line
       
   188         ) loop
       
   189           select COALESCE(sum(movementqty), 0)
       
   190           into v_qty
       
   191           from m_inoutline
       
   192           where m_inout_id = v_Record_ID
       
   193           and c_orderline_id = Cur_OrderLine.c_orderline_id;
       
   194 
       
   195           select qtyordered, (coalesce(qtydelivered, 0) + v_qty)
       
   196           into v_QuantityOrder, v_qty
       
   197           from c_orderline
       
   198           where c_orderline_id = Cur_OrderLine.c_orderline_id;
       
   199 
       
   200           if(v_QuantityOrder < v_qty) then
       
   201             if v_message is null THEN
       
   202               v_message := Cur_OrderLine.line;
       
   203             ELSE
       
   204               v_message := v_message || ', ' || Cur_OrderLine.line;
       
   205             END IF;
       
   206           end if;
       
   207         end loop;
       
   208         if v_message is not null then
       
   209           RAISE_APPLICATION_ERROR(-20000, '@MovementQtyCheck@'||' '||'@Inlines@'||' '||v_message);
       
   210         end if;
       
   211       end if;
   179 
   212 
   180       --Check whether warehouse belongs to the organization.
   213       --Check whether warehouse belongs to the organization.
   181       SELECT count(AD_ORG_ID)
   214       SELECT count(AD_ORG_ID)
   182       INTO v_count
   215       INTO v_count
   183       FROM AD_Org_Warehouse
   216       FROM AD_Org_Warehouse