src-db/database/model/functions/C_CASH_POST.xml
changeset 1605 8a0fe0193bef
parent 1063 b00f96629e5a
child 1929 ad0353d93b0f
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2   <database name="FUNCTION C_CASH_POST">
     2   <database name="FUNCTION C_CASH_POST">
     3     <function name="C_CASH_POST" type="NULL">
     3     <function name="C_CASH_POST" type="NULL">
     4       <parameter name="p_pinstance_id" type="NUMERIC" mode="in">
     4       <parameter name="p_pinstance_id" type="VARCHAR" mode="in">
     5         <default/>
     5         <default/>
     6       </parameter>
     6       </parameter>
     7       <body><![CDATA[/*************************************************************************
     7       <body><![CDATA[/*************************************************************************
     8   * The contents of this file are subject to the Compiere License
     8   * The contents of this file are subject to the Compiere License
     9   License
     9   License
    32   ************************************************************************/
    32   ************************************************************************/
    33   --  Logistice
    33   --  Logistice
    34   v_ResultStr VARCHAR2(2000):='';
    34   v_ResultStr VARCHAR2(2000):='';
    35   v_Result NUMBER;
    35   v_Result NUMBER;
    36   v_Message VARCHAR2(2000):='';
    36   v_Message VARCHAR2(2000):='';
    37   v_Record_ID NUMBER(10) ;
    37   v_Record_ID VARCHAR2(32) ;
    38   v_User NUMBER;
    38   v_User VARCHAR2(32);
    39   v_C_Debt_Payment_Id NUMBER;
    39   v_C_Debt_Payment_ID VARCHAR2(32);
    40   v_C_Order_Id NUMBER;
    40   v_C_Order_ID VARCHAR2(32);
    41   --Added by P.SAROBE
    41   --Added by P.SAROBE
    42 	v_documentno_Settlement VARCHAR2(40);
    42 	v_documentno_Settlement VARCHAR2(40);
    43 	v_dateSettlement DATE;
    43 	v_dateSettlement DATE;
    44 	v_Cancel_Processed CHAR(1);
    44 	v_Cancel_Processed CHAR(1);
    45 	v_nameBankstatement VARCHAR2 (60);
    45 	v_nameBankstatement VARCHAR2 (60);
    46 	v_dateBankstatement DATE;
    46 	v_dateBankstatement DATE;
    47 	v_nameCash VARCHAR2 (60);
    47 	v_nameCash VARCHAR2 (60);
    48 	v_dateCash DATE;
    48 	v_dateCash DATE;
    49 	v_Bankstatementline_ID NUMBER;
    49 	v_Bankstatementline_ID VARCHAR2(32);
    50 	v_CashLine_ID NUMBER;
    50 	v_CashLine_ID VARCHAR2(32);
    51 	v_Settlement_Cancel_ID NUMBER;
    51 	v_Settlement_Cancel_ID VARCHAR2(32);
    52 	v_ispaid CHAR(1);
    52 	v_ispaid CHAR(1);
    53 	--Finish added by P.Sarobe
    53 	--Finish added by P.Sarobe
    54   --  Parameter
    54   --  Parameter
    55   TYPE RECORD IS REF CURSOR;
    55   TYPE RECORD IS REF CURSOR;
    56     Cur_Parameter RECORD;
    56     Cur_Parameter RECORD;
    57     Cur_CashlineDebtpayment RECORD;
    57     Cur_CashlineDebtpayment RECORD;
    58     --  Parameter Variables
    58     --  Parameter Variables
    59     v_Processed CHAR(1) ;
    59     v_Processed CHAR(1) ;
    60     v_Posted CHAR(1) ;
    60     v_Posted CHAR(1) ;
    61     v_count NUMBER;
    61     v_count NUMBER;
    62     v_SettlementDocType_ID NUMBER(10) ;
    62     v_SettlementDocType_ID VARCHAR2(32) ;
    63     v_settlementID NUMBER(10) ;
    63     v_settlementID varchar2(32) ;
    64     v_DocumentNo NUMBER(10) ;
    64     v_DocumentNo NUMBER(10) ;
    65     v_line C_CASHLINE.LINE%TYPE;
    65     v_line C_CASHLINE.LINE%TYPE;
    66     -- CashBook
    66     -- CashBook
    67     v_CB_Currency_ID NUMBER(10) ;
    67     v_CB_Currency_ID VARCHAR2(32) ;
    68     v_CB_Date DATE;
    68     v_CB_Date DATE;
    69     v_AD_Org_ID NUMBER;
    69     v_AD_Org_ID VARCHAR2(32);
    70     v_AD_Client_ID NUMBER;
    70     v_AD_Client_ID VARCHAR2(32);
    71     v_C_Settlement_Id NUMBER;
    71     v_C_Settlement_ID VARCHAR2(32);
    72     v_C_CashBook_ID NUMBER(10) ;
    72     v_C_CashBook_ID VARCHAR2(32) ;
    73     FINISH_PROCESS BOOLEAN:=false;
    73     FINISH_PROCESS BOOLEAN:=false;
    74   BEGIN
    74   BEGIN
    75     --  Update AD_PInstance
    75     --  Update AD_PInstance
    76     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
    76     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
    77     v_ResultStr:='PInstanceNotFound';
    77     v_ResultStr:='PInstanceNotFound';
   126         RAISE_APPLICATION_ERROR(-20000, '@CashDocumentPosted@') ;
   126         RAISE_APPLICATION_ERROR(-20000, '@CashDocumentPosted@') ;
   127       END IF;
   127       END IF;
   128     END IF;--FINISH_PROCESS
   128     END IF;--FINISH_PROCESS
   129     IF(NOT FINISH_PROCESS) THEN
   129     IF(NOT FINISH_PROCESS) THEN
   130       DECLARE
   130       DECLARE
   131         v_Settlement_Cancel NUMBER(10):=NULL;
   131         v_Settlement_Cancel VARCHAR2(32):=NULL;
   132         CurDebtPaymentOrder RECORD;
   132         CurDebtPaymentOrder RECORD;
   133       BEGIN
   133       BEGIN
   134         /*
   134         /*
   135         *  Reversing process
   135         *  Reversing process
   136         */
   136         */
   160             WHERE C_CASH_ID=v_Record_ID
   160             WHERE C_CASH_ID=v_Record_ID
   161               AND CashType IN('O', 'P'));--To be fixed. Cash type ='O' is deprecated. Added by P.Sarobe
   161               AND CashType IN('O', 'P'));--To be fixed. Cash type ='O' is deprecated. Added by P.Sarobe
   162 
   162 
   163           IF(v_Settlement_Cancel IS NOT NULL) THEN --This is the generated settlement (it only can be one)
   163           IF(v_Settlement_Cancel IS NOT NULL) THEN --This is the generated settlement (it only can be one)
   164            DELETE FROM FACT_ACCT
   164            DELETE FROM FACT_ACCT
   165             WHERE AD_TABLE_ID = 800019
   165             WHERE AD_TABLE_ID = '800019'
   166             AND RECORD_ID = v_Settlement_Cancel;
   166             AND RECORD_ID = v_Settlement_Cancel;
   167 
   167 
   168       UPDATE C_Settlement set posted='N' where c_Settlement_ID= v_Settlement_Cancel;
   168       UPDATE C_Settlement set posted='N' where c_Settlement_ID= v_Settlement_Cancel;
   169 
   169 
   170             C_SETTLEMENT_POST(NULL, v_Settlement_Cancel) ;
   170             C_SETTLEMENT_POST(NULL, v_Settlement_Cancel) ;
   417       /**
   417       /**
   418       *  Generate C_debt_payment for cashline with order type
   418       *  Generate C_debt_payment for cashline with order type
   419       */
   419       */
   420       /* Now this goes to c_order_post ALO
   420       /* Now this goes to c_order_post ALO
   421       DECLARE
   421       DECLARE
   422       v_debtPaymentID NUMBER(10);
   422       v_debtPaymentID varchar2(32);
   423       CurCashLinesOrder RECORD;
   423       CurCashLinesOrder RECORD;
   424       BEGIN
   424       BEGIN
   425       FOR CurCashLinesOrder IN (SELECT o.AD_CLIENT_ID, o.AD_ORG_ID, o.ISSOTRX, o.DOCUMENTNO, bp.NAME, o.POREFERENCE, o.C_ORDER_ID, o.C_BPARTNER_ID,
   425       FOR CurCashLinesOrder IN (SELECT o.AD_CLIENT_ID, o.AD_ORG_ID, o.ISSOTRX, o.DOCUMENTNO, bp.NAME, o.POREFERENCE, o.C_ORDER_ID, o.C_BPARTNER_ID,
   426       o.C_CURRENCY_ID, cl.C_CASHLINE_ID, o.PAYMENTRULE, C_Currency_Convert((cl.Amount + cl.WriteOffAmt),
   426       o.C_CURRENCY_ID, cl.C_CASHLINE_ID, o.PAYMENTRULE, C_Currency_Convert((cl.Amount + cl.WriteOffAmt),
   427       cl.C_Currency_ID, o.C_Currency_ID, c.DateAcct, NULL, c.AD_Client_ID, c.AD_Org_ID) AMT,
   427       cl.C_Currency_ID, o.C_Currency_ID, c.DateAcct, NULL, c.AD_Client_ID, c.AD_Org_ID) AMT,
   510       /**
   510       /**
   511       *  Update Balances + De-Activate + Conciliate Debt_Payments
   511       *  Update Balances + De-Activate + Conciliate Debt_Payments
   512       */
   512       */
   513       DECLARE
   513       DECLARE
   514         v_Total NUMBER:=0;
   514         v_Total NUMBER:=0;
   515         v_Currency_ID NUMBER(10):=NULL;
   515         v_Currency_ID VARCHAR2(32):=NULL;
   516         -- Lines
   516         -- Lines
   517         Cur_Lines RECORD;
   517         Cur_Lines RECORD;
   518       BEGIN
   518       BEGIN
   519         -- Calculate Tital
   519         -- Calculate Tital
   520         FOR Cur_Lines IN
   520         FOR Cur_Lines IN