fixes bug#21352
qua: dev:Fabio git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@105362 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
8078d38a1f
commit
3d466d7e1a
|
@ -13,6 +13,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -32,7 +33,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
|
|||
*/
|
||||
public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
||||
|
||||
private Map<String, HashMap<String, Object>> mapCacheConfigComissao;
|
||||
private LinkedHashMap<String, LinkedHashMap<String, Object>> mapCacheConfigComissao;
|
||||
//Mantis 16390
|
||||
//As vendas com impressão posterior não estavam sendo exibidas como prévenda pois só estavam sendo validados os tipoVendaId 18 e 39.
|
||||
//Verifiquei a classe RelatorioImpressaoPosterior e adicionei os tipoVendaId faltantes de acordo com sua regra de negócio.
|
||||
|
@ -40,23 +41,37 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
private Set<PuntoVenta> pontoVendaConfiguracao;
|
||||
|
||||
|
||||
public RelatorioReceitaDiariaAgencia(Map<String, Object> parametros, Connection conexao) throws Exception {
|
||||
public RelatorioReceitaDiariaAgencia(final Map<String, Object> parametros, Connection conexao) throws Exception {
|
||||
|
||||
super(parametros, conexao);
|
||||
|
||||
CalculoImposto.limpaCache();
|
||||
this.mapCacheConfigComissao = new HashMap<String, HashMap<String, Object>>();
|
||||
this.mapCacheConfigComissao = new LinkedHashMap<String, LinkedHashMap<String, Object>>();
|
||||
|
||||
this.setCustomDataSource(new ArrayDataSource(this) {
|
||||
|
||||
protected HashMap<String, HashMap<String, Object>> mapDados;
|
||||
protected LinkedHashMap<String, LinkedHashMap<String, Object>> mapDados;
|
||||
|
||||
@Override
|
||||
public Object valueCustomFields(String fieldName) throws Exception {
|
||||
if (fieldName.equals("RECEITA_TOTAL")) {
|
||||
BigDecimal gap = BigDecimal.ZERO;
|
||||
if( this.getByName("RECZEITA_TARIFA_GAP")!=null) {
|
||||
gap = ((BigDecimal) this.getByName("RECZEITA_TARIFA_GAP"));
|
||||
}
|
||||
if(this.getByName("RECEITA_SEGURO_GAP") !=null) {
|
||||
gap.add((BigDecimal) this.getByName("RECEITA_SEGURO_GAP"));
|
||||
}
|
||||
|
||||
gap = ((BigDecimal) this.getByName("RECEITA_TARIFA_GAP")).add((BigDecimal) this.getByName("RECEITA_SEGURO_GAP")).add((BigDecimal) this.getByName("RECEITA_EMBARQUE_GAP")).add((BigDecimal) this.getByName("RECEITA_PEDAGIO_GAP")).subtract((BigDecimal) this.getByName("TOTAL_DEVOL_GAP"));
|
||||
if(this.getByName("RECEITA_EMBARQUE_GAP")!=null) {
|
||||
gap.add((BigDecimal) this.getByName("RECEITA_EMBARQUE_GAP"));
|
||||
}
|
||||
if(this.getByName("RECEITA_PEDAGIO_GAP")!=null) {
|
||||
gap.add((BigDecimal) this.getByName("RECEITA_PEDAGIO_GAP"));
|
||||
}
|
||||
if(getByName("TOTAL_DEVOL_GAP") !=null) {
|
||||
gap.subtract((BigDecimal) this.getByName("TOTAL_DEVOL_GAP"));
|
||||
}
|
||||
|
||||
return ((BigDecimal) this.getByName("RECEITA_TARIFA")).add((BigDecimal) this.getByName("RECEITA_SEGURO")).add((BigDecimal) this.getByName("RECEITA_BAGAGEM")).add((BigDecimal) this.getByName("RECEITA_EMBARQUE")).add((BigDecimal) this.getByName("RECEITA_PEDAGIO")).subtract((BigDecimal) this.getByName("TOTAL_DEVOL")).add(gap);
|
||||
}
|
||||
|
@ -134,11 +149,11 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
this.resultSet = stmt.executeQuery();
|
||||
}
|
||||
|
||||
public void setRowComissao(Map<String, Object> rowOrigem) throws Exception {
|
||||
Map<String, Object> rowDestino = rowOrigem;
|
||||
public void setRowComissao(LinkedHashMap<String, Object> rowOrigem) throws Exception {
|
||||
LinkedHashMap<String, Object> rowDestino = rowOrigem;
|
||||
|
||||
// Busca as configurações de comissão
|
||||
HashMap<String, Object> configComissao = getConfigComissao((Integer) rowOrigem.get("PUNTOVENTA_ID"), (Integer) rowOrigem.get("EMPRESAPUNTOVENTA_ID"));
|
||||
LinkedHashMap<String, Object> configComissao = getConfigComissao((Integer) rowOrigem.get("PUNTOVENTA_ID"), (Integer) rowOrigem.get("EMPRESAPUNTOVENTA_ID"));
|
||||
if (configComissao == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -246,19 +261,19 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
rowDestino.put("ESTADO_ID", configComissao.get("ESTADO_ID"));
|
||||
rowDestino.put("TIPO_AGENCIA", configComissao.get("TIPO_AGENCIA"));
|
||||
|
||||
mapDados.put(puntoVentaId + "-" + rowOrigem.get("EMPRESA_ID"), (HashMap<String, Object>) rowDestino);
|
||||
mapDados.put(puntoVentaId + "-" + rowOrigem.get("EMPRESA_ID"), (LinkedHashMap<String, Object>) rowDestino);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, Object> getRow(Integer puntoVentaId, Integer empresaId, ResultSet rs) throws SQLException {
|
||||
protected LinkedHashMap<String, Object> getRow(Integer puntoVentaId, Integer empresaId, ResultSet rs) throws SQLException {
|
||||
|
||||
Map<String, Object> row;
|
||||
LinkedHashMap<String, Object> row;
|
||||
if (mapDados.containsKey(puntoVentaId.toString() + "-" + empresaId.toString())) {
|
||||
row = mapDados.get(puntoVentaId.toString() + "-" + empresaId.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new HashMap<String, Object>();
|
||||
row = new LinkedHashMap<String, Object>();
|
||||
row.put("TOTAL_BILHETES", BigDecimal.ZERO);
|
||||
row.put("TOTAL_BILHETES_CANC", BigDecimal.ZERO);
|
||||
row.put("TOTAL_BILHETES_GAP", BigDecimal.ZERO);
|
||||
|
@ -318,7 +333,7 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
public void initDados() throws Exception {
|
||||
pontoVendaConfiguracao = new HashSet<PuntoVenta>();
|
||||
this.prepareQuery();
|
||||
this.mapDados = new HashMap<String, HashMap<String, Object>>();
|
||||
this.mapDados = new LinkedHashMap<String, LinkedHashMap<String, Object>>();
|
||||
|
||||
this.resultSet.setFetchSize(1000);
|
||||
while (this.resultSet.next()) {
|
||||
|
@ -330,9 +345,9 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
Integer idEstado = this.resultSet.getInt("ORIGEM_ESTADO_ID");
|
||||
|
||||
// Inicializa a row atual
|
||||
Map<String, Object> row = this.getRow(puntoVentaId, empresaId, this.resultSet);
|
||||
LinkedHashMap<String, Object> row = this.getRow(puntoVentaId, empresaId, this.resultSet);
|
||||
|
||||
this.mapDados.put(row.get("PUNTOVENTA_ID") + "-" + empresaId.toString(), (HashMap<String, Object>) row);
|
||||
this.mapDados.put(row.get("PUNTOVENTA_ID") + "-" + empresaId.toString(), (LinkedHashMap<String, Object>) row);
|
||||
|
||||
if ((Boolean) getParametros().get("TRANSFERENCIA_PASSAGENS")) {
|
||||
// Utiliza o -1 para retirar as transferências
|
||||
|
@ -451,9 +466,9 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
public void processaParametros() throws Exception {
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getConfigComissao(Integer puntoVentaId, Integer empresaId) throws Exception {
|
||||
public LinkedHashMap<String, Object> getConfigComissao(Integer puntoVentaId, Integer empresaId) throws Exception {
|
||||
|
||||
HashMap<String, Object> cacheConfig = null;
|
||||
LinkedHashMap<String, Object> cacheConfig = null;
|
||||
|
||||
// Verifica se já existe configuração na memoria, caso não exista, realiza busca no banco
|
||||
if (!mapCacheConfigComissao.containsKey(puntoVentaId.toString() + "_" + empresaId.toString())) {
|
||||
|
@ -481,7 +496,7 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
ResultSet rs = stmt.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
cacheConfig = new HashMap<String, Object>();
|
||||
cacheConfig = new LinkedHashMap<String, Object>();
|
||||
|
||||
cacheConfig.put("ISSRETIDO", rs.getBigDecimal("ISSRETIDO"));
|
||||
cacheConfig.put("ROYALTIES", rs.getBigDecimal("ROYALTIES"));
|
||||
|
@ -750,7 +765,7 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio {
|
|||
sql.append(" :ISNUMPUNTOVENTATODOS = 'N') OR (:ISNUMPUNTOVENTATODOS = 'S')) ");
|
||||
sql.append(" AND ((INSTR(:ESTADO_ID, ',' || TRIM(ES.ESTADO_ID) || ',') > 0 AND ");
|
||||
sql.append(" :ISESTADOTODOS = 'N') OR (:ISESTADOTODOS = 'S')) ");
|
||||
sql.append(" ORDER BY to_number(regexp_substr(PV.NUMPUNTOVENTA, '\\d+')), EC.NOMBEMPRESA, ES.CVEESTADO ");
|
||||
sql.append(" ORDER BY lpad(to_number(regexp_substr(PV.NUMPUNTOVENTA, '\\d+')), 6), EC.NOMBEMPRESA, ES.CVEESTADO ");
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue