;** Rm_0110C *******************************************************************
;*  Relacao de Cheques Descontados                                                *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 26/04/2018 por Anivel Augusto Rodrigues
;Ultima Alteracao:   /  /     por .

;*******************************************************************************
;* Rotina p/ Selecionar e Ordernar Registros                                   *
;*******************************************************************************
Proc SelecionaRM_0110C()
ClearAll

If IsTable("\\Sistemas\\Ctacor\\"+Dir_Trab+"MovCont")
  Then 
       {Ask} TypeIn "\\Sistemas\\Ctacor\\"+Dir_Trab+"MovCont" Enter Check
       Moveto [Codigo da Empresa     ] TypeIn "~VSDGEMPRESA2.."
       Moveto [Codigo da Conta       ] TypeIn "~VSDGCONTA.."
       Moveto [Codigo do EmitDest    ] TypeIn "~VSDGDESTINAT.."
       Moveto [Tipo Movimento        ] TypeIn "S"
       Moveto [Tipo da Conta         ] TypeIn "C"
       Moveto [Numero do Cheque      ] TypeIn "~VSDGCHEQUE.."
       Moveto [Serie do Cheque       ] TypeIn "~VSDGSERIE.."
       Moveto [Tipo de Operacao      ] TypeIn "05 or 08"
       Moveto [Data Cheque Descontado] TypeIn "not blank"
       Do_It!
       ClearAll

       {Ask} {Answer} Check
       Moveto [Data Cheque Descontado] TypeIn ">=~VSDGDTINI,<=~VSDGDTFIM"
       Do_It!
       ClearAll
       
       {Ask} {Answer} TypeIn "Fast Delete"
       Moveto [Tipo de Operacao  ] TypeIn "08"
       Moveto [Tipo do Lancamento] TypeIn "O or P"
       Do_It!
       ClearAll
       
EndIf
EndProc

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
Proc ProcessaRM_0110C()

Empty("\\Base\\Sistemas\\Ctacor\\RM_0120")
Tabela = Cria_Temp(PrivDir())

Monta_Dir_Trab(VSDGDTINI,VSDGDTFIM)
While Novo_Dir_Trab()
  If IsTable("Answer")     Then Delete "Answer" EndIf
  SelecionaRM_0110C()
  If Not IsTable("Answer") Then Loop EndIf
  If IsTable(Tabela)
     Then Add "Answer" Tabela
     Else Rename "Answer" Tabela
  EndIf
EndWhile

If IsEmpty(Tabela)
   Then 
        MENSAGEM("N„o existem registros a processar")
   else
        ;***** Ajusta Dados ************************************
        If VSDGEMPRESA="0000"
           Then {Ask} TypeIn Tabela Enter TypeIn "Fast"
                Moveto [Codigo da Empresa      ] TypeIn "changeto 0000"
                Moveto [Nome Fantasia Empresa  ] TypeIn "changeto TOTALIZA EMPRESAS"
                Do_It!
                ClearAll
        EndIf
   
        CopyReport "\\Base\\Sistemas\\Ctacor\\Rm_0120" "9" Tabela "R"
        IMPRIREL(Tabela,"R")
EndIf

Delete Tabela

EndProc

;-- Chamada principal ----------------------------------------------------------
ProcessaRM_0110C()

Release Vars Tabela
Release Procs ProcessaRM_0110C, SelecionaRM_0110C
