Rev 602 | Rev 685 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 602 | Rev 635 | ||
|---|---|---|---|
| Line 74... | Line 74... | ||
| 74 | import br.com.ec.domain.service.lancamento.LancamentoService; |
74 | import br.com.ec.domain.service.lancamento.LancamentoService; |
| 75 | import br.com.ec.domain.service.loja.LojaService; |
75 | import br.com.ec.domain.service.loja.LojaService; |
| 76 | import br.com.ec.domain.service.modelo.ModeloService; |
76 | import br.com.ec.domain.service.modelo.ModeloService; |
| 77 | import br.com.ec.domain.service.parcela.ParcelaService; |
77 | import br.com.ec.domain.service.parcela.ParcelaService; |
| 78 | import br.com.ec.domain.service.pedido.PedidoService; |
78 | import br.com.ec.domain.service.pedido.PedidoService; |
| - | 79 | import br.com.ec.domain.service.posvenda.PosVendaService; |
|
| 79 | import br.com.ec.domain.service.produto.ProdutoService; |
80 | import br.com.ec.domain.service.produto.ProdutoService; |
| 80 | import br.com.ec.domain.service.produtodaloja.ProdutoLojaService; |
81 | import br.com.ec.domain.service.produtodaloja.ProdutoLojaService; |
| 81 | import br.com.ec.domain.service.usuario.UsuarioService; |
82 | import br.com.ec.domain.service.usuario.UsuarioService; |
| 82 | import br.com.ec.domain.service.venda.VendaService; |
83 | import br.com.ec.domain.service.venda.VendaService; |
| 83 | import br.com.ec.domain.service.vendaformapagamento.VendaFormaPagamentoService; |
84 | import br.com.ec.domain.service.vendaformapagamento.VendaFormaPagamentoService; |
| Line 112... | Line 113... | ||
| 112 | private CupomService cupomService; |
113 | private CupomService cupomService; |
| 113 | private BancoHorasService bancoHorasService; |
114 | private BancoHorasService bancoHorasService; |
| 114 | private EstoqueAuditoriaService estoqueAuditoriaService; |
115 | private EstoqueAuditoriaService estoqueAuditoriaService; |
| 115 | private VigenciaService vigenciaService; |
116 | private VigenciaService vigenciaService; |
| 116 | private UsuarioService usuarioService; |
117 | private UsuarioService usuarioService; |
| - | 118 | private PosVendaService posVendaService; |
|
| 117 | 119 | ||
| 118 | private Ordenador ordenador; |
120 | private Ordenador ordenador; |
| 119 | private NotaFiscalRepository notaFiscalRepository; |
121 | private NotaFiscalRepository notaFiscalRepository; |
| 120 | 122 | ||
| 121 | @Autowired |
123 | @Autowired |
| Line 123... | Line 125... | ||
| 123 | VendaFormaPagamentoService vendaFormaPagamentoService, ProdutoService produtoService, ProdutoLojaService produtoLojaService, |
125 | VendaFormaPagamentoService vendaFormaPagamentoService, ProdutoService produtoService, ProdutoLojaService produtoLojaService, |
| 124 | VendedorService vendedorService, FuncionarioService funcionarioService, LojaService lojaService, PedidoService pedidoService, |
126 | VendedorService vendedorService, FuncionarioService funcionarioService, LojaService lojaService, PedidoService pedidoService, |
| 125 | ParcelaService parcelaService, AvaliacaoService avaliacaoService, AvaliacaoFuncionarioService avaliacaoFuncionarioService, |
127 | ParcelaService parcelaService, AvaliacaoService avaliacaoService, AvaliacaoFuncionarioService avaliacaoFuncionarioService, |
| 126 | AvaliacaoLojaService avaliacaoLojaService, VendaVivoService vendaVivoService, ModeloService modeloService, CupomService cupomService, |
128 | AvaliacaoLojaService avaliacaoLojaService, VendaVivoService vendaVivoService, ModeloService modeloService, CupomService cupomService, |
| 127 | BancoHorasService bancoHorasService, EstoqueAuditoriaService estoqueAuditoriaService, VigenciaService vigenciaService, |
129 | BancoHorasService bancoHorasService, EstoqueAuditoriaService estoqueAuditoriaService, VigenciaService vigenciaService, |
| 128 | UsuarioService usuarioService, NotaFiscalRepository notaFiscalRepository) { |
- | |
| - | 130 | UsuarioService usuarioService, PosVendaService posVendaService, NotaFiscalRepository notaFiscalRepository) { |
|
| 129 | super(validador); |
131 | super(validador); |
| 130 | this.vendaRepository = vendaRepository; |
132 | this.vendaRepository = vendaRepository; |
| 131 | this.funcionarioService = funcionarioService; |
133 | this.funcionarioService = funcionarioService; |
| 132 | this.lancamentoService = lancamentoService; |
134 | this.lancamentoService = lancamentoService; |
| 133 | this.vendaFormaPagamentoService = vendaFormaPagamentoService; |
135 | this.vendaFormaPagamentoService = vendaFormaPagamentoService; |
| Line 145... | Line 147... | ||
| 145 | this.cupomService = cupomService; |
147 | this.cupomService = cupomService; |
| 146 | this.bancoHorasService = bancoHorasService; |
148 | this.bancoHorasService = bancoHorasService; |
| 147 | this.estoqueAuditoriaService = estoqueAuditoriaService; |
149 | this.estoqueAuditoriaService = estoqueAuditoriaService; |
| 148 | this.vigenciaService = vigenciaService; |
150 | this.vigenciaService = vigenciaService; |
| 149 | this.usuarioService = usuarioService; |
151 | this.usuarioService = usuarioService; |
| - | 152 | this.posVendaService = posVendaService; |
|
| 150 | this.notaFiscalRepository = notaFiscalRepository; |
153 | this.notaFiscalRepository = notaFiscalRepository; |
| 151 | this.ordenador = new OrdenadorImpl(); |
154 | this.ordenador = new OrdenadorImpl(); |
| 152 | }
|
155 | }
|
| 153 | 156 | ||
| 154 | @Override |
157 | @Override |
| Line 179... | Line 182... | ||
| 179 | 182 | ||
| 180 | public void excluirVenda(Venda venda, Usuario usuario) { |
183 | public void excluirVenda(Venda venda, Usuario usuario) { |
| 181 | List<NotaFiscal> notasVinculadas = desvincularNotaFiscalEmitida(venda, usuario); |
184 | List<NotaFiscal> notasVinculadas = desvincularNotaFiscalEmitida(venda, usuario); |
| 182 | verificarSeExisteLancamentoFinanceiro(venda); |
185 | verificarSeExisteLancamentoFinanceiro(venda); |
| 183 | reporEstoqueAoExcluirVenda(venda); |
186 | reporEstoqueAoExcluirVenda(venda); |
| - | 187 | excluirPosVenda(venda); |
|
| 184 | excluirPagamentos(venda); |
188 | excluirPagamentos(venda); |
| 185 | desvincularPedido(venda, usuario); |
189 | desvincularPedido(venda, usuario); |
| 186 | super.excluir(venda); |
190 | super.excluir(venda); |
| 187 | enviarEmail(venda, usuario, notasVinculadas); |
191 | enviarEmail(venda, usuario, notasVinculadas); |
| 188 | }
|
192 | }
|
| Line 206... | Line 210... | ||
| 206 | 210 | ||
| 207 | public void reporEstoqueAoExcluirVenda(Venda venda) { |
211 | public void reporEstoqueAoExcluirVenda(Venda venda) { |
| 208 | for (Lancamento lancamento : venda.getLancamentos()) { |
212 | for (Lancamento lancamento : venda.getLancamentos()) { |
| 209 | alterarEstoqueProduto(1, venda.getLoja(), lancamento.getProduto().getCodigo(), lancamento.getTipoPersonalizacao()); |
213 | alterarEstoqueProduto(1, venda.getLoja(), lancamento.getProduto().getCodigo(), lancamento.getTipoPersonalizacao()); |
| 210 | }
|
214 | }
|
| - | 215 | }
|
|
| - | 216 | ||
| - | 217 | public void excluirPosVenda(Venda venda) { |
|
| - | 218 | posVendaService.excluirPosVenda(venda.getSequencial()); |
|
| 211 | }
|
219 | }
|
| 212 | 220 | ||
| 213 | private void excluirPagamentos(Venda venda) { |
221 | private void excluirPagamentos(Venda venda) { |
| 214 | for (VendaFormaPagamento vendaFormaPagamento : venda.getListaVendaFormaPagamentos()) { |
222 | for (VendaFormaPagamento vendaFormaPagamento : venda.getListaVendaFormaPagamentos()) { |
| 215 | // vendaFormaPagamentoService.excluirPorId(vendaFormaPagamento);
|
223 | // vendaFormaPagamentoService.excluirPorId(vendaFormaPagamento);
|
| Line 263... | Line 271... | ||
| 263 | lancarExcecaoSeValoresNaoSaoIguais(parametrosVenda); |
271 | lancarExcecaoSeValoresNaoSaoIguais(parametrosVenda); |
| 264 | Venda venda = new Venda(parametrosVenda); |
272 | Venda venda = new Venda(parametrosVenda); |
| 265 | cadastrar(venda); |
273 | cadastrar(venda); |
| 266 | cadastrarLancamentos(parametrosVenda, venda); |
274 | cadastrarLancamentos(parametrosVenda, venda); |
| 267 | cadastrarPagamentos(parametrosVenda, venda); |
275 | cadastrarPagamentos(parametrosVenda, venda); |
| - | 276 | cadastrarPosVenda(venda); |
|
| 268 | alterarSituacaoPedido(parametrosVenda.getPedidoVinculado(), venda); |
277 | alterarSituacaoPedido(parametrosVenda.getPedidoVinculado(), venda); |
| 269 | enviarAlertasPorEmail(parametrosVenda, venda); |
278 | enviarAlertasPorEmail(parametrosVenda, venda); |
| 270 | venda.verificarSePermiteEmissaoNotaFiscal(); |
279 | venda.verificarSePermiteEmissaoNotaFiscal(); |
| 271 | venda.setEmitirNotaFiscal(verificarEmissaoNotaFiscal(parametrosVenda, venda)); |
280 | venda.setEmitirNotaFiscal(verificarEmissaoNotaFiscal(parametrosVenda, venda)); |
| 272 | return venda; |
281 | return venda; |
| Line 862... | Line 871... | ||
| 862 | vendaFormaPagamento.setVenda(venda); |
871 | vendaFormaPagamento.setVenda(venda); |
| 863 | vendaFormaPagamentoService.cadastrar(vendaFormaPagamento); |
872 | vendaFormaPagamentoService.cadastrar(vendaFormaPagamento); |
| 864 | utilizarCupom(vendaFormaPagamento.getCupom()); |
873 | utilizarCupom(vendaFormaPagamento.getCupom()); |
| 865 | }
|
874 | }
|
| 866 | }
|
875 | }
|
| 867 | - | ||
| - | 876 | ||
| 868 | private void adicionarMaquineta(VendaFormaPagamento vendaFormaPagamento, ParametrosVendaDTO parametrosVenda, Venda venda) { |
877 | private void adicionarMaquineta(VendaFormaPagamento vendaFormaPagamento, ParametrosVendaDTO parametrosVenda, Venda venda) { |
| 869 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCartao()) { |
878 | if (vendaFormaPagamento.getFormaPagamento().formaPagamentoEhCartao()) { |
| 870 | if (VerificadorUtil.estaNulo(parametrosVenda.getMaquineta())) { |
879 | if (VerificadorUtil.estaNulo(parametrosVenda.getMaquineta())) { |
| 871 | parametrosVenda.setMaquineta(parametrosVenda.getLoja().getMaquineta()); |
880 | parametrosVenda.setMaquineta(parametrosVenda.getLoja().getMaquineta()); |
| 872 | }
|
881 | }
|
| 873 | venda.setMaquineta(parametrosVenda.getMaquineta()); |
882 | venda.setMaquineta(parametrosVenda.getMaquineta()); |
| 874 | }
|
883 | }
|
| - | 884 | }
|
|
| - | 885 | ||
| - | 886 | private void cadastrarPosVenda(Venda venda) { |
|
| - | 887 | posVendaService.iniciarPosVenda(venda); |
|
| 875 | }
|
888 | }
|
| 876 | 889 | ||
| 877 | private void alterarPagamentos(ParametrosVendaDTO parametrosVenda) { |
890 | private void alterarPagamentos(ParametrosVendaDTO parametrosVenda) { |
| 878 | excluirPagamentosRetiradosDaLista(parametrosVenda, consultarPagamentosCadastrados(parametrosVenda)); |
891 | excluirPagamentosRetiradosDaLista(parametrosVenda, consultarPagamentosCadastrados(parametrosVenda)); |
| 879 | cadastrarNovosPagamentos(parametrosVenda); |
892 | cadastrarNovosPagamentos(parametrosVenda); |