@Override public String getAsString(FacesContext context, UIComponent component, Object value) { if (value != null) { Lancamento lancamento = ((Lancamento) value); return lancamento.getId() == null ? null : lancamento.getId().toString(); } return null; }
private boolean validarCamposLancamento() { boolean lancamentoValido = true; String msg = ""; if (this.frame.getTxfMovDescricao().isEmpty()) { lancamentoValido = false; msg += ">> Descrição inválida.\n"; } if (this.frame.getDtcMovData() == null) { lancamentoValido = false; msg += ">> Data inválida.\n"; } if (this.frame.getDbfMovValor() == 0.0) { lancamentoValido = false; msg += ">> Valor inválido.\n"; } if (this.frame.getCbxMovConta() == null) { lancamentoValido = false; msg += ">> Conta inválida.\n"; } if (this.frame.getCbxMovCaixa() == null) { lancamentoValido = false; msg += ">> Caixa inválida.\n"; } if (this.frame.getDtcMovData() != null && this.frame.getCbxMovConta() != null && this.frame.getCbxMovCaixa() != null && this.transacaoLancamento == 'I') { Lancamento lanc = this.frame.getLancamentoTela(); if (lanc.getCodLancamento() != 0) { Mensagem.info( "Já existe um lançamento para este vencimento, valor, conta e caixa.", this.frame); return (false); } } if (!lancamentoValido) { Mensagem.info("Erro ao inserir lançamento:\n" + msg, this.frame); } return (lancamentoValido); }
private void confirmarIncluirTransferencia() { if (!validarCamposTransferencia()) { return; } Lancamento transf = this.frame.getTransferenciaTela(); if (transf.getPago() == 'S') { // efetivar valores dos caixas this.caixaDAO.adicionarAoSaldo( this.frame.getCbxTransfCaixaDestino().getCodCaixa(), transf.getValor()); this.caixaDAO.subtrairDoSaldo( this.frame.getCbxTransfCaixaOrigem().getCodCaixa(), transf.getValor()); } this.lancamentoDAO.inserir(transf); this.frame.mudarEstado("Transferencia", "NAVEGACAO"); recarregarDoBancoDeDados("Lancamentos"); recarregarDoBancoDeDados("Caixas"); Mensagem.info("Transferência incluída com sucesso.", this.frame); }
private void confirmarIncluirLancamento() { if (!Mensagem.confirmacao("Confirma incluir o lançamento?", this.frame) || !validarCamposLancamento()) { return; } Lancamento lancamento = this.frame.getLancamentoTela(); // tratar recorrencia if (this.frame.getMovRecorrencia() == 'S') { ArrayList<Integer> datasVencimento = DateTools.calcularVencimentos( lancamento.getDataVencimento(), this.frame.getItfNumVezes(), (this.frame.getItfNumPeriodo() * this.frame.getCbxPeriodo().getIDias())); for (Integer data : datasVencimento) { Lancamento provisao = new Lancamento(); provisao.setDataEmissao(lancamento.getDataEmissao()); provisao.setDataVencimento(data); if (lancamento.getDataQuitacao() > 0) { provisao.setDataQuitacao(data); } else { provisao.setDataQuitacao(0); } provisao.setDescricao(lancamento.getDescricao()); provisao.setValor(lancamento.getValor()); provisao.setConta(lancamento.getConta()); provisao.setCaixa(lancamento.getCaixa()); this.lancamentoDAO.inserir(provisao); if (provisao.getDataQuitacao() > 0) { if (lancamento.getConta().getTipo() == 'D') { this.caixaDAO.subtrairDoSaldo( lancamento.getCaixa().getCodCaixa(), lancamento.getValor()); } else { this.caixaDAO.adicionarAoSaldo( lancamento.getCaixa().getCodCaixa(), lancamento.getValor()); } } } } else { this.lancamentoDAO.inserir(lancamento); if (lancamento.getDataQuitacao() > 0) { if (lancamento.getConta().getTipo() == 'D') { this.caixaDAO.subtrairDoSaldo(lancamento.getCaixa().getCodCaixa(), lancamento.getValor()); } else { this.caixaDAO.adicionarAoSaldo( lancamento.getCaixa().getCodCaixa(), lancamento.getValor()); } } } this.frame.mudarEstado("Lancamento", "NAVEGACAO"); recarregarDoBancoDeDados("Lancamentos"); recarregarDoBancoDeDados("Caixas"); }