;** Rp_0258 ********************************************************************
;*  Recibo de Pagamento                                                        *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 08/07/2010 por Bruno Carvalho
;Ultima Alteracao:   /  /     por 
;Motivo Alteracao:  

;*******************************************************************************
;* Rotina para impressao do recibo de pagamento                             ****
;*****************+*************************************************************
Proc IMPRP()

;************************* IMPRESSAO DO CABECALHO *****************************
If Not IsAssigned(NOMEMPRESA)
   Then NOMEMPRESA=""
EndIf

If Not IsAssigned(Sys_Reset_Impressora)
   Then Sys_Reset_Impressora=""
EndIf

Print File ARQIMP Sys_ReSet_Impressora
Print File ARQIMP CI_8LPP

If clieant<>[Duplic->Codigo do Destinatario]
   Then If clieant<>"****"
           Then Rodape()
        EndIf   
        clieant=[Duplic->Codigo do Destinatario]
        VR_RECIBO=0
        Cabecalho()
EndIf   
ITENS()

If ULTIMA_BAIXA 
   Then RODAPE()
EndIF

EndProc ;IMPRP()

;*******************************************************************************
;* Cabe‡alho                                                                   *
;*******************************************************************************
Proc CABECALHO()

Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP CI_15CPP
Print File ARQIMP Fill("=",79)+"\n"
Print File ARQIMP CI_10CPP
Print File ARQIMP CI_IEXP
Print File ARQIMP CI_INEG

Switch
  Case [DupBaixa->Tipo da Baixa]="NORMAL"   :  Print File ARQIMP "RECIBO DE PAGAMENTO"
  Case [DupBaixa->Tipo da Baixa]="DEVOLUCAO":  Print File ARQIMP "RECIBO DE DEVOLUCAO"
  Case [DupBaixa->Tipo da Baixa]="CANCELADO":  Print File ARQIMP "RECIBO DE CANCELAMENTO"
EndSwitch

Print File ARQIMP CI_15CPP
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG+"\n"

Print File ARQIMP "EMISSAO: "+Format("D13",Today())+"-"+Time()+"\n"
;Print File ARQIMP Spaces(10)+"VEND: "+Format("W21,AL",[Nome Fantasia Represent])
;Print File ARQIMP Spaces(03)+ "N§.: "+Format("W6,AL",[Numero do Lancamento])+"\n"

Print File ARQIMP Fill("-",79)+"\n"
Print File ARQIMP "EMITIDO PARA CONTROLE INTERNO NŽO TEM  VALOR FISCAL"+"\n"
Print File ARQIMP Fill("-",79)+"\n"
Print File ARQIMP "CLIENTE..: "+Format("W04,AL",[Duplic->Codigo do Destinatario])+"-"+Format("W20,AL",[Duplic->Nome Fantasia EmitDest])+"\n"
Print File ARQIMP "ENDERE€O.: "+ Format("W40,AL",ENDERECO)+"\n"
Print File ARQIMP "BAIRRO...: "+ Format("W20,AL",BAIRRO)+
"FONE: " + Format("W20,AL",TELEFONE)+"\n"
Print File ARQIMP "CIDADE...: "+Format("W20,AL",CIDADE)+"\n\n"

Print File ARQIMP Spaces(01)+"                       ------------------- Valores -------------------\n"
Print File ARQIMP Spaces(01)+"N§ Lanc. Documento        Original Juros/Multa    Desconto       Total\n"
Print File ARQIMP Spaces(01)+"-------- ------------- ----------- ----------- ----------- -----------\n"

EndProc ;CABECALHO()

;*******************************************************************************
;* Impressao dos Itens                                                      *
;*******************************************************************************
Proc ITENS()

Print File ARQIMP CI_15CPP
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG

Print File ARQIMP Spaces(01)+Format("W06,AL",[Duplic->Numero do Lancamento])
Print File ARQIMP Spaces(03)+Format("W10,AL",[Duplic->Numero do Documento])
Print File ARQIMP "-"+[Sequencia da Baixa]
Print File ARQIMP Format("W13.2,EIC",([Valor do Recebimento]+[Valor do Desconto])-[Valor do Juros])
Print File ARQIMP Format("W12.2,EIC",[Valor do Juros])
Print File ARQIMP Format("W12.2,EIC",[Valor do Desconto])
Print File ARQIMP Format("W12.2,EIC",[Valor do Recebimento])+"\n"

VR_RECIBO=VR_RECIBO+[Valor do Recebimento]
        
EndProc ;ITENS()

;*******************************************************************************
;* Impressao dos Rodap‚                                                        *
;*******************************************************************************
Proc RODAPE()

Print File ARQIMP CI_15CPP
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG

Print File ARQIMP Fill("-",79)+"\n"

Print File ARQIMP Spaces(08)+"Data do Pagamento: "
Print File ARQIMP Format("D13",[Data do Pagamento])
                                    
Switch
  Case [DupBaixa->Tipo da Baixa]="NORMAL"    : Print File ARQIMP Spaces(05)+"Valor Recebido: "
  Case [DupBaixa->Tipo da Baixa]="DEVOLUCAO" : Print File ARQIMP Spaces(05)+"Valor Devolvido: "
  Case [DupBaixa->Tipo da Baixa]="CANCELADO" : Print File ARQIMP Spaces(05)+"Valor Cancelado: "
EndSwitch

Print File ARQIMP LTrim(Format("W11.2,EIC",VR_RECIBO))+"\n"

Print File ARQIMP Fill("=",79)
If Not ULTIMA_BAIXA
   THEN PRINT FILE ARQIMP "\N\N"
   ELSE PRINT FILE ARQIMP FILL("\N",22)
ENDIF

Print File ARQIMP CI_10CPP
Print File ARQIMP CI_6LPP

EndProc ;RODAPE()

;*******************************************************************************
;* Rotina Principal                                                            *
;*****************+*************************************************************
AGUARDE("Imprimindo Recibo de Pagamento-> "+[Duplic->Numero do Lancamento])
IMPRP()
LIMPAGUARDE()

Release Procs IMPRP, RODAPE, ITENS, CABECALHO
