fixes bug #8046
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@61823 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
8ab322d8cb
commit
b5176bb71b
|
@ -2,17 +2,13 @@ package com.rjconsultores.ventaboletos.relatorios.impl;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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.web.utilerias.NamedParameterStatement;
|
||||
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
public class RelatorioVendasComissao extends Relatorio {
|
||||
|
||||
private static Logger log = Logger.getLogger(RelatorioVendasComissao.class);
|
||||
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
private List<RelatorioVendasComissaoBean> lsDadosRelatorio;
|
||||
|
||||
private Timestamp fecInicio;
|
||||
private Timestamp fecFinal;
|
||||
private Integer marcaId;
|
||||
private Integer empresaId;
|
||||
|
||||
public RelatorioVendasComissao(Map<String, Object> parametros, Connection conexao) throws Exception {
|
||||
super(parametros, conexao);
|
||||
|
@ -44,8 +40,8 @@ public class RelatorioVendasComissao extends Relatorio {
|
|||
Map<String, Object> parametros = this.relatorio.getParametros();
|
||||
fecInicio = (Timestamp) parametros.get("dataFiltroInicial");
|
||||
fecFinal = (Timestamp) parametros.get("dataFiltroFinal");
|
||||
if(parametros.get("MARCA_ID")!=null){
|
||||
marcaId = Integer.valueOf(parametros.get("MARCA_ID").toString());
|
||||
if(parametros.get("EMPRESA_ID")!=null){
|
||||
empresaId = Integer.valueOf(parametros.get("EMPRESA_ID").toString());
|
||||
}
|
||||
|
||||
Connection conexao = this.relatorio.getConexao();
|
||||
|
@ -95,30 +91,33 @@ public class RelatorioVendasComissao extends Relatorio {
|
|||
RelatorioVendasComissaoBean relatorioVendasPacotesBoletosBean = new RelatorioVendasComissaoBean();
|
||||
relatorioVendasPacotesBoletosBean.setNumPuntoVenta(rset.getString("NUMPUNTOVENTA"));
|
||||
relatorioVendasPacotesBoletosBean.setNombPuntoVenta(rset.getString("NOMBPUNTOVENTA"));
|
||||
boolean indreimpresion = rset.getBoolean("INDREIMPRESION");
|
||||
String indstatusboleto = rset.getString("INDSTATUSBOLETO");
|
||||
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.setNombPuntoVenta(rset.getString("NOMBPTOVTAVENTA"));
|
||||
}
|
||||
|
||||
boolean contain = lsDadosRelatorio.contains(relatorioVendasPacotesBoletosBean);
|
||||
if(contain) {
|
||||
relatorioVendasPacotesBoletosBean = lsDadosRelatorio.get(lsDadosRelatorio.indexOf(relatorioVendasPacotesBoletosBean));
|
||||
int indice = lsDadosRelatorio.indexOf(relatorioVendasPacotesBoletosBean);
|
||||
if(indice > -1) {
|
||||
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.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.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.setTotalTaxasVendasDevolucao(relatorioVendasPacotesBoletosBean.getTotalTaxasVendasDevolucao().add(rset.getBigDecimal("TOTAL_TAXAS") != null ? rset.getBigDecimal("TOTAL_TAXAS") : new BigDecimal(0)));
|
||||
}
|
||||
|
||||
if(!contain) {
|
||||
if(indice == -1) {
|
||||
lsDadosRelatorio.add(relatorioVendasPacotesBoletosBean);
|
||||
}
|
||||
}
|
||||
|
@ -129,22 +128,37 @@ public class RelatorioVendasComissao extends Relatorio {
|
|||
return "C".equals(indstatusboleto);
|
||||
}
|
||||
|
||||
private boolean isVenda(String indstatusboleto) {
|
||||
return "V".equals(indstatusboleto);
|
||||
}
|
||||
|
||||
private boolean isCancelamentoCaja(String indstatusboleto, Long motivocancelacionId) {
|
||||
return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_CANCELACION.equals(motivocancelacionId);
|
||||
private boolean isVenda(String indstatusboleto, boolean indreimpresion) {
|
||||
return "V".equals(indstatusboleto) && !indreimpresion;
|
||||
}
|
||||
|
||||
private boolean isDevolucaoCaja(String indstatusboleto, Long motivocancelacionId) {
|
||||
return "C".equals(indstatusboleto) && Constantes.MVO_CANCEL_DEVOLUCAO.equals(motivocancelacionId);
|
||||
private boolean isTroca(String indstatusboleto, boolean indreimpresion) {
|
||||
return "T".equals(indstatusboleto) && !indreimpresion;
|
||||
}
|
||||
|
||||
private boolean isDevolucaoOrCancelamentoCaja(String indstatusboleto, Long motivocancelacionId) {
|
||||
return isCancelamentoCaja(indstatusboleto, motivocancelacionId) || isDevolucaoCaja(indstatusboleto, motivocancelacionId);
|
||||
private boolean isCancelamentoCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
|
||||
return isCancelamento(indstatusboleto) && Constantes.MVO_CANCEL_CANCELACION.equals(motivocancelacionId) && !indreimpresion;
|
||||
}
|
||||
|
||||
private boolean isDevolucaoCaja(String indstatusboleto, Long motivocancelacionId, boolean indreimpresion) {
|
||||
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 {
|
||||
String sql = getSqlPacotes();
|
||||
log.info(sql);
|
||||
|
@ -157,8 +171,8 @@ public class RelatorioVendasComissao extends Relatorio {
|
|||
if(fecFinal != null) {
|
||||
stmt.setTimestamp("fecFinal", fecFinal);
|
||||
}
|
||||
if(marcaId != null){
|
||||
stmt.setInt("MARCA_ID", marcaId);
|
||||
if(empresaId != null){
|
||||
stmt.setInt("EMPRESA_ID", empresaId);
|
||||
}
|
||||
|
||||
return stmt;
|
||||
|
@ -167,19 +181,20 @@ public class RelatorioVendasComissao extends Relatorio {
|
|||
protected String getSqlPacotes() {
|
||||
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, ")
|
||||
.append("SUM( COALESCE (C.PRECIOPAGADO,0) + COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL, ")
|
||||
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.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL_TAXAS ")
|
||||
.append("FROM CAJA C ")
|
||||
.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("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 ");
|
||||
if(parametros.get("MARCA_ID")!= null){
|
||||
sQuery.append("AND C.MARCA_ID =:MARCA_ID ");
|
||||
if(parametros.get("EMPRESA_ID")!= null){
|
||||
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 ")
|
||||
.append("ORDER BY PV.NUMPUNTOVENTA, PV1.NUMPUNTOVENTA, C.INDSTATUSBOLETO");
|
||||
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");
|
||||
|
||||
return sQuery.toString();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ConferenciaController extends MyGenericForwardComposer {
|
|||
|
||||
@Autowired
|
||||
private ConferenciaComissaoService conferenciaComissaoService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TipoInformativoComissaoService tipoInformativoComissaoService;
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class ConferenciaController extends MyGenericForwardComposer {
|
|||
private MyListbox formapagosList;
|
||||
|
||||
private ConferenciaComissaoVO conferenciaComissao;
|
||||
|
||||
|
||||
private Label lblTipoInformativo;
|
||||
private Combobox cmbTipoInformativo;
|
||||
|
||||
|
@ -802,7 +802,7 @@ public class ConferenciaController extends MyGenericForwardComposer {
|
|||
conferencia.setDatamovimento(DateUtil.getDateFromString(datamovimento, "dd/MM/yyyy"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Short getDebitoCreditoInfo(){
|
||||
if(rCredito.isSelected()){
|
||||
return (short) 1;
|
||||
|
@ -812,7 +812,6 @@ public class ConferenciaController extends MyGenericForwardComposer {
|
|||
return (short) 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onClick$btnAdicionarObservacaoLog(Event event) throws InterruptedException {
|
||||
try {
|
||||
|
@ -847,32 +846,28 @@ public class ConferenciaController extends MyGenericForwardComposer {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
||||
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"),
|
||||
}catch(Exception e){
|
||||
Messagebox.show(Labels.getLabel("conferenciaController.MSG.tipoInfomativoObrigatorio"),
|
||||
Labels.getLabel("conferenciaController.window.title"),
|
||||
Messagebox.OK, Messagebox.ERROR);
|
||||
Messagebox.OK,Messagebox.ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class RelatorioVendasComissaoController extends MyGenericForwardComposer
|
|||
Comboitem itemEmpresa = cmbEmpresa.getSelectedItem();
|
||||
if (itemEmpresa != null) {
|
||||
Empresa empresa = (Empresa) itemEmpresa.getValue();
|
||||
parametros.put("MARCA_ID", empresa.getEmpresaId());
|
||||
parametros.put("EMPRESA_ID", empresa.getEmpresaId());
|
||||
parametros.put("empresa", empresa.getNombempresa());
|
||||
} else{
|
||||
parametros.put("empresa", "Todas;");
|
||||
|
|
Loading…
Reference in New Issue