Buenas tardes, hice un query que me trae los pagos recibidos en un mes con sus respectivas facturas, datos generales,etc. Sin embargo no considera los pagos a cuenta ¿cómo lo puedo resolver?.
SELECT distinct T3.[DeposDate] as "FECHA PAGO", T6.[SeriesName] as "SERIE", T3.[Memo] as "COMENTARIOS", T3.[DeposNum] as "N° DOCUMENTO", T3.[TransAbs] as "N° TRANS.", T5.[DocNum] as "N° FACTURA", T1.[CardName] as "NOMBRE DEL CLIENTE", T7.[LicTradNum] as "RFC",T1.[DocNum] as "PR", T5.[DocDate] as "FECHA FACTURA",T5.[U_EDOCNUM] as "UUID", T8.[TaxCode] as "TASA IVA", T5.[DocRate] as "TC FACTURA", T1.[DocRate] as "TC COBRO",(T4.[SumApplied]/T5.[DocRate]) as "IMPORTE COBRADO EN DLLS",T4.[SumApplied] as "IMPORTE FACT EN MN",(T1.[DocRate]*(T4.[SumApplied]/T5.[DocRate])) as "IMPORTE COBRO EN MN"
FROM ORCT T1
INNER JOIN OCHH T2 ON T1.[DocEntry] = T2.[RcptNum]
INNER JOIN ODPS T3 ON T2.[DpstAbs] = T3.[DeposId]
LEFT OUTER JOIN NNM1 T6 ON T1.SERIES = T6.SERIES
LEFT OUTER JOIN RCT2 T4 ON T1.DocEntry = T4.DocNum
LEFT OUTER JOIN OINV T5 ON T4.DocTRANSID = T5.TRANSID
LEFT OUTER JOIN OCRD T7 ON T1.CardName = T7.CardName
INNER JOIN INV1 T8 ON T8.[DocEntry]=T5.[DocEntry]
WHERE T3.[DeposDate] BETWEEN [%0] AND [%1]
AND T3.[BanckAcct] =[%2]
Les agradezco desde ahora su apoyo.