Hi All,
I have one query which gives the TDS values including AP credit memo. i have 2 problems in this query.
1. I raised some AP invoices in OCTOBER month but against that AP Invoices i raised AP Credit memos in November month. Now if i select the period for November month i.e, 01/11/14 to 30/11/14, the report is showing all the AP invoices and as well as the credit memos which are raised against that AP invoices in November. But it is not showing the credit memos which are raised in NOVEMBER which base documents (AP Invoice) were raised in OCTOBER.
But i want all the AP invoices and AP Credit memos in the particular period to calculate TDS.
2. This report is showing Line item wise. if document contains more than 1 line item, it is showing no. of line items wise (same values multiple times).
what condition i should give to get my exact requirement?
Query:
SELECT T1.[DocDate], T1.[DocNum], T1.[CardName] as 'Vendor Name', T1.[Address], T3.[TaxId0] as 'PAN No', T6.[Descr] as 'Type', T1.[NumAtCard] as 'Vendor Ref No', ISNULL((SELECT SUM(Z0.TaxSum) FROM PCH4 Z0 WHERE Z0.DocEntry = T1.DocEntry AND Z0.staType IN(5,6,-10)),0) as 'Service Tax Amt',T0.[TdsRate], T0.[TaxbleAmnt], T0.[WTAmnt],T0.[WTAmnt]+T0.[TaxbleAmnt] as Total, T2.[AcctName], T4.[WTName],T4.OffclCode,T5.location, T8.[DocNum] as 'AP CreditMemo Num', T8.[DocDate] 'AP CreditMemo DocDate', T8.[CardName] as 'Vendor Name', T8.[BaseAmnt] 'Taxble Amnt', T8.[WTApplied] as 'WT Amount', (T8.BaseAmnt + T8.WTApplied) as 'Total'
FROM PCH5 T0
INNER JOIN OPCH T1 ON T0.AbsEntry = T1.DocEntry
INNER JOIN OACT T2 ON T0.TDSACC = T2.AcctCode
INNER JOIN PCH12 T3 ON T1.DocEntry = T3.DocEntry
INNER JOIN OWHT T4 ON T0.WTCode = T4.WTCode
INNER JOIN OLCT T5 ON T4.Location=T5.Code
INNER JOIN ONOA T6 ON T6.AbsId = T4.Assessee
LEFT JOIN RPC1 T7 on T7.[BaseEntry] = T1.DocEntry
LEFT JOIN ORPC T8 ON T7.DocEntry = T8.DocEntry
WHERE T1.[DocDate] BETWEEN [%0] AND [%1]
ORDER BY 'DocDate'
Thanks & Regards,
Ravi.