fixes bug#14405
dev:julio qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@93790 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
17a1234ddb
commit
0f34470fc8
|
@ -8,6 +8,7 @@ import java.sql.ResultSetMetaData;
|
|||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -3671,11 +3672,13 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
|
||||
List<DetalhadoRMD> list = new ArrayList<DetalhadoRMD>();
|
||||
try {
|
||||
boolean isDif = validaConstanteCustom(empresaId.toString(), "IMPORT_FISCAL_DIF");
|
||||
|
||||
String sql = null;
|
||||
if (isECF && !isCancelamento) {
|
||||
sql = getSqlImpressaoRMDTipoECF();
|
||||
} else if (isManual && !isCancelamento) {
|
||||
sql = getSqlImpressaoRMDTipoBPR();
|
||||
sql = getSqlImpressaoRMDTipoBPR(isDif);
|
||||
} else if (isCancelamento) {
|
||||
sql = getSqlImpressaoRMDCancelados();
|
||||
}
|
||||
|
@ -3755,7 +3758,19 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
return list;
|
||||
}
|
||||
|
||||
private String getSqlImpressaoRMDTipoBPR() {
|
||||
public boolean validaConstanteCustom(String valor, String nomeConstante) {
|
||||
ConstanteService constanteService = (ConstanteService) AppContext.getApplicationContext().getBean("constanteService");
|
||||
String value = constanteService.buscarPorNomeConstante(nomeConstante).getValorconstante();
|
||||
|
||||
if (StringUtils.isBlank(value))
|
||||
return false;
|
||||
|
||||
List<String> valuesList = Arrays.asList(value.split(",", -1));
|
||||
return valuesList.contains(valor);
|
||||
}
|
||||
|
||||
private String getSqlImpressaoRMDTipoBPR(boolean isDif) {
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select distinct ");
|
||||
sql.append(" b.caja_id as cajaId, ");
|
||||
|
@ -3828,8 +3843,17 @@ public class FiscalHibernateDAO extends HibernateDaoSupport implements FiscalDAO
|
|||
sql.append(" left join estado eie on eie.estado_id = cie.estado_id ");
|
||||
sql.append(" left join empresa_imposto ei on ei.empresa_id = b.empresacorrida_id ");
|
||||
sql.append(" and ei.estado_id = coalesce(ae.estado_id, e_ag.estado_id, eos.estado_id, eo.estado_id) and ei.activo = 1 ");
|
||||
sql.append("where ((b.tipoventa_id = 3 and b.indstatusboleto = 'V' and b.indreimpresion = 0) ");
|
||||
sql.append("where ");
|
||||
|
||||
if (isDif) {
|
||||
sql.append(" ((b.tipoventa_id not in (5,12,18,81,82,49,41) and b.indstatusboleto = 'V' and b.indreimpresion = 0) ");
|
||||
sql.append(" or (b.tipoventa_id in (5,12,18,81,82,49,41) and b.indstatusboleto = 'E' and b.numfoliosistema = b.numfoliopreimpreso)) ");
|
||||
sql.append(" and a.aidf_id is not null ");
|
||||
} else {
|
||||
sql.append(" ((b.tipoventa_id = 3 and b.indstatusboleto = 'V' and b.indreimpresion = 0) ");
|
||||
sql.append(" or (b.tipoventa_id in (12,18) and b.indstatusboleto = 'E' and b.numfoliosistema = b.numfoliopreimpreso)) ");
|
||||
}
|
||||
|
||||
sql.append(" and (b.motivocancelacion_id is null or b.motivocancelacion_id <> 35) ");
|
||||
sql.append(" and b.indcancelacion = 0 ");
|
||||
sql.append(" and b.empresacorrida_id = :EMPRESA_ID ");
|
||||
|
|
Loading…
Reference in New Issue