bug #7500
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@56388 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
9fb07a50b9
commit
0a05c5917e
|
@ -193,7 +193,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId,Connection connection) throws SQLException {
|
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId, Connection connection) throws SQLException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rset = null;
|
ResultSet rset = null;
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" r3.totparcial AS aliquota, ");
|
sql.append(" r3.totparcial AS aliquota, ");
|
||||||
sql.append(" r3.valoracumulado AS imposto, ");
|
sql.append(" r3.valoracumulado AS imposto, ");
|
||||||
sql.append(" ifi.numserie AS numpdv, ");
|
sql.append(" ifi.numserie AS numpdv, ");
|
||||||
sql.append(" e.cnpj AS cnpj, ");
|
sql.append(" TRANSLATE(t2.cnpj, ' / - . ', ' ') AS cnpj,");
|
||||||
sql.append(" r2.totgeral AS gtFinal, ");
|
sql.append(" r2.totgeral AS gtFinal, ");
|
||||||
sql.append(" anterior.totgeral AS gtInicial ");
|
sql.append(" anterior.totgeral AS gtInicial ");
|
||||||
sql.append("FROM fiscal_r2 r2 ");
|
sql.append("FROM fiscal_r2 r2 ");
|
||||||
|
@ -225,18 +225,16 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" AND r3.fiscalimpressora_id = ifi.fiscalimpressora_id ");
|
sql.append(" AND r3.fiscalimpressora_id = ifi.fiscalimpressora_id ");
|
||||||
sql.append(" inner join fiscal_t2 t2 ");
|
sql.append(" inner join fiscal_t2 t2 ");
|
||||||
sql.append(" ON ifi.fiscalimpressora_id = t2.fiscalimpressora_id ");
|
sql.append(" ON ifi.fiscalimpressora_id = t2.fiscalimpressora_id ");
|
||||||
sql.append(" inner join empresa e ON TRANSLATE(t2.cnpj, ' / - . ', ' ') ");
|
sql.append(" inner join empresa e ON (TRANSLATE(t2.cnpj, ' / - . ', ' ') = (TRANSLATE(e.cnpj, ' / - . ', ' ')) ) or ");
|
||||||
sql.append(" in (TRANSLATE(e.cnpj, ' / - . ', ' '), ");
|
sql.append(" (TRANSLATE(t2.cnpj, ' / - . ', ' ') in ");
|
||||||
sql.append(" (select TRANSLATE(cnpj, ' / - . ', ' ') from inscricao_estadual where empresa_id = ? )),");
|
sql.append(" (select TRANSLATE(cnpj, ' / - . ', ' ') from inscricao_estadual where empresa_id = ? and activo = 1 )), ");
|
||||||
sql.append(" (SELECT numserie20, crz, totgeral ");
|
sql.append(" (SELECT numserie20, crz, totgeral ");
|
||||||
sql.append(" FROM fiscal_r2) anterior ");
|
sql.append(" FROM fiscal_r2) anterior ");
|
||||||
sql.append("WHERE r2.datamov BETWEEN ? AND ? ");
|
sql.append("WHERE r2.datamov BETWEEN ? AND ? ");
|
||||||
sql.append(" AND r2.activo = 1 ");
|
sql.append(" AND r2.activo = 1 ");
|
||||||
sql.append(" AND e.empresa_id = ? ");
|
sql.append(" AND e.empresa_id = ? ");
|
||||||
sql.append(" AND r3.totparcial not in (");
|
sql.append(" AND r3.totparcial not in (");
|
||||||
sql.append("'" + SituacaoTributaria.CANCELADO.getValue() + "'").append(", ");
|
sql.append("'" + SituacaoTributaria.NAO_FISCAL.getValue() + "'").append(")");
|
||||||
sql.append("'" + SituacaoTributaria.DESCRITIVO.getValue() + "'").append(", ");
|
|
||||||
sql.append("'" + SituacaoTributaria.OPCIONAL.getValue() + "'").append(")");
|
|
||||||
sql.append(" AND anterior.numserie20 = r2.numserie20 ");
|
sql.append(" AND anterior.numserie20 = r2.numserie20 ");
|
||||||
sql.append(" AND anterior.crz = r2.crz - 1 ");
|
sql.append(" AND anterior.crz = r2.crz - 1 ");
|
||||||
sql.append("GROUP BY r2.datamov, ");
|
sql.append("GROUP BY r2.datamov, ");
|
||||||
|
@ -252,7 +250,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" r3.totparcial, ");
|
sql.append(" r3.totparcial, ");
|
||||||
sql.append(" r3.valoracumulado, ");
|
sql.append(" r3.valoracumulado, ");
|
||||||
sql.append(" ifi.numserie, ");
|
sql.append(" ifi.numserie, ");
|
||||||
sql.append(" e.cnpj, ");
|
sql.append(" t2.cnpj, ");
|
||||||
sql.append(" r2.totgeral, ");
|
sql.append(" r2.totgeral, ");
|
||||||
sql.append(" anterior.totgeral ");
|
sql.append(" anterior.totgeral ");
|
||||||
sql.append("ORDER BY r2.datamov, ");
|
sql.append("ORDER BY r2.datamov, ");
|
||||||
|
@ -329,7 +327,8 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" 'C' as status, ");
|
sql.append(" 'C' as status, ");
|
||||||
sql.append(" b.motivocancelacion_id as motivocancelacion, ");
|
sql.append(" b.motivocancelacion_id as motivocancelacion, ");
|
||||||
sql.append(" ee.impingreso as valorMulta, ");
|
sql.append(" ee.impingreso as valorMulta, ");
|
||||||
sql.append(" cs.descclase as claseServicio ");
|
sql.append(" cs.descclase as claseServicio, ");
|
||||||
|
sql.append(" translate(fi.numcnpj, ' / - . ', ' ') as cnpjEcf ");
|
||||||
sql.append(" FROM fiscal_r4 r4 ");
|
sql.append(" FROM fiscal_r4 r4 ");
|
||||||
sql.append(" INNER JOIN fiscal_r5 r5 ON r4.numserie20 = r5.numserie20 AND r4.coo = r5.coo ");
|
sql.append(" INNER JOIN fiscal_r5 r5 ON r4.numserie20 = r5.numserie20 AND r4.coo = r5.coo ");
|
||||||
sql.append(" AND r4.datamov = r5.datamov AND r4.contador = r5.contador ");
|
sql.append(" AND r4.datamov = r5.datamov AND r4.contador = r5.contador ");
|
||||||
|
@ -349,6 +348,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" WHERE r4.datamov BETWEEN ? AND ? ");
|
sql.append(" WHERE r4.datamov BETWEEN ? AND ? ");
|
||||||
sql.append(" AND b.marca_id = ? ");
|
sql.append(" AND b.marca_id = ? ");
|
||||||
sql.append(" AND b.motivocancelacion_id in (31, 32, 10) ");
|
sql.append(" AND b.motivocancelacion_id in (31, 32, 10) ");
|
||||||
|
sql.append(" AND r4.indcancelamento = 'N' ");
|
||||||
sql.append(" GROUP BY r4.numserie20, ");
|
sql.append(" GROUP BY r4.numserie20, ");
|
||||||
sql.append(" r4.coo, ");
|
sql.append(" r4.coo, ");
|
||||||
sql.append(" r4.datainicialemissao, ");
|
sql.append(" r4.datainicialemissao, ");
|
||||||
|
@ -376,7 +376,8 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" b.importetaxaembarque, ");
|
sql.append(" b.importetaxaembarque, ");
|
||||||
sql.append(" b.importepedagio, ");
|
sql.append(" b.importepedagio, ");
|
||||||
sql.append(" b.importeseguro, ");
|
sql.append(" b.importeseguro, ");
|
||||||
sql.append(" cs.descclase ");
|
sql.append(" cs.descclase, ");
|
||||||
|
sql.append(" fi.numcnpj ");
|
||||||
sql.append(" ORDER BY r4.datainicialemissao, ");
|
sql.append(" ORDER BY r4.datainicialemissao, ");
|
||||||
sql.append(" r4.numserie20, ");
|
sql.append(" r4.numserie20, ");
|
||||||
sql.append(" r4.coo, ");
|
sql.append(" r4.coo, ");
|
||||||
|
@ -413,6 +414,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" b.importepedagio as importepedagio, ");
|
sql.append(" b.importepedagio as importepedagio, ");
|
||||||
sql.append(" b.importeseguro as importeseguro, ");
|
sql.append(" b.importeseguro as importeseguro, ");
|
||||||
sql.append(" cs.descclase as claseServicio, ");
|
sql.append(" cs.descclase as claseServicio, ");
|
||||||
|
sql.append(" translate(fi.numcnpj, ' / - . ', ' ') as cnpjEcf, ");
|
||||||
sql.append(" 'N' as status ");
|
sql.append(" 'N' as status ");
|
||||||
sql.append(" FROM fiscal_r4 r4 ");
|
sql.append(" FROM fiscal_r4 r4 ");
|
||||||
sql.append(" INNER JOIN fiscal_r5 r5 ON r4.numserie20 = r5.numserie20 AND r4.coo = r5.coo ");
|
sql.append(" INNER JOIN fiscal_r5 r5 ON r4.numserie20 = r5.numserie20 AND r4.coo = r5.coo ");
|
||||||
|
@ -431,6 +433,7 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" INNER JOIN estado ed ON ed.estado_id = cd.estado_id ");
|
sql.append(" INNER JOIN estado ed ON ed.estado_id = cd.estado_id ");
|
||||||
sql.append(" WHERE r4.datamov BETWEEN ? AND ? ");
|
sql.append(" WHERE r4.datamov BETWEEN ? AND ? ");
|
||||||
sql.append(" AND b.marca_id = ? ");
|
sql.append(" AND b.marca_id = ? ");
|
||||||
|
sql.append(" AND r4.indcancelamento = 'N' ");
|
||||||
sql.append(" GROUP BY r4.numserie20, ");
|
sql.append(" GROUP BY r4.numserie20, ");
|
||||||
sql.append(" r4.coo, ");
|
sql.append(" r4.coo, ");
|
||||||
sql.append(" r4.datainicialemissao, ");
|
sql.append(" r4.datainicialemissao, ");
|
||||||
|
@ -456,7 +459,8 @@ public class FiscalHibernateDAO implements FiscalDAO {
|
||||||
sql.append(" b.importetaxaembarque, ");
|
sql.append(" b.importetaxaembarque, ");
|
||||||
sql.append(" b.importepedagio, ");
|
sql.append(" b.importepedagio, ");
|
||||||
sql.append(" b.importeseguro, ");
|
sql.append(" b.importeseguro, ");
|
||||||
sql.append(" cs.descclase ");
|
sql.append(" cs.descclase, ");
|
||||||
|
sql.append(" fi.numcnpj ");
|
||||||
sql.append(" ORDER BY r4.datainicialemissao, ");
|
sql.append(" ORDER BY r4.datainicialemissao, ");
|
||||||
sql.append(" r4.numserie20, ");
|
sql.append(" r4.numserie20, ");
|
||||||
sql.append(" r4.coo, ");
|
sql.append(" r4.coo, ");
|
||||||
|
|
|
@ -457,12 +457,36 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
List<ImportacionFiscalReducaoZVO> aux = new ArrayList<ImportacionFiscalReducaoZVO>();
|
List<ImportacionFiscalReducaoZVO> aux = new ArrayList<ImportacionFiscalReducaoZVO>();
|
||||||
|
|
||||||
BigDecimal valorNaoTributado = null;
|
BigDecimal valorNaoTributado = null;
|
||||||
|
BigDecimal valorNaoIncluido = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
ImportacionFiscalReducaoZVO item = null;
|
||||||
|
|
||||||
for (ImportacionFiscalReducaoZVO ifr : list) {
|
for (ImportacionFiscalReducaoZVO ifr : list) {
|
||||||
if (ifr.getAliquota().equals(SituacaoTributaria.NAO_TRIBUTADO.getValue())) {
|
|
||||||
|
if (!ifr.equals(item)) {
|
||||||
|
valorNaoIncluido = BigDecimal.ZERO;
|
||||||
|
item = ifr;
|
||||||
|
}
|
||||||
|
|
||||||
|
String tipoMovimento = ifr.getAliquota();
|
||||||
|
if (tipoMovimento.equals(SituacaoTributaria.CANCELADO.getValue()) ||
|
||||||
|
tipoMovimento.equals(SituacaoTributaria.DESCONTO.getValue())) {
|
||||||
|
|
||||||
|
valorNaoIncluido = valorNaoIncluido.add(ifr.getImposto());
|
||||||
|
ifr.setValorNaoIncluido(valorNaoIncluido);
|
||||||
|
|
||||||
|
} else if (tipoMovimento.equals(SituacaoTributaria.NAO_TRIBUTADO.getValue())) {
|
||||||
valorNaoTributado = ifr.getImposto();
|
valorNaoTributado = ifr.getImposto();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ifr.setValorNaoTributado(valorNaoTributado);
|
ifr.setValorNaoTributado(valorNaoTributado);
|
||||||
|
ifr.setValorNaoIncluido(valorNaoIncluido);
|
||||||
|
|
||||||
|
BigDecimal valorReducaoZ = ifr.getVendabrutadiaria().subtract(valorNaoIncluido);
|
||||||
|
ifr.setVendabrutadiaria(valorReducaoZ);
|
||||||
|
|
||||||
aux.add(ifr);
|
aux.add(ifr);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,6 +540,7 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
|
|
||||||
String data = item.getDataEmissao();
|
String data = item.getDataEmissao();
|
||||||
String brancos = StringHelper.preencherStringEspacoEsquerda(null, 202);
|
String brancos = StringHelper.preencherStringEspacoEsquerda(null, 202);
|
||||||
|
String cnpjEcf = item.getCnpjEcf() == null ? cnpjFilial : item.getCnpjEcf();
|
||||||
|
|
||||||
String serie = item.getNumImpressora();
|
String serie = item.getNumImpressora();
|
||||||
if (serie.length() >= 20) {
|
if (serie.length() >= 20) {
|
||||||
|
@ -579,7 +604,7 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
String claseServicio = StringHelper.preencherStringEspacoDireita(item.getClaseServicio(), 30);
|
String claseServicio = StringHelper.preencherStringEspacoDireita(item.getClaseServicio(), 30);
|
||||||
String seqHeader = StringHelper.preencherZeroEsquerda(Integer.valueOf(seq).toString(), 6);
|
String seqHeader = StringHelper.preencherZeroEsquerda(Integer.valueOf(seq).toString(), 6);
|
||||||
|
|
||||||
header = headerDocumentoFiscal("1", data, cnpjFilial, coo, serie, especie, codigoCliente,
|
header = headerDocumentoFiscal("1", data, cnpjEcf, coo, serie, especie, codigoCliente,
|
||||||
filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, aliquota, imposto,
|
filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, aliquota, imposto,
|
||||||
valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origenUf, origen,
|
valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origenUf, origen,
|
||||||
destinoUf, destino, null, null, status, motivocancelacion, valorMulta, brancos, claseServicio, seqHeader);
|
destinoUf, destino, null, null, status, motivocancelacion, valorMulta, brancos, claseServicio, seqHeader);
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class ImportacionFiscalReducaoZVO {
|
||||||
private String numpdv;
|
private String numpdv;
|
||||||
private BigDecimal gtFinal;
|
private BigDecimal gtFinal;
|
||||||
private BigDecimal gtInicial;
|
private BigDecimal gtInicial;
|
||||||
|
private BigDecimal valorNaoIncluido;
|
||||||
|
|
||||||
public String getDatamov() {
|
public String getDatamov() {
|
||||||
return datamov;
|
return datamov;
|
||||||
|
@ -158,4 +159,61 @@ public class ImportacionFiscalReducaoZVO {
|
||||||
this.gtInicial = gtInicial;
|
this.gtInicial = gtInicial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getValorNaoIncluido() {
|
||||||
|
return valorNaoIncluido;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValorNaoIncluido(BigDecimal valorNaoIncluido) {
|
||||||
|
this.valorNaoIncluido = valorNaoIncluido;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((coofinal == null) ? 0 : coofinal.hashCode());
|
||||||
|
result = prime * result + ((cooinicial == null) ? 0 : cooinicial.hashCode());
|
||||||
|
result = prime * result + ((datamov == null) ? 0 : datamov.hashCode());
|
||||||
|
result = prime * result + ((datareducao == null) ? 0 : datareducao.hashCode());
|
||||||
|
result = prime * result + ((numserie20 == null) ? 0 : numserie20.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ImportacionFiscalReducaoZVO other = (ImportacionFiscalReducaoZVO) obj;
|
||||||
|
if (coofinal == null) {
|
||||||
|
if (other.coofinal != null)
|
||||||
|
return false;
|
||||||
|
} else if (!coofinal.equals(other.coofinal))
|
||||||
|
return false;
|
||||||
|
if (cooinicial == null) {
|
||||||
|
if (other.cooinicial != null)
|
||||||
|
return false;
|
||||||
|
} else if (!cooinicial.equals(other.cooinicial))
|
||||||
|
return false;
|
||||||
|
if (datamov == null) {
|
||||||
|
if (other.datamov != null)
|
||||||
|
return false;
|
||||||
|
} else if (!datamov.equals(other.datamov))
|
||||||
|
return false;
|
||||||
|
if (datareducao == null) {
|
||||||
|
if (other.datareducao != null)
|
||||||
|
return false;
|
||||||
|
} else if (!datareducao.equals(other.datareducao))
|
||||||
|
return false;
|
||||||
|
if (numserie20 == null) {
|
||||||
|
if (other.numserie20 != null)
|
||||||
|
return false;
|
||||||
|
} else if (!numserie20.equals(other.numserie20))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class ImportacionFiscalVO {
|
||||||
private BigDecimal valorPedagio;
|
private BigDecimal valorPedagio;
|
||||||
private BigDecimal valorEmbarque;
|
private BigDecimal valorEmbarque;
|
||||||
private BigDecimal valorSeguro;
|
private BigDecimal valorSeguro;
|
||||||
|
private String cnpjEcf;
|
||||||
|
|
||||||
private List<ItemFiscalVO> itensFiscais;
|
private List<ItemFiscalVO> itensFiscais;
|
||||||
|
|
||||||
|
@ -294,4 +295,12 @@ public class ImportacionFiscalVO {
|
||||||
this.descmotivocancelamento = descmotivocancelamento;
|
this.descmotivocancelamento = descmotivocancelamento;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCnpjEcf() {
|
||||||
|
return cnpjEcf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCnpjEcf(String cnpjEcf) {
|
||||||
|
this.cnpjEcf = cnpjEcf;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.rjconsultores.ventaboletos.vo.impressaofiscal;
|
package com.rjconsultores.ventaboletos.vo.impressaofiscal;
|
||||||
|
|
||||||
public enum SituacaoTributaria {
|
public enum SituacaoTributaria {
|
||||||
TRIBUTADO("T"), NAO_TRIBUTADO("N1"), CANCELADO("Can-T"), DESCRITIVO("DT"), OPCIONAL("OPNF");
|
TRIBUTADO("T"), NAO_TRIBUTADO("N1"), CANCELADO("Can-T"), DESCONTO("DT"), NAO_FISCAL("OPNF");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue