wilian 2017-03-28 22:01:30 +00:00
parent 332dec1021
commit 81680bfb81
5 changed files with 118 additions and 48 deletions

View File

@ -707,9 +707,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("BO1.MOTIVOCANCELACION_ID \"motivoCancelacionOriginal1\", BO2.MOTIVOCANCELACION_ID \"motivoCancelacionOriginal2\", ") .append("BO1.MOTIVOCANCELACION_ID \"motivoCancelacionOriginal1\", BO2.MOTIVOCANCELACION_ID \"motivoCancelacionOriginal2\", ")
.append("NVL(tarifa.PRECIO,0) + NVL(tarifa.IMPORTEPEDAGIO,0) + NVL(tarifa.IMPORTETAXAEMBARQUE,0) + NVL(tarifa.IMPORTESEGURO,0) + NVL(tarifa.IMPORTEOUTROS,0) AS \"valorTabela\", ") .append("NVL(tarifa.PRECIO,0) + NVL(tarifa.IMPORTEPEDAGIO,0) + NVL(tarifa.IMPORTETAXAEMBARQUE,0) + NVL(tarifa.IMPORTESEGURO,0) + NVL(tarifa.IMPORTEOUTROS,0) AS \"valorTabela\", ")
.append("NVL(OCD.VALOR_PAGAR,0) AS \"valorPagarOcd\", NVL(OCD.VALOR_TARJETA,0) AS \"valorTarjetaOcd\", ") .append("NVL(OCD.VALOR_PAGAR,0) AS \"valorPagarOcd\", NVL(OCD.VALOR_TARJETA,0) AS \"valorTarjetaOcd\", ")
.append("B.INDCANCELACION AS \"indCancelacion\", ") .append("B.INDCANCELACION AS \"indCancelacion\", BA.TIPOVENTA_ID AS \"tipoventaAnteriorId\", B.INDREIMPRESION AS \"indreimpresion\" ")
.append("BA.TIPOVENTA_ID AS \"tipoventaAnteriorId\", ")
.append("BA.BOLETO_ID AS \"boletoAnteriorId\" ")
.append("FROM BOLETO B ") .append("FROM BOLETO B ")
.append("LEFT JOIN BOLETO BO1 ON BO1.BOLETO_ID = B.BOLETOORIGINAL_ID ") .append("LEFT JOIN BOLETO BO1 ON BO1.BOLETO_ID = B.BOLETOORIGINAL_ID ")
.append("LEFT JOIN BOLETO BO2 ON BO2.BOLETO_ID = BO1.BOLETOORIGINAL_ID ") .append("LEFT JOIN BOLETO BO2 ON BO2.BOLETO_ID = BO1.BOLETOORIGINAL_ID ")
@ -789,7 +787,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.addScalar("valorTarjetaOcd", Hibernate.BIG_DECIMAL) .addScalar("valorTarjetaOcd", Hibernate.BIG_DECIMAL)
.addScalar("indCancelacion", Hibernate.BOOLEAN) .addScalar("indCancelacion", Hibernate.BOOLEAN)
.addScalar("tipoventaAnteriorId", Hibernate.INTEGER) .addScalar("tipoventaAnteriorId", Hibernate.INTEGER)
.addScalar("boletoAnteriorId", Hibernate.LONG) .addScalar("indreimpresion", Hibernate.BOOLEAN)
.setResultTransformer(Transformers.aliasToBean(BoletoComissao.class)); .setResultTransformer(Transformers.aliasToBean(BoletoComissao.class));
setParametros(qr, parametros); setParametros(qr, parametros);
@ -848,7 +846,8 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ") .append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ")
.append("O.INDPAGO AS \"indpago\", O.VALOR_PAGAR AS \"valorPagar\", (B.PRECIOPAGADO * (O.PENALIZACION / 100)) AS \"penalizacion\", LOG.STATUS AS \"status\", ") .append("O.INDPAGO AS \"indpago\", O.VALOR_PAGAR AS \"valorPagar\", (B.PRECIOPAGADO * (O.PENALIZACION / 100)) AS \"penalizacion\", LOG.STATUS AS \"status\", ")
.append("U.NOMBUSUARIO AS \"nombusuario\", LOG.LOGCONFERENCIA_ID AS \"logconferenciaId\", U.CVEUSUARIO AS \"login\", B.NUMFOLIOSISTEMA AS \"numFolioSistema\", ") .append("U.NOMBUSUARIO AS \"nombusuario\", LOG.LOGCONFERENCIA_ID AS \"logconferenciaId\", U.CVEUSUARIO AS \"login\", B.NUMFOLIOSISTEMA AS \"numFolioSistema\", ")
.append("CEC.INDOCD AS \"exigeConferenciaAba\" ").append("FROM OCD O ") .append("CEC.INDOCD AS \"exigeConferenciaAba\" ")
.append("FROM OCD O ")
.append("INNER JOIN BOLETO B ON B.BOLETO_ID = O.BOLETO_ID ") .append("INNER JOIN BOLETO B ON B.BOLETO_ID = O.BOLETO_ID ")
.append("INNER JOIN MARCA M ON B.MARCA_ID = M.MARCA_ID ") .append("INNER JOIN MARCA M ON B.MARCA_ID = M.MARCA_ID ")
.append("LEFT JOIN LOG_CONFERENCIA LOG ON LOG.OCD_ID = O.OCD_ID AND LOG.ACTIVO = 1 ") .append("LEFT JOIN LOG_CONFERENCIA LOG ON LOG.OCD_ID = O.OCD_ID AND LOG.ACTIVO = 1 ")

View File

@ -55,7 +55,7 @@ public interface ConferenciaComissaoService extends GenericService<Conferencia,
public boolean isOcdSemConferencia(List<OcdVO> lsOcd) throws BusinessException; public boolean isOcdSemConferencia(List<OcdVO> lsOcd) throws BusinessException;
public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException; public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, Boolean indreimpression, IndStatusBoleto... statusBilhete) throws BusinessException;
public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException; public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException;

View File

@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.zkoss.util.resource.Labels; import org.zkoss.util.resource.Labels;
import com.rjconsultores.ventaboletos.constantes.Constantes;
import com.rjconsultores.ventaboletos.dao.ConferenciaComissaoDAO; import com.rjconsultores.ventaboletos.dao.ConferenciaComissaoDAO;
import com.rjconsultores.ventaboletos.dao.EmpresaDAO; import com.rjconsultores.ventaboletos.dao.EmpresaDAO;
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO; import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
@ -374,7 +375,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
} }
@Override @Override
public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException { public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, Boolean indreimpression, IndStatusBoleto... statusBilhete) throws BusinessException {
List<IndStatusBoleto> lStatusBilhete = null; List<IndStatusBoleto> lStatusBilhete = null;
if (statusBilhete != null && statusBilhete.length > 0) { if (statusBilhete != null && statusBilhete.length > 0) {
lStatusBilhete = Arrays.asList(statusBilhete); lStatusBilhete = Arrays.asList(statusBilhete);
@ -383,6 +384,10 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
if (lsBoletoComissao != null) { if (lsBoletoComissao != null) {
for (BoletoComissao boletoComissao : lsBoletoComissao) { for (BoletoComissao boletoComissao : lsBoletoComissao) {
if(indreimpression != null && !indreimpression.equals(boletoComissao.getIndreimpresion())) {
continue;
}
if ((lStatusBilhete == null || lStatusBilhete.contains(boletoComissao.getIndstatusboletoEnum())) && if ((lStatusBilhete == null || lStatusBilhete.contains(boletoComissao.getIndstatusboletoEnum())) &&
!boletoComissao.isVendaBilheteConfirmaAberto(boletoComissao.getTipoVenta())) { !boletoComissao.isVendaBilheteConfirmaAberto(boletoComissao.getTipoVenta())) {
total = total.add(boletoComissao.getTotal()); total = total.add(boletoComissao.getTotal());
@ -399,7 +404,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
BigDecimal totalOcd = BigDecimal.ZERO; BigDecimal totalOcd = BigDecimal.ZERO;
if (lsBoletoComissao != null) { if (lsBoletoComissao != null) {
for (BoletoComissao boletoComissao : lsBoletoComissao) { for (BoletoComissao boletoComissao : lsBoletoComissao) {
if (boletoComissao.isMotivocancelacionGeracaoOcd()) { if (boletoComissao.isOcd()) {
totalOcd = totalOcd.add(boletoComissao.getTotal()); totalOcd = totalOcd.add(boletoComissao.getTotal());
} else if (boletoComissao.isMotivocancelacionDevolvido()) { } else if (boletoComissao.isMotivocancelacionDevolvido()) {
totalDevolvidos = totalDevolvidos.add(boletoComissao.getTotal()); totalDevolvidos = totalDevolvidos.add(boletoComissao.getTotal());
@ -454,12 +459,62 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros); carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros);
resumoComissao.setValorDeposito(conferenciaComissaoDAO.carregarValorDepositoContaCorrente(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento())); subtrairOcdFormapagoDinheiro(totalOcd, resumoComissao);
resumoComissao.setValorDeposito(carregarTotalFormapagoDinheiro(resumoComissao));
resumoComissao.setQuantidadeEcf(puntoVentaDAO.quantidadeECFPorPuntoVenta(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId())); resumoComissao.setQuantidadeEcf(puntoVentaDAO.quantidadeECFPorPuntoVenta(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId()));
return resumoComissao; return resumoComissao;
} }
/**
* Retorna o valor total de forma pago do tipo DINHEIRO
* @param resumoComissao
* @return
*/
private BigDecimal carregarTotalFormapagoDinheiro(ResumoComissao resumoComissao) {
for (FormapagoVO formapagoVO : resumoComissao.getTotalFormapago()) {
if(formapagoVO.getFormapagoId().equals(Constantes.FORMA_PAGO_DINHEIRO.intValue())) {
return formapagoVO.getImporte();
}
}
return BigDecimal.ZERO;
}
/**
* Subtrai do total de forma pago o total pago das ocds.
* @param totalOcd
* @param resumoComissao
*/
private void subtrairOcdFormapagoDinheiro(OcdVO totalOcd, ResumoComissao resumoComissao) {
FormapagoVO formapagoDinheiro = null;
for (FormapagoVO formapagoVO : resumoComissao.getTotalFormapago()) {
if(formapagoVO.getFormapagoId().equals(Constantes.FORMA_PAGO_DINHEIRO.intValue())) {
formapagoDinheiro = formapagoVO;
break;
}
}
if(formapagoDinheiro == null) {
formapagoDinheiro = new FormapagoVO(Constantes.FORMA_PAGO_DINHEIRO.intValue(), "DINHEIRO", null, BigDecimal.ZERO);
}
formapagoDinheiro.subtract(totalOcd.getValorPagar());
if(!resumoComissao.getTotalFormapago().contains(formapagoDinheiro)) {
resumoComissao.getTotalFormapago().add(formapagoDinheiro);
}
}
/**
* Totaliza os valores conforme o forma pago, apenas do bilhetes que geraram registros em caixa
* (+) Abas: Bilhetes Manual, Bilhetes, Gap Venda
* (-) Abas: Bilhetes Cancelados, Bilhetes Devolvidos, Gap Cancelados, Gap Devolvidos
* @param resumoComissao
* @param boletoComissaos
* @param lsEventosFinanceiros
*/
private void carregarTotalFormapago(ResumoComissao resumoComissao, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros) { private void carregarTotalFormapago(ResumoComissao resumoComissao, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros) {
List<FormapagoVO> totalFormapagos = new ArrayList<FormapagoVO>(); List<FormapagoVO> totalFormapagos = new ArrayList<FormapagoVO>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
@ -473,9 +528,9 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
totalFormapagos.add(formapago); totalFormapagos.add(formapago);
} }
if (boletoComissao.isStatusVendido() || boletoComissao.isStatusTroca()) { if (boletoComissao.isAbaBilheteVendido() || boletoComissao.isAbaGapVendido() || boletoComissao.isAbaBilheteManual()) {
formapago.add(formapagoBoleto.getImporte()); formapago.add(formapagoBoleto.getImporte());
} else if (boletoComissao.isAbaBilheteCancelado() || boletoComissao.isAbaBilheteDevolvido() || boletoComissao.isAbaGapCancelado() || boletoComissao.isAbaGapDevolvido()) { } else if ((boletoComissao.isAbaBilheteCancelado() || boletoComissao.isAbaBilheteDevolvido() || boletoComissao.isAbaGapCancelado() || boletoComissao.isAbaGapDevolvido())) {
formapago.subtract(formapagoBoleto.getImporte()); formapago.subtract(formapagoBoleto.getImporte());
} }
} }

View File

@ -76,8 +76,9 @@ public class BoletoComissao {
private Boolean indCancelacion; private Boolean indCancelacion;
private Boolean indreimpresion;
private Integer tipoventaAnteriorId; private Integer tipoventaAnteriorId;
private Long boletoAnteriorId;
public Integer getEmpresaId() { public Integer getEmpresaId() {
return empresaId; return empresaId;
@ -389,17 +390,25 @@ public class BoletoComissao {
public String getSituacaoBilhete() { public String getSituacaoBilhete() {
if (isOcd()) { if (isOcd()) {
return "OCD"; return "OCD";
} else if ((isStatusCancelado()) && (isMotivocancelacionDevolvido() || isMotivocancelacionCancelado()) }
if(isStatusVendido()) {
return IndStatusBoleto.getIndStatusBoleto(getIndstatusboleto()).getValue();
}
if ((isStatusCancelado()) && (isMotivocancelacionDevolvido() || isMotivocancelacionCancelado())
&& StringUtils.isNotBlank(getDescmotivocancelacion())) { && StringUtils.isNotBlank(getDescmotivocancelacion())) {
return getDescmotivocancelacion(); return getDescmotivocancelacion();
} else if ((isStatusVendido() || isStatusCancelado()) }
&& !isMotivocancelacionDevolvido() && !isMotivocancelacionCancelado()) {
if (isStatusCancelado() && isMotivocancelacionTrocado()) { if (isStatusCancelado()) {
return "B. VENDIDO TROCADO"; if (isMotivocancelacionTrocado() || (isMotivocancelacionGeracaoOcd() && isFormapagoTrocaPassagem())) {
} else if (isStatusVendido() && isMotivocancelacionTransferido()) { return "TROCADO";
return "B. VENDIDO TRANSFERIDO"; } else if (isMotivocancelacionTransferido()) {
return "TRANSFERIDO";
} }
} else if (isStatusTroca()) { }
if (isStatusTroca()) {
if (isVendaBilheteTroca(getTipoVenta()) || isVendaGap(getTipoVenta())) { if (isVendaBilheteTroca(getTipoVenta()) || isVendaGap(getTipoVenta())) {
return "B. DA TROCA"; return "B. DA TROCA";
} else if (isVendaBilheteTransferencia(getTipoVenta()) || isVendaGap(getTipoVenta())) { } else if (isVendaBilheteTransferencia(getTipoVenta()) || isVendaGap(getTipoVenta())) {
@ -413,8 +422,16 @@ public class BoletoComissao {
return indStatusBoleto != null ? indStatusBoleto.getValue() : ""; return indStatusBoleto != null ? indStatusBoleto.getValue() : "";
} }
public boolean isFormapagoTrocaPassagem() {
boolean fpTrocapassagem = false;
for (FormapagoVO formapagoVO : formapagos) {
fpTrocapassagem = formapagoVO.getFormapagoId().equals(Constantes.FORMA_PAGO_TROCA_PASSAGEM.intValue());
}
return fpTrocapassagem;
}
public boolean isOcd() { public boolean isOcd() {
return getOcdId() != null && isStatusCancelado(); return getOcdId() != null && isStatusCancelado() && !isFormapagoTrocaPassagem();
} }
public String getNombusuario() { public String getNombusuario() {
@ -742,21 +759,19 @@ public class BoletoComissao {
public boolean isTotalizarFormapago() { public boolean isTotalizarFormapago() {
boolean totalizar = isTotalizarTipovenda(); boolean totalizar = isTotalizarTipovenda();
if (totalizar) { totalizar = !isOcd();
totalizar = !isOcd(); totalizar = !getIndreimpresion();
}
return totalizar; return totalizar;
} }
private boolean isTotalizarTipovenda() { private boolean isTotalizarTipovenda() {
return isAbaBilheteCancelado() || return isAbaBilheteManual() ||
isAbaBilheteVendido() ||
isAbaBilheteCancelado() ||
isAbaBilheteDevolvido() || isAbaBilheteDevolvido() ||
isAbaGapCancelado() ||
isAbaGapDevolvido() ||
isAbaBilheteManual() ||
isAbaGapVendido() || isAbaGapVendido() ||
isAbaBilheteVendido(); isAbaGapCancelado() ||
isAbaGapDevolvido();
} }
public String getOrderExigeConferencia() { public String getOrderExigeConferencia() {
@ -786,15 +801,15 @@ public class BoletoComissao {
return false; return false;
} }
if(isMotivocancelacionTransferido()) {
return false;
}
if(isVendaGap(getTipoVenta()) && !isStatusEntregue()) { if(isVendaGap(getTipoVenta()) && !isStatusEntregue()) {
return false; return false;
} }
return isStatusVendido() || isStatusEntregue() || isStatusTroca(); if((isVendaBilheteTransferencia(getTipoVenta())) && isVendaGap(getTipoVentaOriginal())) {
return false;
}
return isStatusVendido() || isStatusTroca() || isStatusEntregue();
} }
/** Define bilhete na aba de venda cancelada */ /** Define bilhete na aba de venda cancelada */
@ -837,11 +852,11 @@ public class BoletoComissao {
return false; return false;
} }
if(isMotivocancelacionTransferido()) { if(!isVendaGap(getTipoVenta()) && !isVendaBilheteTransferencia(getTipoVenta())) {
return false; return false;
} }
if(!isVendaGap(getTipoVenta())) { if((isVendaBilheteTransferencia(getTipoVenta())) && !isVendaGap(getTipoVentaOriginal())) {
return false; return false;
} }
@ -906,16 +921,16 @@ public class BoletoComissao {
this.tipoventaAnteriorId = tipoventaAnteriorId; this.tipoventaAnteriorId = tipoventaAnteriorId;
} }
public Long getBoletoAnteriorId() {
return boletoAnteriorId;
}
public void setBoletoAnteriorId(Long boletoAnteriorId) {
this.boletoAnteriorId = boletoAnteriorId;
}
private boolean isNotNumFolioPreImpressoGerado() { private boolean isNotNumFolioPreImpressoGerado() {
return StringUtils.isBlank(getNumFolioPreImpreso()); return StringUtils.isBlank(getNumFolioPreImpreso());
} }
public Boolean getIndreimpresion() {
return indreimpresion;
}
public void setIndreimpresion(Boolean indreimpresion) {
this.indreimpresion = indreimpresion;
}
} }

View File

@ -4,6 +4,7 @@ import java.math.BigDecimal;
import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil; import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil;
import com.rjconsultores.ventaboletos.utilerias.LocaleUtil; import com.rjconsultores.ventaboletos.utilerias.LocaleUtil;
import com.rjconsultores.ventaboletos.utilerias.MoneyHelper;
public class FormapagoVO { public class FormapagoVO {
@ -89,11 +90,11 @@ public class FormapagoVO {
} }
public void add(BigDecimal importe) { public void add(BigDecimal importe) {
this.importe = this.importe.add(importe != null ? importe : BigDecimal.ZERO); this.importe = MoneyHelper.somar(this.importe, (importe != null ? importe : BigDecimal.ZERO));
} }
public void subtract(BigDecimal importe) { public void subtract(BigDecimal importe) {
this.importe = this.importe.subtract(importe != null ? importe : BigDecimal.ZERO); this.importe = MoneyHelper.subtrair(this.importe,(importe != null ? importe : BigDecimal.ZERO));
} }
} }