on 07-22-2011 2:33 AM
Hi Experts,
First of all, thanks for Rahul and Gordon for help this query.
About Below query, I can see all today's invoice with payment details, however, there are missing incoming payments which invoice didn't made today. I might need another query to see today's incoming payments which AR invoice made not today.
Could you guys help this?
Thanks
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
(T0.[DocTotal] - T0.[PaidToDate]) as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T0.DocDate,GetDate()) = 0
UNION ALL
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal * -1 as 'AR Invoice Total',
T0.PaidToDate * -1 as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM ORIN T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T0.DocDate,GetDate()) = 0
ORDER BY T1.CreditSum, T1.CheckSum, T1.CashSum, T1.TrsfrSum, 'AR Sum'
Hi,
You can replace
WHERE DateDiff(D,T0.DocDate,GetDate()) = 0 with
WHERE DateDiff(D,T1.DocDate,GetDate()) = 0
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen......
Try this........
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
(T0.DocTotal - T0.PaidToDate) as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T0.DocDate,GetDate()) = 0 Or (T0.DocDate>='[%0]' And T0.DocDate<='[%1]')
UNION ALL
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal * -1 as 'AR Invoice Total',
T0.PaidToDate * -1 as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM ORIN T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T0.DocDate,GetDate()) = 0 Or (T0.DocDate>='[%0]' And T0.DocDate<='[%1]')
ORDER BY T1.CreditSum, T1.CheckSum, T1.CashSum, T1.TrsfrSum, 'AR Sum'
When you execute above query you get the Date Range Parameter and you have to put the date and the invoice will appear within that date range which will include all previous and today's invoices......
Hope this will help you.....
Regards,
Rahul
Then simplt remove datediff criteria from where clause and put only Date Range criteria and do not select today's date in To range....
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
(T0.DocTotal - T0.PaidToDate) as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE (T0.DocDate>='[%0]' And T0.DocDate<='[%1]')
UNION ALL
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal * -1 as 'AR Invoice Total',
T0.PaidToDate * -1 as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM ORIN T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE (T0.DocDate>='[%0]' And T0.DocDate<='[%1]')
ORDER BY T1.CreditSum, T1.CheckSum, T1.CashSum, T1.TrsfrSum, 'AR Sum'
Regards,
Rahul
Hi Stephen....
then instead of AR Invoice date you have to define date range criteria as per Receipt Date....
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
(T0.DocTotal - T0.PaidToDate) as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE (T1.DocDate>='[%0]' And T1.DocDate<='[%1]')
UNION ALL
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T0.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal * -1 as 'AR Invoice Total',
T0.PaidToDate * -1 as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM ORIN T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE (T1.DocDate>='[%0]' And T1.DocDate<='[%1]')
ORDER BY T1.CreditSum, T1.CheckSum, T1.CashSum, T1.TrsfrSum, 'AR Sum'
In above query I just replaced the Invoice date Criteria to Receipt date Criteria
Hope this will help you finally :).............
Regards,
Rahul
Really appreciate fast response.
Thanks again to Rahul and Gordon.
Final query is below:
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T1.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal as 'AR Invoice Total',
(T0.DocTotal - T0.PaidToDate) as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM OINV T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T1.DocDate,GetDate()) = 0 AND DateDiff(D,T0.DocDate,GetDate()) > 0
UNION ALL
SELECT
T0.DocDate as 'Posting Date',
T0.DocNum as 'AR Invoice Number',
T0.CardName,
T1.DocDate as 'Payment Date',
T1.DocNum as 'Incoming Payment Number ',
T0.DocTotal * -1 as 'AR Invoice Total',
T0.PaidToDate * -1 as 'AR Sum',
T1.TrsfrSum,
T1.CashSum,
T1.CheckSum,
T1.CreditSum,
T2.CheckNum as 'Cheque Number'
FROM ORIN T0
LEFT JOIN ORCT T1 ON T0.ReceiptNum = T1.DocEntry
LEFT JOIN RCT1 T2 ON T1.DocNum = T2.DocNum
Left Join OSLP T3 ON T3.SlpCode= T0.SlpCode
WHERE DateDiff(D,T1.DocDate,GetDate()) = 0 AND DateDiff(D,T0.DocDate,GetDate()) > 0
ORDER BY T1.CreditSum, T1.CheckSum, T1.CashSum, T1.TrsfrSum, 'AR Sum'
User | Count |
---|---|
100 | |
11 | |
10 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.