Hola buenas tardes, compañero
necesito realizar un reporte con las tablas de factura de proveedor, factura de anticipo y pagos efectuados
Pero necesito que igual me de el tipo de pago.
tengo el siguiente código pero no me da mas que puros de tipo proveedor
SELECT
t1.DocNum 'Número de pago '
,case t1.DocType when 'C' then 'Cliente'
when 'S' then 'Proveedor'
when 'A' then 'Cuenta' else null end 'Tipo de pago'
, t1.CardCode 'Codigo de prov'
, t1.CardName 'Nombre de prov'
,T0.DocNum 'Número de fatura'
,fpi.OcrCode 'Departamento'
,fpi.OcrCode2 'Oficina'
, t1.DocDate 'Fecha del contabilización'
, t1.DocDueDate 'Fecha vencimiento'
, t1.TaxDate 'Fecha documento'
, case t1.DocCurr
when 'USD' then t1.TrsfrSumFC
when 'MXP' then t1.TrsfrSum else
t1.TrsfrSumFC end 'Monto del depósito'
, t1.DocCurr 'Moneda del depósito'
,t1.TrsfrSumSy 'Monto del depósito en USD'
,t0.DocDate 'Fecha de factura'
, Case t0.DocCur when 'USD' then t0.DocTotalFC-t0.VatSumFC
when 'MXP' then t0.DocTotal-t0.VatSum
else t0.DocTotalFC-t0.VatSumFC end 'Subtotal de factura'
, t0.DocCur 'Moneda de factura'
, Case t0.DocCur when 'USD' then t0.DocTotal-t0.VatSum
when 'MXP' then t0.DocTotal-t0.VatSum
else t0.DocTotal-t0.VatSum end 'Subtotal de factura en MXP'
, Case t0.DocCur when 'USD' then t0.VatSumFC
when 'MXP' then t0.VatSum
else t0.VatSumFC end 'Impuesto'
, Case t0.DocCur when 'USD' then t0.VatSum
when 'MXP' then t0.VatSum
else t0.VatSum end 'Impuesto en MXP'
, Case t0.DocCur when 'USD' then t0.DocTotalFC
when 'MXP' then t0.DocTotal
else t0.DocTotalFC end 'Total Fact'
, t0.Doctotal 'Total de Fact en MXP'
, t0.DocTotalSy 'Total de Fact en USD'
,t0.U_CC_ProjectName 'Nombre del proyecto'
,t0.U_CC_ProjectCode 'Codigo del proyecto'
,t0.U_CC_AGCode 'Acuerdo global'
FROM Odpo T0
inner join dpo1 fpi on t0.DocEntry = fpi.DocEntry
inner JOIN OVPM T1 ON T1.DocEntry = T0.ReceiptNum
where t1.Canceled='N'
group by t1.DocNum,t0.DocNum,T0.DocTotal,t1.Canceled,t1.DocDate,t1.DocCurr,t1.TrsfrSumFC,t1.TrsfrSum,t0.VatSum,t0.VatSumFC
,t0.DocTotalFC,t0.DocTotalSy,t1.TrsfrSumSy,t0.DocCur,t0.DocDate,t0.U_CC_ProjectName,t0.U_CC_ProjectCode,t0.U_CC_AGCode,t1.CardCode,
t1.CardName,t1.DocDate,t1.DocDueDate,t1.TaxDate,fpi.OcrCode,fpi.OcrCode2,t1.DocType
UNION ALL
SELECT
t3.DocNum 'Número de pago '
,case t3.DocType when 'C' then 'Cliente'
when 'S' then 'Proveedor'
when 'A' then 'Cuenta' else null end 'Tipo de pago'
, t3.CardCode 'Codigo de prov'
, t3.CardName 'Nombre de prov'
, t2.DocNum 'Número de fatura'
, fp.OcrCode 'Departamento'
, fp.OcrCode2 'Oficina'
, t3.DocDate 'Fecha del contabilización'
, t3.DocDueDate 'Fecha vencimiento'
, t3.TaxDate 'Fecha documento'
, case t3.DocCurr
when 'USD' then t3.TrsfrSumFC
when 'MXP' then t3.TrsfrSum else
t3.TrsfrSumFC end 'Monto del depósito'
, t3.DocCurr 'Moneda del depósito'
, t3.TrsfrSumSy 'Monto del depósito en USD'
,t2.DocDate 'Fecha de factura'
, Case t2.DocCur when 'USD' then t2.DocTotalFC-t2.VatSumFC
when 'MXP' then t2.DocTotal-t2.VatSum
else t2.DocTotalFC-t2.VatSumFC end 'Subtotal de factura'
, t2.DocCur 'Moneda de factura'
, Case t2.DocCur when 'USD' then t2.DocTotal-t2.VatSum
when 'MXP' then t2.DocTotal-t2.VatSum
else t2.DocTotal-t2.VatSum end 'Subtotal de factura en MXP'
, Case t2.DocCur when 'USD' then t2.VatSumFC
when 'MXP' then t2.VatSum
else t2.VatSumFC end 'Impuesto'
, Case t2.DocCur when 'USD' then t2.VatSum
when 'MXP' then t2.VatSum
else t2.VatSum end 'Impuesto en MXP'
, Case t2.DocCur when 'USD' then t2.DocTotalFC
when 'MXP' then t2.DocTotal
else t2.DocTotalFC end 'Total Fact'
, t2.Doctotal 'Total de Fact en MXP'
, t2.DocTotalSy 'Total de Fact en USD'
, t2.U_CC_ProjectName 'Nombre del proyecto'
, t2.U_CC_ProjectCode 'Codigo del proyecto'
, t2.U_CC_AGCode 'Acuerdo global'
FROM OPCH T2
inner join pch1 fp on t2.DocEntry = fp.DocEntry
inner JOIN OVPM T3 ON T3.DocEntry = T2.ReceiptNum
where t3.Canceled = 'N'
group by t3.DocNum,t2.DocNum,t2.DocTotal,t3.Canceled,t3.DocDate,t3.DocCurr,t3.TrsfrSumFC,t3.TrsfrSum,t2.VatSum,t2.VatSumFC
,t2.DocTotalFC,t2.DocTotalSy,t3.TrsfrSumSy,t2.DocCur,t2.DocDate,t2.Doctotal,t2.U_CC_ProjectName,t2.U_CC_ProjectCode,t2.U_CC_AGCode,
t3.CardCode,t3.CardName, t3.DocDueDate,t3.TaxDate,fp.OcrCode,fp.OcrCode2,t3.DocType