;** Rm_1501A *******************************************************************
;* Resumo de Saida Consignado II                                               *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 25/02/2019 por Anivel Augusto Rodrigues
;Ultima Alteracao: 27/02/2019 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes deduzir descontos nos calculos e no faturaI/pedidoI enova estrutura
;Ultima Alteracao: 16/03/2019 por Anivel Augusto Rodrigues                           
;Motivo Alteracao: Ajustes Numero_Lancamento("Interno","Locked_Down")
;Ultima Alteracao: 02/05/2019 por Anivel Augusto Rodrigues                           
;Motivo Alteracao: Ajustes desconto no item

;*******************************************************************************
;* Rotina p/ Impressao                                                         *
;*******************************************************************************
Proc Rm_1501A_Imprimir()
private qtddiferdescto
 
AGUARDE("Aguarde, processando dados")

Print File ARQIMP ASP1+CI_15CPP+ASP2+"\n"
Print File ARQIMP ASP1+CI_6LPP+ASP2+"\n"
If Not IsAssigned(NOMEMPRESA) Then NOMEMPRESA="" EndIf

Sort Tabela2 On "Codigo da Empresa", "Codigo", "Descricao do Item" To "Answer"
ClearAll
    
View Tabela1
View "Answer"

EMPANT  = "****"
CODCLI  = "****"

pag=0                 
lin=0
Scan
  
  If [Codigo da Empresa]<>EMPANT  Or
     [Codigo           ]<>CODCLI
     Then
          Rm_1501A_TotalItem()
          Rm_1501A_TotalFinanc()

          EMPANT =[Codigo da Empresa]
          CODCLI =[Codigo           ]
          
          Moveto Tabela1
          Moveto [Codigo da Empresa]
          Locate EMPANT, CODCLI
          
          Rm_1501A_Cabecalho()
  EndIf
 
  QTDDIFER=([Saida_Qtd]+[Troca_Qtd])-([Retorno_Qtd]+[RetornoOutros_Qtd]+[Devol_Qtd]+[Venda_Qtd])
  Switch
    Case QTDDIFER=0 : QTDDIFER=BlankNum() 
    OtherWise       : QTDDIFER=QTDDIFER*-1 
  EndSwitch
  
  If (VSDGOPITE="T") Or
     (VSDGOPITE="D" And not isblank(QTDDIFER))
     Then 
          Rm_1501A_Detalhe()
          
          TIT_QTD  =TIT_QTD  +QTDDIFER
          TIT_SAIDA=TIT_SAIDA+[Saida_VrTotal        ]
          TIT_RETOR=TIT_RETOR+[Retorno_VrTotal      ]
          TIT_RETOU=TIT_RETOU+[RetornoOutros_VrTotal]
          TIT_VENDA=TIT_VENDA+[Venda_VrTotal        ]
          
  EndIf

  TOT_SAIDA       = TOT_SAIDA      +[Saida_VrTotal        ]    TOT_QSAIDA      = TOT_QSAIDA+[Saida_Qtd        ]
  
  qtddiferdescto=([Saida_Qtd]+[Troca_Qtd])-([Retorno_Qtd]+[RetornoOutros_Qtd]+[Devol_Qtd])
  if qtddiferdescto>0
     then TOT_SAIDA_DESC  = TOT_SAIDA_DESC + numval(Format("W15.2",( ([Saida_DescTotal]/[Saida_Qtd]) * qtddiferdescto )))
  endif 

  TOT_RETOR       = TOT_RETOR      +[Retorno_VrTotal      ]    TOT_QRETOR      = TOT_QRETOR+[Retorno_Qtd      ]
  TOT_RETOU       = TOT_RETOU      +[RetornoOutros_VrTotal]    TOT_QRETOU      = TOT_QRETOU+[RetornoOutros_Qtd] 
  TOT_VENDA       = TOT_VENDA      +[Venda_VrTotal        ]    TOT_QVENDA      = TOT_QVENDA+[Venda_Qtd        ] ; Vendas Realizadas
  TOT_VENDA_DESC  = TOT_VENDA_DESC +[Venda_DescTotal      ]
  TOT_VENDA_COMIS = TOT_VENDA_COMIS+[Venda_Comissao       ] 

  TOT_VENDA_PROJ  = TOT_SAIDA-TOT_RETOR                        TOT_QVENDA_PROJ = TOT_QSAIDA-TOT_QRETOR          ; Vendas Projetadas

  Moveto "Answer"
  
EndScan
Rm_1501A_TotalItem()
Rm_1501A_TotalFinanc()

Do_It!
ClearAll

return true

EndProc   ;  (Imprimir)

;*******************************************************************************
;* Rotina checagem n. de linhas                                                *
;*******************************************************************************
Proc Rm_1501A_ChecaLinhaPagina(MaxLin)
Private MaxLin

If lin>=MaxLin
   Then While True
          If OPCAOPAG<>"Todas"
             Then If pag<OPCAOPAGINI Or
                     pag>OPCAOPAGFIM
                     Then QuitLoop
                  EndIf
          EndIf
          Print File ARQIMP ASP1+"\f"+ASP2+"\n"
          QuitLoop
        EndWhile
        Rm_1501A_Cabecalho()

EndIf
EndProc

;*******************************************************************************
;* Rotina p/ Cabecalho                                                         *
;*******************************************************************************
Proc Rm_1501A_Cabecalho()
While True
  pag=pag+1
  lin=13
  If OPCAOPAG<>"Todas"
     Then If pag<OPCAOPAGINI Or
             pag>OPCAOPAGFIM
             Then QuitLoop
          EndIf
  EndIf

  Moveto Tabela1
  Print File ARQIMP ASP1+Fill("-",137)+ASP2+"\n"

  Print File ARQIMP ASP1+COMPLETA(NOMEMPRESA,97," ")+"Emissao.: "+
             AlinhM(LTrim(Format("D13",Today())),10)+"-"+
             AlinhM(LTrim(Time()),8)+"  Pag.:"+Format("W4,EIC",pag)+ASP2+"\n"

  Print File ARQIMP ASP1+Fill("-",137)+ASP2+"\n\n"

  Print File ARQIMP ASP1+Format("W137,AC","Diferenca de Consignado X Vendas X Retornos")+ASP2+"\n\n"

  Print File ARQIMP ASP1+"Cliente: "+[Codigo]+" "+[Razao Social]+ASP2+"\n"

  Print File ARQIMP ASP1+COMPLETA("Empresa: "+[Codigo da Empresa]+" "+[Nome Fantasia Empresa],57," ")      ;40 -> 57
  ;Print File ARQIMP      "Cliente: "+COMPLETA([CARREGAMENTO],17," ")
  Print File ARQIMP      "Emissao: "+Format("D13",[Data de Emissao])+"          Itens: "+VSDGDESCOPITE+ASP2+"\n"

  Print File ARQIMP ASP1+COMPLETA("Repres.: "+[Codigo do Representante]+" "+[Nome Fantasia Represent],31," ")
  Print File ARQIMP      "         "+COMPLETA("",10," ")+" "+COMPLETA("",6," ")
  Print File ARQIMP      "Tabela.: "+COMPLETA([Codigo da Tabela],20," ")+ASP2+"\n\n"
  ;Print File ARQIMP      "Docto: "+[Tipo do Documento]+"/"+[Numero do Documento]+ASP2+"\n\n"
                         
  If Not IMPRIME_APURACAO Then 
  Print File ARQIMP ASP1+"                                                                          Outros             _________________ Valores _________________"+ASP2+"\n"                                                                                                      
  Print File ARQIMP ASP1+"Produto                                   UN  Vr.Unit Saida Retorno   %   Retorn Venda Difer      Saida    Retorno  RetOutros      Venda"+ASP2+"\n"
  Print File ARQIMP ASP1+"----------------------------------------- -- -------- ----- ------------- ------ ----- ----- ---------- ---------- ---------- ----------"+ASP2+"\n"
                         ;1234567890 123456789012345678901234567890 XX 9.999,99 99999 999999 9999,9 999999 99999 99999 999.999,99 999.999,99 999.999,99 999.999,99
  lin = 10
  EndIf                       
                                                                                                            
  Moveto "Answer"

  QuitLoop
EndWhile


EndProc   ; (Cabecalho)

;*******************************************************************************
;* Rotina p/ Detalhe                                                           *
;*******************************************************************************
Proc Rm_1501A_Detalhe()
Rm_1501A_ChecaLinhaPagina(58)
While True
  If OPCAOPAG<>"Todas"
     Then If pag<OPCAOPAGINI Or
             pag>OPCAOPAGFIM
             Then QuitLoop
          EndIf
  EndIf

  Print File ARQIMP ASP1+COMPLETA([Codigo do Item],11," ")
  Print File ARQIMP COMPLETA([Descricao do Item  ],30," ")+Spaces(1)
  Print File ARQIMP COMPLETA([Unidade Fiscal     ],02," ")+Spaces(1)
  Print File ARQIMP Format("W8.2,EIC",[Preco Unitario ])+Spaces(01)
  Print File ARQIMP Format("W5,AR",[Saida_Qtd    ])+Spaces(01)
  Print File ARQIMP Format("W6,AR",[Retorno_Qtd  ])+Spaces(01)
  Print File ARQIMP Format("W6.1,EIC",([Retorno_Qtd]/[Saida_Qtd])*100)
  Print File ARQIMP Format("W7,AR",[RetornoOutros_Qtd])+Spaces(01) 
  ;Print File ARQIMP Format("W7,AR",[Troca_Qtd    ]) 
  ;Print File ARQIMP Format("W7,AR",[Devol_Qtd    ])+Spaces(01) 
  Print File ARQIMP Format("W5,AR",[Venda_Qtd    ])+Spaces(01) 
  Print File ARQIMP Format("W5,AR,S+",QTDDIFER)
  Print File ARQIMP Format("W11.2,EIC",[Saida_VrTotal  ])
  Print File ARQIMP Format("W11.2,EIC",[Retorno_VrTotal])
  Print File ARQIMP Format("W11.2,EIC",[RetornoOutros_VrTotal])  
  Print File ARQIMP Format("W11.2,EIC",[Venda_VrTotal  ])  
  Print File ARQIMP ASP2+"\n"
  QuitLoop
EndWhile
lin=lin+1                                 
EndProc    ;  (Detalhe)

;*******************************************************************************
;* Rotina p/ SubTotal                                                          *
;*******************************************************************************
Proc Rm_1501A_TotalItem()
While pag>0
  Rm_1501A_ChecaLinhaPagina(58)
  lin=lin+2
  
  If OPCAOPAG<>"Todas"
     Then If pag<OPCAOPAGINI Or
             pag>OPCAOPAGFIM
             Then QuitLoop
          EndIf
  EndIf
                                            
  Print File ARQIMP ASP1+Format("W136,AR","----- ---------- ---------- ---------- ----------")+ASP2+"\n"
  Print File ARQIMP ASP1+CI_INEG+Format("W85,AR","Total...")
  Print File ARQIMP      Format("W7,AR",TIT_QTD)
  Print File ARQIMP      Format("W11.2,EIC",TIT_SAIDA)
  Print File ARQIMP      Format("W11.2,EIC",TIT_RETOR)
  Print File ARQIMP      Format("W11.2,EIC",TIT_RETOU)
  Print File ARQIMP      Format("W11.2,EIC",TIT_VENDA)+CI_FNEG+ASP2+"\n" 
  QuitLoop
EndWhile 

EndProc    ;  (Total)                

;*******************************************************************************
;* Cabecalho Apuracao                                                          *
;*******************************************************************************
Proc Rm_1501A_Cabecalho_Apuracao()

LINHA_AP = LINHA_AP + 3

Print File ARQIMP ASP1+ASP2+"\n"
Print File ARQIMP ASP1+CI_INEG+"Apura‡”es: "+CI_FNEG+ASP2+"\n"
Print File ARQIMP ASP1+CI_INEG+"         DtEmiss„o  DtVencto   Documento         SaldoDocto      VrDocto    Observa‡„o"+CI_FNEG+ASP2+"\n"

EndProc ;Cabecalho_Apuracao()     

;*******************************************************************************
;* Rotina p/ Total                                                             *
;*******************************************************************************
Proc Rm_1501A_TotalFinanc()  
Private CONT, TIPO, VR_DEBITO, VR_CREDITO, TOTAL, CONTROLA_TOTAL
  
While pag>0
  Rm_1501A_ChecaLinhaPagina(40)

  If OPCAOPAG<>"Todas"                                 
     Then If pag<OPCAOPAGINI Or
             pag>OPCAOPAGFIM
             Then QuitLoop
          EndIf
  EndIf

  Print File ARQIMP ASP1+Fill("-",137)+ASP2+"\n"

  If Not IsBlank(RELDOCTO_SAIDA) Then Print File ARQIMP ASP1+"Notas de Saida  : "+RELDOCTO_SAIDA+ASP2+"\n" EndIf
  If Not IsBlank(RELDOCTO_RETOR) Then Print File ARQIMP ASP1+"Notas de Retorno: "+RELDOCTO_RETOR+ASP2+"\n" EndIf
  If Not IsBlank(RELDOCTO_VENDA) Then Print File ARQIMP ASP1+"Notas de Venda  : "+RELDOCTO_VENDA+ASP2+"\n" EndIf
  If Not IsBlank(RELDOCTO_TROCA) Then Print File ARQIMP ASP1+"Notas de Troca  : "+RELDOCTO_TROCA+ASP2+"\n" EndIf
  
  VR_DEBITO  = 0
  VR_CREDITO = 0
  
  If Not IsEmpty(Tabela3)
     Then ;--- Adicionado em 25.06.2014 - Controle de Linha (Cabecalho_Apuracao(), LINHA_AP, LINHA_MAX, IMPRIME_APURACAO) ------
          LINHA_MAX = 93
          LINHA_AP  = lin
          IMPRIME_APURACAO = True
          Rm_1501A_Cabecalho_Apuracao()
          For CONT From 1 To 2
              Switch 
                Case CONT=1 : TIPO = "D"
                Case CONT=2 : TIPO = "C"  
              EndSwitch
              
              VR_DEBCRED    = 0
              SALDO_DEBCRED = 0
              
              View Tabela3
              Scan For [Tipo]=TIPO                                         
                Switch
                  Case [Tipo]="D" : DEB_CRED = "DEBITO   " 
                  Case [Tipo]="C" : DEB_CRED = "CREDITO  "
                EndSwitch  
                
                VR_DEBCRED    = VR_DEBCRED    + [Saldo do Documento] ;[Valor do Documento]    
                SALDO_DEBCRED = SALDO_DEBCRED + [Saldo do Documento] 
                LINHA_AP      = LINHA_AP      + 1
                
                LINHA_AP = LINHA_AP + 1
                Print File ARQIMP ASP1+DEB_CRED+Format("D13",[Data de Emissao])+" "+Format("D13",[Data de Vencimento])+Spaces(01)+
                                       Format("W5,AL",[Tipo do Documento])+Format("W11,AL",[Numero do Documento])+Format("W12.2,EIC",[Saldo do Documento])+
                                       Spaces(01)+Format("W12.2,EIC",[Valor do Documento])+Spaces(04)+Format("W40,AL",[Observacoes])+ASP2+"\n"
                
                If LINHA_AP >= LINHA_MAX
                   Then Print File ARQIMP ASP1+"\f"+ASP2+"\n"
                        LINHA_MAX = 105
                        LINHA_AP  = 0
                        Rm_1501A_Cabecalho()
                        Rm_1501A_Cabecalho_Apuracao()
                EndIf     
                Moveto Tabela3                               
              EndScan                                                     
              If SALDO_DEBCRED<>0 Or VR_DEBCRED<>0
                 Then Print File ARQIMP ASP1+CI_INEG+Spaces(37)+"Total...: "+Format("W12.2,EIC",SALDO_DEBCRED)+Spaces(01)+
                                        Format("W12.2,EIC",VR_DEBCRED)+CI_FNEG+ASP2+"\n"
              EndIf            
              ClearImage 

              Switch 
                Case CONT=1 : VR_DEBITO  = VR_DEBCRED
                Case CONT=2 : VR_CREDITO = VR_DEBCRED
              EndSwitch
          EndFor   
          IMPRIME_APURACAO = False 
  EndIf
  
  Print File ARQIMP ASP1+Fill("-",137)+ASP2+"\n"

  If VSDGOPACVR="S"
     Then Print File ARQIMP ASP1+"\f"+ASP2+"\n"
          QuitLoop
  EndIf

  txdescto    = (TOT_VENDA_DESC/TOT_VENDA)*100
;;TOT_RETOU   = TOT_RETOU-numval(format("W15.2",((TOT_RETOU*txdescto)/100)))
  TX_COMISDOC = (TOT_VENDA_COMIS/(TOT_VENDA-TOT_VENDA_DESC))*100

  COMISSAORET = (TOT_RETOU*TX_COMISDOC)/100
  COMISSAOLIQ = TOT_VENDA_COMIS-COMISSAORET
  
  TOT_VENDA_LIQ = TOT_VENDA - TOT_VENDA_DESC
  
  
  Print File ARQIMP ASP1+CI_INEG+"Operacao                                 Pecas       Valor            Apura‡„o de Valores"+CI_FNEG+ASP2+"\n"
                                                      
  Print File ARQIMP ASP1+"(S) Saidas                      :"+Format("W13,EIC",TOT_QSAIDA)+Format("W12.2,EIC",TOT_SAIDA) +"(=)"+Spaces(9)+           
                         "(V) Vendas                          :"+Format("W12.2,EIC",TOT_VENDA)+"(=)"+ASP2+"\n"

  Print File ARQIMP ASP1+"(R) Retornos                    :"+Format("W13,EIC",TOT_QRETOR)+Format("W12.2,EIC",TOT_RETOR)+"(-)"+Spaces(9)+            
                         "(D) Descontos                       :"+Format("W12.2,EIC",TOT_VENDA_DESC)+"(-)  "+Format("W6.2",txdescto)+"%"+ASP2+"\n"



  Print File ARQIMP ASP1+"(P) Projetado Vendas  (S-R)     :"+Format("W13,EIC",TOT_QVENDA_PROJ)+Format("W12.2,EIC",TOT_VENDA_PROJ)+"(=)"+Spaces(9)+  
                         "(L) Liquido (V-D)                   :"+Format("W12.2,EIC",(TOT_VENDA_LIQ))      +"(=)"+ASP2+"\n"
                                                       
  Print File ARQIMP ASP1+"(X) Projetado Descontos/Saidas  :"+                                  Format("W25.2,EIC",TOT_SAIDA_DESC)+"(-)"+Spaces(9)+  
                         "(C) Comissao Vendas (%) (L)         :"+Format("W12.2,EIC",TOT_VENDA_COMIS)+"(=)  "+Format("W6.2",TX_COMISDOC)+"%"+ASP2+"\n"
                         




  Print File ARQIMP ASP1+"(W) Projetado Liquido (P-X)     :"+Format("W13,EIC",TOT_QVENDA)+Format("W12.2,EIC",TOT_VENDA_PROJ-TOT_SAIDA_DESC)+"(=)"+Spaces(9)+            
                         "(O) Outros Retornos - Desconto      :"+Format("W12.2,EIC",TOT_RETOU)+"(-)"+ASP2+"\n"


  Print File ARQIMP ASP1+CI_INEG+"    Diferen‡a: (W-L)            :"+Format("W13,EIC",(TOT_QVENDA_PROJ-TOT_QVENDA))+
                                                                     Format("W12.2,EIC",(TOT_VENDA_PROJ-TOT_SAIDA_DESC-TOT_VENDA_LIQ))+"(=)"+CI_FNEG+Spaces(9)+
                         "(M) Comissao Out.Retornos (%) (O)   :"+Format("W12.2,EIC",COMISSAORET)+"(=)  "+Format("W6.2",TX_COMISDOC)+"%"+ASP2+"\n"
                         
  Print File ARQIMP ASP1+Spaces(70)+"(N) Comissao Liquida (C-M)          :"+Format("W12.2,EIC",(COMISSAOLIQ))+"(-)"+ASP2+"\n"                        
  
  Print File ARQIMP ASP1+"(U) Outros Retornos             :"+Format("W13,EIC",TOT_QRETOU)+Format("W12.2,EIC",TOT_RETOU)+"(U)"+Spaces(9)+
                                                                   "(B) Outros Debitos                  :"+Format("W12.2,EIC",VR_DEBITO)+"(+)"+ASP2+"\n"
  
  If SYS_CODIGO_CLIENTE="0266"
      Then Print File ARQIMP ASP1+CI_INEG+"Diferen‡a "+CI_FNEG+"(Saidas-Ret.-Out.Ret.):"+
                                  CI_INEG+Format("W13,EIC",TOT_QSAIDA-TOT_QRETOR-TOT_QRETOU)+
                                  Format("W12.2,EIC",TOT_SAIDA-TOT_RETOR-TOT_RETOU)+"( )"+ 
                                  Spaces(09)+"(T) Credito                         :"+Format("W12.2,EIC",VR_CREDITO)+"(-)"+ASP2+"\n"
      Else Print File ARQIMP ASP1+Spaces(70)+"(T) Credito                         :"+Format("W12.2,EIC",VR_CREDITO)+"(-)"+ASP2+"\n"
  EndIf
                                                    
  TOTAL=TOT_VENDA+VR_DEBITO-(TOT_VENDA_DESC+COMISSAOLIQ+TOT_RETOU+VR_CREDITO)
  If TOTAL >=0
     Then CONTROLA_TOTAL="Liquido a Receber "
     Else CONTROLA_TOTAL="Cr‚dito a Pagar   " 
  EndIF

  Print File ARQIMP ASP1+"    Vendas(P)-Outros Retornos(U):"+Format("W13,EIC",TOT_QVENDA_PROJ-TOT_QRETOU)+Format("W12.2,EIC",TOT_VENDA_PROJ-TOT_RETOU)+"   "+Spaces(9)+
             CI_INEG+CONTROLA_TOTAL+"(L-O-N-T)+(B)     :"+  Format("W12.2,EIC",TOTAL)+"(=)"+CI_FNEG+ASP2+"\n"

  Moveto Tabela1
  Print File ARQIMP ASP1+ASP2+"\n"
  Print File ARQIMP ASP1+"Recebemos de "+[Razao Social]+" no dia ___/___/___"+ASP2+"\n"
  Moveto "Answer"

  Print File ARQIMP ASP1+Fill("-",137)+ASP2+"\n"

  Print File ARQIMP ASP1+"\f"+ASP2+"\n"

  QuitLoop
EndWhile

TOT_SAIDA       = 0    
TOT_SAIDA_DESC  = 0
TOT_RETOR       = 0 
TOT_RETOU       = 0
TOT_VENDA       = 0 
TOT_VENDA_DESC  = 0
TOT_VENDA_COMIS = 0 
TOT_VENDA_PROJ  = 0
                                            
TOT_QSAIDA      = 0   
TOT_QRETOR      = 0   
TOT_QRETOU      = 0
TOT_QVENDA      = 0   
TOT_QVENDA_PROJ = 0

TIT_QTD         = 0    
TIT_SAIDA       = 0    
TIT_RETOR       = 0    
TIT_RETOU       = 0
TIT_VENDA       = 0    

EndProc    ;  (TotalFinanc)


;*******************************************************************************
;* Monta Relat¢rio p/ ImpressÆo do Consignado                                  * 
;*******************************************************************************
Proc Rm_1501A_Monta_Relatorio()
private result             
 
ConfGeral("Deseja imprimir o relat¢rio de consignado ?")
If Ok<>"S"
   Then Return False
EndIf                       
 
DISPOSITIVO()
If OK=""
    Then Return False
EndIf

ASP1=""
ASP2=""
ARQIMP = DIREPORT+"ACERTO.TXT"
Switch
  Case OK="A": ARQIMP = DIREPORT+ARQUIVO+".TXT"
  Case OK="V": ASP1="\""
               ASP2="\""
EndSwitch
If IsFile(ARQIMP)
   Then Deleta_Arquivo(ARQIMP)
EndIf

AGUARDE("Imprimindo")

result=Gera_Dados()
if result
   Then
        Rm_1501A_Imprimir()
        
        If OK="V"
          Then If IsTable("Answer") Then Delete "Answer" EndIf
          
               {Tools} {Copy} {Table} {\\Base\\Sistemas\\Estoque\\Rm_tx250} {Answer} ClearAll
               {Tools} {ExportImport} {Import} {ASCII} {AppendDelimited} TypeIn ARQIMP Enter
               {Answer} ClearAll
        
               OPCAOPAG="Todas"
               IMPRIREL("Answer","1")
        
               Deleta_Arquivo(ARQIMP)
               FastMsg("Impress„o Concluida !")
                 
          Else If OK="I"
                  Then 
                       ImpriArq(ARQIMP)
                       FastMsg("Impress„o Concluida !")
               EndIf
        EndIf
EndIf

DeletaTabelas()
        
Return result

EndProc ;Monta_Relatorio()


;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************

Retorno_ok=true

Retorno_ok=Rm_1501A_Monta_Relatorio()

Release Vars  ASP1,ASP2,ARQIMP,OPCAOPAG,OPCAOPAGINI,OPCAOPAGFIM,
              EMPANT,CODCLI,pag,lin,LINHA_AP

Release Procs Rm_1501A_Imprimir, Rm_1501A_ChecaLinhaPagina, Rm_1501A_Cabecalho, Rm_1501A_Detalhe,
              Rm_1501A_TotalItem, Rm_1501A_Cabecalho_Apuracao, Rm_1501A_TotalFinanc  
