SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250101000000' and data<='20250131235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250101000000' and InvoiceDate<='20250131235959' 
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250101000000' AND v.data<='20250131235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250101000000' AND v.data<='20250131235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250101000000' and data<='20250131235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250101000000' and InvoiceDate<='20250131235959' 
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250101000000' AND v.data<='20250131235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250101000000' AND v.data<='20250131235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250101000000' and data<='20250131235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250101000000' and InvoiceDate<='20250131235959' 
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250101000000' AND v.data<='20250131235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250101000000' AND v.data<='20250131235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250201000000' and data<='20250228235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250201000000' and InvoiceDate<='20250228235959' 
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250201000000' AND v.data<='20250228235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250201000000' AND v.data<='20250228235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250401000000' and data<='20250430235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250401000000' and InvoiceDate<='20250430235959' 
SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250501000000' and data<='20250531235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250501000000' and InvoiceDate<='20250531235959' 
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250501000000' AND v.data<='20250531235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT l.tpdoc as ltpdoc,l.numero as lnumero,l.linha,l.codigo,l.nome,l.qtd,l.preco,l.iva,l.cozinha,l.qtd_cozinha,l.tipo,l.chupito,l.combinado,l.valor,l.guia,l.miva,v.numero as vnumero,v.data,v.tot_valor,v.mesa,v.mpag,v.opr,v.hora,v.factura,v.numero_cf,v.desconto,v.tot_desconto,v.num_doc,v.anulado,v.nif,v.posto,v.tpiva,v.danul,v.data2 as vdata2,v.serie2,v.num2,h.numero  as hash_numero,h.numero2 as hash_numero2,h.data1   as hash_data1,h.data2   as hash_data2,h.valor   as hash_valor,h.hash    as hash_hash,h.versao  as hash_versao,art.miva  as art_miva FROM  vendaslinhas as l left join vendas as v using (posto,tpdoc,numero) left join vendas_hash as h using (posto,tpdoc,numero) left join artigo as art on (art.codigo=l.codigo) WHERE v.data>='20250501000000' AND v.data<='20250531235959' AND l.numero>0 AND l.tpdoc in (1,2,4,11,12,14,21,22,24) ORDER BY l.posto,l.tpdoc,l.Numero,l.linha
SELECT count(*) as qtd,sum(if(tpdoc<>4 and tot_valor>0 and anulado<>1,tot_valor,0)) as totalc,sum(if(tpdoc=4  and tot_valor>0 and anulado<>1,tot_valor,0)) as totald FROM vendas WHERE data>='20250501000000' and data<='20250531235959'  and tpdoc in (1,2,4,11,12,14,21,22,24)  and numero>0 order by Numero;
SELECT count(*) as qtd,sum(if(InvoiceStatus='N',NetTotal,0)) as totalc,sum(0) as totald FROM invoice WHERE InvoiceDate>='20250501000000' and InvoiceDate<='20250531235959' 
