Skip to content

Instantly share code, notes, and snippets.

@diego-aslz
Created June 5, 2016 18:09
Show Gist options
  • Save diego-aslz/58fa454af0e834982bc6ca84f818c2da to your computer and use it in GitHub Desktop.
Save diego-aslz/58fa454af0e834982bc6ca84f818c2da to your computer and use it in GitHub Desktop.
SELECT
I.ID_PRODUTO,
P.NOME,
SUM(I.QUANTIDADE) AS QUANTIDADE,
AVG(I.VALOR_UNITARIO) AS VALOR_UNITARIO,
SUM(I.DESCONTO) AS DESCONTO,
SUM(I.VALOR) AS VALOR,
MIN(I.DT_LANCAMENTO) AS DT_LANCAMENTO
FROM ITENS I
JOIN PRODUTOS P
ON P.ID = I.ID_PRODUTO
WHERE ID_VENDA = :VENDA
GROUP BY I.ID_PRODUTO, P.NOME
ORDER BY MIN(DT_LANCAMENTO)
procedure TFVendasCad.ImprimeFechamento;
begin
if FRFechamentoVenda = nil then
FRFechamentoVenda := TFRFechamentoVenda.Create(Application);
DMConfiguracoes.QConfiguracoes.Close;
DMConfiguracoes.QConfiguracoes.Open;
QItensFechamento.Close;
QItensFechamento.ParamByName('VENDA').AsInteger := QCadastroID.Value;
QItensFechamento.Open;
FRFechamentoVenda.QRRelatorio.Preview;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment