bug#11600
dev: julio qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@85402 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
921eb5398a
commit
d489fe9a88
|
@ -69,4 +69,7 @@ public interface FiscalDAO {
|
|||
public void cancelarRMDBoleto(Connection connection, Date inicio, Date fim, Integer empresaId, Estado estado, Aidf aidf, String folioInicial, String folioFinal, boolean isCancela, boolean isInativa, boolean isECF, boolean isBPR);
|
||||
|
||||
public List<FiscalRdi> buscarRelatorioRDI(Connection connection, Date inicio, Date fim, Integer empresaId, List<Estado> estados, boolean isReceitaTerceiros);
|
||||
|
||||
public void limparCache(Connection connection);
|
||||
|
||||
}
|
||||
|
|
|
@ -396,7 +396,6 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
|
|||
String vBC = null;
|
||||
String pICMS = null;
|
||||
String vICMS = null;
|
||||
String pRedBC = null;
|
||||
|
||||
if (StringUtils.isNotBlank(xml)) {
|
||||
if (tbpe.getInfBPe().getImp().getICMS().getICMS00() != null) {
|
||||
|
@ -407,7 +406,6 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
|
|||
vBC = tbpe.getInfBPe().getImp().getICMS().getICMS20().getVBC();
|
||||
pICMS = tbpe.getInfBPe().getImp().getICMS().getICMS20().getPICMS();
|
||||
vICMS = tbpe.getInfBPe().getImp().getICMS().getICMS20().getVICMS();
|
||||
pRedBC = tbpe.getInfBPe().getImp().getICMS().getICMS20().getPRedBC();
|
||||
}
|
||||
|
||||
if (tbpe.getInfBPe().getInfValorBPe() != null) {
|
||||
|
@ -454,7 +452,6 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
|
|||
aliquotaAnt = aliquota;
|
||||
|
||||
BigDecimal icms = new BigDecimal(vICMS == null ? "0.0" : vICMS);
|
||||
BigDecimal outros = new BigDecimal(pRedBC == null ? "0.0" : pRedBC);
|
||||
|
||||
BigDecimal cp = null;
|
||||
if (isEstadual) {
|
||||
|
@ -465,8 +462,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
|
|||
|
||||
BigDecimal credPres = icms.multiply(cp.divide(BigDecimal.TEN.multiply(BigDecimal.TEN)));
|
||||
BigDecimal icmsRec = icms.subtract(credPres);
|
||||
|
||||
BigDecimal vRedBC = new BigDecimal(pRedBC == null ? "0.0" : pRedBC);
|
||||
BigDecimal vRedBC = det.getRedBaseCalcIcms();
|
||||
BigDecimal outros = isentos.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : passagem.subtract(isentos).subtract(baseCalculo);
|
||||
|
||||
rdis.add(new FiscalRdi(det.getEstadoOrigem(), tipoViagem, det.getTipoReceita(), tarifa,
|
||||
seguro, taxaEmbarque, pedagio, passagem, isentos, outros, vRedBC,
|
||||
|
|
|
@ -29,8 +29,10 @@ import org.springframework.stereotype.Repository;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.FiscalDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Aidf;
|
||||
import com.rjconsultores.ventaboletos.entidad.Constante;
|
||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.MoneyHelper;
|
||||
import com.rjconsultores.ventaboletos.utilerias.StringHelper;
|
||||
|
@ -62,12 +64,12 @@ import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionNaoFiscalVO;
|
|||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||
|
||||
@Repository("fiscalDAO")
|
||||
public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO {
|
||||
private static final String DATE_FORMAT_FISCAL = "yyyyMMdd";
|
||||
private static final String DATE_FORMAT_DMY = "dd/MM/yyyy";
|
||||
private static final BigDecimal ZERO = BigDecimal.ZERO;
|
||||
|
||||
private static final String CODIGO_INDICADOR_CONTR_PREVIDENCIARIA = "00000060";
|
||||
|
||||
|
@ -1419,6 +1421,32 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
return exportacaoECF;
|
||||
}
|
||||
|
||||
public void limparCache(Connection connection) {
|
||||
|
||||
ConstanteService constanteService = (ConstanteService) AppContext.getApplicationContext().getBean("constanteService");
|
||||
Constante contante = constanteService.buscarPorNomeConstante("LIMPA_CACHE_RELATORIOS");
|
||||
String command = null;
|
||||
if ((contante != null && (StringUtils.isNotBlank(contante.getValorconstante())))) {
|
||||
command = contante.getValorconstante();
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = connection.prepareStatement(command);
|
||||
pstmt.executeBatch();
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
} finally {
|
||||
try {
|
||||
if (pstmt != null && !pstmt.isClosed()) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<ExportacaoECFTipoCFC> buscarRegistroECFTipoCFC(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado) {
|
||||
|
@ -4034,8 +4062,8 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
|
||||
for (DetalhadoFiscal det : list) {
|
||||
|
||||
BigDecimal passagem = BigDecimal.ZERO;
|
||||
BigDecimal isentos = BigDecimal.ZERO;
|
||||
BigDecimal passagem = valorPassagem(det, isReceitaTerceiros);
|
||||
BigDecimal isentos = valorIsenta(det, isReceitaTerceiros);
|
||||
BigDecimal outros = BigDecimal.ZERO;
|
||||
BigDecimal rbc = BigDecimal.ZERO;
|
||||
BigDecimal baseCalculo = BigDecimal.ZERO;
|
||||
|
@ -4045,55 +4073,44 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
BigDecimal credPres = BigDecimal.ZERO;
|
||||
BigDecimal icmsRec = BigDecimal.ZERO;
|
||||
|
||||
if (det.getIsenta()) {
|
||||
isentos = somarTotalBilhete(det, isReceitaTerceiros);
|
||||
if (det.isInterEstadual()) {
|
||||
aliquota = det.getTributacaoImportacao() != null ? det.getTributacaoImportacao() : det.getIcmsInterestadual();
|
||||
} else {
|
||||
passagem = somarTotalBilhete(det, isReceitaTerceiros);
|
||||
|
||||
if (det.isInterEstadual()) {
|
||||
aliquota = det.getTributacaoImportacao() != null ? det.getTributacaoImportacao() : det.getIcmsInterestadual();
|
||||
} else {
|
||||
aliquota = det.getTributacaoImportacao() != null ? det.getTributacaoImportacao() : det.getIcmsIntermunicipal();
|
||||
}
|
||||
|
||||
if (det.isInterEstadual()) {
|
||||
cp = det.getPorcRedEstadual() == null ? BigDecimal.ZERO : det.getPorcRedEstadual();
|
||||
} else {
|
||||
cp = det.getPorcRedMunicipal() == null ? BigDecimal.ZERO : det.getPorcRedMunicipal();
|
||||
}
|
||||
|
||||
rbc = det.getRedBaseCalcIcms() == null ? BigDecimal.ZERO : det.getRedBaseCalcIcms().divide(UtiliteriasFiscal.CEM);
|
||||
BigDecimal redutor = passagem.multiply(rbc);
|
||||
baseCalculo = passagem.subtract(redutor);
|
||||
icms = baseCalculo.multiply(aliquota.divide(BigDecimal.TEN.multiply(BigDecimal.TEN)));
|
||||
credPres = icms.multiply(cp.divide(BigDecimal.TEN.multiply(BigDecimal.TEN)));
|
||||
icmsRec = icms.subtract(credPres);
|
||||
aliquota = det.getTributacaoImportacao() != null ? det.getTributacaoImportacao() : det.getIcmsIntermunicipal();
|
||||
}
|
||||
|
||||
if (det.isInterEstadual()) {
|
||||
cp = det.getPorcRedEstadual() == null ? BigDecimal.ZERO : det.getPorcRedEstadual();
|
||||
} else {
|
||||
cp = det.getPorcRedMunicipal() == null ? BigDecimal.ZERO : det.getPorcRedMunicipal();
|
||||
}
|
||||
|
||||
rbc = det.getRedBaseCalcIcms() == null ? BigDecimal.ZERO : det.getRedBaseCalcIcms().divide(UtiliteriasFiscal.CEM);
|
||||
|
||||
BigDecimal tarifa = valorBaseCalculo(det, isReceitaTerceiros);
|
||||
BigDecimal redutor = tarifa.multiply(rbc);
|
||||
baseCalculo = tarifa.subtract(redutor);
|
||||
|
||||
icms = baseCalculo.multiply(aliquota.divide(BigDecimal.TEN.multiply(BigDecimal.TEN)));
|
||||
credPres = icms.multiply(cp.divide(BigDecimal.TEN.multiply(BigDecimal.TEN)));
|
||||
icmsRec = icms.subtract(credPres);
|
||||
|
||||
outros = isentos.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : passagem.subtract(isentos).subtract(baseCalculo);
|
||||
|
||||
String tipoViagem = null;
|
||||
if (det.isInterEstadual()) {
|
||||
tipoViagem = "IE";
|
||||
} else {
|
||||
tipoViagem = "IM";
|
||||
}
|
||||
String tipoViagem = det.isInterEstadual() ? "IE" : "IM";
|
||||
BigDecimal taxaEmbarque = isReceitaTerceiros && det.getTaxaEmbarque() == null ? BigDecimal.ZERO : det.getTaxaEmbarque();
|
||||
BigDecimal pedagio = isReceitaTerceiros && det.getPedagio() == null ? BigDecimal.ZERO : det.getPedagio();
|
||||
BigDecimal seguro = isReceitaTerceiros && det.getSeguro() == null ? BigDecimal.ZERO : det.getSeguro();
|
||||
|
||||
if (isReceitaTerceiros) {
|
||||
rdis.add(new FiscalRdi(det.getEstadoOrigem(), tipoViagem, det.getTipoReceita(), det.getTarifa(),
|
||||
det.getSeguro(), det.getTaxaEmbarque(), det.getPedagio(), passagem, isentos, outros, det.getRedBaseCalcIcms(),
|
||||
baseCalculo, aliquota, icms, cp, credPres, icmsRec));
|
||||
} else {
|
||||
rdis.add(new FiscalRdi(det.getEstadoOrigem(), tipoViagem, det.getTipoReceita(), det.getTarifa(),
|
||||
ZERO, ZERO, ZERO, passagem, isentos, outros, det.getRedBaseCalcIcms(),
|
||||
baseCalculo, aliquota, icms, cp, credPres, icmsRec));
|
||||
}
|
||||
rdis.add(new FiscalRdi(det.getEstadoOrigem(), tipoViagem, det.getTipoReceita(), det.getTarifa(),
|
||||
seguro, taxaEmbarque, pedagio, passagem, isentos, outros, det.getRedBaseCalcIcms(),
|
||||
baseCalculo, aliquota, icms, cp, credPres, icmsRec));
|
||||
}
|
||||
|
||||
return rdis;
|
||||
}
|
||||
|
||||
private BigDecimal somarTotalBilhete(DetalhadoFiscal det, boolean isReceitaTerceiros) {
|
||||
|
||||
private BigDecimal valorBaseCalculo(DetalhadoFiscal det, boolean isReceitaTerceiros) {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
total = total.add(det.getTarifa() == null ? BigDecimal.ZERO : det.getTarifa());
|
||||
|
||||
|
@ -4109,6 +4126,30 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
return total;
|
||||
}
|
||||
|
||||
private BigDecimal valorIsenta(DetalhadoFiscal det, boolean isReceitaTerceiros) {
|
||||
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
if (isReceitaTerceiros && (det.isInterEstadual() && !det.getIndTxembarqueEstadual() || !det.isInterEstadual() && !det.getIndTxembarqueMunicipal()))
|
||||
total = total.add(det.getTaxaEmbarque() == null ? BigDecimal.ZERO : det.getTaxaEmbarque());
|
||||
|
||||
if (isReceitaTerceiros && (det.isInterEstadual() && !det.getIndPedagioEstdual() || !det.isInterEstadual() && !det.getIndPedagioMunicipal()))
|
||||
total = total.add(det.getPedagio() == null ? BigDecimal.ZERO : det.getPedagio());
|
||||
|
||||
if (isReceitaTerceiros && (det.isInterEstadual() && !det.getIndSeguroEstadual() || !det.isInterEstadual() && !det.getIndSeguroMunicipal()))
|
||||
total = total.add(det.getSeguro() == null ? BigDecimal.ZERO : det.getSeguro());
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private BigDecimal valorPassagem(DetalhadoFiscal det, boolean isReceitaTerceiros) {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
total = total.add(det.getTarifa() == null ? BigDecimal.ZERO : det.getTarifa());
|
||||
total = total.add(det.getTaxaEmbarque() == null ? BigDecimal.ZERO : det.getTaxaEmbarque());
|
||||
total = total.add(det.getPedagio() == null ? BigDecimal.ZERO : det.getPedagio());
|
||||
total = total.add(det.getSeguro() == null ? BigDecimal.ZERO : det.getSeguro());
|
||||
return total;
|
||||
}
|
||||
|
||||
private List<DetalhadoFiscal> montaRelatorioRDI(Connection connection, Date inicio, Date fim, Integer empresaId, String ufs) {
|
||||
|
||||
List<DetalhadoFiscal> list = new ArrayList<DetalhadoFiscal>();
|
||||
|
|
|
@ -963,6 +963,8 @@ public class FiscalServiceImpl implements FiscalService {
|
|||
log.info("Tempo na busca dos registros " + tempo);
|
||||
tempos.add(tempo);
|
||||
|
||||
fiscalDAO.limparCache(connection);
|
||||
|
||||
return exportacaoFiscal.gerarArquivoECF(tempos, nomeArquivo, inicio, fim, estado.getCveestado(), empresa.getNombempresa(), listaRegistroECFTipoCFC, listaRegistroECFTipoCCF, listaRegistroECFTipoICF,
|
||||
listaRegistroECFTipoPRC);
|
||||
|
||||
|
@ -1048,6 +1050,8 @@ public class FiscalServiceImpl implements FiscalService {
|
|||
tempo = infoTempo("BPS", begin);
|
||||
log.info("Tempo na busca dos registros " + tempo);
|
||||
|
||||
fiscalDAO.limparCache(connection);
|
||||
|
||||
return exportacaoFiscal.gerarArquivoRMD(inicio, fim, nomeArquivo, empresa.getNombempresa(), listaRegistroRMDTipoPAR, listaRegistroRMDTipoRMD, listaRegistroRMDTipoBPS,
|
||||
listaRegistroRMDTipoDBP, listaRegistroRMDTipoSeqBPS);
|
||||
|
||||
|
|
|
@ -16,12 +16,14 @@ public class FinanceiroSintetico implements Comparable<FinanceiroSintetico> {
|
|||
private BigDecimal difTarifaMaior;
|
||||
private BigDecimal totalOutrasReceitas;
|
||||
private BigDecimal txEmb;
|
||||
private BigDecimal txConveniencia;
|
||||
private BigDecimal pedagio;
|
||||
private BigDecimal segFacult;
|
||||
private BigDecimal totalTerceiros;
|
||||
private BigDecimal receitaBruta;
|
||||
private BigDecimal devolBPR;
|
||||
private BigDecimal devolGAP;
|
||||
private BigDecimal devolOCD;
|
||||
private BigDecimal receitaLiquida;
|
||||
private BigDecimal despesas;
|
||||
private BigDecimal pgOCD;
|
||||
|
@ -266,4 +268,20 @@ public class FinanceiroSintetico implements Comparable<FinanceiroSintetico> {
|
|||
this.receitaEb = receitaEb;
|
||||
}
|
||||
|
||||
public BigDecimal getTxConveniencia() {
|
||||
return txConveniencia;
|
||||
}
|
||||
|
||||
public void setTxConveniencia(BigDecimal txConveniencia) {
|
||||
this.txConveniencia = txConveniencia;
|
||||
}
|
||||
|
||||
public BigDecimal getDevolOCD() {
|
||||
return devolOCD;
|
||||
}
|
||||
|
||||
public void setDevolOCD(BigDecimal devolOCD) {
|
||||
this.devolOCD = devolOCD;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue