Documente Academic
Documente Profesional
Documente Cultură
ch'
#include 'hbutton.ch'
/*
Funcao
ValidPerg Autor Vitor Kwon
Data 12/07/14
*/
User Function FatByMl()
Local oReport
oReport := ReportDef()
oReport:PrintDialog()
Return
Static Function ReportDef()
Local
Local
Local
Local
Local
oReport
oSecTion1
oSecTion2
cPerg := "FatByMl"
obreak
fValidPerg(cPerg)
Pergunte(cPerg,.F.)
oReport:= TReport():New("RelLdComp","Relatrio de Faturamento por Ml",cPer
g,{|oReport|PrintReport(oReport)},"Relatrio de Faturamento por Ml")
oReport:SetTotalInLine(.f.)
oReport:SetLandscape()
oReport:lParamPage := .f.
oSection1 := TRSection():New(oReport,"Relatrio de Faturamento por Ml",{"S
F2","SD2","SB1"})
TRCell():New(oSection1,"F2_EMISSAO","SF2","Emisso",,,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"D2_DOC","SD2","Num.NF",,,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"D2_COD","SD2","Produto",,,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"D2_QUANT","SD2","Quantidade",,,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"B1_ML","SDB1","ML",,,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"D2_PRCVEN","SD2","Vl.Unitrio",,,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"ML","","Total Litros","@E 999,999,999",11,,,,,,,
,,,,.F.)
TRCell():New(oSection1,"D2_TOTAL","SD2","Valor Total",,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"D2_VALIPI","SD2","IPI",,,,,"RIGHT",,,,,,,,.F.)
TRCell():New(oSection1,"D2_VALICM","SD2","ICMS",,,,,"RIGHT",,,,,,,,.F.)
TRCell():New(oSection1,"D2_CF","SD2","CFOP",,,,,,,,,,,,,.t.)
TRCell():New(oSection1,"D2_CONTA","SD2","Conta Contbil",,,,,,,,,,,,,.F.)
TRCell():New(oSection1,"D2_CUSTO1","SD2","Custo",,,,,,,,,,,,,.t.)
TRCell():New(oSection1,"D2_ICMSRET","SD2","ICMS ST",,,,,,,,,,,,,.t.)
TRCell():New(oSection1,"D2_VALIMP5","SD2","COFINS",,,,,,,,,,,,,.t.)
TRCell():New(oSection1,"D2_VALIMP6","SD2","PIS",,,,,,,,,,,,,.t.)
TRCell():New(oSection1,"D2_VALBRUT","SD2","Valor Bruto",,,,,,,,,,,,,.t.)
oBreak := TRBreak():New(oSection1,{|| },{|| "Total: "},.F.)
f.)
)
)
)
.)
.)
.)
.)
TRFunction():New(oSection1:Cell("D2_QUANT"),NIL,"SUM",oBreak,,,,.F.,.f.)
TRFunction():New(oSection1:Cell("ML"),NIL,"SUM",oBreak,,"9999999",,.F.,.
TRFunction():New(oSection1:Cell("D2_TOTAL"),NIL,"SUM",oBreak,,,,.F.,.f.)
TRFunction():New(oSection1:Cell("D2_VALIPI"),NIL,"SUM",oBreak,,,,.F.,.f.
TRFunction():New(oSection1:Cell("D2_VALICM"),NIL,"SUM",oBreak,,,,.F.,.f.
TRFunction():New(oSection1:Cell("D2_CUSTO1"),NIL,"SUM",oBreak,,,,.F.,.f.
TRFunction():New(oSection1:Cell("D2_ICMSRET"),NIL,"SUM",oBreak,,,,.F.,.f
TRFunction():New(oSection1:Cell("D2_VALIMP5"),NIL,"SUM",oBreak,,,,.F.,.f
TRFunction():New(oSection1:Cell("D2_VALIMP6"),NIL,"SUM",oBreak,,,,.F.,.f
TRFunction():New(oSection1:Cell("D2_VALBRUT"),NIL,"SUM",oBreak,,,,.F.,.f
oSection2 := TRSection():New(oReport,"Resumo",{"SF2","SD2","SB1"})
TRCell():New(oSection2,"D2_TOTAL","SD2","Valor Total",,,,,,,,,,,,,.F.)
TRCell():New(oSection2,"D2_VALIPI","SD2","IPI",,,,,"RIGHT",,,,,,,,.F.)
TRCell():New(oSection2,"D2_ICMSRET","SD2","ICMS ST",,,,,,,,,,,,,.t.)
TRCell():New(oSection2,"TOTAL","","Total Geral",,,,,,,,,,,,,,.F.)
Return oReport
/*/
Funcao
PrintReportAutor Bruno de Oliveira Data 29/12/11
Descricao
IMPRIME O RELATORIO
/*/
Static Function PrintReport(oReport)
Local oSection1 := oReport:Section(1)
Local oSection2 := oReport:Section(2)
Local cCFOPs
:= Replace(mv_par05,",","','")
oSection1:BeginQuery()
BeginSql alias "RelLdComp"
%noparser%
Select F2_EMISSAO, D2_DOC, D2_COD, D2_QUANT, B1_ML, D2_PRCVEN, (
D2_QUANT*B1_ML)/1000 ML, D2_TOTAL, D2_VALIPI, D2_VALICM, D2_CF, D2_CONTA, D2_CUS
TO1,
D2_ICMSRET, D2_VALIMP5, D2_VALIMP6, D2_VALBRUT
Funcao
ValidPerg Autor Bruno de Oliveira
Data 29/12/11
/*/
Static Function fValidPerg(cPerg)
Local aArea
Local aRegs
cPerg
aAdd(aRegs,{"01","Da Emisso...............?",
"mv_par01",""
,""
,"","",""})
aAdd(aRegs,{"02","At Emisso..............?",
"mv_par02",""
,""
,"","",""})
aAdd(aRegs,{"03","Do Produto....... .......?",
"mv_par03",""
,""
,"","SB1",""})
aAdd(aRegs,{"04","At Produto..............?",
"mv_par04",""
,""
,"","SB1",""})
aAdd(aRegs,{"05","CFOP's...................?",
"mv_par05",""
,""
,"","",""})
"mv_ch1","D",8 ,0,0,"G",
"mv_ch2","D",8 ,0,0,"G",
"mv_ch3","C",15,0,0,"G",
"mv_ch4","C",15,0,0,"G",
"mv_ch5","C",50,0,0,"G",
dbSelectArea("SX1")
dbSetOrder(1)
For i:=1 to Len(aRegs)
dbSeek(cPerg+aRegs[i][1])//Localiza um registro com determinado
valor da expresso de chave de ndic
If !Found()//found retorna a ultima busca realizada pelo process
amento corrente
RecLock("SX1",!Found()) //ReckLock Bloqueia registro pos
icionado na tabela para comandos de alterao em modo exclusivo
SX1->X1_GRUPO
:= cPerg
SX1->X1_ORDEM
:= aRegs[i][01]
SX1->X1_PERGUNT
:= aRegs[i][02]
SX1->X1_VARIAVL
:= aRegs[i][03]
SX1->X1_TIPO
:= aRegs[i][04]
SX1->X1_TAMANHO
:= aRegs[i][05]
SX1->X1_DECIMAL
:= aRegs[i][06]
SX1->X1_PRESEL
:= aRegs[i][07]
SX1->X1_GSC
:= aRegs[i][08]
SX1->X1_VAR01
:= aRegs[i][09]
SX1->X1_DEF01
:= aRegs[i][10]
SX1->X1_DEF02
:= aRegs[i][11]
SX1->X1_DEF03
:= aRegs[i][12]
SX1->X1_F3
:= aRegs[i][13]
SX1->X1_VALID
:= aRegs[i][14]
MsUnlock()
Endif
Next
RestArea(aArea)
Return