cancel
Showing results for 
Search instead for 
Did you mean: 

Necesito sacar el total de la deuda con proveedores y los dias de vencimien

Former Member
0 Kudos

Necesito sacar el total de la deuda con proveedores y los dias de vencimiento ya intente sacar de una tabla pero me da muchos problemas esto es lo que yo hice

SELECT T0.[CardCode], T0.[CardName], T0.[Comments], T0.[DocTotal], T0.[TaxDate], cast(DATEDIFF(DAY, T0.[TaxDate], GETDATE()) as varchar) + ' Dias vencidos'

FROM OPCH T0 where T0.[DocTotal] > T0.[PaidSum]

necesito ayuda

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Muchas gracias por haber respondido mi duda me ayudaron mucho

Former Member
0 Kudos

Estimado,

En la tabla OPCH solo encontraras las facturas, te faltarian los Asientos manuales y las notas de credito.

Creo que debes sacar la informacion de los asientos de la tabla OJDT y JDT1.

PD: En la version 2007 el folio queda en la tabla OJDT

att,

Manuel Lazcano

Former Member
0 Kudos

bueno pero como saco el saldo esa es mi duda y los dias de vencimiento me podes dar alguna ayudadita extra

Former Member
0 Kudos

Alguien sabe de esto

former_member649942
Active Participant
0 Kudos

VERIFICA ESTOYME COMENTAS PORFAS:

SELECT DISTINCT T0.CardCode AS CodigoCliente, T0.CardName AS NombreCliente, DocNum AS NumFactura, T0.DocDate AS FechaDoc, T0.DocDueDate AS FechaVenc, T1.SlpName AS Vendedor, T2.WhsCode,

'Saldo'= (case when DocCur='$' then (T0.DocTotalFC-T0.PaidFC) else (DocTotal-PaidToDate) end), DocCur as Moneda,

'Por Vencer' = (case when (Doccur='$' and getdate() <= DocDueDate) then (DocTotal-PaidToDate) else (case when getdate() <= DocDueDate and Doccur='$' then (DocTotalFC-PaidFC) else 0 end) end),

'0-30' = (case when (Doccur='$' and DATEDIFF(day, docduedate, getdate())>=0 and DATEDIFF(day, docduedate, getdate())<=30) then (T0.DocTotal-T0.PaidToDate) else (case when DATEDIFF(day, docduedate, getdate())>=0 and DATEDIFF(day, docduedate, getdate())<=30 and Doccur='$' then (DocTotalFC-PaidFC) else 0 end) end),

'31-60' = (case when (DocCur='$' and DATEDIFF(day, docduedate, getdate())>=31 and DATEDIFF(day, docduedate, getdate())<=60) then (T0.DocTotal-T0.PaidToDate) else (case when DATEDIFF(day, docduedate, getdate())>=31 and DATEDIFF(day, docduedate, getdate())<=60 and DocCur='$' then (DocTotalFC-PaidFC) else 0 end) end),

'61-90' = (case when (DocCur='$' and DATEDIFF(day, docduedate, getdate())>=61 and DATEDIFF(day, docduedate, getdate())<=90) then (T0.DocTotal-T0.PaidToDate) else (case when DATEDIFF(day, docduedate, getdate())>=61 and DATEDIFF(day, docduedate, getdate())<=90 and DocCur='$' then (DocTotalFC-PaidFC) else 0 end) end),

'90+' = (case when (DocCur='$' and DATEDIFF(day, docduedate, getdate())>=90) then (T0.DocTotal-T0.PaidToDate) else (case when (DocCur='$' and DATEDIFF(day, docduedate, getdate())>=90) then (T0.DocTotalFC-T0.PaidFC) else 0 end) end)

FROM OPCH T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode INNER JOIN PCH1 T2 ON T0.DocEntry = T2.DocEntry WHERE (T0.DocTotal-T0.PaidToDate>0 or DocTotalFC-PaidFC >0) AND T0.DocDate >= '2008-07-01' AND T0.DocDate <= '2008-09-30'

order by CardCode

Si te marca algun error, puedes contactarme a juliancab(arroba)autopartesrv.com.mx o msn julian_chino(arroba)hotmail.com

Saludos