ALIAS HELP

VARIAVEL sPrtLineLen = 82
VARIAVEL Z_DE = DATE()
VARIAVEL Z_ATE =  DATE()
VARIAVEL sFgDebugAlert:=.t.
VARIAVEL LQD_ES:=0
VARIAVEL LQD_CH:=0
VARIAVEL LQD_CT:=0
VARIAVEL LQD_BC:=0
VARIAVEL zCmdsDurante:=''

VARIAVEL #TEXTO_FONTE
   Private zValFp, zValEs, zValCh, zValCt, zValCv, zValCa, zValOo, zTotES:=0, zTotCH:=0, zTotCT:=0, zTotCV:=0, zTotCA:=0, zTotFP:=0, zTotVenda:=0, zTotLqd:=0
   if .not. QuickDialog("Lst_Emistot", "Parametros", {{"Data Inicial:", "@z_De", @z_de, "99.99.9999", "", ""},{"Data Final..:", "@z_Ate", @z_Ate, "99.99.9999", "", ""} })
      Return
   endif

   OLST:lOutputPDF := .t.
      
   oLst:lOutputXML := .f.
   OLST:lOutputXLS := .f.
      
   OLST:lOutputFr3 := .f.
    
   Abra('0NOIDX',r_siga,'sccrcli','sccrcli')
   Abra('0NOIDX', r_siga, 'sccrdup', 'sccrdup')
   
   oLst:Cab1( "QUITACOES DE CLIENTES ENTRE "+DTOC(Z_DE)+" E "+DTOC(Z_ATE) )

   oLst:AddCab( '_LINHA_FINA_' )
   oLst:AddCab( '_CABCOLS_' )       
   oLst:AddCab( '_LINHA_GROSSA_' )

   oLst:AddCol('Controle;Cr_num_ped;C;@S10;10;;')
   oLst:AddCol('DataPg;cr_DATA;D;99.99.9999;8;;')
   oLst:AddCol('Hora;cr_hora;C;99:99;5;;')
   oLst:AddCol('CodCli;CR_COD_CLI;N;999999;6;;')
   oLst:AddCol('Cliente;(SCCRCLI->(DbGoto(SccrDup->CR_COD_CLI),CR_NOME));P;@S35;35;;')
   oLst:AddCol('Valor_Lqd;CR_VAL_LQD;D;@E 999,999.99;10;;')
   oLst:AddCol('Controle;cr_obs;C;@S15;15;;')
   oLst:AddCol('Cx;si_caixa;N;99;2;;')
   oLst:AddCol('Fech;si_NumFech;N;999999;6;;')
   oLst:AddCol('Usuario;cr_usuario;C;@S10;10;;')

   // D[CR_NUM_PED][cr_tip_dup] [STRZERO(CR_COD_CLI,6)] [SCCRCLI->CR_NOME @S20] [Z_vALORIG @e 999,999.99] [CR_VAL_LQD @e 999,999.99] [CR_USUARIO] [CR_HORA] 

   BLOCO_TXT zCmdsDurante
      LQD_ES  := LQD_ES + IF(CR_TIP_DUP="ES", CR_VAL_LQD,0) 
      LQD_CH  := LQD_CH + IF(CR_tip_dup="CH", CR_VAL_LQD,0) 
      LQD_CT  := LQD_CT + IF(cr_tip_dup="CT", CR_VAL_LQD,0) 
      LQD_BC  := LQD_BC + IF(cr_tip_dup="BC", CR_VAL_LQD,0) 
      zTotLqd := zTotLqd + CR_VAL_LQD
   FIM_BLOCO_TXT

   oLst:AddRodape( '_LINHA_FINA_', "", {|| "Pagina "+Str(++pag,4)+" / ####"} )

   oLst:DbEval(zCmdsDurante,{||CR_DT_LQD>=Z_DE.AND.CR_DT_LQD<=Z_ATE.AND.CR_VAL_LQD>0.AND.(left(cr_num_ped,2)="CX".or.right(cr_num_ped,2)="CX")})
   
   SccrDup->(DbCloseArea())
   sccrcli->(DbCloseArea())

   Abra ('0NOIDX', r_siga, 'sccrdup', 'sccrdup', 'scrid_nd', 'cr_num_ped')
   Abra ('0NOIDX', r_siga, sf_fat, 'sf_fatnf', sf_fat_d, 'fdataemi')
   if DbSeek(Z_DE, .t.)
      Do While .not. eof() .and. fdataemi>=Z_DE.AND.fdataemi<=Z_ATE
         if .not. deleted() .and. fg_fat<>"C" .and. fg_lib<>"C" .and. fval>0 .and. fdataemi>=Z_DE.AND.fdataemi<=Z_ATE
            (zValFp:=fsubsidio, zValCh:=0, zValCt:=0, zValCa:=0, zValCv:=0, zValEs:=0, zValOo:=0)
            DesmembraFormasPagVda(Fval, @ZvalES, @ZValCH, @ZValCT, @ZvalCV, @ZvalCA, @ZvalOO)
            zValCv := if( ZvalCV-zValFp>=0, ZvalCV-zValFp, 0)
            zTotES += zValES
            zTotCH += zValCH
            zTotCT += zValCT
            zTotCV += zValCV
            zTotCA += zValCA
            zTotFP += zValFP
         endif
         DbSkip()
      EndDo
   endif
   sf_fatnf->(DbCloseArea())
   sccrdup->(DbCloseArea())
   // debugalert('4 ')  
   
   zTotVenda:=zTotES + zTotCH + zTotCT + zTotCV + zTotFP + zTotCA

   oLst:PrtD('','')
   oLst:PrtD('', 'LIQUIDACOES em Especie......:', transform(LQD_ES, '@E 99,999,999.99'))
   oLst:PrtD('', 'LIQUIDACOES em Cheque.......:', transform(LQD_CH, '@E 99,999,999.99'))
   oLst:PrtD('', 'LIQUIDACOES em Cartao.......:', transform(LQD_CT, '@E 99,999,999.99'))
   oLst:PrtD('', 'LIQUIDACOES em Banco........:', transform(LQD_BC, '@E 99,999,999.99'))
   oLst:PrtD('')
   oLst:PrtD('', 'TOTAL DAS LIQUIDACOES.......:', transform(zTotLqd,'@E 999,999,999.99'))
   oLst:PrtD('', 'TOTAL DAS VENDAS EM DINHEIRO:', transform(zTotES,'@E 999,999,999.99'))
   oLst:PrtD('')
   oLst:PrtD('', 'TOTAL LIQUIDACOES + DINHEIRO:', transform(zTotLqd+zTotES,'@E 999,999,999.99'))
   oLst:PrtD('')
   oLst:PrtD('')

   // debugalert('5 ')  
   oLst:PrtD('Total Vendas em Especie........:', transform(zTotES, '@E 99,999,999.99'))
   oLst:PrtD('Total Vendas em Cheque.........:', transform(zTotCH, '@E 99,999,999.99'))
   oLst:PrtD('Total Vendas em Cartao.........:', transform(zTotCT, '@E 99,999,999.99'))
   oLst:PrtD('Total Vendas em Convenio.......:', transform(zTotCV, '@E 99,999,999.99'))
   oLst:PrtD('Total Vendas em Crediario......:', transform(zTotCA, '@E 99,999,999.99'))
   oLst:PrtD('                                ', '--------------')
   oLst:PrtD('TOTAL DAS VENDAS...............:', transform(zTotVenda,  '@E 999,999,999.99'))
   oLst:PrtD('                                ', '')
   oLst:PrtD('TOTAL DAS VENDAS + LIQUIDACOES.:', transform(zTotLqd+zTotVenda,'@E 999,999,999.99') )
   
   // debugalert('4 ')  
   oLst:Run()
   oLst:End()

   // debugalert('5 ')  
   DbSelectArea('help')
#FIM_TEXTO_FONTE

COMANDO ANTES DBGOBOTTOM()