src-db/database/model/functions/C_INVOICE_POST.xml
changeset 25787 1e8206167887
parent 23871 512af3124e23
child 25799 c28206c4abc9
equal deleted inserted replaced
25786:e349db370752 25787:1e8206167887
   171   v_bpartner_name c_bpartner.name%TYPE;
   171   v_bpartner_name c_bpartner.name%TYPE;
   172   v_productname m_product.name%TYPE;
   172   v_productname m_product.name%TYPE;
   173 
   173 
   174   v_iscashvat C_Invoice.IsCashVat%TYPE;
   174   v_iscashvat C_Invoice.IsCashVat%TYPE;
   175   v_invoiceline_qtysum NUMBER;
   175   v_invoiceline_qtysum NUMBER;
   176     
   176   v_PriceList_ID varchar2(32);
       
   177    
   177 BEGIN
   178 BEGIN
   178   IF (p_PInstance_ID IS NOT NULL) THEN
   179   IF (p_PInstance_ID IS NOT NULL) THEN
   179     --  Update AD_PInstance
   180     --  Update AD_PInstance
   180     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
   181     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
   181     v_ResultStr:='PInstanceNotFound';
   182     v_ResultStr:='PInstanceNotFound';
   247   END IF;
   248   END IF;
   248   /**
   249   /**
   249    * Read Invoice
   250    * Read Invoice
   250    */
   251    */
   251   v_ResultStr:='ReadingInvoice';
   252   v_ResultStr:='ReadingInvoice';
   252   SELECT i.Processing, i.Processed, i.DocAction, i.DocStatus,
   253    SELECT i.Processing, i.Processed, i.DocAction, i.DocStatus,
   253       i.C_DocType_ID, i.C_DocTypeTarget_ID,
   254       i.C_DocType_ID, i.C_DocTypeTarget_ID,
   254       i.PaymentRule, i.C_PaymentTerm_ID, i.DateAcct, i.DateInvoiced,
   255       i.PaymentRule, i.C_PaymentTerm_ID, i.DateAcct, i.DateInvoiced,
   255       i.AD_Client_ID, i.AD_Org_ID, i.UpdatedBy, i.DocumentNo,
   256       i.AD_Client_ID, i.AD_Org_ID, i.UpdatedBy, i.DocumentNo,
   256       i.C_Order_ID, i.IsSOTrx, i.C_BPartner_ID, i.AD_User_ID,
   257       i.C_Order_ID, i.IsSOTrx, i.C_BPartner_ID, i.AD_User_ID,
   257       i.C_Currency_ID, i.POReference, i.Posted,
   258       i.C_Currency_ID, i.POReference, i.Posted,
   258       i.c_Project_Id, i.C_WithHolding_ID, dt.isreturn,
   259       i.c_Project_Id, i.C_WithHolding_ID, i.IsCashVat, i.M_PriceList_ID
   259       pl.istaxincluded, i.IsCashVat
       
   260   INTO v_Processing, v_Processed, v_DocAction, v_DocStatus,
   260   INTO v_Processing, v_Processed, v_DocAction, v_DocStatus,
   261       v_DocType_ID, v_DocTypeTarget_ID,
   261       v_DocType_ID, v_DocTypeTarget_ID,
   262       v_PaymentRule, v_PaymentTerm, v_DateAcct, v_DateInvoiced,
   262       v_PaymentRule, v_PaymentTerm, v_DateAcct, v_DateInvoiced,
   263       v_Client_ID, v_Org_ID, v_UpdatedBy, v_DocumentNo,
   263       v_Client_ID, v_Org_ID, v_UpdatedBy, v_DocumentNo,
   264       v_Order_ID, v_IsSOTrx, v_BPartner_ID, v_BPartner_User_ID,
   264       v_Order_ID, v_IsSOTrx, v_BPartner_ID, v_BPartner_User_ID,
   265       v_Currency_ID, v_POReference, v_Posted,
   265       v_Currency_ID, v_POReference, v_Posted,
   266       v_C_Project_Id, cWithHoldID, v_isreturndoctype,
   266       v_C_Project_Id, cWithHoldID, v_iscashvat, v_PriceList_ID
   267       v_istaxincluded, v_iscashvat
       
   268   FROM C_INVOICE i
   267   FROM C_INVOICE i
   269         JOIN c_doctype dt ON i.c_doctypetarget_id = dt.c_doctype_id
       
   270         JOIN m_pricelist pl ON i.m_pricelist_id = pl.m_pricelist_id
       
   271   WHERE i.C_Invoice_ID=v_Record_ID FOR UPDATE;
   268   WHERE i.C_Invoice_ID=v_Record_ID FOR UPDATE;
       
   269 
       
   270   SELECT dt.isreturn  
       
   271   INTO  v_isreturndoctype    
       
   272   FROM  c_doctype dt  
       
   273   WHERE dt.c_doctype_id= v_DocTypeTarget_ID;
       
   274 
       
   275   SELECT pl.istaxincluded
       
   276   INTO   v_istaxincluded
       
   277   FROM   m_pricelist pl 
       
   278   WHERE pl.m_pricelist_id= v_PriceList_ID;
       
   279   
   272   DBMS_OUTPUT.PUT_LINE('Invoice_ID=' || v_Record_ID ||', DocAction=' || v_DocAction || ', DocStatus=' || v_DocStatus || ', DocType_ID=' || v_DocType_ID || ', DocTypeTarget_ID=' || v_DocTypeTarget_ID) ;
   280   DBMS_OUTPUT.PUT_LINE('Invoice_ID=' || v_Record_ID ||', DocAction=' || v_DocAction || ', DocStatus=' || v_DocStatus || ', DocType_ID=' || v_DocType_ID || ', DocTypeTarget_ID=' || v_DocTypeTarget_ID) ;
   273   /**
   281   /**
   274    * Invoice Voided, Closed, or Reversed - No Action
   282    * Invoice Voided, Closed, or Reversed - No Action
   275    */
   283    */
   276   IF (v_User_ID IS NOT NULL) THEN
   284   IF (v_User_ID IS NOT NULL) THEN