A/P Cash Discounts Query
I am trying to query the list of all Open AP Invoices which are eligible for Cash Discounts.
Scenario : For Instance in OEC Computers,I have the following Open documents in SAP
DocNum CardCode PostingDate DueDate PaymentTerms
110 V10000 06/18/2010 07/19/2010 2P10Net30 ( Eligible for 2 % discount if paid within 10 days from posting date)
114 V20000 06/18/2010 08/09/2010 2P10Net45 ( Eligible for 2 % discount if paid within 10 days from posting date)
Let us say a user wants to run a check today and would like to know what documents are eligible for cash discounts based on duedate 07/02/10.
I am using the following query but does not seems to be working exactly:
,t0.DocTotal as Amount
,t0.DocDate as PostingDate
,t0.DocDueDate as DueDate
,t1.PymntGroup as PaymentTerms
from OPCH t0 inner join OCTG t1 on t0.GroupNum=t1.GroupNum
inner join CDC1 t2 on t1.DiscCode=t2.CdcCode
where T0.DocDate>= '[%0]' AND T0.DocDueDate<= '[%1]'+DATEADD(DAY,10,t0.DocDate) and t0.DocStatus='O'
Any help would be appreciated.