bug #8121
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@64295 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
3165f78959
commit
a7a2ac19a5
|
@ -5,6 +5,7 @@ import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Aidf;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCCF;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCCF;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCFC;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCFC;
|
||||||
|
@ -49,4 +50,8 @@ public interface FiscalDAO {
|
||||||
public List<ExportacaoRMDTipoDBP> buscarRegistroRMDTipoDBP(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado);
|
public List<ExportacaoRMDTipoDBP> buscarRegistroRMDTipoDBP(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado);
|
||||||
|
|
||||||
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado, String rmd);
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado, String rmd);
|
||||||
|
|
||||||
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoECF(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado, String rmd);
|
||||||
|
|
||||||
|
public void gravarRMDBoleto(Connection connection, List<ImpressaoRMD> rmds, Aidf aidf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.FiscalDAO;
|
import com.rjconsultores.ventaboletos.dao.FiscalDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Aidf;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.StringHelper;
|
import com.rjconsultores.ventaboletos.utilerias.StringHelper;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCCF;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCCF;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCFC;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoCFC;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoICF;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoECFTipoICF;
|
||||||
|
@ -32,7 +34,7 @@ import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRM
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRMDTipoDBP;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRMDTipoDBP;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRMDTipoPAR;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRMDTipoPAR;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRMDTipoRMD;
|
import com.rjconsultores.ventaboletos.utilerias.exportacaofiscal.vo.ExportacaoRMDTipoRMD;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.impressaormd.vo.DetalhadoRMDTipoDVB;
|
import com.rjconsultores.ventaboletos.utilerias.impressaormd.vo.DetalhadoRMD;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.impressaormd.vo.ImpressaoRMD;
|
import com.rjconsultores.ventaboletos.utilerias.impressaormd.vo.ImpressaoRMD;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalVO;
|
||||||
|
@ -1077,12 +1079,12 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sb.append(" and c.feccorrida between :datIni and :datFim ");
|
sb.append(" and c.feccorrida between :datIni and :datFim ");
|
||||||
sb.append(" and c.corrida_id in (:corridaId) ");
|
sb.append(" and c.corrida_id in (:corridaId) ");
|
||||||
sb.append(" and CODPRODUTO(t.origen_id , t.destino_id , rc.ruta_id) not in (select codproduto from fiscal_p2) ");
|
sb.append(" and CODPRODUTO(t.origen_id , t.destino_id , rc.ruta_id) not in (select codproduto from fiscal_p2) ");
|
||||||
//sb.append(" and ROWNUM < 50 ");
|
// sb.append(" and ROWNUM < 50 ");
|
||||||
|
|
||||||
int qtd = 0;
|
int qtd = 0;
|
||||||
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
try{
|
try {
|
||||||
connection = dataSource.getConnection();
|
connection = dataSource.getConnection();
|
||||||
|
|
||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
|
@ -1091,21 +1093,19 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
|
|
||||||
ps.setDate(1, new java.sql.Date(dataDe.getTime()));
|
ps.setDate(1, new java.sql.Date(dataDe.getTime()));
|
||||||
ps.setDate(2, new java.sql.Date(dataAte.getTime()));
|
ps.setDate(2, new java.sql.Date(dataAte.getTime()));
|
||||||
ps.setString(3,StringUtils.join(idsCorrida, ","));
|
ps.setString(3, StringUtils.join(idsCorrida, ","));
|
||||||
|
|
||||||
qtd = ps.executeUpdate();
|
qtd = ps.executeUpdate();
|
||||||
|
|
||||||
connection.commit();
|
connection.commit();
|
||||||
}catch(Throwable t){
|
} catch (Throwable t) {
|
||||||
connection.rollback();
|
connection.rollback();
|
||||||
}finally{
|
} finally {
|
||||||
if (connection != null){
|
if (connection != null) {
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return qtd;
|
return qtd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1144,14 +1144,14 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sb.append(" and cto.fechorsalida between vt.feciniciovigencia and vt.fecfinvigencia ");
|
sb.append(" and cto.fechorsalida between vt.feciniciovigencia and vt.fecfinvigencia ");
|
||||||
sb.append(" and c.feccorrida between :datIni and :datFim ");
|
sb.append(" and c.feccorrida between :datIni and :datFim ");
|
||||||
sb.append(" and c.corrida_id in (:corridaId) ");
|
sb.append(" and c.corrida_id in (:corridaId) ");
|
||||||
//sb.append(" and ROWNUM < 2 ");
|
// sb.append(" and ROWNUM < 2 ");
|
||||||
|
|
||||||
Integer[] idsCorrida = getIdsCorrida(lsEsquemaCorrida);
|
Integer[] idsCorrida = getIdsCorrida(lsEsquemaCorrida);
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
|
||||||
int qtd = 0;
|
int qtd = 0;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
connection = dataSource.getConnection();
|
connection = dataSource.getConnection();
|
||||||
|
|
||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
|
@ -1160,21 +1160,20 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
|
|
||||||
ps.setDate(1, new java.sql.Date(dataDe.getTime()));
|
ps.setDate(1, new java.sql.Date(dataDe.getTime()));
|
||||||
ps.setDate(2, new java.sql.Date(dataAte.getTime()));
|
ps.setDate(2, new java.sql.Date(dataAte.getTime()));
|
||||||
ps.setString(3,StringUtils.join(idsCorrida, ","));
|
ps.setString(3, StringUtils.join(idsCorrida, ","));
|
||||||
|
|
||||||
qtd = ps.executeUpdate();
|
qtd = ps.executeUpdate();
|
||||||
|
|
||||||
connection.commit();
|
connection.commit();
|
||||||
|
|
||||||
}catch(Throwable t){
|
} catch (Throwable t) {
|
||||||
connection.rollback();
|
connection.rollback();
|
||||||
}finally{
|
} finally {
|
||||||
if (connection != null){
|
if (connection != null) {
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return qtd;
|
return qtd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2184,12 +2183,41 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
return retorno;
|
return retorno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado, String rmd) {
|
@Override
|
||||||
|
public void gravarRMDBoleto(Connection connection, List<ImpressaoRMD> rmds, Aidf aidf) {
|
||||||
|
|
||||||
|
for (ImpressaoRMD imp : rmds) {
|
||||||
|
for (DetalhadoRMD det : imp.getDetalhada()) {
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try {
|
||||||
|
sb.append(" update boleto set rmd_id = ").append(aidf.getAidfId()).append(", ");
|
||||||
|
sb.append(" fecmodif = SYSDATE, usuario_id = ").append(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
sb.append(" where boleto_id = ").append(det.getBoletoId());
|
||||||
|
pstmt = connection.prepareStatement(sb.toString());
|
||||||
|
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
pstmt.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Integer empresaId,
|
||||||
|
String cveestado, String rmd) {
|
||||||
|
|
||||||
List<ImpressaoRMD> list = new ArrayList<ImpressaoRMD>();
|
List<ImpressaoRMD> list = new ArrayList<ImpressaoRMD>();
|
||||||
|
|
||||||
// IMPRESSAO RMD MANUAL
|
// IMPRESSAO RMD MANUAL
|
||||||
|
|
||||||
String serie = null;
|
String serie = null;
|
||||||
Date data = null;
|
Date data = null;
|
||||||
// int primeiroFolio = 0;
|
// int primeiroFolio = 0;
|
||||||
|
@ -2197,7 +2225,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
|
|
||||||
ImpressaoRMD impRmd = null;
|
ImpressaoRMD impRmd = null;
|
||||||
|
|
||||||
for (DetalhadoRMDTipoDVB brp : buscarRegistroImpressaoRMDTipoDVB(connection, inicio, fim, empresaId, cveestado)) {
|
for (DetalhadoRMD brp : buscarRegistroImpressaoRMD(connection, inicio, fim, empresaId, cveestado, false)) {
|
||||||
|
|
||||||
if (serie == null) {
|
if (serie == null) {
|
||||||
impRmd = new ImpressaoRMD(brp.getEmpresa(), brp.getEnderecoEmpresa(), brp.getCnpjEmpresa(), brp.getIeEmpresa(),
|
impRmd = new ImpressaoRMD(brp.getEmpresa(), brp.getEnderecoEmpresa(), brp.getCnpjEmpresa(), brp.getIeEmpresa(),
|
||||||
|
@ -2257,7 +2285,83 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal somarTotalBilhete(DetalhadoRMDTipoDVB brp) {
|
@Override
|
||||||
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoECF(Connection connection, Date inicio, Date fim, Integer empresaId,
|
||||||
|
String cveestado, String rmd) {
|
||||||
|
|
||||||
|
List<ImpressaoRMD> list = new ArrayList<ImpressaoRMD>();
|
||||||
|
|
||||||
|
// IMPRESSAO RMD ECF
|
||||||
|
String serie = null;
|
||||||
|
Date data = null;
|
||||||
|
int anteriorFolio = 0;
|
||||||
|
|
||||||
|
ImpressaoRMD impRmd = null;
|
||||||
|
|
||||||
|
for (DetalhadoRMD brp : buscarRegistroImpressaoRMD(connection, inicio, fim, empresaId, cveestado, true)) {
|
||||||
|
|
||||||
|
if (serie == null) {
|
||||||
|
impRmd = new ImpressaoRMD(brp.getEmpresa(), brp.getEnderecoEmpresa(), brp.getCnpjEmpresa(), brp.getIeEmpresa(),
|
||||||
|
brp.getFechorVenta(), rmd, "SERVIÇO DE TRANSPORTE", "ECF", brp.getEcf(), brp.getEstadoOrigem());
|
||||||
|
serie = brp.getEcf();
|
||||||
|
data = brp.getFechorVenta();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (serie.equals(brp.getEcf()) && data.equals(brp.getFechorVenta())) {
|
||||||
|
int coo = Integer.parseInt(brp.getCoo());
|
||||||
|
if (anteriorFolio + 1 == coo) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
impRmd.setNumero(brp.getCoo());
|
||||||
|
list.add(impRmd);
|
||||||
|
|
||||||
|
impRmd = new ImpressaoRMD(brp.getEmpresa(), brp.getEnderecoEmpresa(), brp.getCnpjEmpresa(), brp.getIeEmpresa(),
|
||||||
|
brp.getFechorVenta(), rmd, "SERVIÇO DE TRANSPORTE", "ECF", brp.getEcf(), brp.getEstadoOrigem());
|
||||||
|
serie = brp.getEcf();
|
||||||
|
data = brp.getFechorVenta();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
impRmd.setNumero(brp.getCoo());
|
||||||
|
list.add(impRmd);
|
||||||
|
|
||||||
|
impRmd = new ImpressaoRMD(brp.getEmpresa(), brp.getEnderecoEmpresa(), brp.getCnpjEmpresa(), brp.getIeEmpresa(),
|
||||||
|
brp.getFechorVenta(), rmd, "SERVIÇO DE TRANSPORTE", "ECF", brp.getEcf(), brp.getEstadoOrigem());
|
||||||
|
serie = brp.getEcf();
|
||||||
|
data = brp.getFechorVenta();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal valorContabil = impRmd.getValorContabil() == null ? BigDecimal.ZERO : impRmd.getValorContabil().add(somarTotalBilhete(brp));
|
||||||
|
BigDecimal baseCalculo = impRmd.getBaseCalculo() == null ? BigDecimal.ZERO : impRmd.getBaseCalculo().add(
|
||||||
|
brp.getTarifa() == null ? BigDecimal.ZERO : brp.getTarifa());
|
||||||
|
|
||||||
|
BigDecimal aliquota = brp.getIcmsInterestadual();
|
||||||
|
BigDecimal icms = baseCalculo.multiply(aliquota.divide(BigDecimal.TEN.multiply(BigDecimal.TEN)));
|
||||||
|
|
||||||
|
BigDecimal isentos = BigDecimal.ZERO;
|
||||||
|
BigDecimal outros = valorContabil.subtract(baseCalculo);
|
||||||
|
|
||||||
|
impRmd.setValorContabil(valorContabil);
|
||||||
|
impRmd.setBaseCalculo(baseCalculo);
|
||||||
|
impRmd.setAliquota(aliquota);
|
||||||
|
impRmd.setIcms(icms);
|
||||||
|
impRmd.setIsentos(isentos);
|
||||||
|
impRmd.setOutros(outros);
|
||||||
|
|
||||||
|
impRmd.getDetalhada().add(brp);
|
||||||
|
anteriorFolio = brp.getFolio();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal somarTotalBilhete(DetalhadoRMD brp) {
|
||||||
|
|
||||||
BigDecimal total = BigDecimal.ZERO;
|
BigDecimal total = BigDecimal.ZERO;
|
||||||
total = total.add(brp.getTarifa() == null ? BigDecimal.ZERO : brp.getTarifa());
|
total = total.add(brp.getTarifa() == null ? BigDecimal.ZERO : brp.getTarifa());
|
||||||
|
@ -2268,10 +2372,77 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DetalhadoRMDTipoDVB> buscarRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado) {
|
public List<DetalhadoRMD> buscarRegistroImpressaoRMD(Connection connection, Date inicio, Date fim,
|
||||||
|
Integer empresaId, String cveestado, boolean isECF) {
|
||||||
|
|
||||||
List<DetalhadoRMDTipoDVB> list = new ArrayList<DetalhadoRMDTipoDVB>();
|
List<DetalhadoRMD> list = new ArrayList<DetalhadoRMD>();
|
||||||
try {
|
try {
|
||||||
|
String sql = null;
|
||||||
|
if (isECF) {
|
||||||
|
sql = getSqlImpressaoRMDTipoECF();
|
||||||
|
} else {
|
||||||
|
sql = getSqlImpressaoRMDTipoDVB();
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStatement ps = connection.prepareStatement(sql);
|
||||||
|
ps.setLong(1, Long.valueOf(empresaId));
|
||||||
|
ps.setDate(2, new java.sql.Date(inicio.getTime()));
|
||||||
|
ps.setDate(3, new java.sql.Date(fim.getTime()));
|
||||||
|
ps.setString(4, cveestado);
|
||||||
|
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
|
||||||
|
DetalhadoRMD brp = new DetalhadoRMD();
|
||||||
|
brp.setBoletoId(rs.getLong("boletoId"));
|
||||||
|
brp.setNumoperacion(rs.getString("numoperacion"));
|
||||||
|
brp.setSerie(rs.getString("serieCompl"));
|
||||||
|
brp.setFolio(rs.getInt("folio"));
|
||||||
|
brp.setEstadoId(rs.getInt("estadoId"));
|
||||||
|
brp.setFechorVenta(rs.getDate("fechorVenta"));
|
||||||
|
brp.setEmpresa(rs.getString("empresa"));
|
||||||
|
brp.setEnderecoEmpresa(rs.getString("enderecoEmpresa"));
|
||||||
|
brp.setCnpjEmpresa(rs.getString("cnpjEmpresa"));
|
||||||
|
brp.setIeEmpresa(rs.getString("ieEmpresa"));
|
||||||
|
brp.setIcmsInterestadual(rs.getBigDecimal("icmsInterestadual"));
|
||||||
|
brp.setIcmsIntermunicipal(rs.getBigDecimal("icmsIntermunicipal"));
|
||||||
|
brp.setEstadoOrigem(rs.getString("estadoOrigem"));
|
||||||
|
brp.setEstadoDestino(rs.getString("estadoDestino"));
|
||||||
|
brp.setMunicipioOrigem(rs.getString("municipioOrigem"));
|
||||||
|
brp.setInterEstadual(rs.getBoolean("isInterEstadual"));
|
||||||
|
brp.setIcmsInterestadual(rs.getBigDecimal("icmsInterestadual"));
|
||||||
|
brp.setRedBaseCalcIcms(rs.getBigDecimal("redBaseCalcIcms"));
|
||||||
|
brp.setPorcRedMunicipal(rs.getBigDecimal("porcRedMunicipal"));
|
||||||
|
brp.setPorcRedEstadual(rs.getBigDecimal("porcRedEstadual"));
|
||||||
|
brp.setTributacaoImportacao(rs.getBigDecimal("tributacaoImportacao"));
|
||||||
|
brp.setIsenta(rs.getBigDecimal("isenta"));
|
||||||
|
brp.setTarifa(rs.getBigDecimal("tarifa"));
|
||||||
|
brp.setTaxaEmbarque(rs.getBigDecimal("taxaEmbarque"));
|
||||||
|
brp.setPedagio(rs.getBigDecimal("pedagio"));
|
||||||
|
brp.setSeguro(rs.getBigDecimal("seguro"));
|
||||||
|
brp.setOutros(rs.getBigDecimal("outros"));
|
||||||
|
|
||||||
|
if (isECF) {
|
||||||
|
brp.setEcf(rs.getString("ecf"));
|
||||||
|
brp.setDatamov(rs.getString("datamov"));
|
||||||
|
brp.setCoo(rs.getString("coo"));
|
||||||
|
brp.setTotalFiscal(rs.getString("totalFiscal"));
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(brp);
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSqlImpressaoRMDTipoDVB() {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("select ");
|
sql.append("select ");
|
||||||
sql.append(" b.boleto_id as boletoId, ");
|
sql.append(" b.boleto_id as boletoId, ");
|
||||||
|
@ -2339,60 +2510,97 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append("where ");
|
sql.append("where ");
|
||||||
sql.append(" b.activo = 1 ");
|
sql.append(" b.activo = 1 ");
|
||||||
sql.append(" and b.tipoventa_id = 3 ");
|
sql.append(" and b.tipoventa_id = 3 ");
|
||||||
sql.append(" and b.indstatusboleto like 'V' ");
|
sql.append(" and b.rmd_id is null ");
|
||||||
|
sql.append(" and b.indstatusboleto = 'V' ");
|
||||||
sql.append(" and b.empresacorrida_id = ? ");
|
sql.append(" and b.empresacorrida_id = ? ");
|
||||||
sql.append(" and b.fechorventa between ? and ? ");
|
sql.append(" and b.fechorventa between ? and ? ");
|
||||||
sql.append(" and coalesce(eos.cveestado, eo.cveestado) = ? ");
|
sql.append(" and coalesce(eos.cveestado, eo.cveestado) = ? ");
|
||||||
sql.append("order by estadoId, fechorVenta ");
|
sql.append("order by estadoId, serieCompl, folio, fechorVenta ");
|
||||||
|
|
||||||
PreparedStatement ps = connection.prepareStatement(sql.toString());
|
return sql.toString();
|
||||||
ps.setLong(1, Long.valueOf(empresaId));
|
|
||||||
ps.setDate(2, new java.sql.Date(inicio.getTime()));
|
|
||||||
ps.setDate(3, new java.sql.Date(fim.getTime()));
|
|
||||||
ps.setString(4, cveestado);
|
|
||||||
|
|
||||||
ResultSet rs = ps.executeQuery();
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
DetalhadoRMDTipoDVB brp = new DetalhadoRMDTipoDVB();
|
|
||||||
brp.setBoletoId(rs.getLong("boletoId"));
|
|
||||||
brp.setNumoperacion(rs.getString("numoperacion"));
|
|
||||||
brp.setSerie(rs.getString("serieCompl"));
|
|
||||||
brp.setFolio(rs.getInt("folio"));
|
|
||||||
brp.setEstadoId(rs.getInt("estadoId"));
|
|
||||||
brp.setFechorVenta(rs.getDate("fechorVenta"));
|
|
||||||
brp.setEmpresa(rs.getString("empresa"));
|
|
||||||
brp.setEnderecoEmpresa(rs.getString("enderecoEmpresa"));
|
|
||||||
brp.setCnpjEmpresa(rs.getString("cnpjEmpresa"));
|
|
||||||
brp.setIeEmpresa(rs.getString("ieEmpresa"));
|
|
||||||
brp.setIcmsInterestadual(rs.getBigDecimal("icmsInterestadual"));
|
|
||||||
brp.setIcmsIntermunicipal(rs.getBigDecimal("icmsIntermunicipal"));
|
|
||||||
brp.setEstadoOrigem(rs.getString("estadoOrigem"));
|
|
||||||
brp.setEstadoDestino(rs.getString("estadoDestino"));
|
|
||||||
brp.setMunicipioOrigem(rs.getString("municipioOrigem"));
|
|
||||||
brp.setInterEstadual(rs.getBoolean("isInterEstadual"));
|
|
||||||
brp.setIcmsInterestadual(rs.getBigDecimal("icmsInterestadual"));
|
|
||||||
brp.setRedBaseCalcIcms(rs.getBigDecimal("redBaseCalcIcms"));
|
|
||||||
brp.setPorcRedMunicipal(rs.getBigDecimal("porcRedMunicipal"));
|
|
||||||
brp.setPorcRedEstadual(rs.getBigDecimal("porcRedEstadual"));
|
|
||||||
brp.setTributacaoImportacao(rs.getBigDecimal("tributacaoImportacao"));
|
|
||||||
brp.setIsenta(rs.getBigDecimal("isenta"));
|
|
||||||
brp.setTarifa(rs.getBigDecimal("tarifa"));
|
|
||||||
brp.setTaxaEmbarque(rs.getBigDecimal("taxaEmbarque"));
|
|
||||||
brp.setPedagio(rs.getBigDecimal("pedagio"));
|
|
||||||
brp.setSeguro(rs.getBigDecimal("seguro"));
|
|
||||||
brp.setOutros(rs.getBigDecimal("outros"));
|
|
||||||
|
|
||||||
list.add(brp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
public String getSqlImpressaoRMDTipoECF() {
|
||||||
ps.close();
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
StringBuilder sql = new StringBuilder();
|
||||||
log.error("", e);
|
sql.append("select ");
|
||||||
}
|
sql.append(" b.boleto_id as boletoId, ");
|
||||||
|
sql.append(" b.numoperacion as numoperacion, ");
|
||||||
|
sql.append(" b.numseriepreimpresa as serieCompl, ");
|
||||||
|
sql.append(" b.numfoliopreimpreso as folio, ");
|
||||||
|
sql.append(" a.acfiscal as numAidf, ");
|
||||||
|
sql.append(" a.serie as serieAidf, ");
|
||||||
|
sql.append(" a.subserie as subSerieAidf, ");
|
||||||
|
sql.append(" trunc(b.fechorventa) as fechorVenta, ");
|
||||||
|
sql.append(" e.nombempresa as empresa, ");
|
||||||
|
sql.append(" e.cnpj as cnpjEmpresa, ");
|
||||||
|
sql.append(" e.logradouro || ', ' || e.numero || ' - ' || e.bairro || ', ' || ce.nombciudad ");
|
||||||
|
sql.append(" || ' - ' || ee.cveestado || ', ' || e.cep ");
|
||||||
|
sql.append(" as enderecoEmpresa, ");
|
||||||
|
sql.append(" ie.numinscricaoestadual as ieEmpresa, ");
|
||||||
|
sql.append(" coalesce(eos.estado_id, eo.estado_id) as estadoId, ");
|
||||||
|
sql.append(" coalesce(ei.icms, eo.icms) as icmsInterestadual, ");
|
||||||
|
sql.append(" ei.icmsim as icmsIntermunicipal, ");
|
||||||
|
sql.append(" coalesce(eos.cveestado, eo.cveestado) as estadoOrigem, ");
|
||||||
|
sql.append(" coalesce(eds.cveestado, ed.cveestado) as estadoDestino, ");
|
||||||
|
sql.append(" coalesce(cos.codibge, co.codibge) as municipioOrigem, ");
|
||||||
|
sql.append(" case when((coalesce(eos.cveestado, eo.cveestado)) = ");
|
||||||
|
sql.append(" (coalesce(eds.cveestado, ed.cveestado))) ");
|
||||||
|
sql.append(" then 0 else 1 ");
|
||||||
|
sql.append(" end as isInterEstadual, ");
|
||||||
|
sql.append(" ei.porcredbaseicms as redBaseCalcIcms, ");
|
||||||
|
sql.append(" ei.porcredmunicipal as porcRedMunicipal, ");
|
||||||
|
sql.append(" ei.porcredestadual as porcRedEstadual, ");
|
||||||
|
sql.append(" ei.tributacaoimportacao as tributacaoImportacao, ");
|
||||||
|
sql.append(" case when (coalesce(pos.regionmetropolitana_id, po.regionmetropolitana_id, -1) = ");
|
||||||
|
sql.append(" coalesce(pds.regionmetropolitana_id, pd.regionmetropolitana_id, -2)) ");
|
||||||
|
sql.append(" then 1 else 0 end as isenta, ");
|
||||||
|
sql.append(" coalesce(b.preciopagado, 0) as tarifa, ");
|
||||||
|
sql.append(" coalesce(b.importetaxaembarque, 0) as taxaEmbarque, ");
|
||||||
|
sql.append(" coalesce(b.importepedagio, 0) as pedagio, ");
|
||||||
|
sql.append(" coalesce(b.importeseguro, 0) as seguro, ");
|
||||||
|
sql.append(" coalesce(b.importeoutros, 0) as outros, ");
|
||||||
|
sql.append(" r4.numserie20 as ecf, ");
|
||||||
|
sql.append(" r4.datamov as datamov, ");
|
||||||
|
sql.append(" r4.coo as coo, ");
|
||||||
|
sql.append(" r4.impsubtotal as totalFiscal ");
|
||||||
|
sql.append("from fiscal_r4 r4 ");
|
||||||
|
sql.append(" join boleto b on b.boleto_id = r4.boleto_id ");
|
||||||
|
sql.append(" join empresa e on e.empresa_id = b.empresacorrida_id ");
|
||||||
|
sql.append(" join ciudad ce on ce.ciudad_id = e.ciudad_id ");
|
||||||
|
sql.append(" join estado ee on ee.estado_id = ce.estado_id ");
|
||||||
|
sql.append(" join parada po on po.parada_id = b.origen_id ");
|
||||||
|
sql.append(" join ciudad co on co.ciudad_id = po.ciudad_id ");
|
||||||
|
sql.append(" join estado eo on eo.estado_id = co.estado_id ");
|
||||||
|
sql.append(" join parada pd on pd.parada_id = b.destino_id ");
|
||||||
|
sql.append(" join ciudad cd on cd.ciudad_id = pd.ciudad_id ");
|
||||||
|
sql.append(" join estado ed on ed.estado_id = cd.estado_id ");
|
||||||
|
sql.append(" left join alias_servico s on s.origen_id = b.origen_id ");
|
||||||
|
sql.append(" and s.destino_id = b.destino_id and s.corrida_id = b.corrida_id ");
|
||||||
|
sql.append(" and s.ruta_id = b.ruta_id ");
|
||||||
|
sql.append(" left join parada pos on pos.parada_id = s.aliasorigen_id ");
|
||||||
|
sql.append(" left join ciudad cos on cos.ciudad_id = pos.ciudad_id ");
|
||||||
|
sql.append(" left join estado eos on eos.estado_id = cos.estado_id ");
|
||||||
|
sql.append(" left join parada pds on pds.parada_id = s.aliasdestino_id ");
|
||||||
|
sql.append(" left join ciudad cds on cds.ciudad_id = pds.ciudad_id ");
|
||||||
|
sql.append(" left join estado eds on eds.estado_id = cds.estado_id ");
|
||||||
|
sql.append(" join inscricao_estadual ie on e.empresa_id = ie.empresa_id ");
|
||||||
|
sql.append(" and ie.estado_id = coalesce(eos.estado_id, eo.estado_id) and ie.activo = 1 ");
|
||||||
|
sql.append(" join empresa_imposto ei on ei.empresa_id = b.empresacorrida_id ");
|
||||||
|
sql.append(" and ei.estado_id = coalesce(eos.estado_id, eo.estado_id) and ei.activo = 1 ");
|
||||||
|
sql.append(" left join aidf a on a.serie = substr(b.numseriepreimpresa, 1, 3) ");
|
||||||
|
sql.append(" and a.estado_id = (CASE WHEN s.aliasorigen_id IS NULL ");
|
||||||
|
sql.append(" THEN eo.estado_id ELSE eos.estado_id END) ");
|
||||||
|
sql.append("where ");
|
||||||
|
sql.append(" b.activo = 1 ");
|
||||||
|
sql.append(" and b.tipoventa_id <> 3 ");
|
||||||
|
sql.append(" and b.rmd_id is null ");
|
||||||
|
sql.append(" and b.indstatusboleto = 'V' ");
|
||||||
|
sql.append(" and b.empresacorrida_id = ? ");
|
||||||
|
sql.append(" and b.fechorventa between ? and ? ");
|
||||||
|
sql.append(" and coalesce(eos.cveestado, eo.cveestado) = ? ");
|
||||||
|
sql.append("order by estadoId, ecf, coo, fechorVenta ");
|
||||||
|
|
||||||
return list;
|
return sql.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Aidf;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
@ -47,4 +48,8 @@ public interface FiscalService {
|
||||||
public File buscarArquivoExportacaoRMD(Date value, Date value2, Empresa empresa, Estado estado);
|
public File buscarArquivoExportacaoRMD(Date value, Date value2, Empresa empresa, Estado estado);
|
||||||
|
|
||||||
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Empresa empresa, Estado estado, String rmd);
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Empresa empresa, Estado estado, String rmd);
|
||||||
|
|
||||||
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoECF(Connection connection, Date inicio, Date fim, Empresa empresa, Estado estado, String rmd);
|
||||||
|
|
||||||
|
public void gravarRMDBoleto(Connection connection, List<ImpressaoRMD> rmds, Aidf aidf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.FiscalDAO;
|
import com.rjconsultores.ventaboletos.dao.FiscalDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Aidf;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||||
|
@ -87,11 +88,21 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
return fiscalDAO.gerarRegistroP2_F2(lsEsquemaCorrida, dataDe, dataAte);
|
return fiscalDAO.gerarRegistroP2_F2(lsEsquemaCorrida, dataDe, dataAte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gravarRMDBoleto(Connection connection, List<ImpressaoRMD> rmds, Aidf aidf) {
|
||||||
|
fiscalDAO.gravarRMDBoleto(connection, rmds, aidf);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Empresa empresa, Estado estado, String rmd) {
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoDVB(Connection connection, Date inicio, Date fim, Empresa empresa, Estado estado, String rmd) {
|
||||||
return fiscalDAO.getRegistroImpressaoRMDTipoDVB(connection, inicio, fim, empresa.getEmpresaId(), estado.getCveestado(), rmd);
|
return fiscalDAO.getRegistroImpressaoRMDTipoDVB(connection, inicio, fim, empresa.getEmpresaId(), estado.getCveestado(), rmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ImpressaoRMD> getRegistroImpressaoRMDTipoECF(Connection connection, Date inicio, Date fim, Empresa empresa, Estado estado, String rmd) {
|
||||||
|
return fiscalDAO.getRegistroImpressaoRMDTipoECF(connection, inicio, fim, empresa.getEmpresaId(), estado.getCveestado(), rmd);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File importacionFiscalECFManual(Date inicio, Date fim, Empresa empresa) {
|
public File importacionFiscalECFManual(Date inicio, Date fim, Empresa empresa) {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.rjconsultores.ventaboletos.utilerias.impressaormd.vo;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class DetalhadoRMDTipoDVB {
|
public class DetalhadoRMD {
|
||||||
|
|
||||||
private Long boletoId;
|
private Long boletoId;
|
||||||
private String numoperacion;
|
private String numoperacion;
|
||||||
|
@ -33,6 +33,12 @@ public class DetalhadoRMDTipoDVB {
|
||||||
private BigDecimal seguro;
|
private BigDecimal seguro;
|
||||||
private BigDecimal outros;
|
private BigDecimal outros;
|
||||||
|
|
||||||
|
// CAMPOS ECF
|
||||||
|
private String ecf;
|
||||||
|
private String datamov;
|
||||||
|
private String coo;
|
||||||
|
private String totalFiscal;
|
||||||
|
|
||||||
public Long getBoletoId() {
|
public Long getBoletoId() {
|
||||||
return boletoId;
|
return boletoId;
|
||||||
}
|
}
|
||||||
|
@ -249,4 +255,36 @@ public class DetalhadoRMDTipoDVB {
|
||||||
this.outros = outros;
|
this.outros = outros;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEcf() {
|
||||||
|
return ecf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEcf(String ecf) {
|
||||||
|
this.ecf = ecf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatamov() {
|
||||||
|
return datamov;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatamov(String datamov) {
|
||||||
|
this.datamov = datamov;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCoo() {
|
||||||
|
return coo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoo(String coo) {
|
||||||
|
this.coo = coo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTotalFiscal() {
|
||||||
|
return totalFiscal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalFiscal(String totalFiscal) {
|
||||||
|
this.totalFiscal = totalFiscal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ public class ImpressaoRMD {
|
||||||
private BigDecimal icms;
|
private BigDecimal icms;
|
||||||
private String obs;
|
private String obs;
|
||||||
|
|
||||||
private List<DetalhadoRMDTipoDVB> detalhada;
|
private List<DetalhadoRMD> detalhada;
|
||||||
|
|
||||||
public ImpressaoRMD(String empresa, String enderecoEmpresa, String cnpjEmpresa, String ieEmpresa,
|
public ImpressaoRMD(String empresa, String enderecoEmpresa, String cnpjEmpresa, String ieEmpresa,
|
||||||
Date data, String rmd, String naturezaOperacao, String tipo, String serie, String obs) {
|
Date data, String rmd, String naturezaOperacao, String tipo, String serie, String obs) {
|
||||||
|
@ -170,14 +170,14 @@ public class ImpressaoRMD {
|
||||||
this.obs = obs;
|
this.obs = obs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DetalhadoRMDTipoDVB> getDetalhada() {
|
public List<DetalhadoRMD> getDetalhada() {
|
||||||
if (detalhada == null) {
|
if (detalhada == null) {
|
||||||
detalhada = new ArrayList<DetalhadoRMDTipoDVB>();
|
detalhada = new ArrayList<DetalhadoRMD>();
|
||||||
}
|
}
|
||||||
return detalhada;
|
return detalhada;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDetalhada(List<DetalhadoRMDTipoDVB> detalhada) {
|
public void setDetalhada(List<DetalhadoRMD> detalhada) {
|
||||||
this.detalhada = detalhada;
|
this.detalhada = detalhada;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue