Rev 693 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 693 | Rev 710 | ||
|---|---|---|---|
| Line 674... | Line 674... | ||
| 674 | }); |
674 | }); |
| 675 | }
|
675 | }
|
| 676 | 676 | ||
| 677 | public void adicionarPagamentoComCashback() { |
677 | public void adicionarPagamentoComCashback() { |
| 678 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
678 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 679 | public void execute() { |
- | |
| - | 679 | public void execute() { |
|
| - | 680 | for (VendaFormaPagamento pagamento : getParametrosVenda().getLancamentosPagamentos()) { |
|
| - | 681 | if (pagamento.getFormaPagamento().formaPagamentoEhCashback()) { |
|
| - | 682 | throw new NegocioException("SÓ É PERMITIDO APENAS UM CASHBACK NA VENDA"); |
|
| - | 683 | }
|
|
| - | 684 | }
|
|
| - | 685 | ||
| 680 | Double valorCashback = new Double(getValorPagamento()); |
686 | Double valorCashback = new Double(getValorPagamento()); |
| 681 | Double valorCashbackDisponivel = new Double(getParametrosVenda().getCliente().getValorCashbackDisponivel()); |
687 | Double valorCashbackDisponivel = new Double(getParametrosVenda().getCliente().getValorCashbackDisponivel()); |
| 682 | if (VerificadorUtil.naoEstaNuloOuVazio(valorCashback)) { |
688 | if (VerificadorUtil.naoEstaNuloOuVazio(valorCashback)) { |
| 683 | if (VerificadorUtil.naoEstaNuloOuVazio(valorCashbackDisponivel)) { |
689 | if (VerificadorUtil.naoEstaNuloOuVazio(valorCashbackDisponivel)) { |
| 684 | if (valorCashbackDisponivel < valorCashback) { |
690 | if (valorCashbackDisponivel < valorCashback) { |
| Line 688... | Line 694... | ||
| 688 | }
|
694 | }
|
| 689 | 695 | ||
| 690 | FormaPagamento formaPagamento = formaPagamentoService.consultarPorId(new FormaPagamento(ConstantesSEC.FormasDePagamento.FORMAPAGAMENTO_CASHBACK_28)); |
696 | FormaPagamento formaPagamento = formaPagamentoService.consultarPorId(new FormaPagamento(ConstantesSEC.FormasDePagamento.FORMAPAGAMENTO_CASHBACK_28)); |
| 691 | VendaFormaPagamento vendaFormaPagamento = new VendaFormaPagamento(getEntidade(), formaPagamento); |
697 | VendaFormaPagamento vendaFormaPagamento = new VendaFormaPagamento(getEntidade(), formaPagamento); |
| 692 | vendaFormaPagamento.setValorPagamento(getValorPagamento()); |
698 | vendaFormaPagamento.setValorPagamento(getValorPagamento()); |
| 693 | retirarCashbackCliente(getValorPagamento()); |
- | |
| 694 | adicionarPagamento(vendaFormaPagamento); |
699 | adicionarPagamento(vendaFormaPagamento); |
| - | 700 | retirarCashbackCliente(valorCashback); |
|
| 695 | }
|
701 | }
|
| 696 | 702 | ||
| 697 | private void retirarCashbackCliente(Double valor) { |
703 | private void retirarCashbackCliente(Double valor) { |
| 698 | getParametrosVenda().getCliente().setValorCashbackDisponivel(getParametrosVenda().getCliente().getValorCashbackDisponivel() - valor); |
704 | getParametrosVenda().getCliente().setValorCashbackDisponivel(getParametrosVenda().getCliente().getValorCashbackDisponivel() - valor); |
| - | 705 | }
|
|
| - | 706 | }); |
|
| - | 707 | }
|
|
| - | 708 | public void retirarPagamentosCashback() { |
|
| - | 709 | for (VendaFormaPagamento pagamento : getParametrosVenda().getLancamentosPagamentos()) { |
|
| - | 710 | if (pagamento.getFormaPagamento().formaPagamentoEhCashback()) { |
|
| - | 711 | throw new NegocioException("RETIRE O CASHBACK DA VENDA PARA PROSSEGUIR"); |
|
| - | 712 | }
|
|
| - | 713 | }
|
|
| - | 714 | }
|
|
| - | 715 | ||
| - | 716 | public void retirarPagamentoComCashback(final VendaFormaPagamento pagamento) { |
|
| - | 717 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 718 | public void execute() { |
|
| - | 719 | if (pagamento.getFormaPagamento().formaPagamentoEhCashback()) { |
|
| - | 720 | if (VerificadorUtil.naoEstaNulo(getParametrosVenda().getCliente().getValorCashbackDisponivel())) { |
|
| - | 721 | getParametrosVenda().getCliente().setValorCashbackDisponivel(getParametrosVenda().getCliente().getValorCashbackDisponivel() + pagamento.getValorPagamento()); |
|
| - | 722 | }
|
|
| - | 723 | }
|
|
| 699 | }
|
724 | }
|
| 700 | }); |
725 | }); |
| 701 | }
|
726 | }
|
| 702 | 727 | ||
| 703 | public void adicionarPagamento(final VendaFormaPagamento vendaFormaPagamento) { |
728 | public void adicionarPagamento(final VendaFormaPagamento vendaFormaPagamento) { |
| Line 747... | Line 772... | ||
| 747 | 772 | ||
| 748 | public void removerPagamento(final VendaFormaPagamento pagamento) { |
773 | public void removerPagamento(final VendaFormaPagamento pagamento) { |
| 749 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
774 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 750 | public void execute() { |
775 | public void execute() { |
| 751 | getParametrosVenda().getLancamentosPagamentos().remove(pagamento); |
776 | getParametrosVenda().getLancamentosPagamentos().remove(pagamento); |
| - | 777 | retirarPagamentoComCashback(pagamento); |
|
| 752 | LancadorMensagem.lancarSucesso("PRODUTO REMOVIDO COM SUCESSO"); |
778 | LancadorMensagem.lancarSucesso("PRODUTO REMOVIDO COM SUCESSO"); |
| 753 | }
|
779 | }
|
| 754 | }); |
780 | }); |
| 755 | }
|
781 | }
|
| 756 | 782 | ||
| Line 765... | Line 791... | ||
| 765 | }
|
791 | }
|
| 766 | }); |
792 | }); |
| 767 | }
|
793 | }
|
| 768 | 794 | ||
| 769 | public void retirarCliente() { |
795 | public void retirarCliente() { |
| 770 | getParametrosVenda().setCliente(null); |
- | |
| - | 796 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 797 | public void execute() { |
|
| - | 798 | retirarPagamentosCashback(); |
|
| - | 799 | getParametrosVenda().setCliente(null); |
|
| - | 800 | }
|
|
| - | 801 | }); |
|
| 771 | }
|
802 | }
|
| 772 | 803 | ||
| 773 | public List<Vendedor> consultarVendedoresColaboradores() { |
804 | public List<Vendedor> consultarVendedoresColaboradores() { |
| 774 | return vendedorService.consultarVendedoresColaboradores(); |
805 | return vendedorService.consultarVendedoresColaboradores(); |
| 775 | }
|
806 | }
|
| Line 1149... | Line 1180... | ||
| 1149 | if (getParametrosVenda().getPedidoVinculado().getTipoSituacao().equals(TipoSituacaoPedido.INVALIDO.getValor())) { |
1180 | if (getParametrosVenda().getPedidoVinculado().getTipoSituacao().equals(TipoSituacaoPedido.INVALIDO.getValor())) { |
| 1150 | throw new NegocioException("VÍNCULO NÃO REALIZADO: PEDIDO INVÁLIDO"); |
1181 | throw new NegocioException("VÍNCULO NÃO REALIZADO: PEDIDO INVÁLIDO"); |
| 1151 | }
|
1182 | }
|
| 1152 | }
|
1183 | }
|
| 1153 | }); |
1184 | }); |
| - | 1185 | }
|
|
| - | 1186 | ||
| - | 1187 | public void verificarCashback() { |
|
| - | 1188 | if (VerificadorUtil.naoEstaNulo(getParametrosVenda().getCliente())) { |
|
| - | 1189 | getParametrosVenda().getCliente().setValorCashbackDisponivel(cashbackService.consultarSaldoCliente(getParametrosVenda().getCliente().getSequencial())); |
|
| - | 1190 | }
|
|
| 1154 | }
|
1191 | }
|
| 1155 | 1192 | ||
| 1156 | }
|
1193 | }
|