src-db/database/model/functions/C_INVOICE_POST.xml
changeset 31570 68702618a590
parent 30970 3d4b4857dc35
child 31600 86dcf5d294d9
equal deleted inserted replaced
31569:9c931e5263c1 31570:68702618a590
    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-2016 Openbravo, S.L.U.
    25   * Contributions are Copyright (C) 2001-2017 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: C_Invoice_Post.sql,v 1.32 2003/07/22 05:41:27 jjanke Exp $
    30   * $Id: C_Invoice_Post.sql,v 1.32 2003/07/22 05:41:27 jjanke Exp $
   172 
   172 
   173   v_iscashvat C_Invoice.IsCashVat%TYPE;
   173   v_iscashvat C_Invoice.IsCashVat%TYPE;
   174   v_invoiceline_qtysum NUMBER;
   174   v_invoiceline_qtysum NUMBER;
   175   v_PriceList_ID varchar2(32);
   175   v_PriceList_ID varchar2(32);
   176   v_prepaymentamt NUMBER;
   176   v_prepaymentamt NUMBER;
       
   177   v_prepayment_inorders NUMBER;
   177   v_hasTaxes NUMBER;
   178   v_hasTaxes NUMBER;
   178    
   179    
   179 BEGIN
   180 BEGIN
   180   IF (p_PInstance_ID IS NOT NULL) THEN
   181   IF (p_PInstance_ID IS NOT NULL) THEN
   181     --  Update AD_PInstance
   182     --  Update AD_PInstance
  1794     IF (NOT FINISH_PROCESS AND v_IsSOTrx='Y') THEN
  1795     IF (NOT FINISH_PROCESS AND v_IsSOTrx='Y') THEN
  1795       C_BP_SOCREDITUSED_REFRESH(v_BPartner_ID) ;
  1796       C_BP_SOCREDITUSED_REFRESH(v_BPartner_ID) ;
  1796     END IF;
  1797     END IF;
  1797   END IF;--FINISH_PROCESS
  1798   END IF;--FINISH_PROCESS
  1798   IF (NOT FINISH_PROCESS AND NOT END_PROCESSING) THEN
  1799   IF (NOT FINISH_PROCESS AND NOT END_PROCESSING) THEN
       
  1800     --Update the prepayment amount from orders related to the invoice lines.
       
  1801     SELECT COALESCE(SUM(fps.paidamt),0)
       
  1802       INTO v_prepayment_inorders
       
  1803     FROM fin_payment_schedule fps
       
  1804       JOIN c_order o ON o.c_order_id=fps.c_order_id
       
  1805       JOIN c_orderline ol ON ol.c_order_id = o.c_order_id
       
  1806       JOIN c_invoiceline il ON il.c_orderline_id = ol.c_orderline_id
       
  1807     WHERE il.c_invoice_id = v_Record_ID;
       
  1808 
  1799     -- Finish up -------------------------------------------------------------
  1809     -- Finish up -------------------------------------------------------------
  1800     UPDATE C_INVOICE
  1810     UPDATE C_INVOICE
  1801     SET DocStatus='CO',
  1811     SET DocStatus='CO',
  1802         Processed='Y',
  1812         Processed='Y',
  1803         DocAction='RE',
  1813         DocAction='RE',
       
  1814         PrepaymentAmt=v_prepayment_inorders,
  1804         Updated=now(),
  1815         Updated=now(),
  1805         UpdatedBy=v_UpdatedBy
  1816         UpdatedBy=v_UpdatedBy
  1806     WHERE C_Invoice_ID=v_Record_ID;
  1817     WHERE C_Invoice_ID=v_Record_ID;
  1807   END IF;--FINISH_PROCESS
  1818   END IF;--FINISH_PROCESS
  1808   IF (NOT FINISH_PROCESS) THEN
  1819   IF (NOT FINISH_PROCESS) THEN