Rev 704 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 704 | Rev 710 | ||
|---|---|---|---|
| Line 282... | Line 282... | ||
| 282 | Venda venda = new Venda(parametrosVenda); |
282 | Venda venda = new Venda(parametrosVenda); |
| 283 | cadastrar(venda); |
283 | cadastrar(venda); |
| 284 | cadastrarLancamentos(parametrosVenda, venda); |
284 | cadastrarLancamentos(parametrosVenda, venda); |
| 285 | cadastrarPagamentos(parametrosVenda, venda); |
285 | cadastrarPagamentos(parametrosVenda, venda); |
| 286 | cadastrarPosVenda(venda); |
286 | cadastrarPosVenda(venda); |
| 287 | atualizarCashback(parametrosVenda, venda); |
- | |
| - | 287 | atualizarCashback(parametrosVenda, venda.getSequencial()); |
|
| 288 | alterarSituacaoPedido(parametrosVenda.getPedidoVinculado(), venda); |
288 | alterarSituacaoPedido(parametrosVenda.getPedidoVinculado(), venda); |
| 289 | enviarAlertasPorEmail(parametrosVenda, venda); |
289 | enviarAlertasPorEmail(parametrosVenda, venda); |
| 290 | venda.verificarSePermiteEmissaoNotaFiscal(); |
290 | venda.verificarSePermiteEmissaoNotaFiscal(); |
| 291 | venda.setEmitirNotaFiscal(verificarEmissaoNotaFiscal(parametrosVenda, venda)); |
291 | venda.setEmitirNotaFiscal(verificarEmissaoNotaFiscal(parametrosVenda, venda)); |
| 292 | return venda; |
292 | return venda; |
| Line 675... | Line 675... | ||
| 675 | }
|
675 | }
|
| 676 | }
|
676 | }
|
| 677 | return total; |
677 | return total; |
| 678 | }
|
678 | }
|
| 679 | 679 | ||
| 680 | //TODO : AJUSTAR CASHBACK AO ALTERAR NA VENDA
|
- | |
| 681 | private void ajustarCashbackSeAlterarCliente(ParametrosVendaDTO parametrosVenda) { |
680 | private void ajustarCashbackSeAlterarCliente(ParametrosVendaDTO parametrosVenda) { |
| 682 | // parametrosVenda.getVenda().setCliente(parametrosVenda.getCliente());
|
- | |
| 683 | Cliente clienteAnterior = parametrosVenda.getVenda().getCliente(); |
681 | Cliente clienteAnterior = parametrosVenda.getVenda().getCliente(); |
| 684 | Cliente clienteNovo = parametrosVenda.getCliente(); |
682 | Cliente clienteNovo = parametrosVenda.getCliente(); |
| 685 | if (VerificadorUtil.naoEstaNulo(clienteAnterior) && VerificadorUtil.estaNulo(clienteNovo)) { |
683 | if (VerificadorUtil.naoEstaNulo(clienteAnterior) && VerificadorUtil.estaNulo(clienteNovo)) { |
| 686 | // RETIRAR CASHBACK DO CLIENTE ANTERIOR
|
- | |
| 687 | }
|
- | |
| 688 | if (VerificadorUtil.naoEstaNulo(clienteNovo) && VerificadorUtil.estaNulo(clienteAnterior)) { |
- | |
| 689 | // ADICIONAR CASHBACK DO CLIENTE NOVO
|
- | |
| 690 | }
|
- | |
| 691 | if (VerificadorUtil.naoEstaNulo(clienteAnterior) && VerificadorUtil.naoEstaNulo(clienteNovo)) { |
- | |
| - | 684 | cashbackService.excluirCashbackVenda(parametrosVenda.getVenda().getSequencial()); |
|
| - | 685 | } else if (VerificadorUtil.naoEstaNulo(clienteNovo) && VerificadorUtil.estaNulo(clienteAnterior)) { |
|
| - | 686 | atualizarCashback(parametrosVenda, parametrosVenda.getVenda().getSequencial()); |
|
| - | 687 | } else if (VerificadorUtil.naoEstaNulo(clienteAnterior) && VerificadorUtil.naoEstaNulo(clienteNovo)) { |
|
| 692 | if (!clienteAnterior.getSequencial().equals(clienteNovo.getSequencial())) { |
688 | if (!clienteAnterior.getSequencial().equals(clienteNovo.getSequencial())) { |
| 693 | // RETIRAR CASHBACK DO CLIENTE ANTERIOR
|
- | |
| 694 | // ADICIONAR CASHBACK DO CLIENTE NOVO
|
- | |
| - | 689 | cashbackService.excluirCashbackVenda(parametrosVenda.getVenda().getSequencial()); |
|
| - | 690 | atualizarCashback(parametrosVenda, parametrosVenda.getVenda().getSequencial()); |
|
| - | 691 | } else { |
|
| - | 692 | Double valorCashbackAnterior = 0.0; |
|
| - | 693 | Double valorCashbackPosterior = 0.0; |
|
| - | 694 | List<VendaFormaPagamento> pagamentosAnteriores = consultarPagamentosCadastrados(parametrosVenda); |
|
| - | 695 | if (!VerificadorUtil.isListaNulaOuVazia(pagamentosAnteriores)) { |
|
| - | 696 | for (VendaFormaPagamento pagamento : pagamentosAnteriores) { |
|
| - | 697 | if (pagamento.getCodigoDaFormaPagamento().equals(ConstantesSEC.FormasDePagamento.FORMAPAGAMENTO_CASHBACK_28)) { |
|
| - | 698 | valorCashbackAnterior += pagamento.getValorPagamento(); |
|
| - | 699 | }
|
|
| - | 700 | }
|
|
| - | 701 | }
|
|
| - | 702 | if (!VerificadorUtil.isListaNulaOuVazia(parametrosVenda.getLancamentosPagamentos())) { |
|
| - | 703 | for (VendaFormaPagamento pagamento : parametrosVenda.getLancamentosPagamentos()) { |
|
| - | 704 | if (pagamento.getCodigoDaFormaPagamento().equals(ConstantesSEC.FormasDePagamento.FORMAPAGAMENTO_CASHBACK_28)) { |
|
| - | 705 | valorCashbackPosterior += pagamento.getValorPagamento(); |
|
| - | 706 | }
|
|
| - | 707 | }
|
|
| - | 708 | }
|
|
| - | 709 | if (!valorCashbackAnterior.equals(valorCashbackPosterior)) { |
|
| - | 710 | cashbackService.excluirCashbackVenda(parametrosVenda.getVenda().getSequencial()); |
|
| - | 711 | atualizarCashback(parametrosVenda, parametrosVenda.getVenda().getSequencial()); |
|
| - | 712 | }
|
|
| 695 | }
|
713 | }
|
| 696 | }
|
714 | }
|
| 697 | }
|
715 | }
|
| 698 | 716 | ||
| 699 | private void atualizarDadosDaVenda(ParametrosVendaDTO parametrosVenda) { |
717 | private void atualizarDadosDaVenda(ParametrosVendaDTO parametrosVenda) { |
| Line 810... | Line 828... | ||
| 810 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCartao() || |
828 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCartao() || |
| 811 | vendaFormaPagamento.getFormaPagamento().formaPagamentoEhPix()) { |
829 | vendaFormaPagamento.getFormaPagamento().formaPagamentoEhPix()) { |
| 812 | if (VerificadorUtil.estaNulo(parametrosVenda.getMaquineta())) { |
830 | if (VerificadorUtil.estaNulo(parametrosVenda.getMaquineta())) { |
| 813 | throw new NegocioException("Informe a maquineta"); |
831 | throw new NegocioException("Informe a maquineta"); |
| 814 | }
|
832 | }
|
| - | 833 | }
|
|
| - | 834 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCashback() && VerificadorUtil.estaNulo(parametrosVenda.getCliente())) { |
|
| - | 835 | throw new NegocioException("Informe o cliente para utilizar o cashback como pagamento"); |
|
| 815 | }
|
836 | }
|
| 816 | }
|
837 | }
|
| 817 | if (possuiLancamentoPersonalizacao(parametrosVenda.getLancamentos())) { |
838 | if (possuiLancamentoPersonalizacao(parametrosVenda.getLancamentos())) { |
| 818 | if (VerificadorUtil.estaNulo(parametrosVenda.getCliente()) && VerificadorUtil.estaNuloOuVazio(parametrosVenda.getObservacao())) { |
839 | if (VerificadorUtil.estaNulo(parametrosVenda.getCliente()) && VerificadorUtil.estaNuloOuVazio(parametrosVenda.getObservacao())) { |
| 819 | throw new NegocioException("Informe o cliente ou o contato do cliente nas observações"); |
840 | throw new NegocioException("Informe o cliente ou o contato do cliente nas observações"); |
| Line 920... | Line 941... | ||
| 920 | 941 | ||
| 921 | private void cadastrarPosVenda(Venda venda) { |
942 | private void cadastrarPosVenda(Venda venda) { |
| 922 | posVendaService.iniciarPosVenda(venda); |
943 | posVendaService.iniciarPosVenda(venda); |
| 923 | }
|
944 | }
|
| 924 | 945 | ||
| 925 | private void atualizarCashback(ParametrosVendaDTO parametrosVenda, Venda venda) { |
- | |
| - | 946 | private void atualizarCashback(ParametrosVendaDTO parametrosVenda, Long sequencialVenda) { |
|
| 926 | // RETIRAR DO SALDO O CASHBACK
|
947 | // RETIRAR DO SALDO O CASHBACK
|
| 927 | Double valorCashback = 0.0; |
948 | Double valorCashback = 0.0; |
| 928 | for (VendaFormaPagamento vendaFormaPagamento : parametrosVenda.getLancamentosPagamentos()) { |
949 | for (VendaFormaPagamento vendaFormaPagamento : parametrosVenda.getLancamentosPagamentos()) { |
| 929 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCashback()) { |
950 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCashback()) { |
| 930 | valorCashback += vendaFormaPagamento.getValorPagamento(); |
951 | valorCashback += vendaFormaPagamento.getValorPagamento(); |
| 931 | }
|
952 | }
|
| 932 | }
|
953 | }
|
| 933 | if (valorCashback > 0.0) { |
954 | if (valorCashback > 0.0) { |
| 934 | cashbackService.utilizarCashback(venda, valorCashback); |
- | |
| - | 955 | cashbackService.utilizarCashback(sequencialVenda, parametrosVenda.getCliente().getSequencial(), valorCashback); |
|
| 935 | } else { |
956 | } else { |
| 936 | // GERAR SE NÃO HOUVER UTILIZAÇÃO DO CASHBACK
|
957 | // GERAR SE NÃO HOUVER UTILIZAÇÃO DO CASHBACK
|
| 937 | cashbackService.gerarCashback(parametrosVenda, venda); |
- | |
| - | 958 | cashbackService.gerarCashback(parametrosVenda, sequencialVenda); |
|
| 938 | }
|
959 | }
|
| 939 | 960 | ||
| 940 | }
|
961 | }
|
| 941 | 962 | ||
| 942 | private void alterarPagamentos(ParametrosVendaDTO parametrosVenda) { |
963 | private void alterarPagamentos(ParametrosVendaDTO parametrosVenda) { |