Saturday, 24 January 2015

Query for Total On Account Receipt Amount

Select Nvl(Sum(Ps.Amount_Due_Remaining), 0) Total_Onacct_Receipts
  From Hz_Cust_Accounts_All           Cust_Acct,
       Ar_Payment_Schedules_All       Ps,
       Ar_Receivable_Applications_All Arr,
       Hz_Cust_Acct_Sites_All         Acct_Site,
       Hz_Party_Sites                 Party_Site,
       Hz_Locations                   Loc,
       Hz_Cust_Site_Uses_All          Site_Uses,
       Ar_Cash_Receipts_All           Acr,
       Ar_Cash_Receipt_History_All    Crh,
       Gl_Code_Combinations           Cc
 Where Trunc(Ps.Gl_Date) <= :p_As_Of_Date
   And Ps.Customer_Id = Cust_Acct.Cust_Account_Id
   And Cust_Acct.Account_Number = :p_Account_Number
   And Ps.Customer_Id = Cust_Acct.Cust_Account_Id
   And Acct_Site.Party_Site_Id = Party_Site.Party_Site_Id
   And Loc.Location_Id = Party_Site.Location_Id
   And Ps.Cash_Receipt_Id = Acr.Cash_Receipt_Id
   And Acr.Cash_Receipt_Id = Crh.Cash_Receipt_Id
   And Crh.Account_Code_Combination_Id = Cc.Code_Combination_Id
   And Ps.Trx_Date <= :p_As_Of_Date
   And Ps.Class = 'PMT'
   And Ps.Cash_Receipt_Id = Arr.Cash_Receipt_Id
   And Arr.Status In ('ACC')
   And Ps.Status = 'OP'
   And Site_Uses.Site_Use_Code = 'BILL_TO'
   And Site_Uses.Cust_Acct_Site_Id = Acct_Site.Cust_Acct_Site_Id
   And Nvl(Site_Uses.Status, 'A') = 'A'
   And Cust_Acct.Cust_Account_Id = Acct_Site.Cust_Account_Id
   And Acct_Site.Cust_Acct_Site_Id = Site_Uses.Cust_Acct_Site_Id
   And Ps.Customer_Id = Acct_Site.Cust_Account_Id
   And Ps.Customer_Site_Use_Id = Site_Uses.Site_Use_Id Having
 Nvl(Sum(Arr.Amount_Applied), 0) > 0;

No comments:

Post a Comment

Query to Find Receipt Class and its GL Combinition Query

SELECT ARC.NAME ReceiptClass,        ARC.CREATION_METHOD_CODE Creation_Mehthod,        DECODE (ARC.REMIT_METHOD_CODE,             ...