diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java index 213df620e..e65317174 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java @@ -531,19 +531,22 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO carregarBilhetesGapsVendidos(List boletoComissaos, ComEmpConferencia comEmpConferencia) { Set boletos = new HashSet(); for (BoletoComissao boletoComissao : boletoComissaos) { - if(boletoComissao.getNumoperacion().equals("010047068229")) { - System.out.println(""); - } - if (boletoComissao.isAbaGapVendido()) { if (comEmpConferencia != null) { @@ -487,21 +483,20 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic BigDecimal totalDeposito = BigDecimal.ZERO; for (BoletoComissao boletoComissao : boletoComissaos) { - if(boletoComissao.isNaoSomarBilhete()) { - continue; - } - for (FormapagoVO formapago : boletoComissao.getFormapagos()) { - if(formaspagosDeposito.contains(formapago.getFormapagoId())) { - //somando as vendas - if(boletoComissao.isAbaBilheteVendido() || boletoComissao.isAbaGapVendido() || boletoComissao.isAbaBilheteManual()) { - totalDeposito = MoneyHelper.somar(totalDeposito, formapago.getImporte()); - //subtraindo os cancelamentos - } else if(boletoComissao.isAbaBilheteCancelado() || boletoComissao.isAbaGapCancelado()) { - totalDeposito = MoneyHelper.subtrair(totalDeposito, formapago.getImporte()); - //subtraindo as trocas - } else if(boletoComissao.isAbaBilheteDevolvido() || boletoComissao.isAbaGapDevolvido()) { - if(boletoComissao.isMotivocancelacionTrocado() || boletoComissao.isMotivocancelacionDevolvido()) { + if (!boletoComissao.isNaoSomarBilhete()) { + for (FormapagoVO formapago : boletoComissao.getFormapagos()) { + if(formaspagosDeposito.contains(formapago.getFormapagoId())) { + //somando as vendas + if(boletoComissao.isAbaBilheteVendido() || boletoComissao.isAbaGapVendido() || boletoComissao.isAbaBilheteManual()) { + totalDeposito = MoneyHelper.somar(totalDeposito, formapago.getImporte()); + //subtraindo os cancelamentos + } else if(boletoComissao.isAbaBilheteCancelado() || boletoComissao.isAbaGapCancelado()) { totalDeposito = MoneyHelper.subtrair(totalDeposito, formapago.getImporte()); + //subtraindo as trocas + } else if(boletoComissao.isAbaBilheteDevolvido() || boletoComissao.isAbaGapDevolvido()) { + if(boletoComissao.isMotivocancelacionTrocado() || boletoComissao.isMotivocancelacionDevolvido()) { + totalDeposito = MoneyHelper.subtrair(totalDeposito, formapago.getImporte()); + } } } } @@ -514,13 +509,15 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic if (eventosFinanceiros.isCredito()) { totalDeposito = MoneyHelper.somar(totalDeposito, eventosFinanceiros.getImpingreso()); } else if (eventosFinanceiros.isDebito()) { - totalDeposito = MoneyHelper.subtrair(totalDeposito, eventosFinanceiros.getImpingreso()); + totalDeposito = MoneyHelper.subtrair(totalDeposito, eventosFinanceiros.getImpingreso().compareTo(BigDecimal.ZERO) >= 0 ? eventosFinanceiros.getImpingreso() : eventosFinanceiros.getImpingreso().abs()); } } } //subtraindo as ocds pagas - totalDeposito = MoneyHelper.subtrair(totalDeposito, resumoComissao.getTotalOcd().getValorPagar()); + if(resumoComissao.getTotalOcd() != null && resumoComissao.getTotalOcd().getValorPagar() != null) { + totalDeposito = MoneyHelper.subtrair(totalDeposito, resumoComissao.getTotalOcd().getValorPagar()); + } resumoComissao.setValorDeposito(totalDeposito); @@ -532,6 +529,10 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic * @param resumoComissao */ private void subtrairOcdFormapagoDinheiro(OcdVO totalOcd, ResumoComissao resumoComissao) { + if(totalOcd == null || totalOcd.getValorPagar() == null) { + return; + } + FormapagoVO formapagoDinheiro = null; for (FormapagoVO formapagoVO : resumoComissao.getTotalFormapago()) { if(formapagoVO.getFormapagoId().equals(Constantes.FORMA_PAGO_DINHEIRO.intValue())) { @@ -562,7 +563,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic private void carregarTotalFormapago(ResumoComissao resumoComissao, List boletoComissaos, List lsEventosFinanceiros) { List totalFormapagos = new ArrayList(); for (BoletoComissao boletoComissao : boletoComissaos) { - if (boletoComissao.isTotalizarTipovenda() && !boletoComissao.isNaoSomarBilhete()) { + if (!boletoComissao.isNaoSomarBilhete()) { for (FormapagoVO formapagoBoleto : boletoComissao.getFormapagos()) { FormapagoVO formapago; if (totalFormapagos.contains(formapagoBoleto)) { @@ -596,9 +597,10 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic if (eventosFinanceiros.isCredito()) { formapagoEventoFinanceiro.add(eventosFinanceiros.getImpingreso()); } else if (eventosFinanceiros.isDebito()) { - formapagoEventoFinanceiro.subtract(eventosFinanceiros.getImpingreso()); + formapagoEventoFinanceiro.subtract(eventosFinanceiros.getImpingreso().compareTo(BigDecimal.ZERO) >= 0 ? eventosFinanceiros.getImpingreso() : eventosFinanceiros.getImpingreso().abs()); } } + resumoComissao.setTotalFormapago(totalFormapagos); } diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java b/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java index 47b7c6f7b..2eff50fc6 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java @@ -953,13 +953,17 @@ public class BoletoComissao { public void setIndreimpresion(Boolean indreimpresion) { this.indreimpresion = indreimpresion; } - + @Override public String toString() { - return "BoletoComissao [boletoId=" + boletoId + ", tipoVenta=" + tipoVenta + ", indstatusboleto=" + indstatusboleto + ", motivoCancelacionId=" + motivoCancelacionId + ", descmotivocancelacion=" + descmotivocancelacion + ", tipoVentaOriginal1=" + tipoVentaOriginal1 + ", tipoVentaOriginal2=" + tipoVentaOriginal2 + ", indCancelacion=" + indCancelacion + ", indreimpresion=" + indreimpresion + "]"; + return "BoletoComissao [boletoId=" + boletoId + ", tipoVenta=" + tipoVenta + ", indstatusboleto=" + indstatusboleto + ", motivoCancelacionId=" + motivoCancelacionId + ", descmotivocancelacion=" + descmotivocancelacion + ", tipoVentaOriginal1=" + tipoVentaOriginal1 + ", tipoVentaOriginal2=" + tipoVentaOriginal2 + ", indCancelacion=" + indCancelacion + ", indreimpresion=" + indreimpresion + ", total=" + getTotal() + "]"; } public boolean isNaoSomarBilhete() { + /*if(getIndreimpresion() != null && getIndreimpresion()) { + return true; + }*/ + if(isStatusTroca() && isVendaBilheteTransferencia(getTipoVenta())) { return true; } @@ -980,10 +984,6 @@ public class BoletoComissao { return true; } - if(getIndreimpresion() != null && getIndreimpresion()) { - return true; - } - return false; }