cancel
Showing results for 
Search instead for 
Did you mean: 

Crear un saldo Inicial dentro de un reporte

Former Member
0 Kudos

Buen dia

veran que necesito crear un reporte de estado de cuenta de cliente credito el cual entregamos al cliente en el cual muestre los credito y debito

el cual ya tengo hecho pero el problema es que he intentado poner el saldo inicial y lo he logrado pero no me esta funcionando bien me

gustaria saber si alguno de ustedes lo ha hecho antes  pego mi query acontinuacion para ver si me pueden ayuda:

select OrderBy, DocType, DocDate, DocNum, CardCode, CardName, Debitamount, CreditAmount, comments

from   (

              select        OrderBy = 0, DocType = 'Saldo Anterior', DocDate = null, DocNum = 0, CardCode, CardName, 

                                  Debitamount = sum( Debitamount - CreditAmount ),

                                  CreditAmount = sum( Debitamount - CreditAmount ),

                                  comments = 'Saldo Anterior'

              from      (

                         

            SELECT  OrderBy = 1, DocType = Case when HInvoice.series = '117' then 'Nota Debito' else 'Factura' end , DocDate, DocNum, CardCode, CardName, Debitamount = DocTotal, CreditAmount = 0, Comments

              FROM   OINV HInvoice

              Union all

             

              select OrderBy = 1, DocType = 'Nota Credito', DocDate, DocNum, CardCode, CardName,  Debitamount = 0, CreditAmount = DocTotal, Comments

              from orin

             

           

              UNION ALL

              SELECT  OrderBy = 1, DocType = 'Recibo', DocDate, DocNum, CardCode, CardName, Debitamount = 0, CreditAmount = DocTotal, Comments

              FROM   ORCT

              WHERE       Canceled = 'N' ) EstadoCuenta

              where  

               docdate between {?Fecha Desde} and {?Fecha Hasta} and

              CardCode = '{?CodigoCliente}'

              group by CardCode, CardName

             

             

              union all

             

             

              select    OrderBy, DocType, DocDate, DocNum, CardCode, CardName, Debitamount, CreditAmount, comments

              from      (

              SELECT  OrderBy = 1, DocType  = Case when HInvoice.series = '117' then 'Nota Debito' else 'Factura' end , DocDate, DocNum, CardCode, CardName, Debitamount = DocTotal, CreditAmount = 0, Comments

             

              FROM       OINV HInvoice

             

        

                                                   

             Union all

             

              select OrderBy = 1, DocType = 'Nota Credito', DocDate, DocNum, CardCode, CardName,  Debitamount = 0, CreditAmount = DocTotal, Comments

              from orin

              UNION ALL

              SELECT  OrderBy = 1, DocType = 'Recibo', DocDate, DocNum, CardCode, CardName, Debitamount = 0, CreditAmount = DocTotal, Comments

              FROM   ORCT

              WHERE       Canceled = 'N') EstadoCuenta

              where  

              DocDate between {?Fecha Desde} and {?Fecha Hasta} and

                            CardCode = '{?CodigoCliente}' ) Movimientos

order by OrderBy, DocDate, DocType, DocNum

El reporte de ve asi

Saludos

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

creo que tu query tiene que ir a las contabilizaciones y no a los documentos.

Te recomiendo que tu query sea con las talas ojdt y jdt1