|
Question : Need to create an AR Aging Query
|
|
I have a table that records all the payments made by customers and another table that has billing details of all the bills created for the customers. (new bills added every month for the customers) I need to create an aging query to show outstanding balances in "buckets" like current, > 30 days, > 60 days, >90 days and all over 120 days. The basic theory as I think should be is to "Find out the sum of all payments made, and adjust the payments on FIFO basis against the various bills & find the outstanding in various buckets."
Problem: What's the best way to accomplish this? I've tried creating various types of queries, and can't get any of them to work. Someone suggested me to use a combination of partition function & crosstab query, but I was unable to implement them to get a workable solution. I would like to view the resultant query in the format CustId, CustName, Dues in Bucket(Current, >30, >60, >90, >120), TotalDues
Once I get the data in this format I will be using it for further analysis. Any suggestions would be greatly appreciated along with the appropriate syntax/sql to accomplish the task. I'm sure this is simple for the experts here, but I can't seem to get a handle on a proper approach.
Structure of Payments Table [Revenue Master] CustId [BAN Number] BillId[Invoice Number] Amount [Payments] PmtDate [Date of Collection]
Structure of Bill Table [Billing Master] CustId [BAN Number] BillId [Invoice Number] Amount[Monthly Due] BillDt [Invoice Date] BillDueDt[Due Date]
Names in the [] brackets denote the actual table/field names. I have not included the structure of the Customer table here but a truncated version is present in the sample DB.
A sample stripped off database with some records is posted on the URL http://www.geocities.com/neeraj_chow/Sample_Age_DB.mdb
Any help/guidance to resolve the problem will be highly appreciated.
|
|
Answer : Need to create an AR Aging Query
|
|
Modified SQL view for Query1 ~~~~~~~~~~~~~~~~~~~
SELECT [Billing Master].[Invoice Number], [Billing Master].[BAN Number], [Billing Master].[Invoice Date], [Billing Master].[Due Date], IIf(IsNull([Payments]),0,[Payments]) AS Pymts, [Revenue Master].[Date of Collection], [Billing Master].[Monthly Due] FROM [Billing Master] LEFT JOIN [Revenue Master] ON [Billing Master].[Invoice Number] = [Revenue Master].[Invoice Number] ORDER BY [Billing Master].[Invoice Number];
***********************
Accordingly Modified SQL View for Query2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT Query1.[Invoice Number], Query1.[BAN Number], Query1.[Invoice Date], Query1.[Due Date], Query1.[Monthly Due], Query1.[Date of Collection], Query1.Pymts, IIf(Now()-[Due Date]<=30,[Monthly Due]-[Pymts],0) AS [0-30 Days], IIf(Now()-[Due Date]>30 And Now()-[Due Date]<=60,[Monthly Due]-[Pymts],0) AS [30-60 Days], IIf(Now()-[Due Date]>60 And Now()-[Due Date]<=90,[Monthly Due]-[Pymts],0) AS [60-90 Days], IIf(Now()-[Due Date]>90 And Now()-[Due Date]<=120,[Monthly Due]-[Pymts],0) AS [90-120 Days], IIf(Now()-[Due Date]>120,[Monthly Due]-[Pymts],0) AS [> 120 Days], IIf([Monthly Due]-[Pymts]>0,"YES","NO") AS InvStat FROM Query1 WHERE (((IIf([Monthly Due]-[Pymts]>0,"YES","NO"))="YES")) ORDER BY Query1.[Invoice Number]; ***************************
This will show the invoices for which no payments has been received for example :
invoice # 280004056371 for Monthly Due $ 36,000.00
if u have any further explanation/problem ... i m waiing to dig further.
Aziz
|
|
|
|