;** Ro_0093 ********************************************************************
;** Imprime a Digitacao do Romaneio               Roupa Fillas                 *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 18/07/2003 por Karen Lauar Nery
;Alterado em     : 23/08/2004 Nikolas M. Mateus
;Motivo Alteracao: Inclusao do CPF do cliente
;Alterado em     : 20/07/2007 por Nikolas
;Motivo Alteracao: Ajustes
;Ultima Alteracao: 14/08/2007 por Antonio Marcelo Alves
;Motivo Alteracao: Ajustes Deleta_Arquivo
;Ultima Alteracao: 30/08/2007 por Humberto F.Santos.
;Motivo Alteracao: Inclusao do Nome da Empresa.
;Ultima Alteracao: 26/06/2018 por Anivel Augusto Rodrigues                           
;Motivo Alteracao: Ajustes itens mercadoria/servico

;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPRO()

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

Moveto "FaturaC"

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

Switch
  Case Search("DEV",[Descricao da Destinacao])>0            : Print File ARQIMP "DEVOLU€ŽO"
  Case Search("SIMPLES REMESSA",[Descricao da Destinacao])>0: Print File ARQIMP "SIMPLES REMESSA"
  Case [Codigo da Destinacao]="005"                         : Print File ARQIMP Format("W30,AL",[Descricao da Destinacao])
  OtherWise                                                 : Print File ARQIMP "NOTA PROMISSORIA"+"\n"
EndSwitch
Print File ARQIMP CI_15CPP

Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP "\027E"

Print File ARQIMP Spaces(01)+"ROUPAFILLAS DESIGN"
Print File ARQIMP "\027F"
Print File ARQIMP Spaces(10)+Username()
Print File ARQIMP "\n"

Print File ARQIMP Spaces(01)+"EMISSAO: "+Format("D13",Today())+"-"+Time()+"  "+
                  " NUMERO:  "+Format("W06.3,AL",NOTAFISC)+"\n"
Print File ARQIMP Spaces(01)+"VEND: "+Format("W21,AL",[Nome Fantasia Represent])+"\n"


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

Print File ARQIMP Spaces(02)+"CLIENTE.: "
Print File ARQIMP Format("W05,AL",[Codigo])
Print File ARQIMP Format("W40,AL",[Razao Social])+"\n"
Print File ARQIMP Spaces(02)+"CPF/CNPJ: "+Format("W27,AL",[CGC])+"\n"
Print File ARQIMP Spaces(02)+"AUTORIZ.: "+Format("W30,AL",[Nome do Autorizado])+Format("W14,AL",[CPF do Autorizado])+"\n"
CLIENTE=[Razao Social]
Print File ARQIMP Spaces(02)+"ENDERECO.: "+ Format("W40,AL",[Endereco])+"\n"
Print File ARQIMP Spaces(02)+"BAIRRO.: "+ Format("W20,AL",[Bairro])+
"FONE: " + Format("W19,AL",[Telefone])+"\n"
Print File ARQIMP Spaces(02)+"CIDADE.: "+Format("W20,AL",[Cidade])+Spaces(10)
Print File ARQIMP "PEDIDO: "+[Numero do Pedido]+"\n"

If Not Isblank(SubStr([Observacao na Nota Fiscal],001,48))
   Then Print File ARQIMP Spaces(02)+"OBS...:"
        Moveto "FaturaC"
        Print File ARQIMP Format("W48,AL",SubStr([Observacao na Nota Fiscal],001,48))+"\n"
        If Not IsBlank (SubStr([Observacao na Nota Fiscal],049,48))
           Then Print File ARQIMP Spaces(02)+Format("W48,AL",SubStr([Observacao na Nota Fiscal],049,48))+"\n"
                If Not IsBlank(SubStr([Observacao na Nota Fiscal],97,48))
                   Then Print File ARQIMP Spaces(02)+Format("W48,AL",SubStr([Observacao na Nota Fiscal],97,48))+"\n"
                EndIf
        EndIf
EndIf

;********** PARCELAS/VENCIMENTOS ********************

Print File ARQIMP Fill("-",57)+"\n"
Print File ARQIMP Spaces(09)+"PARCELA"+Spaces(05)+"ND"+Spaces(05)+"VENCIMENTO"+Spaces(07)+"VALOR"+Spaces(02)+"FP"+"\n"

Moveto "FaturaV"
Moveto [Numero da OF]
Locate [FaturaC->Numero da OF]
If RetVal
   Then While ([Numero da OF]=[FaturaC->Numero da OF])
          Print File ARQIMP Spaces(12)+AlinhM([Sequencia],2)+Spaces(05)+Format("W4",[Numero de Dias])+
                            Spaces(05)+ Format("D13",[Data])+Spaces(01)+Format("W11.2,EIC",[Valor])+Spaces(02)+Format("W2",[Forma de Pagamento])+"\n"
          Skip
          If EOT() Then QuitLoop EndIf
        EndWhile
EndIf

;******************************** IMPRESSAO DOS ITENS ********************************
Print File ARQIMP Fill("=",56)+"\n"
 Print File ARQIMP " PRODUTO                       UF QTD Vr.Uni  Vr.Total"+"\n"
 ;                  12345612345678901234567890123 123123 123456 23456789
Moveto "FaturaI"
Moveto [Numero da OF]
Locate [FaturaC->Numero da OF]
QUANT=0
TOT  =0

While [Numero da OF]=[FaturaC->Numero da OF]
   Print File ARQIMP Format("W06,AL",SubStr([Codigo do Item],6,5))
   Print File ARQIMP Format("W24,AL",[Descricao do Item])+" "
   Print File ARQIMP Format("W03,AL",[Unidade Fiscal])
   Print File ARQIMP Format("W03,EIC",[Quantidade])+Spaces(01)
   Print File ARQIMP Format("W06.2,EIC",[Preco Unitario])+"  "
   Print File ARQIMP Format("W08.2,EIC",[Preco Total])+"\n"

   QUANT=QUANT+[Quantidade]
   TOT=TOT+[Preco Total]
   Skip
   If EOT() Then QuitLoop EndIf
EndWhile

Moveto "FaturaC"
Print File ARQIMP Spaces(48)+"------"+"\n"
Print File ARQIMP Spaces(43)+Format("W11.2,EIC",[Valor Mercadoria]+[Valor Servico])+"\n"
Print File ARQIMP Fill("-",56)+"\n"

Print File ARQIMP Spaces(02)+"VR.MERCADORIAS: "+Format("W11.2,EIC",[Valor Mercadoria])+
                  Spaces(05)+"VR.DESCTO: "+Format("W8.2,EIC",[Valor Desconto])+"\n"

Print File ARQIMP Spaces(02)+"VR.SERVICO....: "+Format("W11.2,EIC",[Valor Servico])+
                  Spaces(05)+"VR.DESCTO: "+Format("W8.2,EIC",[Valor Desconto Servico])+"\n"

Print File ARQIMP Spaces(02)+"VR.FRETE......: "+Format("W11.2,EIC",[Valor do Frete])+"\n\n"

Print File ARQIMP Spaces(02)+"   VR A PAGAR.: "
Print File ARQIMP CI_10CPP
Print File ARQIMP CI_IEXP
Print File ARQIMP LTrim(Format("W11.2,EIC",[Valor Nota Fiscal]))+"\n\n"
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_15CPP
Print File ARQIMP Fill("-",56)+"\n\n\n"
Print File ARQIMP Spaces(07)+Fill("-",40)+"\n"
Print File ARQIMP Chr(27)+Chr(98)
Print File ARQIMP Spaces(07)+Format("W40,AC",CLIENTE)+"\n"
Print File ARQIMP Fill("-",56)+"\n"
Print File ARQIMP Spaces(07)+"NAO VALE COMO N.F PROCURE O CUPOM NO CAIXA"+"\n"
Print File ARQIMP Spaces(07)+"         AGRADECEMOS A PREFERENCIA"+"\n"
Print File ARQIMP Spaces(07)+"         ''NAO TEMOS COBRADOR''     "+"\n"
Print File ARQIMP Spaces(07)+ "     HAVERA AUMENTO APOS O VENCIMENTO "+"\n"
Print File ARQIMP Fill("-",56)+"\n"
Print File ARQIMP Fill("\n",10)
EndProc ; (IMPRO)

;*******************************************************************************
;* Rotina Principal                                                            *
;*****************+*************************************************************
ArqImp=PrivDir()+"Ro_0023.Txt"
If IsFile(ArqImp)
   Then Deleta_Arquivo(ARQIMP)
EndIf

AGUARDE("Imprimindo Orcamento -> "+NOTAFISC)
IMPRO()

;---- Imprime Arquivo Impressao ------------------------------------------------
ImpriArq(ARQIMP)

Release Vars  CLIENTE,END_ENT,BAI_ENT,CID_ENT,CEP_ENT
Release Procs IMPRO
LIMPAGUARDE()


