alias help

VARIAVEL d_de   = DATE()
VARIAVEL d_ate  = DATE()
VARIAVEL z_move = ""
VARIAVEL z_fat  = ""
VARIAVEL z_fatf = ""

VARIAVEL T_Np  = 0
VARIAVEL T_Un  = 0
VARIAVEL T_Vce = 0

VARIAVEL T_eNp  = 0
VARIAVEL T_eUn  = 0
VARIAVEL T_eVce = 0

VARIAVEL T_sNp  = 0
VARIAVEL T_sUn  = 0
VARIAVEL T_sVce = 0

VARIAVEL Z_VNDES = 0
VARIAVEL Z_VNDCT = 0
VARIAVEL Z_VNDCH = 0
VARIAVEL Z_VNDCV = 0
VARIAVEL Z_VNDMT = 0

VARIAVEL Z_DSCES = 0
VARIAVEL Z_DSCCH = 0
VARIAVEL Z_DSCCT = 0
VARIAVEL Z_DSCCV = 0
VARIAVEL Z_DSCMT = 0

VARIAVEL Z_CAFRAFEP = 1
VARIAVEL Z_CSAND    = 2
VARIAVEL Z_CFUNC    = 44
VARIAVEL Z_1VND = 0
VARIAVEL Z_2VND = 0
VARIAVEL Z_3VND = 0
VARIAVEL Z_4VND = 0
VARIAVEL Z_1DSC = 0
VARIAVEL Z_2DSC = 0
VARIAVEL Z_3DSC = 0
VARIAVEL Z_4DSC = 0
VARIAVEL Z_1VND1 = 0
VARIAVEL Z_2VND1 = 0
VARIAVEL Z_3VND1 = 0
VARIAVEL Z_4VND1 = 0
VARIAVEL Z_1DSC1 = 0
VARIAVEL Z_2DSC1 = 0
VARIAVEL Z_3DSC1 = 0
VARIAVEL Z_4DSC1 = 0

VARIAVEL Z_1VND2  = 0
VARIAVEL Z_1DSC2  = 0


T 8,20,17,65,Parametros
T 2,4,Data Inicial........:,8,d_de,99.99.99
T 3,4,Data Final..........:,8,d_ate,99.99.99

//T 5,4,Codigo AFRAFEP-SAUDE:,4,Z_CAFRAFEP,9999
//T 6,4,Codigo SAMD.........:,4,Z_CSAND,9999
//T 7,4,Codigo Func. AFRAFEP:,4,Z_CFUNC,9999


COMANDO ANTES Z_AAMM = SubStr( DTOS(d_ate), 3,4)
COMANDO DEPOIS SetAliasAaMm(Z_AAMM)
COMANDO ANTES Z_MOVE = wse_mov
COMANDO ANTES Z_FAT  = wsf_fat
COMANDO ANTES Z_FATF = wsf_fatf
COMANDO ANTES DBGOBOTTOM()

ARQUIVO SE_PROD
COMANDO ANTES Mensagem("Processando Estoque",1)
FILTRO PEATUAL>0.and.pvluvenda>0
COMANDO DURANTE T_Np  = T_Np  + 1
COMANDO DURANTE T_Un  = T_Un  + PEATUAL
COMANDO DURANTE T_Vce = T_Vce + PEATUAL*if(pvluven3>0,pvluven3,PVLUVENDA*(1-pdescvar/100) )

ARQUIVO (z_fatf)
COMANDO ANTES Mensagem("Processando Entradas",1)
FILTRO pfdatache>=d_de.and.pfdatache<=d_ate
COMANDO DURANTE T_eNp  = T_eNp  + if(type("pfprods")<>"U",pfprods,0)
COMANDO DURANTE T_eUn  = T_eUn  + if(type("pfunids")<>"U",pfunids,0)
COMANDO DURANTE T_eVce = T_eVce + pfval

ARQUIVO (z_fat)
COMANDO ANTES Mensagem("Processando Vendas",1)
FILTRO fdataemi>=d_de.and.fdataemi<=d_ate.and.ftipoven$"12345"
COMANDO DURANTE T_sNp  = T_sNp  + ftotprod
COMANDO DURANTE T_sUn  = T_sUn  + ftotunid
COMANDO DURANTE T_sVce = T_sVce + if(type("fval3")<>"U".and.fval3>0,fval3,fval+fdesconto-fvaldev)

COMANDO DURANTE Z_VNDES = Z_VNDES + if( fTIPOVEN ="1",   fVal+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_VNDCH = Z_VNDCH + if( fTIPOVEN ="2",   fVal+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_VNDCT = Z_VNDCT + if( fTIPOVEN ="3",   fVal+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_VNDCV = Z_VNDCV + if( fTIPOVEN ="4",   fVal+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_VNDMT = Z_VNDMT + if(!fTIPOVEN$"1234", fVal+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_DSCES = Z_DSCES + if( fTIPOVEN ="1",   Fdesconto,0)
COMANDO DURANTE Z_DSCCH = Z_DSCCH + if( fTIPOVEN ="2",   Fdesconto,0)
COMANDO DURANTE Z_DSCCT = Z_DSCCT + if( fTIPOVEN ="3",   Fdesconto,0)
COMANDO DURANTE Z_DSCCV = Z_DSCCV + if( fTIPOVEN ="4",   Fdesconto,0)
COMANDO DURANTE Z_DSCMT = Z_DSCMT + if(!fTIPOVEN$"1234", Fdesconto,0)

COMANDO DURANTE Z_1VND  = Z_1VND + if( fTIPOVEN $"12345".and.fcli=z_cafrafep,fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_2VND  = Z_2VND + if( fTIPOVEN $"12345".and.fcli=z_csand   ,fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_3VND  = Z_3VND + if( fTIPOVEN $"12345".and.fcli=z_cfunc   ,fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_4VND  = Z_4VND + if( fTIPOVEN $"12345".and.fcli<>z_cfunc.AND.fcli<>z_cafrafep.AND.fcli<>z_csand, fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_1DSC  = Z_1DSC + if( fTIPOVEN $"12345".and.fcli=z_cafrafep,fdesconto,0)
COMANDO DURANTE Z_2DSC  = Z_2DSC + if( fTIPOVEN $"12345".and.fcli=z_csand   ,fdesconto,0)
COMANDO DURANTE Z_3DSC  = Z_3DSC + if( fTIPOVEN $"12345".and.fcli=z_cfunc   ,fdesconto,0)
COMANDO DURANTE Z_4DSC  = Z_4DSC + if( fTIPOVEN $"12345".and.fcli<>z_cfunc.AND.fcli<>z_cafrafep.AND.fcli<>z_csand, fdesconto,0)

COMANDO DURANTE Z_1VND1  = Z_1VND1 + if( fTIPOVEN $"123".and.fcli=z_cafrafep.and.fbanco<>999,fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_1VND2  = Z_1VND2 + if( fTIPOVEN $"2".and.fcli=z_cafrafep.and.fbanco=999,fval+Fdesconto-fvaldev,0)
*- Asterisque a linha de cima e Retire o asterisco abaixo para liberar cheque social para todo mundo
*- COMANDO DURANTE Z_1VND2  = Z_1VND2 + if( fTIPOVEN $"2".and.fbanco=999,fval+Fdesconto-fvaldev,0)

COMANDO DURANTE Z_2VND1  = Z_2VND1 + if( fTIPOVEN $"123".and.fcli=z_csand   ,fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_3VND1  = Z_3VND1 + if( fTIPOVEN $"123".and.fcli=z_cfunc   ,fval+Fdesconto-fvaldev,0)
COMANDO DURANTE Z_4VND1  = Z_4VND1 + if( fTIPOVEN $"123".and.fcli<>z_cfunc.AND.fcli<>z_cafrafep.AND.fcli<>z_csand, fval+Fdesconto-fvaldev,0)

COMANDO DURANTE Z_1DSC1  = Z_1DSC1 + if( fTIPOVEN $"123".and.fcli=z_cafrafep.and.fbanco<>999,fdesconto,0)
COMANDO DURANTE Z_1DSC2  = Z_1DSC2 + if( fTIPOVEN $"123".and.fcli=z_cafrafep.and.fbanco=999,fdesconto,0)

COMANDO DURANTE Z_2DSC1  = Z_2DSC1 + if( fTIPOVEN $"123".and.fcli=z_csand   ,fdesconto,0)
COMANDO DURANTE Z_3DSC1  = Z_3DSC1 + if( fTIPOVEN $"123".and.fcli=z_cfunc   ,fdesconto,0)
COMANDO DURANTE Z_4DSC1  = Z_4DSC1 + if( fTIPOVEN $"123".and.fcli<>z_cfunc.AND.fcli<>z_cafrafep.AND.fcli<>z_csand, fdesconto,0)

COMANDO DEPOIS Z_TOTVND = Z_VNDES +Z_VNDCH +Z_VNDCT +Z_VNDCV +Z_VNDMT
COMANDO DEPOIS Z_DESCO  = Z_DSCES +Z_DSCCH +Z_DSCCT +Z_DSCCV +Z_DSCMT

ULTPAG
ULTPAG[&m_expandido][EMPRESA][&m_naoexpandi]    Data [date()]
ULTPAG[]Periodo de [d_de] ate [d_ate]
ULTPAG[repl("=",80)]
ULTPAG
ULTPAG                       []POSICAO ATUAL DO ESTOQUE
ULTPAG
ULTPAG   Valor do Estoque..................: [][T_Vce @e 999,999,999.99]
ULTPAG   Total de Produtos em Discriminacao: [][T_Np @e 999,999,999]
ULTPAG   Total de Produtos em Unidades.....: [][T_Un @e 999,999,999]
ULTPAG

ULTPAG[repl("+",80)]

COMANDO DEPOIS z_subtotaf = Z_1VND-Z_1VND1-Z_1VND2
COMANDO DEPOIS z_dscaf    = Z_1DSC-Z_1DSC1-Z_1DSC2

ULTPAG
ULTPAG                       []POSICAO DE ENTRADAS E SAIDAS
ULTPAG
ULTPAG                            Unidades         Valor R$
ULTPAG   Total Compradas...:   [][t_eUn @e 999,999,999]   [T_eVce @e 999,999,999.99]
ULTPAG   Total Vendidas....:   [][T_sUn @e 999,999,999]   [T_sVce @e 999,999,999.99]
ULTPAG                      [REPL("-",50)]
ULTPAG            TOTAL....:   [][t_eUn-t_sUn @e 999,999,999]   [t_eVce-t_sVce @e 999,999,999.99]
ULTPAG[repl(".",80)]
ULTPAG
ULTPAG                       []POSICAO DAS VENDAS DO PERIODO
ULTPAG

ULTPAG                                   SubTotal       Descontos          Total
ULTPAG   ** Vendas em Dinheiro...: [][Z_VNDES-Z_1VND2 @e 999,999,999.99]  [Z_DSCES-Z_1DSC2 @e 9,999,999.99] [(Z_VNDES-Z_DSCES)-(Z_1VND2-Z_1DSC2) @e 999,999,999.99]
ULTPAG   ** Vendas Cheque Social.: [][Z_1VND2 @e 999,999,999.99]  [Z_1DSC2 @e 9,999,999.99] [Z_1VND2-Z_1DSC2 @e 999,999,999.99]
ULTPAG   ** Vendas em Cheque.....: [][Z_VNDch @e 999,999,999.99]  [Z_DSCCH @e 9,999,999.99] [Z_VNDCH-Z_DSCCH @e 999,999,999.99]
ULTPAG   ** Vendas em Cartao.....: [][Z_VNDct @e 999,999,999.99]  [Z_DSCCT @e 9,999,999.99] [Z_VNDCT-Z_DSCCT @e 999,999,999.99]
ULTPAG   ** Vendas em Convenio...: [][Z_VNDcv @e 999,999,999.99]  [Z_DSCCV @e 9,999,999.99] [Z_VNDCV-Z_DSCCV @e 999,999,999.99]
ULTPAG   ** Vendas em Prazo Misto: [][Z_VNDmt @e 999,999,999.99]  [Z_DSCMT @e 9,999,999.99] [Z_VNDMT-Z_DSCMT @e 999,999,999.99]
ULTPAG                            [REPL("-",50)]
ULTPAG                  TOTAL....: [][Z_TOTVND @e 999,999,999.99]  [Z_DESCO @e 9,999,999.99] [Z_TOTVND-Z_DESCO @e 999,999,999.99]
ULTPAG
ULTPAG
ULTPAG
//ULTPAG                       []POSICAO DO CONVENIO
//ULTPAG
//ULTPAG
//ULTPAG                                   SubTotal       Descontos          Total
//ULTPAG
//ULTPAG   ** Vendas do AFRAFEP-SAUDE (c[z_cafrafep 99]): [][Z_1VND @e 9,999,999.99]  [Z_1DSC @e 9,999,999.99] [Z_1VND-Z_1DSC @e 9,999,999.99]
//ULTPAG         Dinheiro/Cheq/Cartao .....: [][Z_1VND1 @e 9,999,999.99]  [Z_1DSC1 @e 9,999,999.99] [Z_1VND1-Z_1DSC1 @e 9,999,999.99]
//ULTPAG         Vendas em Cheque Social ..: [][Z_1VND2 @e 9,999,999.99]  [Z_1DSC2 @e 9,999,999.99] [Z_1VND2-Z_1DSC2 @e 9,999,999.99]
//ULTPAG         Convenio/Desconto em Folha: [][z_subtotaf @e 9,999,999.99]  [z_dscaf @e 9,999,999.99] [z_subtotaf-z_dscaf @e 9,999,999.99]
//ULTPAG   
//ULTPAG   ** Vendas do SAMD......... (c[z_csand 99]): [][Z_2VND @e 9,999,999.99]  [Z_2DSC @e 9,999,999.99] [Z_2VND-Z_2DSC @e 9,999,999.99]
//ULTPAG         Dinheiro/Cheq/Cartao .....: [][Z_2VND1 @e 9,999,999.99]  [Z_2DSC1 @e 9,999,999.99] [Z_2VND1-Z_2DSC1 @e 9,999,999.99]
//ULTPAG         Convenio/Desconto em Folha: [][Z_2VND-Z_2VND1 @e 9,999,999.99]  [Z_2DSC-Z_2DSC1 @e 9,999,999.99] [(Z_2VND-Z_2DSC)-(Z_2VND1-Z_2DSC1) @e 9,999,999.99]
//ULTPAG   
//ULTPAG   ** Vendas do Func. AFRAFEP (c[z_cfunc 99]): [][Z_3VND @e 9,999,999.99]  [Z_3DSC @e 9,999,999.99] [Z_3VND-Z_3DSC @e 9,999,999.99]
//ULTPAG         Dinheiro/Cheq/Cartao .....: [][Z_3VND1 @e 9,999,999.99]  [Z_3DSC1 @e 9,999,999.99] [Z_3VND1-Z_3DSC1 @e 9,999,999.99]
//ULTPAG         Convenio/Desconto em Folha: [][Z_3VND-Z_3VND1 @e 9,999,999.99]  [Z_3DSC-Z_3DSC1 @e 9,999,999.99] [(Z_3VND-Z_3DSC)-(Z_3VND1-Z_3DSC1) @e 9,999,999.99]
//ULTPAG   
//ULTPAG   ** Vendas em Outros Codigos.....: [][Z_4VND @e 9,999,999.99]  [Z_4DSC @e 9,999,999.99] [Z_4VND-Z_4DSC @e 9,999,999.99]
//ULTPAG         Dinheiro/Cheq/Cartao .....: [][Z_4VND1 @e 9,999,999.99]  [Z_4DSC1 @e 9,999,999.99] [Z_4VND1-Z_4DSC1 @e 9,999,999.99]
//ULTPAG         Convenio/Desconto em Folha: [][Z_4VND-Z_4VND1 @e 9,999,999.99]  [Z_4DSC-Z_4DSC1 @e 9,999,999.99] [(Z_4VND-Z_4DSC)-(Z_4VND1-Z_4DSC1) @e 9,999,999.99]
//ULTPAG   
//ULTPAG                            [REPL("-",50)]
//ULTPAG                   Total das Vendas: [][Z_TOTVND @e 9,999,999.99]  [Z_DESCO @e 9,999,999.99] [Z_TOTVND-Z_DESCO @e 9,999,999.99]
//ULTPAG
//ULTPAG

