wilian 2016-10-20 17:10:43 +00:00
parent 8ab322d8cb
commit b5176bb71b
3 changed files with 70 additions and 60 deletions

View File

@ -2,17 +2,13 @@ package com.rjconsultores.ventaboletos.relatorios.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -22,17 +18,17 @@ import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasComissaoBean; import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasComissaoBean;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
public class RelatorioVendasComissao extends Relatorio { public class RelatorioVendasComissao extends Relatorio {
private static Logger log = Logger.getLogger(RelatorioVendasComissao.class); private static Logger log = Logger.getLogger(RelatorioVendasComissao.class);
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
private List<RelatorioVendasComissaoBean> lsDadosRelatorio; private List<RelatorioVendasComissaoBean> lsDadosRelatorio;
private Timestamp fecInicio; private Timestamp fecInicio;
private Timestamp fecFinal; private Timestamp fecFinal;
private Integer marcaId; private Integer empresaId;
public RelatorioVendasComissao(Map<String, Object> parametros, Connection conexao) throws Exception { public RelatorioVendasComissao(Map<String, Object> parametros, Connection conexao) throws Exception {
super(parametros, conexao); super(parametros, conexao);
@ -44,8 +40,8 @@ public class RelatorioVendasComissao extends Relatorio {
Map<String, Object> parametros = this.relatorio.getParametros(); Map<String, Object> parametros = this.relatorio.getParametros();
fecInicio = (Timestamp) parametros.get("dataFiltroInicial"); fecInicio = (Timestamp) parametros.get("dataFiltroInicial");
fecFinal = (Timestamp) parametros.get("dataFiltroFinal"); fecFinal = (Timestamp) parametros.get("dataFiltroFinal");
if(parametros.get("MARCA_ID")!=null){ if(parametros.get("EMPRESA_ID")!=null){
marcaId = Integer.valueOf(parametros.get("MARCA_ID").toString()); empresaId = Integer.valueOf(parametros.get("EMPRESA_ID").toString());
} }
Connection conexao = this.relatorio.getConexao(); Connection conexao = this.relatorio.getConexao();
@ -95,30 +91,33 @@ public class RelatorioVendasComissao extends Relatorio {
RelatorioVendasComissaoBean relatorioVendasPacotesBoletosBean = new RelatorioVendasComissaoBean(); RelatorioVendasComissaoBean relatorioVendasPacotesBoletosBean = new RelatorioVendasComissaoBean();
relatorioVendasPacotesBoletosBean.setNumPuntoVenta(rset.getString("NUMPUNTOVENTA")); relatorioVendasPacotesBoletosBean.setNumPuntoVenta(rset.getString("NUMPUNTOVENTA"));
relatorioVendasPacotesBoletosBean.setNombPuntoVenta(rset.getString("NOMBPUNTOVENTA")); relatorioVendasPacotesBoletosBean.setNombPuntoVenta(rset.getString("NOMBPUNTOVENTA"));
boolean indreimpresion = rset.getBoolean("INDREIMPRESION");
String indstatusboleto = rset.getString("INDSTATUSBOLETO"); String indstatusboleto = rset.getString("INDSTATUSBOLETO");
Long motivocancelacionId = rset.getLong("MOTIVOCANCELACION_ID"); Long motivocancelacionId = rset.getLong("MOTIVOCANCELACION_ID");
if(isDevolucaoOrCancelamentoCaja(indstatusboleto, motivocancelacionId) && StringUtils.isNotBlank(rset.getString("NUMPTOVTAVENTA"))) { if(isDevolucaoOrCancelamentoCaja(indstatusboleto, motivocancelacionId, indreimpresion) && StringUtils.isNotBlank(rset.getString("NUMPTOVTAVENTA"))) {
relatorioVendasPacotesBoletosBean.setNumPuntoVenta(rset.getString("NUMPTOVTAVENTA")); relatorioVendasPacotesBoletosBean.setNumPuntoVenta(rset.getString("NUMPTOVTAVENTA"));
relatorioVendasPacotesBoletosBean.setNombPuntoVenta(rset.getString("NOMBPTOVTAVENTA")); relatorioVendasPacotesBoletosBean.setNombPuntoVenta(rset.getString("NOMBPTOVTAVENTA"));
} }
boolean contain = lsDadosRelatorio.contains(relatorioVendasPacotesBoletosBean); int indice = lsDadosRelatorio.indexOf(relatorioVendasPacotesBoletosBean);
if(contain) { if(indice > -1) {
relatorioVendasPacotesBoletosBean = lsDadosRelatorio.get(lsDadosRelatorio.indexOf(relatorioVendasPacotesBoletosBean)); relatorioVendasPacotesBoletosBean = lsDadosRelatorio.get(indice);
} }
if(isVenda(indstatusboleto)) { if(isVenda(indstatusboleto, indreimpresion) || isTroca(indstatusboleto, indreimpresion)) {
relatorioVendasPacotesBoletosBean.setTotalVendas(relatorioVendasPacotesBoletosBean.getTotalVendas().add(rset.getBigDecimal("TOTAL") != null ? rset.getBigDecimal("TOTAL") : new BigDecimal(0))); relatorioVendasPacotesBoletosBean.setTotalVendas(relatorioVendasPacotesBoletosBean.getTotalVendas().add(rset.getBigDecimal("TOTAL") != null ? rset.getBigDecimal("TOTAL") : new BigDecimal(0)));
relatorioVendasPacotesBoletosBean.setTotalTaxasVendas(relatorioVendasPacotesBoletosBean.getTotalTaxasVendas().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0))); relatorioVendasPacotesBoletosBean.setTotalTaxasVendas(relatorioVendasPacotesBoletosBean.getTotalTaxasVendas().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0)));
} else if(isCancelamentoCaja(indstatusboleto, motivocancelacionId)) { } else if(isCancelamentoCaja(indstatusboleto, motivocancelacionId, indreimpresion)) {
relatorioVendasPacotesBoletosBean.setTotalVendasCanceladas(relatorioVendasPacotesBoletosBean.getTotalVendasCanceladas().add(rset.getBigDecimal("TOTAL") != null ? rset.getBigDecimal("TOTAL") : new BigDecimal(0))); relatorioVendasPacotesBoletosBean.setTotalVendasCanceladas(relatorioVendasPacotesBoletosBean.getTotalVendasCanceladas().add(rset.getBigDecimal("TOTAL") != null ? rset.getBigDecimal("TOTAL") : new BigDecimal(0)));
relatorioVendasPacotesBoletosBean.setTotalTaxasVendasCanceladas(relatorioVendasPacotesBoletosBean.getTotalTaxasVendasCanceladas().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0))); relatorioVendasPacotesBoletosBean.setTotalTaxasVendasCanceladas(relatorioVendasPacotesBoletosBean.getTotalTaxasVendasCanceladas().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0)));
} else if(isDevolucaoCaja(indstatusboleto, motivocancelacionId)) { } else if(isDevolucaoCaja(indstatusboleto, motivocancelacionId, indreimpresion) ||
isDevolucaoOcdCaja(indstatusboleto, motivocancelacionId, indreimpresion) ||
isDevolucaoTrocaCaja(indstatusboleto, motivocancelacionId, indreimpresion)) {
relatorioVendasPacotesBoletosBean.setTotalVendasDevolucao(relatorioVendasPacotesBoletosBean.getTotalVendasDevolucao().add(rset.getBigDecimal("TOTAL") != null ? rset.getBigDecimal("TOTAL") : new BigDecimal(0))); relatorioVendasPacotesBoletosBean.setTotalVendasDevolucao(relatorioVendasPacotesBoletosBean.getTotalVendasDevolucao().add(rset.getBigDecimal("TOTAL") != null ? rset.getBigDecimal("TOTAL") : new BigDecimal(0)));
relatorioVendasPacotesBoletosBean.setTotalTaxasVendasDevolucao(relatorioVendasPacotesBoletosBean.getTotalTaxasVendasDevolucao().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0))); relatorioVendasPacotesBoletosBean.setTotalTaxasVendasDevolucao(relatorioVendasPacotesBoletosBean.getTotalTaxasVendasDevolucao().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0)));
} }
if(!contain) { if(indice == -1) {
lsDadosRelatorio.add(relatorioVendasPacotesBoletosBean); lsDadosRelatorio.add(relatorioVendasPacotesBoletosBean);
} }
} }
@ -129,20 +128,35 @@ public class RelatorioVendasComissao extends Relatorio {
return "C".equals(indstatusboleto); return "C".equals(indstatusboleto);
} }
private boolean isVenda(String indstatusboleto) { private boolean isVenda(String indstatusboleto, boolean indreimpresion) {
return "V".equals(indstatusboleto); return "V".equals(indstatusboleto) && !indreimpresion;
} }
private boolean isCancelamentoCaja(String indstatusboleto, Long motivocancelacionId) { private boolean isTroca(String indstatusboleto, boolean indreimpresion) {
return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_CANCELACION.equals(motivocancelacionId); return "T".equals(indstatusboleto) && !indreimpresion;
} }
private boolean isDevolucaoCaja(String indstatusboleto, Long motivocancelacionId) { private boolean isCancelamentoCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
return "C".equals(indstatusboleto) && Constantes.MVO_CANCEL_DEVOLUCAO.equals(motivocancelacionId); return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_CANCELACION.equals(motivocancelacionId) && !indreimpresion;
} }
private boolean isDevolucaoOrCancelamentoCaja(String indstatusboleto, Long motivocancelacionId) { private boolean isDevolucaoCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
return isCancelamentoCaja(indstatusboleto, motivocancelacionId) || isDevolucaoCaja(indstatusboleto, motivocancelacionId); return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_DEVOLUCAO.equals(motivocancelacionId) && !indreimpresion;
}
private boolean isDevolucaoTrocaCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_TROCA.equals(motivocancelacionId) && !indreimpresion;
}
private boolean isDevolucaoOcdCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_GERACAO_OCD.equals(motivocancelacionId) && indreimpresion;
}
private boolean isDevolucaoOrCancelamentoCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
return isCancelamentoCaja(indstatusboleto, motivocancelacionId, indreimpresion) ||
isDevolucaoCaja(indstatusboleto, motivocancelacionId, indreimpresion) ||
isDevolucaoOcdCaja(indstatusboleto, motivocancelacionId, indreimpresion) ||
isDevolucaoTrocaCaja(indstatusboleto, motivocancelacionId, indreimpresion);
} }
private NamedParameterStatement carregarNamedParameterStatement(Connection conexao) throws SQLException { private NamedParameterStatement carregarNamedParameterStatement(Connection conexao) throws SQLException {
@ -157,8 +171,8 @@ public class RelatorioVendasComissao extends Relatorio {
if(fecFinal != null) { if(fecFinal != null) {
stmt.setTimestamp("fecFinal", fecFinal); stmt.setTimestamp("fecFinal", fecFinal);
} }
if(marcaId != null){ if(empresaId != null){
stmt.setInt("MARCA_ID", marcaId); stmt.setInt("EMPRESA_ID", empresaId);
} }
return stmt; return stmt;
@ -167,18 +181,19 @@ public class RelatorioVendasComissao extends Relatorio {
protected String getSqlPacotes() { protected String getSqlPacotes() {
StringBuilder sQuery = new StringBuilder(); StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT PV.PUNTOVENTA_ID, PV.NUMPUNTOVENTA, PV.NOMBPUNTOVENTA, C.PTOVTAVENTA_ID, PV1.NUMPUNTOVENTA as NUMPTOVTAVENTA, PV1.NOMBPUNTOVENTA AS NOMBPTOVTAVENTA, C.INDSTATUSBOLETO, C.MOTIVOCANCELACION_ID, ") sQuery.append("SELECT PV.PUNTOVENTA_ID, PV.NUMPUNTOVENTA, PV.NOMBPUNTOVENTA, C.PTOVTAVENTA_ID, PV1.NUMPUNTOVENTA as NUMPTOVTAVENTA, PV1.NOMBPUNTOVENTA AS NOMBPTOVTAVENTA, C.INDSTATUSBOLETO, C.MOTIVOCANCELACION_ID, C.INDREIMPRESION, ")
.append("SUM( COALESCE (C.PRECIOPAGADO,0) + COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL, ") .append("SUM(COALESCE (C.PRECIOPAGADO,0) + COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL, ")
.append("SUM(COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL_TAXAS ") .append("SUM(COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL_TAXAS ")
.append("FROM CAJA C ") .append("FROM CAJA C ")
.append("JOIN PUNTO_VENTA PV ON PV.PUNTOVENTA_ID = C.PUNTOVENTA_ID ") .append("JOIN PUNTO_VENTA PV ON PV.PUNTOVENTA_ID = C.PUNTOVENTA_ID ")
.append("JOIN MARCA M ON M.MARCA_ID = C.MARCA_ID ")
.append("LEFT JOIN PUNTO_VENTA PV1 ON PV1.PUNTOVENTA_ID = C.PTOVTAVENTA_ID ") .append("LEFT JOIN PUNTO_VENTA PV1 ON PV1.PUNTOVENTA_ID = C.PTOVTAVENTA_ID ")
.append("WHERE (C.INDSTATUSBOLETO = 'V' OR (C.INDCANCELACION = 1 AND C.INDSTATUSBOLETO = 'C')) ") .append("WHERE ((C.INDSTATUSBOLETO = 'V' AND C.INDREIMPRESION = 0) OR (C.INDSTATUSBOLETO = 'T' AND C.INDREIMPRESION = 0) OR (C.INDCANCELACION = 1 AND C.INDSTATUSBOLETO = 'C')) ")
.append("AND C.FECHORVENTA BETWEEN :fecInicio AND :fecFinal "); .append("AND C.FECHORVENTA BETWEEN :fecInicio AND :fecFinal ");
if(parametros.get("MARCA_ID")!= null){ if(parametros.get("EMPRESA_ID")!= null){
sQuery.append("AND C.MARCA_ID =:MARCA_ID "); sQuery.append("AND M.EMPRESA_ID =:EMPRESA_ID ");
} }
sQuery.append("GROUP BY PV.PUNTOVENTA_ID, PV.NUMPUNTOVENTA, PV.NOMBPUNTOVENTA, C.PTOVTAVENTA_ID, PV1.NUMPUNTOVENTA, PV1.NOMBPUNTOVENTA, C.INDSTATUSBOLETO, C.MOTIVOCANCELACION_ID ") sQuery.append("GROUP BY PV.PUNTOVENTA_ID, PV.NUMPUNTOVENTA, PV.NOMBPUNTOVENTA, C.PTOVTAVENTA_ID, PV1.NUMPUNTOVENTA, PV1.NOMBPUNTOVENTA, C.INDSTATUSBOLETO, C.MOTIVOCANCELACION_ID, C.INDREIMPRESION ")
.append("ORDER BY PV.NUMPUNTOVENTA, PV1.NUMPUNTOVENTA, C.INDSTATUSBOLETO"); .append("ORDER BY PV.NUMPUNTOVENTA, PV1.NUMPUNTOVENTA, C.INDSTATUSBOLETO");
return sQuery.toString(); return sQuery.toString();

View File

@ -813,7 +813,6 @@ public class ConferenciaController extends MyGenericForwardComposer {
} }
} }
public void onClick$btnAdicionarObservacaoLog(Event event) throws InterruptedException { public void onClick$btnAdicionarObservacaoLog(Event event) throws InterruptedException {
try { try {
if (validarCamposObservacao()) { if (validarCamposObservacao()) {
@ -847,6 +846,16 @@ public class ConferenciaController extends MyGenericForwardComposer {
} }
private boolean validarCamposObservacao() throws InterruptedException { private boolean validarCamposObservacao() throws InterruptedException {
try{
if(rInformativo.isSelected() && cmbTipoInformativo.getValue() == null){
return false;
}
}catch(Exception e){
Messagebox.show(Labels.getLabel("conferenciaController.MSG.tipoInfomativoObrigatorio"),
Labels.getLabel("conferenciaController.window.title"),
Messagebox.OK,Messagebox.ERROR);
return false;
}
try{ try{
if(rInformativo.isSelected() && cmbTipoInformativo.getValue() == null){ if(rInformativo.isSelected() && cmbTipoInformativo.getValue() == null){
@ -859,20 +868,6 @@ public class ConferenciaController extends MyGenericForwardComposer {
return false; return false;
} }
try {
if (StringUtils.isBlank(txtObservacaoLog.getValue())) {
Messagebox.show(Labels.getLabel("conferenciaController.MSG.observacaoObrigatorio"),
Labels.getLabel("conferenciaController.window.title"),
Messagebox.OK, Messagebox.ERROR);
return false;
}
} catch (Exception e) {
Messagebox.show(Labels.getLabel("conferenciaController.MSG.observacaoObrigatorio"),
Labels.getLabel("conferenciaController.window.title"),
Messagebox.OK, Messagebox.ERROR);
return false;
}
return true; return true;
} }

View File

@ -68,7 +68,7 @@ public class RelatorioVendasComissaoController extends MyGenericForwardComposer
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem(); Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
if (itemEmpresa != null) { if (itemEmpresa != null) {
Empresa empresa = (Empresa) itemEmpresa.getValue(); Empresa empresa = (Empresa) itemEmpresa.getValue();
parametros.put("MARCA_ID", empresa.getEmpresaId()); parametros.put("EMPRESA_ID", empresa.getEmpresaId());
parametros.put("empresa", empresa.getNombempresa()); parametros.put("empresa", empresa.getNombempresa());
} else{ } else{
parametros.put("empresa", "Todas;"); parametros.put("empresa", "Todas;");