bug#10939
dev: julio qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@83352 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
fa919b8a27
commit
cae18c4edb
|
@ -656,8 +656,8 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
sql.append(" and coalesce(case when s.aliasorigen_id is null then ei.activo else eis.activo end, 0) = 1 ");
|
sql.append(" and coalesce(case when s.aliasorigen_id is null then ei.activo else eis.activo end, 0) = 1 ");
|
||||||
sql.append(" and c.serieimpfiscal is not null ");
|
sql.append(" and c.serieimpfiscal is not null ");
|
||||||
sql.append(" and ((c.indreimpresion = 0 and c.motivocancelacion_id is null and c.numfoliosistema is not null) or (c.indstatusboleto = 'E' and c.indreimpresion = 1)) ");
|
sql.append(" and ((c.indreimpresion = 0 and c.motivocancelacion_id is null and c.numfoliosistema is not null) or (c.indstatusboleto = 'E' and c.indreimpresion = 1)) ");
|
||||||
// sql.append(" and (coalesce(c.preciopagado,0) + coalesce(c.importetaxaembarque,0) + coalesce(c.importeseguro,0) + coalesce(c.importepedagio,0) + coalesce(c.importeoutros,0)) > 0 ");
|
// sql.append(" and (coalesce(c.preciopagado,0) + coalesce(c.importetaxaembarque,0) + coalesce(c.importeseguro,0) + coalesce(c.importepedagio,0) + coalesce(c.importeoutros,0)) > 0 ");
|
||||||
// sql.append(" and ((case when coalesce(r.indtribtarifa,0) = 1 then c.preciopagado else 0 end) + (case when coalesce(r.indtribtaxaembarque,0) = 1 then c.importetaxaembarque else 0 end) + (case when coalesce(r.indtribpedagio,0) = 1 then c.importepedagio else 0 end)) > 0 ");
|
// sql.append(" and ((case when coalesce(r.indtribtarifa,0) = 1 then c.preciopagado else 0 end) + (case when coalesce(r.indtribtaxaembarque,0) = 1 then c.importetaxaembarque else 0 end) + (case when coalesce(r.indtribpedagio,0) = 1 then c.importepedagio else 0 end)) > 0 ");
|
||||||
sql.append(" and c.feccreacion >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') and c.feccreacion <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') ");
|
sql.append(" and c.feccreacion >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') and c.feccreacion <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') ");
|
||||||
sql.append(" and c.empresacorrida_id = :EMPRESA_ID ");
|
sql.append(" and c.empresacorrida_id = :EMPRESA_ID ");
|
||||||
sql.append(isEstadoTodos ? "" : " and ((case when s.aliasorigen_id is null then eo.estado_id else eos.estado_id end) = :ESTADO_ID )");
|
sql.append(isEstadoTodos ? "" : " and ((case when s.aliasorigen_id is null then eo.estado_id else eos.estado_id end) = :ESTADO_ID )");
|
||||||
|
@ -2338,7 +2338,8 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
sb.append(" left join empresa_imposto eif on eif.activo = 1 and eif.empresa_id = f.empresa_id and eif.estado_id = eof.estado_id");
|
sb.append(" left join empresa_imposto eif on eif.activo = 1 and eif.empresa_id = f.empresa_id and eif.estado_id = eof.estado_id");
|
||||||
sb.append(" left join inscricao_estadual ie on ie.empresa_id = f.empresa_id and ie.estado_id = eof.estado_id and ie.activo = 1");
|
sb.append(" left join inscricao_estadual ie on ie.empresa_id = f.empresa_id and ie.estado_id = eof.estado_id and ie.activo = 1");
|
||||||
sb.append(" left join ciudad cie on cie.ciudad_id = ie.ciudad_id");
|
sb.append(" left join ciudad cie on cie.ciudad_id = ie.ciudad_id");
|
||||||
sb.append(" left join caja b on b.activo = 1 and b.rmd_id = (case when coalesce(f.indcancelacion, 0) = 1 then -1 else f.rmd_id end) and b.empresacorrida_id = f.empresa_id and b.foliormd = f.folio and to_char(b.fechorventa, 'ddmmyyyy') = to_char(f.fechorfolio, 'ddmmyyyy')");
|
// sb.append(" left join caja b on b.activo = 1 and b.rmd_id = (case when coalesce(f.indcancelacion, 0) = 1 then -1 else f.rmd_id end) and b.empresacorrida_id = f.empresa_id and b.foliormd = f.folio and to_char(b.fechorventa, 'ddmmyyyy') = to_char(f.fechorfolio, 'ddmmyyyy')");
|
||||||
|
sb.append(" left join caja b on b.activo = 1 and b.rmd_id = f.rmd_id and b.empresacorrida_id = f.empresa_id and b.foliormd = f.folio and to_char(b.fechorventa, 'ddmmyyyy') = to_char(f.fechorfolio, 'ddmmyyyy')");
|
||||||
sb.append(" left join parada po on po.parada_id = b.origen_id and po.activo = 1 ");
|
sb.append(" left join parada po on po.parada_id = b.origen_id and po.activo = 1 ");
|
||||||
sb.append(" left join ciudad co on co.ciudad_id = po.ciudad_id and co.activo = 1 ");
|
sb.append(" left join ciudad co on co.ciudad_id = po.ciudad_id and co.activo = 1 ");
|
||||||
sb.append(" left join estado eo on eo.estado_id = co.estado_id and eo.activo = 1 ");
|
sb.append(" left join estado eo on eo.estado_id = co.estado_id and eo.activo = 1 ");
|
||||||
|
@ -2597,7 +2598,6 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
sb.append(" and eo.cveestado like ?");
|
sb.append(" and eo.cveestado like ?");
|
||||||
sb.append(" and f.indcancelacion = 1 and f.indbpr = 1 and f.activo = 1");
|
sb.append(" and f.indcancelacion = 1 and f.indbpr = 1 and f.activo = 1");
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = connection.prepareStatement(sb.toString());
|
PreparedStatement ps = connection.prepareStatement(sb.toString());
|
||||||
ps.setLong(1, Long.valueOf(empresaId));
|
ps.setLong(1, Long.valueOf(empresaId));
|
||||||
|
@ -3205,39 +3205,83 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
|
|
||||||
List<String> foliosRmd = new ArrayList<String>();
|
List<String> foliosRmd = new ArrayList<String>();
|
||||||
|
|
||||||
inativarFolioConsumoRmd(connection, empresaId, estado.getEstadoId(), aidf.getAidfId(), folioInicial, folioFinal);
|
if (isCancela) {
|
||||||
|
cancelaFolioConsumoRmd(connection, empresaId, estado.getEstadoId(), aidf.getAidfId(), folioInicial, folioFinal, inicio, fim);
|
||||||
|
} else {
|
||||||
|
inativarFolioConsumoRmd(connection, empresaId, estado.getEstadoId(), aidf.getAidfId(), folioInicial, folioFinal, inicio, fim);
|
||||||
|
|
||||||
for (DetalhadoRMD brp : buscarRegistroImpressaoBPR(connection, inicio, fim, empresaId, estado.getCveestado(), aidf.getAidfId(),
|
for (DetalhadoRMD brp : buscarRegistroImpressaoBPR(connection, inicio, fim, empresaId, estado.getCveestado(), aidf.getAidfId(),
|
||||||
folioInicial, folioFinal, isBPR, isECF, true)) {
|
folioInicial, folioFinal, isBPR, isECF, true)) {
|
||||||
|
|
||||||
if (!foliosRmd.contains(brp.getFoliormd()))
|
if (!foliosRmd.contains(brp.getFoliormd()))
|
||||||
foliosRmd.add(brp.getFoliormd());
|
foliosRmd.add(brp.getFoliormd());
|
||||||
|
|
||||||
if (cont == 999) {
|
if (cont == 999) {
|
||||||
boletos.add(boletoAgr);
|
boletos.add(boletoAgr);
|
||||||
boletoAgr = null;
|
boletoAgr = null;
|
||||||
cont = 0;
|
cont = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boletoAgr == null)
|
||||||
|
boletoAgr = brp.getCajaId().toString();
|
||||||
|
else
|
||||||
|
boletoAgr = boletoAgr + " ," + brp.getCajaId();
|
||||||
|
|
||||||
|
cont++;
|
||||||
|
}
|
||||||
|
boletos.add(boletoAgr);
|
||||||
|
|
||||||
|
for (String folio : foliosRmd) {
|
||||||
|
insereConsulmoFolioRMD(connection, inicio, empresaId, estado.getEstadoId(), aidf, folio,
|
||||||
|
isCancela, isInativa, false, isECF, isBPR, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boletoAgr == null)
|
marcarRMDCaja(connection, boletos, null, null);
|
||||||
boletoAgr = brp.getCajaId().toString();
|
|
||||||
else
|
|
||||||
boletoAgr = boletoAgr + " ," + brp.getCajaId();
|
|
||||||
|
|
||||||
cont++;
|
|
||||||
}
|
}
|
||||||
boletos.add(boletoAgr);
|
}
|
||||||
|
|
||||||
for (String folio : foliosRmd) {
|
private void cancelaFolioConsumoRmd(Connection connection, Integer empresaId, Integer estadoId,
|
||||||
insereConsulmoFolioRMD(connection, inicio, empresaId, estado.getEstadoId(), aidf, folio,
|
Long rmdId, String folioInicial, String folioFinal, Date inicio, Date fim) {
|
||||||
isCancela, isInativa, false, isECF, isBPR, null, null, null, null, null, null);
|
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(" update folio_consumo_rmd ");
|
||||||
|
sb.append(" set activo = 1, fecmodif = sysdate, indcancelacion = 1 ");
|
||||||
|
sb.append(" where activo = 1 ");
|
||||||
|
sb.append(" and indimpresso = 1 ");
|
||||||
|
sb.append(" and rmd_id = ? ");
|
||||||
|
sb.append(" and empresa_id = ? ");
|
||||||
|
sb.append(" and estado_id = ? ");
|
||||||
|
sb.append(" and folio between ? and ? ");
|
||||||
|
sb.append(" and fechorfolio between to_date(?,'dd/MM/yyyy HH24:MI:SS') and to_date(?,'dd/MM/yyyy HH24:MI:SS') ");
|
||||||
|
|
||||||
|
pstmt = connection.prepareStatement(sb.toString());
|
||||||
|
pstmt.setInt(1, rmdId.intValue());
|
||||||
|
pstmt.setInt(2, empresaId);
|
||||||
|
pstmt.setInt(3, estadoId);
|
||||||
|
pstmt.setString(4, folioInicial);
|
||||||
|
pstmt.setString(5, folioFinal);
|
||||||
|
pstmt.setString(6, DateUtil.getStringDate(inicio, DATE_FORMAT_DMY) + " 00:00:00");
|
||||||
|
pstmt.setString(7, DateUtil.getStringDate(fim, DATE_FORMAT_DMY) + " 23:59:59");
|
||||||
|
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (pstmt != null && !pstmt.isClosed()) {
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
marcarRMDCaja(connection, boletos, null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inativarFolioConsumoRmd(Connection connection, Integer empresaId, Integer estadoId,
|
private void inativarFolioConsumoRmd(Connection connection, Integer empresaId, Integer estadoId,
|
||||||
Long rmdId, String folioInicial, String folioFinal) {
|
Long rmdId, String folioInicial, String folioFinal, Date inicio, Date fim) {
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
|
@ -3250,6 +3294,7 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
sb.append(" and empresa_id = ? ");
|
sb.append(" and empresa_id = ? ");
|
||||||
sb.append(" and estado_id = ? ");
|
sb.append(" and estado_id = ? ");
|
||||||
sb.append(" and folio between ? and ? ");
|
sb.append(" and folio between ? and ? ");
|
||||||
|
sb.append(" and fechorfolio between to_date(?,'dd/MM/yyyy HH24:MI:SS') and to_date(?,'dd/MM/yyyy HH24:MI:SS') ");
|
||||||
|
|
||||||
pstmt = connection.prepareStatement(sb.toString());
|
pstmt = connection.prepareStatement(sb.toString());
|
||||||
pstmt.setInt(1, rmdId.intValue());
|
pstmt.setInt(1, rmdId.intValue());
|
||||||
|
@ -3257,6 +3302,8 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
pstmt.setInt(3, estadoId);
|
pstmt.setInt(3, estadoId);
|
||||||
pstmt.setString(4, folioInicial);
|
pstmt.setString(4, folioInicial);
|
||||||
pstmt.setString(5, folioFinal);
|
pstmt.setString(5, folioFinal);
|
||||||
|
pstmt.setString(6, DateUtil.getStringDate(inicio, DATE_FORMAT_DMY) + " 00:00:00");
|
||||||
|
pstmt.setString(7, DateUtil.getStringDate(fim, DATE_FORMAT_DMY) + " 23:59:59");
|
||||||
|
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
|
|
||||||
|
@ -3849,8 +3896,6 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getSqlImpressaoRMDCancelados() {
|
private String getSqlImpressaoRMDCancelados() {
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
|
@ -3868,7 +3913,6 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FiscalRdi> buscarRelatorioRDI(Connection connection, Date inicio, Date fim, Integer empresaId, List<Estado> estados, boolean isReceitaTerceiros) {
|
public List<FiscalRdi> buscarRelatorioRDI(Connection connection, Date inicio, Date fim, Integer empresaId, List<Estado> estados, boolean isReceitaTerceiros) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue