;** Ro_0041 *******************************************************************
;** Imprime a Digitacao do Romaneio             *** Mega Dias Distribuidora  ***
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 03/09/2003 por Karen Lauar Nery
;Alterado em     : 24/12/2003 por Karen Lauar Nery
;Motivo Alteracao: ITEM DA OF
;Alterado em     : 16/06/2006 por Antonio Marcelo Alves
;Motivo Alteracao: Inclusao ImpriArq()
;Ultima Alteracao: 14/08/2007 por Antonio Marcelo Alves
;Motivo Alteracao: Ajustes Deleta_Arquivo
;Ultima Alteracao: 26/06/2018 por Anivel Augusto Rodrigues                           
;Motivo Alteracao: Ajustes itens mercadoria/servico

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

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

Print File ARQIMP CI_15CPP
Print File ARQIMP  "  ------------------------------------------------------------------------------------------------------------------------------------" +"\n"
Print File ARQIMP Spaces(02)+Format("W40,AL",NOMEMPRESA)+Spaces(15)+"Romaneio"+Spaces(32)+"Impressao: "+Format("D13",Today())+"-"+Time()+ "\n"
Print File ARQIMP  "  ------------------------------------------------------------------------------------------------------------------------------------" +"\n"

Print File ARQIMP Spaces(02)+"Cliente: "
Print File ARQIMP Format("W05,AL",[Codigo])
Print File ARQIMP Format("W97,AL",[Razao Social])
Print File ARQIMP "Ronameio No: "+Format("W06.3,AL",NOTAFISC)+"\n"

Print File ARQIMP Spaces(16)+Format("W40,AL",[Endereco])
Print File ARQIMP Format("W18,AL",[CGC])+Spaces(07)+"Emissao: "
Print File ARQIMP Format("D13",[Data de Emissao])+"\n"

Print File ARQIMP Spaces(16)+Format("W20,AL",[Bairro])
Print File ARQIMP Format("W20,AL",[CEP])
Print File ARQIMP Format("W25,AL",[IE])+"\n"

Print File ARQIMP Spaces(16)+Format("W20,AL",[Cidade])
Print File ARQIMP Format("W20,AL",[UF])
Print File ARQIMP Format("W25,AL",[Telefone])
Print File ARQIMP "Empresa: "+Format("W05,AL",[Codigo da Empresa])+Format("W20,AL",[Nome Fantasia Empresa])+"\n\n"


;********************* IMPRESSAO DOS ITENS ********************************
CONTADOR=0
Print File ARQIMP Spaces(02)+" Sq Item                                                Cor/Tecido                Tm   Quantidade Un PrUnitario    PrTotal"+"\n"
Print File ARQIMP Spaces(02)+"--- --------------------------------------------------- ------------------------- --- ----------- -- ---------- ----------"+"\n"
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 Spaces(02)+Format("W03,AR",StrVal([Item da OF]))+" "
   Print File ARQIMP Format("W11,AL",[Codigo do Item])
   Print File ARQIMP Format("W41,AL",[Descricao do Item])
   Print File ARQIMP Format("W05,AL",[Codigo da Cor_Tecido])
   Print File ARQIMP Format("W21,AL",[Descricao da Cor_Tecido])
   Print File ARQIMP Format("W03,AR",[Tamanho])
   Print File ARQIMP Format("W12.3,EIC",[Quantidade])
   Print File ARQIMP Format("W03,AR",[Unidade Fiscal])
   Print File ARQIMP Format("W11.2,EIC",[Preco Unitario])
   Print File ARQIMP Format("W11.2,EIC",[Preco Total])+"\n"
   QUANT=QUANT+[Quantidade]
   TOT=TOT+[Preco Total]
   Skip
   If EOT() Then QuitLoop EndIf
   CONTADOR=CONTADOR+1
EndWhile
While CONTADOR < 14
  Print File ARQIMP "\n"
  CONTADOR=CONTADOR+1
EndWhile

;********************* IMPRESSAO DOS TOTAIS **************************
Moveto "FaturaC"
Print File ARQIMP "\n"
Print File ARQIMP Spaces(77)+"  Mecadorias    Desconto     Liquido     Total     "+"\n"

Print File ARQIMP Spaces(77)+Format("W12.2,EIC",[Valor Mercadoria])

If Not Isblank([Taxa de Desconto])
   Then Print File ARQIMP " "+Format("W10.2,EIC",[Taxa de Desconto])+"%"
   Else Print File ARQIMP "  "+Format("W10.2,EIC",[Valor Desconto])
EndIf

Print File ARQIMP Format("W12.2,EIC",[Valor Mercadoria Liquido])
Print File ARQIMP Format("W010.2,EIC",[Valor Nota Fiscal])+"\n"

;************************* IMPRESSAO DO RODAPE ********************************
Moveto "FaturaC"
Print File ARQIMP Spaces(02)+"Obs....: "+Format("W110,AL",SubStr([Observacao na Nota Fiscal],001,110))+"\n"
If Substr([Observacao na Nota Fiscal],111,110)<>""
   Then Print File ARQIMP Spaces(20)+Format("W110,AL",SubStr([Observacao na Nota Fiscal],111,110))+"\n"
   Else Print File ARQIMP "\n"
EndIf
Print File ARQIMP Spaces(02)+"Representante: "+Format("W05,AL",[Codigo do Representante])
Print File ARQIMP Format("W25,AL",[Nome Fantasia Represent])+Spaces(43)+ "-------------------------------------"+"\n"

Print File ARQIMP Spaces(95)+"Data/Assinatura Responsavel"+"\n\n"
Print File ARQIMP CI_10CPP
Print File ARQIMP CI_6LPP
EndProc

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

AGUARDE("Imprimindo Romaneio -> "+NOTAFISC)
IMPFAT()
Print File ARQIMP CI_10CPP
Print File ARQIMP CI_6LPP

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

Release Vars VALOR,DATA
Release Procs IMPFAT,VENC
LIMPAGUARDE()


