Rev 686 | Rev 690 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 686 | Rev 689 | ||
|---|---|---|---|
| Line 187... | Line 187... | ||
| 187 | List<NotaFiscal> notasVinculadas = desvincularNotaFiscalEmitida(venda, usuario); |
187 | List<NotaFiscal> notasVinculadas = desvincularNotaFiscalEmitida(venda, usuario); |
| 188 | verificarSeExisteLancamentoFinanceiro(venda); |
188 | verificarSeExisteLancamentoFinanceiro(venda); |
| 189 | reporEstoqueAoExcluirVenda(venda); |
189 | reporEstoqueAoExcluirVenda(venda); |
| 190 | excluirPosVenda(venda); |
190 | excluirPosVenda(venda); |
| 191 | excluirPagamentos(venda); |
191 | excluirPagamentos(venda); |
| - | 192 | excluirCashback(venda); |
|
| 192 | desvincularPedido(venda, usuario); |
193 | desvincularPedido(venda, usuario); |
| 193 | super.excluir(venda); |
194 | super.excluir(venda); |
| 194 | enviarEmail(venda, usuario, notasVinculadas); |
195 | enviarEmail(venda, usuario, notasVinculadas); |
| 195 | }
|
196 | }
|
| 196 | 197 | ||
| Line 224... | Line 225... | ||
| 224 | private void excluirPagamentos(Venda venda) { |
225 | private void excluirPagamentos(Venda venda) { |
| 225 | for (VendaFormaPagamento vendaFormaPagamento : venda.getListaVendaFormaPagamentos()) { |
226 | for (VendaFormaPagamento vendaFormaPagamento : venda.getListaVendaFormaPagamentos()) { |
| 226 | // vendaFormaPagamentoService.excluirPorId(vendaFormaPagamento);
|
227 | // vendaFormaPagamentoService.excluirPorId(vendaFormaPagamento);
|
| 227 | vendaFormaPagamentoService.excluir(vendaFormaPagamento); |
228 | vendaFormaPagamentoService.excluir(vendaFormaPagamento); |
| 228 | }
|
229 | }
|
| - | 230 | }
|
|
| - | 231 | ||
| - | 232 | private void excluirCashback(Venda venda) { |
|
| - | 233 | cashbackService.excluirCashbackVenda(venda.getSequencial()); |
|
| 229 | }
|
234 | }
|
| 230 | 235 | ||
| 231 | private void desvincularPedido(Venda venda, Usuario usuario) { |
236 | private void desvincularPedido(Venda venda, Usuario usuario) { |
| 232 | Pedido pedidoCompleto = pedidoService.consultarPedidoCompletoDaVenda(venda); |
237 | Pedido pedidoCompleto = pedidoService.consultarPedidoCompletoDaVenda(venda); |
| 233 | if (VerificadorUtil.naoEstaNulo(pedidoCompleto)) { |
238 | if (VerificadorUtil.naoEstaNulo(pedidoCompleto)) { |
| Line 697... | Line 702... | ||
| 697 | }
|
702 | }
|
| 698 | 703 | ||
| 699 | @Override |
704 | @Override |
| 700 | public Double obterValorTotalBrutoDeVendasPorLojaEePeriodo(Loja loja, Date dataInicial, Date dataFinal) { |
705 | public Double obterValorTotalBrutoDeVendasPorLojaEePeriodo(Loja loja, Date dataInicial, Date dataFinal) { |
| 701 | Double valorTotal = vendaRepository.obterValorTotalBrutoDeVendasPorLojaEePeriodo(loja, dataInicial, dataFinal); |
706 | Double valorTotal = vendaRepository.obterValorTotalBrutoDeVendasPorLojaEePeriodo(loja, dataInicial, dataFinal); |
| 702 | valorTotal = valorTotal - vendaRepository.obterValorDeCuponsUtilizadosPorLojaEePeriodo(new ParametrosConsultaVendasDTO(loja, dataInicial, dataFinal)); |
- | |
| - | 707 | valorTotal = valorTotal - vendaRepository.obterValorDeCuponsOuCashbackUtilizadosPorLojaEePeriodo(new ParametrosConsultaVendasDTO(loja, dataInicial, dataFinal)); |
|
| 703 | return valorTotal; |
708 | return valorTotal; |
| 704 | }
|
709 | }
|
| 705 | 710 | ||
| 706 | @Override |
711 | @Override |
| 707 | public Double obterValorTotalBrutoDeVendasPorLojaEePeriodo(ParametrosConsultaVendasDTO parametrosConsulta) { |
712 | public Double obterValorTotalBrutoDeVendasPorLojaEePeriodo(ParametrosConsultaVendasDTO parametrosConsulta) { |
| 708 | Double valorTotal = vendaRepository.obterValorTotalBrutoDeVendasPorLojaEePeriodo(parametrosConsulta); |
713 | Double valorTotal = vendaRepository.obterValorTotalBrutoDeVendasPorLojaEePeriodo(parametrosConsulta); |
| 709 | valorTotal = valorTotal - vendaRepository.obterValorDeCuponsUtilizadosPorLojaEePeriodo(parametrosConsulta); |
- | |
| - | 714 | valorTotal = valorTotal - vendaRepository.obterValorDeCuponsOuCashbackUtilizadosPorLojaEePeriodo(parametrosConsulta); |
|
| 710 | return valorTotal; |
715 | return valorTotal; |
| 711 | }
|
716 | }
|
| 712 | 717 | ||
| 713 | @Override |
718 | @Override |
| 714 | public Double obterValorTotalDeDescontosPorLojaEePeriodo(ParametrosConsultaVendasDTO parametrosConsulta) { |
719 | public Double obterValorTotalDeDescontosPorLojaEePeriodo(ParametrosConsultaVendasDTO parametrosConsulta) { |
| Line 891... | Line 896... | ||
| 891 | posVendaService.iniciarPosVenda(venda); |
896 | posVendaService.iniciarPosVenda(venda); |
| 892 | }
|
897 | }
|
| 893 | 898 | ||
| 894 | private void atualizarCashback(ParametrosVendaDTO parametrosVenda, Venda venda) { |
899 | private void atualizarCashback(ParametrosVendaDTO parametrosVenda, Venda venda) { |
| 895 | // RETIRAR DO SALDO O CASHBACK
|
900 | // RETIRAR DO SALDO O CASHBACK
|
| 896 | - | ||
| 897 | - | ||
| 898 | // GERAR SE NÃO HOUVER UTILIZAÇÃO DO CASHBACK
|
- | |
| 899 | cashbackService.gerarCashback(parametrosVenda, venda); |
- | |
| - | 901 | Double valorCashback = 0.0; |
|
| - | 902 | for (VendaFormaPagamento vendaFormaPagamento : parametrosVenda.getLancamentosPagamentos()) { |
|
| - | 903 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCashback()) { |
|
| - | 904 | valorCashback += vendaFormaPagamento.getValorPagamento(); |
|
| - | 905 | }
|
|
| - | 906 | }
|
|
| - | 907 | if (valorCashback > 0.0) { |
|
| - | 908 | cashbackService.utilizarCashback(venda, valorCashback); |
|
| - | 909 | } else { |
|
| - | 910 | // GERAR SE NÃO HOUVER UTILIZAÇÃO DO CASHBACK
|
|
| - | 911 | cashbackService.gerarCashback(parametrosVenda, venda); |
|
| - | 912 | }
|
|
| 900 | 913 | ||
| 901 | }
|
914 | }
|
| 902 | 915 | ||
| 903 | private void alterarPagamentos(ParametrosVendaDTO parametrosVenda) { |
916 | private void alterarPagamentos(ParametrosVendaDTO parametrosVenda) { |
| 904 | excluirPagamentosRetiradosDaLista(parametrosVenda, consultarPagamentosCadastrados(parametrosVenda)); |
917 | excluirPagamentosRetiradosDaLista(parametrosVenda, consultarPagamentosCadastrados(parametrosVenda)); |