cancel
Showing results for 
Search instead for 
Did you mean: 

Relatório de Faturamento

Former Member
0 Kudos

Olá a todos!

Alguém teria um relatório de faturamento - ou mesmo uma consulta - que tenha como filtros período e filial?

Desde já agradeço!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Boa tarde,

Tenho um meio simples, mas ajuda muito por aqui, espero que te ajude.

select

t1.Serial  'NF',

t1.DocEntry ,

t1.DocDate 'Data',

Substring(t3.SlpName,1,15) 'Repres',

Substring(t1.CardName,1,25)  'Cliente' ,

t1.DocTotal    'Faturamento Bruto',

t1.DocTotal-t1.vatsum    'Faturamento s/Impostos',

isnull( (sum(t2.taxsum)),'0')  'IPI',

t1.DocTotal-t1.vatsum + sum(t2.taxsum)  'Faturamento c/IPI',

t1.DocTotal  - (t1.DocTotal-t1.vatsum) - (isnull( (sum(t2.taxsum)),'0')) 'ST'

from  oinv t1        

inner join inv4 t2 on t2.docentry = t1.docentry

left  join oslp t3 on T3.slpcode = t1.slpcode

left  join ocrd t4            on t4.cardcode = t1.cardcode

left  join [@GRUPO_CLIENTES] t5 on t5.Code = t4.U_Grp_Cliente

where 

T1.DocDate between '[%0]' and '[%1]'

and  t1.BpLID =  '[%2]'

and left(t2.StaCode,3) ='IPI'

and t1.InvntSttus = 'O' 

and t1.DocTotal >0

GROUP BY t1.CardName,t1.DocTotal,t3.SlpName,t1.Serial,t1.DocEntry,t1.DocDate,t5.Name,t1.DocTotal-t1.vatsum

order by t1.Serial desc