on 01-23-2012 6:32 PM
Estimados Expertos,
Estoy tratando de generar un reporte para mi cliente que le muestre todas las facturas que se crearon en una fecha determinada, mostrando el num. de la factura, importe, vendedor, entre otros datos, pero tambien quiero que muestre la informacion de pago si es que existe y cómo se pagó, es decir, efectivo, cheque, tarjeta, etc. No tengo experiencia en SQL, pero con la ayuda del Generador de Consultas de SBO creo que la estructura del query es más o menos como sigue. Apreciaría mucho si alguien me ayuda a depurarlo o corregirlo para que me dé la informacion que estoy buscando.
SELECT T0.[DocNum] Factura, T0.[DocStatus] Estatus, T0.[DocDate] Fecha, T0.[CardCode] Cliente, T0.[CardName] Nombre, T0.[DocCur] Moneda, T0.[DocTotal] 'Total Factura', T0.[PaidToDate] 'Total Pagado', T1.[SlpName] Vendedor, T2.[PymntGroup] 'Cond. Pago', T0.[DocTotalSy] 'Total USD', T3.[DocNum] 'No.Doc. Pago', T3.[CashSum] Efectivo, T3.[CreditSum] 'T.Crédito', T3.[CheckSum] Cheque, T3.[TrsfrSum] Transf, T3.[DocTotal], 'Total Pago', T3.[DocDate] 'Fecha Pago' FROM OINV T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum INNER JOIN ORCT T3 ON T0.DocNum = T3.DocNum INNER JOIN NNM1 T4 ON T3.Series = T4.Series INNER JOIN RCT2 T5 ON T3.DocEntry = T5.DocNum WHERE T0.[DocDate] = AND T3.[Canceled] = 'N' ORDER BY T0.DocNum
Por ahora como está el Query no me saca información y me dice "No se ha obtenido ningun dato con los criterios de selección utilizados"
Muchas gracias!
Rogelio
Estimados Expertos
Soy Cesar y estoy aprendiendo a crear query he estado trabajando en una query para saber las facturas de clientes pagadas, en el foro estuve leyendo la problematica y es justo lo que andaba buscando, pero hay un detalle que no he podido resolver, explico:
La query que entregaron como solución entrega muy bien los resultados siempre y cuando y pago se realice después de creada la factura, sin embargo hay clientes que pagan por anticipado sin estar facturado, como la perosna de contabilidad debe registrar el pago ésta paga a cuenta, es decir, en ves de seleccionar Cliente o proveedor, se selecciona la opción Cuenta e ingresa el importe recibido, después cuando ya se crea la factura sólo reconcilia los montos.
Entonces, la pregunta es ¿cómo reflejo ese pago?.
Espero me hayan entendido.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check this modification to your query :
SELECT distinct T0.DocNum 'Factura', T0.DocStatus 'Estatus',
T0.DocDate 'Fecha',
T0.CardCode 'Cliente', T0.CardName 'Nombre', T0.DocCur 'Moneda',
T0.DocTotal 'Total Factura', T0.PaidToDate 'Total Pagado',
T1.SlpName 'Vendedor', T2.PymntGroup 'Cond. Pago',
T0.DocTotalSy 'Total USD', T3.DocNum 'No.Doc. Pago',
T3.CashSum 'Efectivo', T3.CreditSum 'T.Crédito',
T3.CheckSum 'Cheque', T3.TrsfrSum 'Transf', T3.DocTotal, 'Total Pago',
T3.DocDate 'Fecha Pago'
FROM OINV T0
INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum
INNER JOIN ORCT T3 ON T0.DocNum = T3.DocNum
INNER JOIN NNM1 T4 ON T3.Series = T4.Series
INNER JOIN RCT2 T5 ON T3.DocEntry = T5.DocNum
WHERE T0.DocDate = '[%1]'
AND T3.Canceled = 'N'
ORDER BY T0.DocNum
You can let know any other fields you require and the same can be added further.
Kind Regards,
Jitin
SAP Business One Forum Team
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jitin, thank you for your reply, though I think something is still not working right as I get no data in return. The message is "No data can be obtained with the selected criteria" or something like that ("No se ha obtenido ningun dato con los criterios de seleccion utilizados") no matter what date I select which I am 100% sure there are invoices and payments in that date. Can you help?
Thanks,
Rogelio
Hi,
Check this whether the same works or not :
SELECT distinct T0.DocNum 'Factura', T0.DocStatus 'Estatus',
T0.DocDate 'Fecha',
T0.CardCode 'Cliente', T0.CardName 'Nombre', T0.DocCur 'Moneda',
T0.DocTotal 'Total Factura', T0.PaidToDate 'Total Pagado',
T1.SlpName 'Vendedor', T2.PymntGroup 'Cond. Pago',
T0.DocTotalSy 'Total USD', T3.DocNum 'No.Doc. Pago',
T3.CashSum 'Efectivo', T3.CreditSum 'T.Crédito',
T3.CheckSum 'Cheque', T3.TrsfrSum 'Transf', T3.DocTotal, 'Total Pago',
T3.DocDate 'Fecha Pago'
FROM OINV T0
INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum
INNER JOIN ORCT T3 ON T0.DocNum = T3.DocNum
INNER JOIN NNM1 T4 ON T3.Series = T4.Series
INNER JOIN RCT2 T5 ON T3.DocEntry = T5.DocNum
WHERE T0.DocDate >= '2011.01.01' and t0.docdate <= '2011.12.31'
AND T3.Canceled = 'N'
ORDER BY T0.DocNum
The date which needs to be entered for the Invoice date.
Kind Regards,
Jitin
SAP Business One Forum Team
Buen día amigos / Good morning friends
Disculpen, no quiero ser maleducado, pero creo que se debería ser más estricto con el español ya que el Foro es SAP Business ONE Foro en Español, espero tomen mi recomendación. / Sorry, I do not want to be rude, but I think it should be stricter with Spanish as the SAP Business Forum ONE Forum is in Spanish, I hope you take my recommendation.
Saludos.
Dios Los Bendiga / God Bless
Traducido por Traductor de Google / Translated by Google Translate
No se si ya repondieron esta pregunta, pero este es el query probado y comprobado, funcionando
SELECT distinct
T0.DocNum 'Factura',
T0.DocStatus 'Estatus',
T0.DocDate 'Fecha',
T0.CardCode 'Cliente',
T0.CardName 'Nombre',
T0.DocCur 'Moneda',
T0.DocTotal 'Total Factura',
T0.PaidToDate 'Total Pagado',
T1.SlpName 'Vendedor',
T2.PymntGroup 'Cond. Pago',
T0.DocTotalSy 'Total USD',
T3.DocNum 'No.Doc. Pago',
T3.CashSum 'Efectivo',
T3.CreditSum 'T.Crédito',
T3.CheckSum 'Cheque',
T3.TrsfrSum 'Transf',
T3.DocTotal, 'Total Pago',
T3.DocDate 'Fecha Pago'
FROM OINV T0
INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum
INNER JOIN ORCT T3 ON T0.[ReceiptNum] = T3.DocNum
INNER JOIN NNM1 T4 ON T3.Series = T4.Series
INNER JOIN RCT2 T5 ON T3.DocEntry = T5.DocNum
WHERE T0.DocDate <= '[%1]'
AND T3.Canceled = 'N'
ORDER BY T0.DocNum
Saludos,
Jesus
Jesús, este mero es el Query. Muchísimas gracias. Solo un detalle, noté que si la factura no está pagada no la incluye en el reporte. Habría forma de que no importa si hay pago o no registrado para esa factura, si se creó en la fecha seleccionada, que aparezca en el reporte, y asi el área de pagos aparecería todo en ceros. Se puede?
De nuevo un millón de gracias por la ayuda.
Rogelio
Hola ojala sea de tu ayuda solo agrega los campos de tipo de pago según los INNER.
Saludos cordiales,
SELECT T0.[CardCode] as 'Codigo', T0.[CardName] as 'Nombre', T0.[DocNum] as 'Factura', 'Plazo' + ' ' + cast(T1.instlmntid as varchar) + ' ' + 'de' + ' ' + CAST(t0.Installmnt as varchar) as 'Plazo', cast(t0.[FolioPref] as varchar) + '-' + cast(T0.[FolioNum] as varchar) as 'Folio', T0.docdate as 'Fecha Creación', t1.[DueDate] as 'Fecha Vencimiento', case when (datediff(day,T1.[DueDate],getdate())< 0) then 0 else datediff(day,T1.[DueDate],getdate()) end as 'Días de Atraso', case when (datediff(day,T1.[DueDate],getdate())< 0) then datediff(day,T1.[DueDate],getdate())*-1 else 0 end as 'Días Para Pago', T0.DocTotal as 'Importe Original', (T1.[InsTotal] - T1.[VatSum]) as 'SubTotal', t1.[VatSum] as 'IVA', t1.[InsTotal] as 'Total', t1.PaidToDate as 'Pagado', t1.[InsTotal] - t1.paidtodate as 'Por Pagar', Case t1.[Status] When 'O' Then 'Abierta' End as 'Status Doc' FROM OPCH T0 inner join PCH6 t1 on t0.docentry = t1.docentry WHERE T0.DocDate >= '[%0]' and t0.DocDate <= '[%1]' and t1.[Status] = 'O' order by T1.instlmntid, t1.[VatSum], T0.docdate
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.