RMD - Arquivo Exportação para QS (bug 0006374) - Parte 3 - MANUAL
Tempo: 21 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@45460 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
99942a4b16
commit
6f10468820
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionManualFiscalVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
||||||
|
|
||||||
public interface FiscalDAO {
|
public interface FiscalDAO {
|
||||||
|
@ -15,4 +16,6 @@ public interface FiscalDAO {
|
||||||
|
|
||||||
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId);
|
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId);
|
||||||
|
|
||||||
|
public List<ImportacionManualFiscalVO> buscaDatosFiscaisECFManual(Date inicio, Date fim, Integer empresaId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import com.rjconsultores.ventaboletos.dao.FiscalDAO;
|
||||||
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.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionManualFiscalVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria;
|
||||||
|
|
||||||
|
@ -31,6 +32,117 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ImportacionManualFiscalVO> buscaDatosFiscaisECFManual(Date inicio, Date fim, Integer empresaId) {
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("select r4.numserie20 as numImpressora, ");
|
||||||
|
sql.append(" coalesce(r4.coo, b.numfoliopreimpreso) as coo, ");
|
||||||
|
sql.append(" b.boleto_id as boletoId, ");
|
||||||
|
sql.append(" b.marca_id as empresaId, ");
|
||||||
|
sql.append(" e.nombempresa as empresa, ");
|
||||||
|
sql.append(" to_char(b.fechorventa, 'yyyyMMdd') as dataEmissao, ");
|
||||||
|
sql.append(" b.preciopagado as valorTotal, ");
|
||||||
|
sql.append(" b.origen_id as origenId, ");
|
||||||
|
sql.append(" r5.totparcial as repTributado, ");
|
||||||
|
sql.append(" b.preciopagado as valorItem, ");
|
||||||
|
sql.append(" r5.tipopassagem as tipoPassagem, ");
|
||||||
|
sql.append(" r5.numitem as numItem, ");
|
||||||
|
sql.append(" r5.codproduto as codProduto, ");
|
||||||
|
sql.append(" b.numseriepreimpresa as serie, ");
|
||||||
|
sql.append(" eio.icms as icms, ");
|
||||||
|
sql.append(" eio.porctributo as porctributo, ");
|
||||||
|
sql.append(" eo.estado_id as estadoIdOrigen, ");
|
||||||
|
sql.append(" ed.estado_id as estadoIdDestino, ");
|
||||||
|
sql.append(" subserie as subSerie, ");
|
||||||
|
sql.append(" docfiscal as aidf, ");
|
||||||
|
sql.append(" case b.importetaxaembarque ");
|
||||||
|
sql.append(" when 0 then null ");
|
||||||
|
sql.append(" else b.importetaxaembarque ");
|
||||||
|
sql.append(" end as importetaxaembarque, ");
|
||||||
|
sql.append(" case b.importepedagio ");
|
||||||
|
sql.append(" when 0 then null ");
|
||||||
|
sql.append(" else b.importepedagio ");
|
||||||
|
sql.append(" end as importepedagio, ");
|
||||||
|
sql.append(" case b.importeoutros ");
|
||||||
|
sql.append(" when 0 then null ");
|
||||||
|
sql.append(" else b.importeoutros ");
|
||||||
|
sql.append(" end as importeoutros, ");
|
||||||
|
sql.append(" case b.importeseguro ");
|
||||||
|
sql.append(" when 0 then null ");
|
||||||
|
sql.append(" else b.importeseguro ");
|
||||||
|
sql.append(" end as importeseguro ");
|
||||||
|
sql.append("from boleto b ");
|
||||||
|
sql.append(" left join fiscal_r4 r4 ");
|
||||||
|
sql.append(" on b.boleto_id = r4.boleto_id ");
|
||||||
|
sql.append(" left outer join fiscal_r5 r5 ");
|
||||||
|
sql.append(" on r4.numserie20 = r5.numserie20 ");
|
||||||
|
sql.append(" and r4.coo = r5.coo ");
|
||||||
|
sql.append(" left outer join fiscal_impressora fi ");
|
||||||
|
sql.append(" on fi.numserie20 = r4.numserie20 ");
|
||||||
|
sql.append(" inner join empresa e ");
|
||||||
|
sql.append(" on e.empresa_id = b.marca_id ");
|
||||||
|
sql.append(" left join alias_servico ase ");
|
||||||
|
sql.append(" on ase.origen_id = b.origen_id ");
|
||||||
|
sql.append(" and ase.destino_id = b.destino_id ");
|
||||||
|
sql.append(" left join parada o ");
|
||||||
|
sql.append(" on coalesce(ase.aliasorigen_id, b.origen_id) = o.parada_id ");
|
||||||
|
sql.append(" left join ciudad co ");
|
||||||
|
sql.append(" on o.ciudad_id = co.ciudad_id ");
|
||||||
|
sql.append(" left join estado eo ");
|
||||||
|
sql.append(" on co.estado_id = eo.estado_id ");
|
||||||
|
sql.append(" left join empresa_imposto eio ");
|
||||||
|
sql.append(" on eo.estado_id = eio.estado_id ");
|
||||||
|
sql.append(" and eio.activo = 1 ");
|
||||||
|
sql.append(" and b.marca_id = eio.empresa_id ");
|
||||||
|
sql.append(" left join parada d ");
|
||||||
|
sql.append(" on coalesce(ase.aliasdestino_id, b.destino_id) = d.parada_id ");
|
||||||
|
sql.append(" left join ciudad cd ");
|
||||||
|
sql.append(" on d.ciudad_id = cd.ciudad_id ");
|
||||||
|
sql.append(" left join estado ed ");
|
||||||
|
sql.append(" on cd.estado_id = ed.estado_id ");
|
||||||
|
sql.append(" left join aidf a ");
|
||||||
|
sql.append(" on a.serie = b.numseriepreimpresa ");
|
||||||
|
sql.append(" and eo.estado_id = a.estado_id ");
|
||||||
|
sql.append(" and a.empresa_id = e.empresa_id ");
|
||||||
|
sql.append("WHERE b.marca_id = :empresaId ");
|
||||||
|
sql.append(" AND b.fechorventa BETWEEN :datIni AND :datFim ");
|
||||||
|
sql.append(" AND b.tipoventa_id = 3");
|
||||||
|
|
||||||
|
Query query = getSession().createSQLQuery(sql.toString())
|
||||||
|
.addScalar("numImpressora", StringType.INSTANCE)
|
||||||
|
.addScalar("coo", StringType.INSTANCE)
|
||||||
|
.addScalar("boletoId", LongType.INSTANCE)
|
||||||
|
.addScalar("origenId", IntegerType.INSTANCE)
|
||||||
|
.addScalar("empresaId", IntegerType.INSTANCE)
|
||||||
|
.addScalar("dataEmissao", StringType.INSTANCE)
|
||||||
|
.addScalar("valorTotal", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("origenId", IntegerType.INSTANCE)
|
||||||
|
.addScalar("repTributado", StringType.INSTANCE)
|
||||||
|
.addScalar("valorItem", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("tipoPassagem", StringType.INSTANCE)
|
||||||
|
.addScalar("numItem", StringType.INSTANCE)
|
||||||
|
.addScalar("codProduto", StringType.INSTANCE)
|
||||||
|
.addScalar("serie", StringType.INSTANCE)
|
||||||
|
.addScalar("icms", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("porctributo", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("estadoIdOrigen", IntegerType.INSTANCE)
|
||||||
|
.addScalar("estadoIdDestino", IntegerType.INSTANCE)
|
||||||
|
.addScalar("importetaxaembarque", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("importepedagio", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("importeoutros", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("importeseguro", BigDecimalType.INSTANCE)
|
||||||
|
.addScalar("subSerie", StringType.INSTANCE)
|
||||||
|
.addScalar("aidf", StringType.INSTANCE);
|
||||||
|
|
||||||
|
query.setResultTransformer(new AliasToBeanResultTransformer(ImportacionManualFiscalVO.class));
|
||||||
|
query.setInteger("empresaId", empresaId);
|
||||||
|
query.setTimestamp("datIni", inicio);
|
||||||
|
query.setTimestamp("datFim", fim);
|
||||||
|
|
||||||
|
return query.list();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId) {
|
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId) {
|
||||||
|
|
||||||
|
@ -146,7 +258,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
||||||
sql.append(" INNER JOIN boleto b ON b.boleto_id = r4.boleto_id ");
|
sql.append(" INNER JOIN boleto b ON b.boleto_id = r4.boleto_id ");
|
||||||
sql.append(" INNER JOIN empresa e ON e.empresa_id = b.marca_id ");
|
sql.append(" INNER JOIN empresa e ON e.empresa_id = b.marca_id ");
|
||||||
sql.append("WHERE b.marca_id = :empresaId ");
|
sql.append("WHERE b.marca_id = :empresaId ");
|
||||||
sql.append(" AND r4.datainicialemissao BETWEEN :datIni AND :datFim ");
|
sql.append(" AND r4.datamov BETWEEN :datIni AND :datFim ");
|
||||||
sql.append("GROUP BY r4.numserie20, ");
|
sql.append("GROUP BY r4.numserie20, ");
|
||||||
sql.append(" r4.coo, ");
|
sql.append(" r4.coo, ");
|
||||||
sql.append(" b.boleto_id, ");
|
sql.append(" b.boleto_id, ");
|
||||||
|
|
|
@ -15,4 +15,6 @@ public interface FiscalService {
|
||||||
|
|
||||||
public File importacionFiscalReducaoZ(Date inicio, Date fim, Empresa empresa);
|
public File importacionFiscalReducaoZ(Date inicio, Date fim, Empresa empresa);
|
||||||
|
|
||||||
|
public File importacionFiscalECFManual(Date inicio, Date fim, Empresa empresa);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,12 @@ import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
||||||
import com.rjconsultores.ventaboletos.service.FiscalService;
|
import com.rjconsultores.ventaboletos.service.FiscalService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.StringHelper;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UtileriasFiscal;
|
import com.rjconsultores.ventaboletos.utilerias.UtileriasFiscal;
|
||||||
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;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionManualFiscalVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria;
|
import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria;
|
||||||
|
|
||||||
|
@ -45,6 +47,193 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
return fiscalDAO.gerarRegistroP2_F2(lsEsquemaCorrida, dataDe, dataAte);
|
return fiscalDAO.gerarRegistroP2_F2(lsEsquemaCorrida, dataDe, dataAte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File importacionFiscalECFManual(Date inicio, Date fim, Empresa empresa) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() + "_" + "fiscal";
|
||||||
|
File arquivo = File.createTempFile(nomeArquivo, ".tmp");
|
||||||
|
|
||||||
|
FileWriter arq = new FileWriter(arquivo);
|
||||||
|
PrintWriter gravarArq = new PrintWriter(arq);
|
||||||
|
|
||||||
|
String cnpjFilial = empresa.getCnpj();
|
||||||
|
String brancos372 = StringHelper.preencherStringEspacoEsquerda(null, 372);
|
||||||
|
String dataAgora = DateUtil.getStringDate(Calendar.getInstance().getTime(), DATE_FORMAT_FISCAL);
|
||||||
|
|
||||||
|
String abertura = aberturaDeArquivo("0", dataAgora, cnpjFilial, brancos372, "00001");
|
||||||
|
gravarArq.println(abertura);
|
||||||
|
|
||||||
|
Integer seq = 1;
|
||||||
|
|
||||||
|
Integer qtdDoc = 0;
|
||||||
|
Integer qtdItens = 0;
|
||||||
|
|
||||||
|
List<ImportacionManualFiscalVO> list = agruparItensFiscaisManual(fiscalDAO.buscaDatosFiscaisECFManual(inicio, fim, empresa.getEmpresaId()));
|
||||||
|
for (ImportacionManualFiscalVO imf : list) {
|
||||||
|
|
||||||
|
qtdDoc++;
|
||||||
|
|
||||||
|
String data = imf.getDataEmissao();
|
||||||
|
|
||||||
|
String coo = StringHelper.preencherZeroEsquerda(imf.getCoo(), 9);
|
||||||
|
String serie = StringHelper.preencherStringEspacoEsquerda(imf.getSerie(), 3);
|
||||||
|
String especie = StringHelper.preencherStringEspacoDireita("RMD", 5);
|
||||||
|
|
||||||
|
String codigoCliente = StringHelper.preencherStringEsquerda(null, 6, "9");
|
||||||
|
String filialCliente = StringHelper.preencherStringEsquerda(null, 2, "9");
|
||||||
|
String condicaoPagamento = StringHelper.preencherStringEsquerda(null, 3, "9");
|
||||||
|
|
||||||
|
BigDecimal valorTotal = UtileriasFiscal.arredondar(imf.getValorTotal());
|
||||||
|
String valorTotalDocumanto = UtileriasFiscal.formataZeroDecimal(valorTotal, 14);
|
||||||
|
String valorItens = UtileriasFiscal.formataZeroDecimal(valorTotal, 14);
|
||||||
|
|
||||||
|
BigDecimal valorICMS = UtileriasFiscal.arredondar(imf.getIcms());
|
||||||
|
String baseCalICMS = UtileriasFiscal.formataZeroDecimal(valorICMS, 14);
|
||||||
|
|
||||||
|
BigDecimal aliquotaCalc = UtileriasFiscal.arredondar(imf.getIcms().divide(CEM));
|
||||||
|
BigDecimal baseCalculo = UtileriasFiscal.arredondar(imf.getValorTotal());
|
||||||
|
BigDecimal valorImposto = UtileriasFiscal.arredondar(baseCalculo.multiply(aliquotaCalc.divide(CEM)));
|
||||||
|
String valorTotalICMS = UtileriasFiscal.formataZeroDecimal(valorImposto, 14);
|
||||||
|
|
||||||
|
String valorPIS = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
String valorCofins = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
String valorCSLL = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
String totalICMSIsento = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
String totalICMSNaotributado = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
|
String origen = StringHelper.preencherStringEspacoEsquerda(imf.getOrigenId().toString(), 5);
|
||||||
|
String subSerie = StringHelper.preencherStringEspacoEsquerda(imf.getSubSerie(), 2);
|
||||||
|
String aidf = StringHelper.preencherStringEspacoEsquerda(imf.getAidf(), 30);
|
||||||
|
String brancos181 = StringHelper.preencherStringEspacoEsquerda(null, 181);
|
||||||
|
|
||||||
|
seq++;
|
||||||
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
|
|
||||||
|
String header = headerDocumentoFiscal("1", data, cnpjFilial, coo, serie, especie, codigoCliente,
|
||||||
|
filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, baseCalICMS, valorTotalICMS,
|
||||||
|
valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origen, subSerie,
|
||||||
|
aidf, brancos181, sequencial);
|
||||||
|
gravarArq.println(header);
|
||||||
|
|
||||||
|
for (String itemDoc : montarItensFiscaisManual(imf, imf.getItens(), seq)) {
|
||||||
|
|
||||||
|
qtdItens++;
|
||||||
|
gravarArq.println(itemDoc);
|
||||||
|
seq++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
String qtdeDocGerados = StringHelper.preencherZeroEsquerda(qtdDoc.toString(), 6);
|
||||||
|
String qtdeItensDocGerados = StringHelper.preencherZeroEsquerda(qtdItens.toString(), 6);
|
||||||
|
String brancos382 = StringHelper.preencherStringEspacoEsquerda(null, 382);
|
||||||
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
|
|
||||||
|
String fechamento = fechamentoDeArquivo("3", qtdeDocGerados, qtdeItensDocGerados, brancos382, sequencial);
|
||||||
|
gravarArq.println(fechamento);
|
||||||
|
|
||||||
|
arq.close();
|
||||||
|
return arquivo;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> montarItensFiscaisManual(ImportacionManualFiscalVO imf, List<BigDecimal> itensFiscais, Integer seq) {
|
||||||
|
|
||||||
|
List<String> itensDocs = new ArrayList<String>();
|
||||||
|
Integer num = 0;
|
||||||
|
|
||||||
|
for (BigDecimal item : itensFiscais) {
|
||||||
|
|
||||||
|
num++;
|
||||||
|
String numItem = StringHelper.preencherZeroEsquerda(num.toString(), 3);
|
||||||
|
|
||||||
|
String cfop = null;
|
||||||
|
if (imf.getEstadoIdOrigen() != imf.getEstadoIdDestino()) {
|
||||||
|
cfop = StringHelper.preencherStringEspacoDireita("6357", 5);
|
||||||
|
} else {
|
||||||
|
cfop = StringHelper.preencherStringEspacoDireita("5357", 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
String codigoTES = StringHelper.preencherStringEsquerda(null, 3, "9");
|
||||||
|
String codProduto = StringHelper.preencherStringEspacoEsquerda(imf.getCodProduto(), 15);
|
||||||
|
String unidade = "UN";
|
||||||
|
String quantidade = "001";
|
||||||
|
|
||||||
|
BigDecimal valorItem = UtileriasFiscal.arredondar(item);
|
||||||
|
String valorUnitario = UtileriasFiscal.formataZeroDecimal(valorItem, 15);
|
||||||
|
String valorTotal = UtileriasFiscal.formataZeroDecimal(valorItem, 15);
|
||||||
|
|
||||||
|
BigDecimal valorICMS = UtileriasFiscal.arredondar(imf.getIcms());
|
||||||
|
String aliquotaItem = UtileriasFiscal.formataZeroDecimal(valorICMS, 7);
|
||||||
|
|
||||||
|
BigDecimal aliquotaCalc = UtileriasFiscal.arredondar(imf.getIcms().divide(CEM));
|
||||||
|
BigDecimal baseCalculo = UtileriasFiscal.arredondar(imf.getValorTotal());
|
||||||
|
BigDecimal valorImposto = UtileriasFiscal.arredondar(baseCalculo.multiply(aliquotaCalc.divide(CEM)));
|
||||||
|
String impostoItem = UtileriasFiscal.formataZeroDecimal(valorImposto, 15);
|
||||||
|
|
||||||
|
String totalICMSIsentoItem = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
String totalICMSNaotributadoItem = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
String aliquotaPIS = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
|
String valorPIS = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
String aliquotaCofins = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
|
String valorCofins = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
String aliquotaCSLL = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
|
String valorCSLL = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
String aliquotaISS = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
|
String valorISS = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
|
||||||
|
seq++;
|
||||||
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
|
String brancos193 = StringHelper.preencherStringEspacoDireita(null, 193);
|
||||||
|
|
||||||
|
String itemDoc = itensDocumentoFiscal("2", numItem, cfop, codigoTES, codProduto,
|
||||||
|
unidade, quantidade, valorUnitario, valorTotal, aliquotaItem, impostoItem,
|
||||||
|
aliquotaPIS, valorPIS, aliquotaCofins, valorCofins, aliquotaCSLL, valorCSLL,
|
||||||
|
aliquotaISS, valorISS, totalICMSIsentoItem, totalICMSNaotributadoItem,
|
||||||
|
brancos193, sequencial);
|
||||||
|
itensDocs.add(itemDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itensDocs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ImportacionManualFiscalVO> agruparItensFiscaisManual(List<ImportacionManualFiscalVO> list) {
|
||||||
|
|
||||||
|
List<ImportacionManualFiscalVO> aux = new ArrayList<ImportacionManualFiscalVO>();
|
||||||
|
|
||||||
|
for (ImportacionManualFiscalVO imf : list) {
|
||||||
|
|
||||||
|
List<BigDecimal> itens = new ArrayList<BigDecimal>();
|
||||||
|
if (imf.getImporteoutros() != null) {
|
||||||
|
itens.add(imf.getImporteoutros());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imf.getImportepedagio() != null) {
|
||||||
|
itens.add(imf.getImportepedagio());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imf.getImporteseguro() != null) {
|
||||||
|
itens.add(imf.getImporteseguro());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imf.getImportetaxaembarque() != null) {
|
||||||
|
itens.add(imf.getImportetaxaembarque());
|
||||||
|
}
|
||||||
|
|
||||||
|
imf.setItens(itens);
|
||||||
|
aux.add(imf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return aux;
|
||||||
|
}
|
||||||
|
|
||||||
public File importacionFiscalReducaoZ(Date inicio, Date fim, Empresa empresa) {
|
public File importacionFiscalReducaoZ(Date inicio, Date fim, Empresa empresa) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -54,9 +243,9 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
FileWriter arq = new FileWriter(arquivo);
|
FileWriter arq = new FileWriter(arquivo);
|
||||||
PrintWriter gravarArq = new PrintWriter(arq);
|
PrintWriter gravarArq = new PrintWriter(arq);
|
||||||
|
|
||||||
String cnpjFilial = somenteNumeros(empresa.getCnpj() == null ? StringUtils.rightPad("", 14, " ") : empresa.getCnpj());
|
String cnpjFilial = StringHelper.retornaSomenteNumeros(empresa.getCnpj() == null ?
|
||||||
|
StringHelper.preencherStringEspacoEsquerda(null, 14) : empresa.getCnpj());
|
||||||
String brancos372 = StringUtils.rightPad("", 372, " ");
|
String brancos372 = StringHelper.preencherStringEspacoEsquerda(null, 372);
|
||||||
String dataAgora = DateUtil.getStringDate(Calendar.getInstance().getTime(), DATE_FORMAT_FISCAL);
|
String dataAgora = DateUtil.getStringDate(Calendar.getInstance().getTime(), DATE_FORMAT_FISCAL);
|
||||||
|
|
||||||
String abertura = aberturaDeArquivo("0", dataAgora, cnpjFilial, brancos372, "00001");
|
String abertura = aberturaDeArquivo("0", dataAgora, cnpjFilial, brancos372, "00001");
|
||||||
|
@ -69,83 +258,44 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
for (ImportacionFiscalReducaoZVO ifrZ : list) {
|
for (ImportacionFiscalReducaoZVO ifrZ : list) {
|
||||||
|
|
||||||
String dataMovimento = ifrZ.getDatamov();
|
String dataMovimento = ifrZ.getDatamov();
|
||||||
String cnpj = somenteNumeros(ifrZ.getCnpj() == null ? StringUtils.rightPad("", 14, " ") : ifrZ.getCnpj());
|
String cnpj = StringHelper.retornaSomenteNumeros(ifrZ.getCnpj() == null ?
|
||||||
|
StringHelper.preencherStringEspacoEsquerda(null, 14) : ifrZ.getCnpj());
|
||||||
|
|
||||||
String numRelatorio = ifrZ.getAliquota().substring(0, 2);
|
String impAliquota = ifrZ.getAliquota() == null ? "" : ifrZ.getAliquota().substring(0, 2);
|
||||||
if (numRelatorio.length() < 6) {
|
String numRelatorio = StringHelper.preencherZeroEsquerda(impAliquota, 6);
|
||||||
numRelatorio = StringUtils.rightPad("", (6 - numRelatorio.length()), "0") + numRelatorio;
|
|
||||||
}
|
|
||||||
|
|
||||||
String numPDV = ifrZ.getNumpdv();
|
String numPDV = StringHelper.preencherStringEspacoEsquerda(ifrZ.getNumpdv(), 10);
|
||||||
if (numPDV.length() < 10) {
|
String numSeriePDV = StringHelper.preencherStringEspacoEsquerda(ifrZ.getNumserie20(), 20);
|
||||||
numPDV = StringUtils.rightPad("", (10 - numPDV.length()), " ") + numPDV;
|
String numReducaoZ = StringHelper.preencherStringEspacoEsquerda(ifrZ.getCrz(), 5);
|
||||||
}
|
|
||||||
|
|
||||||
String numSeriePDV = ifrZ.getNumserie20();
|
String gtInicial = StringHelper.preencherZeroEsquerda(ifrZ.getGtInicial().toString(), 18);
|
||||||
if (numSeriePDV.length() < 20) {
|
String gtFinal = StringHelper.preencherZeroEsquerda(ifrZ.getGtFinal().toString(), 18);
|
||||||
numSeriePDV = StringUtils.rightPad("", (20 - numSeriePDV.length()), " ") + numSeriePDV;
|
|
||||||
}
|
|
||||||
|
|
||||||
String numReducaoZ = ifrZ.getCrz();
|
String docFiscalInic = StringHelper.preencherStringEspacoEsquerda(ifrZ.getCooinicial(), 9);
|
||||||
if (numReducaoZ.length() < 5) {
|
String docFiscalFinal = StringHelper.preencherStringEspacoEsquerda(ifrZ.getCoofinal(), 9);
|
||||||
numReducaoZ = StringUtils.rightPad("", (5 - numReducaoZ.length()), " ") + numReducaoZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
String gtInicial = ifrZ.getGtInicial().toString();
|
String valorCancel = StringHelper.preencherZeroEsquerda(null, 8);
|
||||||
if (gtInicial.length() < 18) {
|
String valorContabil = StringHelper.preencherZeroEsquerda(ifrZ.getVendabrutadiaria().toString(), 14);
|
||||||
gtInicial = StringUtils.rightPad("", (18 - gtInicial.length()), "0") + gtInicial;
|
|
||||||
}
|
|
||||||
|
|
||||||
String gtFinal = ifrZ.getGtFinal().toString();
|
String subtributaria = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
if (gtFinal.length() < 18) {
|
String descontos = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
gtFinal = StringUtils.rightPad("", (18 - gtFinal.length()), "0") + gtFinal;
|
String isento = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
}
|
|
||||||
|
|
||||||
String docFiscalInic = ifrZ.getCooinicial();
|
String valorNaoTributado = ifrZ.getValorNaoTributado() == null ? "" : ifrZ.getValorNaoTributado().toString();
|
||||||
if (docFiscalInic.length() < 9) {
|
String naoTributado = StringHelper.preencherZeroEsquerda(valorNaoTributado, 14);
|
||||||
docFiscalInic = StringUtils.rightPad("", (9 - docFiscalInic.length()), " ") + docFiscalInic;
|
|
||||||
}
|
|
||||||
|
|
||||||
String docFiscalFinal = ifrZ.getCoofinal();
|
String aliquota = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
if (docFiscalFinal.length() < 9) {
|
|
||||||
docFiscalFinal = StringUtils.rightPad("", (9 - docFiscalFinal.length()), " ") + docFiscalFinal;
|
|
||||||
}
|
|
||||||
|
|
||||||
String valorCancel = StringUtils.rightPad("", 8, "0");
|
|
||||||
|
|
||||||
String valorContabil = ifrZ.getVendabrutadiaria().toString();
|
|
||||||
if (valorContabil.length() < 14) {
|
|
||||||
valorContabil = StringUtils.rightPad("", (14 - valorContabil.length()), "0") + valorContabil;
|
|
||||||
}
|
|
||||||
|
|
||||||
String subtributaria = StringUtils.rightPad("", 14, "0");
|
|
||||||
String descontos = StringUtils.rightPad("", 14, "0");
|
|
||||||
String isento = StringUtils.rightPad("", 14, "0");
|
|
||||||
|
|
||||||
String naoTributado = ifrZ.getValorNaoTributado() == null ? "" : ifrZ.getValorNaoTributado().toString();
|
|
||||||
if (naoTributado.length() < 14) {
|
|
||||||
naoTributado = StringUtils.rightPad("", (14 - naoTributado.length()), "0") + naoTributado;
|
|
||||||
}
|
|
||||||
|
|
||||||
String aliquota = StringUtils.rightPad("", 14, "0");
|
|
||||||
if (ifrZ.getAliquota().length() == 7 && ifrZ.getAliquota().substring(2, 3).equals(SituacaoTributaria.TRIBUTADO.getValue())) {
|
if (ifrZ.getAliquota().length() == 7 && ifrZ.getAliquota().substring(2, 3).equals(SituacaoTributaria.TRIBUTADO.getValue())) {
|
||||||
|
|
||||||
aliquota = ifrZ.getAliquota().substring(3, 7);
|
aliquota = ifrZ.getAliquota().substring(3, 7);
|
||||||
if (aliquota.length() < 14) {
|
aliquota = StringHelper.preencherZeroEsquerda(aliquota, 14);
|
||||||
aliquota = StringUtils.rightPad("", (14 - aliquota.length()), "0") + aliquota;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String aliquota2 = StringUtils.rightPad("", 14, "0");
|
String aliquota2 = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
String aliquota3 = StringUtils.rightPad("", 14, "0");
|
String aliquota3 = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
String aliquota4 = StringUtils.rightPad("", 14, "0");
|
String aliquota4 = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
String coo = ifrZ.getCoo();
|
String coo = StringHelper.preencherStringEspacoEsquerda(ifrZ.getCoo(), 6);
|
||||||
if (coo.length() < 6) {
|
String outrosRecebimentos = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
coo = StringUtils.rightPad("", (6 - coo.length()), " ") + coo;
|
|
||||||
}
|
|
||||||
|
|
||||||
String outrosRecebimentos = StringUtils.rightPad("", 14, "0");
|
|
||||||
|
|
||||||
BigDecimal aliquotaCalc = BigDecimal.valueOf(Double.valueOf(aliquota) / CEM.doubleValue());
|
BigDecimal aliquotaCalc = BigDecimal.valueOf(Double.valueOf(aliquota) / CEM.doubleValue());
|
||||||
aliquotaCalc = UtileriasFiscal.arredondar(aliquotaCalc);
|
aliquotaCalc = UtileriasFiscal.arredondar(aliquotaCalc);
|
||||||
|
@ -155,30 +305,16 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
|
|
||||||
BigDecimal valorImposto = baseCalculo.multiply(aliquotaCalc.divide(CEM));
|
BigDecimal valorImposto = baseCalculo.multiply(aliquotaCalc.divide(CEM));
|
||||||
valorImposto = UtileriasFiscal.arredondar(valorImposto);
|
valorImposto = UtileriasFiscal.arredondar(valorImposto);
|
||||||
|
String impostoDebitado = UtileriasFiscal.formataZeroDecimal(valorImposto, 13);
|
||||||
String impostoDebitado = valorImposto.toString();
|
|
||||||
impostoDebitado = impostoDebitado.toString().replace(".", "").replace(",", "");
|
|
||||||
impostoDebitado = UtileriasFiscal.formataNumerico(impostoDebitado, impostoDebitado.length());
|
|
||||||
|
|
||||||
if (impostoDebitado.length() < 13) {
|
|
||||||
impostoDebitado = StringUtils.rightPad("", (13 - impostoDebitado.length()), "0") + impostoDebitado;
|
|
||||||
}
|
|
||||||
|
|
||||||
String dataReducaoZ = ifrZ.getDatareducao();
|
String dataReducaoZ = ifrZ.getDatareducao();
|
||||||
String horaReducaoZ = ifrZ.getHorareducao();
|
String horaReducaoZ = ifrZ.getHorareducao();
|
||||||
|
|
||||||
String valorDocFiscal = ifrZ.getImposto().toString();
|
String valorDocFiscal = StringHelper.preencherZeroEsquerda(ifrZ.getImposto().toString(), 13);
|
||||||
if (valorDocFiscal.length() < 13) {
|
String brancos83 = StringHelper.preencherStringEspacoEsquerda(null, 83);
|
||||||
valorDocFiscal = StringUtils.rightPad("", (13 - valorDocFiscal.length()), "0") + valorDocFiscal;
|
|
||||||
}
|
|
||||||
|
|
||||||
String brancos83 = StringUtils.rightPad("", 83, " ");
|
|
||||||
|
|
||||||
seq++;
|
seq++;
|
||||||
String sequencial = seq.toString();
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
if (sequencial.length() < 5) {
|
|
||||||
sequencial = StringUtils.rightPad("", (5 - sequencial.length()), "0") + sequencial;
|
|
||||||
}
|
|
||||||
|
|
||||||
String redZ = reducaoZ("1", dataMovimento, cnpj, numRelatorio, numPDV, numSeriePDV, numReducaoZ,
|
String redZ = reducaoZ("1", dataMovimento, cnpj, numRelatorio, numPDV, numSeriePDV, numReducaoZ,
|
||||||
gtInicial, gtFinal, docFiscalInic, docFiscalFinal, valorCancel, valorContabil, subtributaria,
|
gtInicial, gtFinal, docFiscalInic, docFiscalFinal, valorCancel, valorContabil, subtributaria,
|
||||||
|
@ -186,22 +322,14 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
impostoDebitado, dataReducaoZ, horaReducaoZ, valorDocFiscal, brancos83, sequencial);
|
impostoDebitado, dataReducaoZ, horaReducaoZ, valorDocFiscal, brancos83, sequencial);
|
||||||
|
|
||||||
gravarArq.println(redZ);
|
gravarArq.println(redZ);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer qtdeDoc = seq - 1;
|
Integer qtdeDoc = seq - 1;
|
||||||
String qtdeDocGerados = qtdeDoc.toString();
|
|
||||||
if (qtdeDocGerados.length() < 6) {
|
|
||||||
qtdeDocGerados = StringUtils.rightPad("", (6 - qtdeDocGerados.length()), "0") + qtdeDocGerados;
|
|
||||||
}
|
|
||||||
|
|
||||||
String brancos388 = StringUtils.rightPad("", 388, " ");
|
|
||||||
|
|
||||||
seq++;
|
seq++;
|
||||||
String sequencial = seq.toString();
|
|
||||||
if (sequencial.length() < 5) {
|
String qtdeDocGerados = StringHelper.preencherZeroEsquerda(qtdeDoc.toString(), 6);
|
||||||
sequencial = StringUtils.rightPad("", (5 - sequencial.length()), "0") + sequencial;
|
String brancos388 = StringHelper.preencherStringEspacoEsquerda(null, 388);
|
||||||
}
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
|
|
||||||
String fechamento = fechamentoDeArquivo("3", qtdeDocGerados, null, brancos388, sequencial);
|
String fechamento = fechamentoDeArquivo("3", qtdeDocGerados, null, brancos388, sequencial);
|
||||||
gravarArq.println(fechamento);
|
gravarArq.println(fechamento);
|
||||||
|
@ -233,47 +361,6 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
return aux;
|
return aux;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String reducaoZ(String identificador, String dataMovimento, String cnpj, String numRelatorio, String numPDV,
|
|
||||||
String numSeriePDV, String numReducaoZ, String gtInicial, String gtFinal, String docFiscalInic,
|
|
||||||
String docFiscalFinal, String valorCancel, String valorContabil, String subtributaria, String descontos,
|
|
||||||
String isento, String naoTributado, String aliquota, String aliquota2, String aliquota3, String aliquota4,
|
|
||||||
String coo, String outrosRecebimentos, String impostoDebitado, String dataReducaoZ, String horaReducaoZ,
|
|
||||||
String valorDocFiscal, String brancos, String sequencial) {
|
|
||||||
|
|
||||||
StringBuilder reducaoZ = new StringBuilder();
|
|
||||||
reducaoZ.append(identificador);
|
|
||||||
reducaoZ.append(dataMovimento);
|
|
||||||
reducaoZ.append(cnpj);
|
|
||||||
reducaoZ.append(numRelatorio);
|
|
||||||
reducaoZ.append(numPDV);
|
|
||||||
reducaoZ.append(numSeriePDV);
|
|
||||||
reducaoZ.append(numReducaoZ);
|
|
||||||
reducaoZ.append(gtInicial);
|
|
||||||
reducaoZ.append(gtFinal);
|
|
||||||
reducaoZ.append(docFiscalInic);
|
|
||||||
reducaoZ.append(docFiscalFinal);
|
|
||||||
reducaoZ.append(valorCancel);
|
|
||||||
reducaoZ.append(valorContabil);
|
|
||||||
reducaoZ.append(subtributaria);
|
|
||||||
reducaoZ.append(descontos);
|
|
||||||
reducaoZ.append(isento);
|
|
||||||
reducaoZ.append(naoTributado);
|
|
||||||
reducaoZ.append(aliquota);
|
|
||||||
reducaoZ.append(aliquota2);
|
|
||||||
reducaoZ.append(aliquota3);
|
|
||||||
reducaoZ.append(aliquota4);
|
|
||||||
reducaoZ.append(coo);
|
|
||||||
reducaoZ.append(outrosRecebimentos);
|
|
||||||
reducaoZ.append(impostoDebitado);
|
|
||||||
reducaoZ.append(dataReducaoZ);
|
|
||||||
reducaoZ.append(horaReducaoZ);
|
|
||||||
reducaoZ.append(valorDocFiscal);
|
|
||||||
reducaoZ.append(brancos);
|
|
||||||
reducaoZ.append(sequencial);
|
|
||||||
|
|
||||||
return reducaoZ.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File importacionFiscalECF(Date inicio, Date fim, Empresa empresa) {
|
public File importacionFiscalECF(Date inicio, Date fim, Empresa empresa) {
|
||||||
|
|
||||||
|
@ -285,7 +372,7 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
PrintWriter gravarArq = new PrintWriter(arq);
|
PrintWriter gravarArq = new PrintWriter(arq);
|
||||||
|
|
||||||
String cnpjFilial = empresa.getCnpj();
|
String cnpjFilial = empresa.getCnpj();
|
||||||
String brancos372 = StringUtils.rightPad("", 372, " ");
|
String brancos372 = StringHelper.preencherStringEspacoEsquerda(null, 372);
|
||||||
String dataAgora = DateUtil.getStringDate(Calendar.getInstance().getTime(), DATE_FORMAT_FISCAL);
|
String dataAgora = DateUtil.getStringDate(Calendar.getInstance().getTime(), DATE_FORMAT_FISCAL);
|
||||||
|
|
||||||
String abertura = aberturaDeArquivo("0", dataAgora, cnpjFilial, brancos372, "00001");
|
String abertura = aberturaDeArquivo("0", dataAgora, cnpjFilial, brancos372, "00001");
|
||||||
|
@ -303,34 +390,22 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
|
|
||||||
qtdDoc++;
|
qtdDoc++;
|
||||||
String data = fiscal.getDataEmissao();
|
String data = fiscal.getDataEmissao();
|
||||||
|
String brancos213 = StringHelper.preencherStringEspacoEsquerda(null, 213);
|
||||||
|
|
||||||
String brancos213 = StringUtils.rightPad("", 213, " ");
|
String serie = StringHelper.preencherStringEspacoEsquerda(null, 3);
|
||||||
|
String especie = StringHelper.preencherStringEspacoDireita("CF", 5);
|
||||||
|
|
||||||
String serie = StringUtils.rightPad("", 3, " ");
|
String codigoCliente = StringHelper.preencherStringEsquerda(null, 6, "9");
|
||||||
String especie = "CF" + StringUtils.rightPad("", 3, " ");
|
String filialCliente = StringHelper.preencherStringEsquerda(null, 2, "9");
|
||||||
|
String condicaoPagamento = StringHelper.preencherStringEsquerda(null, 3, "9");
|
||||||
|
|
||||||
String codigoCliente = StringUtils.rightPad("", 6, "9");
|
String valorPIS = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
String filialCliente = StringUtils.rightPad("", 2, "9");
|
String valorCofins = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
String condicaoPagamento = StringUtils.rightPad("", 3, "9");
|
String valorCSLL = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
String valorPIS = StringUtils.rightPad("", 14, "0");
|
String coo = StringHelper.preencherStringEspacoDireita(fiscal.getCoo(), 9);
|
||||||
String valorCofins = StringUtils.rightPad("", 14, "0");
|
String valorTotalDocumanto = StringHelper.preencherStringEspacoDireita(fiscal.getValorTotal().toString(), 14);
|
||||||
String valorCSLL = StringUtils.rightPad("", 14, "0");
|
String valorItens = StringHelper.preencherStringEspacoDireita(fiscal.getValorTotal().toString(), 14);
|
||||||
|
|
||||||
String coo = fiscal.getCoo();
|
|
||||||
if (coo.length() < 9) {
|
|
||||||
coo = StringUtils.rightPad("", (9 - coo.length()), " ") + coo;
|
|
||||||
}
|
|
||||||
|
|
||||||
String valorTotalDocumanto = fiscal.getValorTotal().toString();
|
|
||||||
if (valorTotalDocumanto.length() < 14) {
|
|
||||||
valorTotalDocumanto = StringUtils.rightPad("", (14 - valorTotalDocumanto.length()), "0") + valorTotalDocumanto;
|
|
||||||
}
|
|
||||||
|
|
||||||
String valorItens = fiscal.getValorTotal().toString();
|
|
||||||
if (valorItens.length() < 14) {
|
|
||||||
valorItens = StringUtils.rightPad("", (14 - valorItens.length()), "0") + valorItens;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<String, String> aliquotaBaseCalculo = getAliquotaBaseCalculo(fiscal);
|
HashMap<String, String> aliquotaBaseCalculo = getAliquotaBaseCalculo(fiscal);
|
||||||
String aliquota = aliquotaBaseCalculo.get("aliquota");
|
String aliquota = aliquotaBaseCalculo.get("aliquota");
|
||||||
|
@ -338,20 +413,15 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
String totalICMSIsento = aliquotaBaseCalculo.get("totalICMSIsento");
|
String totalICMSIsento = aliquotaBaseCalculo.get("totalICMSIsento");
|
||||||
String totalICMSNaotributado = aliquotaBaseCalculo.get("totalICMSNaotributado");
|
String totalICMSNaotributado = aliquotaBaseCalculo.get("totalICMSNaotributado");
|
||||||
|
|
||||||
String origen = fiscal.getOrigenId().toString();
|
String origen = StringHelper.preencherStringEspacoEsquerda(fiscal.getOrigenId().toString(), 5);
|
||||||
if (origen.length() < 5) {
|
|
||||||
origen = StringUtils.rightPad("", (5 - origen.length()), " ") + origen;
|
|
||||||
}
|
|
||||||
|
|
||||||
seq++;
|
seq++;
|
||||||
String sequencial = seq.toString();
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
if (sequencial.length() < 5) {
|
|
||||||
sequencial = StringUtils.rightPad("", (5 - sequencial.length()), "0") + sequencial;
|
|
||||||
}
|
|
||||||
|
|
||||||
String header = headerDocumentoFiscal("1", data, cnpjFilial, coo, serie, especie, codigoCliente,
|
String header = headerDocumentoFiscal("1", data, cnpjFilial, coo, serie, especie, codigoCliente,
|
||||||
filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, aliquota, imposto,
|
filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, aliquota, imposto,
|
||||||
valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origen, brancos213, sequencial);
|
valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origen, null,
|
||||||
|
null, brancos213, sequencial);
|
||||||
gravarArq.println(header);
|
gravarArq.println(header);
|
||||||
|
|
||||||
for (String itemDoc : montarItensFiscais(fiscal.getItensFiscais(), seq)) {
|
for (String itemDoc : montarItensFiscais(fiscal.getItensFiscais(), seq)) {
|
||||||
|
@ -363,23 +433,11 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String qtdeDocGerados = qtdDoc.toString();
|
|
||||||
if (qtdeDocGerados.length() < 6) {
|
|
||||||
qtdeDocGerados = StringUtils.rightPad("", (6 - qtdeDocGerados.length()), "0") + qtdeDocGerados;
|
|
||||||
}
|
|
||||||
|
|
||||||
String qtdeItensDocGerados = qtdItens.toString();
|
|
||||||
if (qtdeItensDocGerados.length() < 6) {
|
|
||||||
qtdeItensDocGerados = StringUtils.rightPad("", (6 - qtdeItensDocGerados.length()), "0") + qtdeItensDocGerados;
|
|
||||||
}
|
|
||||||
|
|
||||||
String brancos382 = StringUtils.rightPad("", 382, " ");
|
|
||||||
|
|
||||||
seq++;
|
seq++;
|
||||||
String sequencial = seq.toString();
|
String qtdeDocGerados = StringHelper.preencherZeroEsquerda(qtdDoc.toString(), 6);
|
||||||
if (sequencial.length() < 5) {
|
String qtdeItensDocGerados = StringHelper.preencherZeroEsquerda(qtdItens.toString(), 6);
|
||||||
sequencial = StringUtils.rightPad("", (5 - sequencial.length()), "0") + sequencial;
|
String brancos382 = StringHelper.preencherStringEspacoEsquerda(null, 382);
|
||||||
}
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
|
|
||||||
String fechamento = fechamentoDeArquivo("3", qtdeDocGerados, qtdeItensDocGerados, brancos382, sequencial);
|
String fechamento = fechamentoDeArquivo("3", qtdeDocGerados, qtdeItensDocGerados, brancos382, sequencial);
|
||||||
gravarArq.println(fechamento);
|
gravarArq.println(fechamento);
|
||||||
|
@ -414,34 +472,23 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
|
|
||||||
String cfop = null;
|
String cfop = null;
|
||||||
if (tipoPassagem.equals("E")) {
|
if (tipoPassagem.equals("E")) {
|
||||||
cfop = StringUtils.rightPad("", 1, " ") + "6357";
|
cfop = StringHelper.preencherStringEspacoDireita("6357", 5);
|
||||||
} else if (tipoPassagem.equals("M")) {
|
} else if (tipoPassagem.equals("M")) {
|
||||||
cfop = StringUtils.rightPad("", 1, " ") + "5357";
|
cfop = StringHelper.preencherStringEspacoDireita("5357", 5);
|
||||||
}
|
|
||||||
|
|
||||||
String codigoTES = "999";
|
|
||||||
String codProduto = item.getCodProduto();
|
|
||||||
if (codProduto.length() < 15) {
|
|
||||||
codProduto = StringUtils.rightPad("", (15 - codProduto.length()), " ") + codProduto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String codigoTES = StringHelper.preencherStringEsquerda(null, 3, "9");
|
||||||
|
String codProduto = StringHelper.preencherStringEspacoEsquerda(item.getCodProduto(), 15);
|
||||||
String unidade = "UN";
|
String unidade = "UN";
|
||||||
String quantidade = "001";
|
String quantidade = "001";
|
||||||
|
|
||||||
String valorUnitario = item.getValorItem().toString();
|
String valorUnitario = StringHelper.preencherZeroEsquerda(item.getValorItem().toString(), 15);
|
||||||
if (valorUnitario.length() < 15) {
|
String valorTotal = StringHelper.preencherZeroEsquerda(item.getValorItem().toString(), 15);
|
||||||
valorUnitario = StringUtils.rightPad("", (15 - valorUnitario.length()), "0") + valorUnitario;
|
|
||||||
}
|
|
||||||
|
|
||||||
String valorTotal = item.getValorItem().toString();
|
String aliquotaItem = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
if (valorTotal.length() < 15) {
|
String impostoItem = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
valorTotal = StringUtils.rightPad("", (15 - valorTotal.length()), "0") + valorTotal;
|
String totalICMSIsentoItem = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
}
|
String totalICMSNaotributadoItem = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
|
||||||
String aliquotaItem = StringUtils.rightPad("", 7, "0");
|
|
||||||
String impostoItem = StringUtils.rightPad("", 15, "0");
|
|
||||||
String totalICMSIsentoItem = StringUtils.rightPad("", 15, "0");
|
|
||||||
String totalICMSNaotributadoItem = StringUtils.rightPad("", 15, "0");
|
|
||||||
|
|
||||||
HashMap<String, BigDecimal> aliquotaItens = new HashMap<String, BigDecimal>(0);
|
HashMap<String, BigDecimal> aliquotaItens = new HashMap<String, BigDecimal>(0);
|
||||||
|
|
||||||
|
@ -460,12 +507,7 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
} else if (item.getRepTributado().equals(SituacaoTributaria.NAO_TRIBUTADO.getValue())) {
|
} else if (item.getRepTributado().equals(SituacaoTributaria.NAO_TRIBUTADO.getValue())) {
|
||||||
|
|
||||||
BigDecimal soma = item.getValorItem();
|
BigDecimal soma = item.getValorItem();
|
||||||
totalICMSNaotributadoItem = soma.toString();
|
totalICMSNaotributadoItem = StringHelper.preencherZeroEsquerda(soma.toString(), 15);
|
||||||
|
|
||||||
if (totalICMSNaotributadoItem.length() < 15) {
|
|
||||||
totalICMSNaotributadoItem = StringUtils.rightPad("", (15 - totalICMSNaotributadoItem.length()), "0") + totalICMSNaotributadoItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key : aliquotaItens.keySet()) {
|
for (String key : aliquotaItens.keySet()) {
|
||||||
|
@ -480,38 +522,22 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
BigDecimal valorImposto = baseCalculo.multiply(aliquotaCalc.divide(CEM));
|
BigDecimal valorImposto = baseCalculo.multiply(aliquotaCalc.divide(CEM));
|
||||||
valorImposto = UtileriasFiscal.arredondar(valorImposto);
|
valorImposto = UtileriasFiscal.arredondar(valorImposto);
|
||||||
|
|
||||||
impostoItem = valorImposto.toString().replace(".", "").replace(",", "");
|
impostoItem = UtileriasFiscal.formataZeroDecimal(valorImposto, 15);
|
||||||
impostoItem = UtileriasFiscal.formataNumerico(impostoItem, impostoItem.length());
|
aliquotaItem = UtileriasFiscal.formataZeroDecimal(aliquotaCalc, 7);
|
||||||
|
|
||||||
aliquotaItem = aliquotaCalc.toString().replace(".", "").replace(",", "");
|
|
||||||
aliquotaItem = UtileriasFiscal.formataNumerico(aliquotaItem, aliquotaItem.length());
|
|
||||||
|
|
||||||
if (aliquotaItem.length() < 7) {
|
|
||||||
aliquotaItem = StringUtils.rightPad("", (7 - aliquotaItem.length()), "0") + aliquotaItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impostoItem.length() < 15) {
|
String aliquotaPIS = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
impostoItem = StringUtils.rightPad("", (15 - impostoItem.length()), "0") + impostoItem;
|
String valorPIS = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
}
|
String aliquotaCofins = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
}
|
String valorCofins = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
|
String aliquotaCSLL = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
String aliquotaPIS = StringUtils.rightPad("", 7, "0");
|
String valorCSLL = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
String valorPIS = StringUtils.rightPad("", 15, "0");
|
String aliquotaISS = StringHelper.preencherZeroEsquerda(null, 7);
|
||||||
String aliquotaCofins = StringUtils.rightPad("", 7, "0");
|
String valorISS = StringHelper.preencherZeroEsquerda(null, 15);
|
||||||
String valorCofins = StringUtils.rightPad("", 15, "0");
|
|
||||||
String aliquotaCSLL = StringUtils.rightPad("", 7, "0");
|
|
||||||
String valorCSLL = StringUtils.rightPad("", 15, "0");
|
|
||||||
|
|
||||||
String aliquotaISS = StringUtils.rightPad("", 7, "0");
|
|
||||||
String valorISS = StringUtils.rightPad("", 15, "0");
|
|
||||||
|
|
||||||
seq++;
|
seq++;
|
||||||
String sequencial = seq.toString();
|
String sequencial = StringHelper.preencherZeroEsquerda(seq.toString(), 5);
|
||||||
if (sequencial.length() < 5) {
|
String brancos193 = StringHelper.preencherStringEspacoEsquerda(null, 193);
|
||||||
sequencial = StringUtils.rightPad("", (5 - sequencial.length()), "0") + sequencial;
|
|
||||||
}
|
|
||||||
|
|
||||||
String brancos193 = StringUtils.rightPad("", 193, " ");
|
|
||||||
|
|
||||||
String itemDoc = itensDocumentoFiscal("2", numItem, cfop, codigoTES, codProduto,
|
String itemDoc = itensDocumentoFiscal("2", numItem, cfop, codigoTES, codProduto,
|
||||||
unidade, quantidade, valorUnitario, valorTotal, aliquotaItem, impostoItem,
|
unidade, quantidade, valorUnitario, valorTotal, aliquotaItem, impostoItem,
|
||||||
|
@ -594,7 +620,7 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
totalICMSNaotributado = soma.toString();
|
totalICMSNaotributado = soma.toString();
|
||||||
|
|
||||||
if (totalICMSNaotributado.length() < 14) {
|
if (totalICMSNaotributado.length() < 14) {
|
||||||
totalICMSNaotributado = StringUtils.rightPad("", (14 - totalICMSNaotributado.length()), "0") + totalICMSNaotributado;
|
totalICMSNaotributado = StringHelper.preencherZeroEsquerda(totalICMSNaotributado, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -611,33 +637,22 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
BigDecimal valorImposto = baseCalculo.multiply(aliquotaCalc.divide(CEM));
|
BigDecimal valorImposto = baseCalculo.multiply(aliquotaCalc.divide(CEM));
|
||||||
valorImposto = UtileriasFiscal.arredondar(valorImposto);
|
valorImposto = UtileriasFiscal.arredondar(valorImposto);
|
||||||
|
|
||||||
imposto = valorImposto.toString().replace(".", "").replace(",", "");
|
imposto = UtileriasFiscal.formataZeroDecimal(valorImposto, 14);
|
||||||
imposto = UtileriasFiscal.formataNumerico(imposto, imposto.length());
|
aliquota = UtileriasFiscal.formataZeroDecimal(aliquotaCalc, 14);
|
||||||
|
|
||||||
aliquota = aliquotaCalc.toString().replace(".", "").replace(",", "");
|
|
||||||
aliquota = UtileriasFiscal.formataNumerico(aliquota, aliquota.length());
|
|
||||||
|
|
||||||
if (aliquota.length() < 14) {
|
|
||||||
aliquota = StringUtils.rightPad("", (14 - aliquota.length()), "0") + aliquota;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imposto.length() < 14) {
|
|
||||||
imposto = StringUtils.rightPad("", (14 - imposto.length()), "0") + imposto;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(aliquota))
|
if (StringUtils.isBlank(aliquota))
|
||||||
aliquota = StringUtils.rightPad("", 14, "0");
|
aliquota = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
if (StringUtils.isBlank(imposto))
|
if (StringUtils.isBlank(imposto))
|
||||||
imposto = StringUtils.rightPad("", 14, "0");
|
imposto = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
if (StringUtils.isBlank(totalICMSIsento))
|
if (StringUtils.isBlank(totalICMSIsento))
|
||||||
totalICMSIsento = StringUtils.rightPad("", 14, "0");
|
totalICMSIsento = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
if (StringUtils.isBlank(totalICMSNaotributado))
|
if (StringUtils.isBlank(totalICMSNaotributado))
|
||||||
totalICMSNaotributado = StringUtils.rightPad("", 14, "0");
|
totalICMSNaotributado = StringHelper.preencherZeroEsquerda(null, 14);
|
||||||
|
|
||||||
resp.put("aliquota", aliquota);
|
resp.put("aliquota", aliquota);
|
||||||
resp.put("imposto", imposto);
|
resp.put("imposto", imposto);
|
||||||
|
@ -647,6 +662,47 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String reducaoZ(String identificador, String dataMovimento, String cnpj, String numRelatorio, String numPDV,
|
||||||
|
String numSeriePDV, String numReducaoZ, String gtInicial, String gtFinal, String docFiscalInic,
|
||||||
|
String docFiscalFinal, String valorCancel, String valorContabil, String subtributaria, String descontos,
|
||||||
|
String isento, String naoTributado, String aliquota, String aliquota2, String aliquota3, String aliquota4,
|
||||||
|
String coo, String outrosRecebimentos, String impostoDebitado, String dataReducaoZ, String horaReducaoZ,
|
||||||
|
String valorDocFiscal, String brancos, String sequencial) {
|
||||||
|
|
||||||
|
StringBuilder reducaoZ = new StringBuilder();
|
||||||
|
reducaoZ.append(identificador);
|
||||||
|
reducaoZ.append(dataMovimento);
|
||||||
|
reducaoZ.append(cnpj);
|
||||||
|
reducaoZ.append(numRelatorio);
|
||||||
|
reducaoZ.append(numPDV);
|
||||||
|
reducaoZ.append(numSeriePDV);
|
||||||
|
reducaoZ.append(numReducaoZ);
|
||||||
|
reducaoZ.append(gtInicial);
|
||||||
|
reducaoZ.append(gtFinal);
|
||||||
|
reducaoZ.append(docFiscalInic);
|
||||||
|
reducaoZ.append(docFiscalFinal);
|
||||||
|
reducaoZ.append(valorCancel);
|
||||||
|
reducaoZ.append(valorContabil);
|
||||||
|
reducaoZ.append(subtributaria);
|
||||||
|
reducaoZ.append(descontos);
|
||||||
|
reducaoZ.append(isento);
|
||||||
|
reducaoZ.append(naoTributado);
|
||||||
|
reducaoZ.append(aliquota);
|
||||||
|
reducaoZ.append(aliquota2);
|
||||||
|
reducaoZ.append(aliquota3);
|
||||||
|
reducaoZ.append(aliquota4);
|
||||||
|
reducaoZ.append(coo);
|
||||||
|
reducaoZ.append(outrosRecebimentos);
|
||||||
|
reducaoZ.append(impostoDebitado);
|
||||||
|
reducaoZ.append(dataReducaoZ);
|
||||||
|
reducaoZ.append(horaReducaoZ);
|
||||||
|
reducaoZ.append(valorDocFiscal);
|
||||||
|
reducaoZ.append(brancos);
|
||||||
|
reducaoZ.append(sequencial);
|
||||||
|
|
||||||
|
return reducaoZ.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private String aberturaDeArquivo(String identificador, String data, String cnpjFilial, String brancos372, String sequencial) {
|
private String aberturaDeArquivo(String identificador, String data, String cnpjFilial, String brancos372, String sequencial) {
|
||||||
|
|
||||||
StringBuilder abertura = new StringBuilder();
|
StringBuilder abertura = new StringBuilder();
|
||||||
|
@ -662,7 +718,7 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
private String headerDocumentoFiscal(String identificador, String data, String cnpjImpressora, String coo, String serie,
|
private String headerDocumentoFiscal(String identificador, String data, String cnpjImpressora, String coo, String serie,
|
||||||
String especie, String codigoCliente, String filialCliente, String condicaoPagamento, String valorTotalDocumanto,
|
String especie, String codigoCliente, String filialCliente, String condicaoPagamento, String valorTotalDocumanto,
|
||||||
String valorItens, String aliquota, String imposto, String valorPIS, String valorCofins, String valorCSLL,
|
String valorItens, String aliquota, String imposto, String valorPIS, String valorCofins, String valorCSLL,
|
||||||
String totalICMSIsento, String totalICMSNaotributado, String origen, String brancos213, String sequencial) {
|
String totalICMSIsento, String totalICMSNaotributado, String origen, String subSerie, String aidf, String brancos, String sequencial) {
|
||||||
|
|
||||||
StringBuilder header = new StringBuilder();
|
StringBuilder header = new StringBuilder();
|
||||||
header.append(identificador);
|
header.append(identificador);
|
||||||
|
@ -684,7 +740,9 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
header.append(totalICMSIsento);
|
header.append(totalICMSIsento);
|
||||||
header.append(totalICMSNaotributado);
|
header.append(totalICMSNaotributado);
|
||||||
header.append(origen);
|
header.append(origen);
|
||||||
header.append(brancos213);
|
header.append(subSerie == null ? "" : subSerie);
|
||||||
|
header.append(aidf == null ? "" : aidf);
|
||||||
|
header.append(brancos);
|
||||||
header.append(sequencial);
|
header.append(sequencial);
|
||||||
|
|
||||||
return header.toString();
|
return header.toString();
|
||||||
|
@ -737,12 +795,4 @@ public class FiscalServiceImpl implements FiscalService {
|
||||||
return fechamento.toString();
|
return fechamento.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String somenteNumeros(String s) {
|
|
||||||
if (s == null || s.trim().equals("")) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.replaceAll("[^0-9]", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
package com.rjconsultores.ventaboletos.utilerias;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
public class StringHelper {
|
||||||
|
|
||||||
|
private static String[] REPLACES = { "a", "e", "i", "o", "u", "c", "A", "E", "I", "O", "U", "C" };
|
||||||
|
private static Pattern[] PATTERNS = null;
|
||||||
|
|
||||||
|
private StringHelper() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void compilePatterns() {
|
||||||
|
PATTERNS = new Pattern[REPLACES.length];
|
||||||
|
PATTERNS[0] = Pattern.compile("[âãáàä]");
|
||||||
|
PATTERNS[1] = Pattern.compile("[éèêë]");
|
||||||
|
PATTERNS[2] = Pattern.compile("[íìîï]");
|
||||||
|
PATTERNS[3] = Pattern.compile("[óòôõö]");
|
||||||
|
PATTERNS[4] = Pattern.compile("[úùûü]");
|
||||||
|
PATTERNS[5] = Pattern.compile("[ç]");
|
||||||
|
PATTERNS[6] = Pattern.compile("[ÂÃÁÀÄ]");
|
||||||
|
PATTERNS[7] = Pattern.compile("[ÉÈÊË]");
|
||||||
|
PATTERNS[8] = Pattern.compile("[ÍÌÎÏ]");
|
||||||
|
PATTERNS[9] = Pattern.compile("[ÓÒÔÕÖ]");
|
||||||
|
PATTERNS[10] = Pattern.compile("[ÚÙÛÜ]");
|
||||||
|
PATTERNS[11] = Pattern.compile("[Ç]");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String replaceAcento(String text) {
|
||||||
|
if (PATTERNS == null) {
|
||||||
|
compilePatterns();
|
||||||
|
}
|
||||||
|
|
||||||
|
String result = text;
|
||||||
|
for (int i = 0; i < PATTERNS.length; i++) {
|
||||||
|
Matcher matcher = PATTERNS[i].matcher(result);
|
||||||
|
result = matcher.replaceAll(REPLACES[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String retornaSomenteNumeros(String str) {
|
||||||
|
if (str != null) {
|
||||||
|
return str.replaceAll("[^0123456789]", "");
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String removeStringEsquerda(String str, String strRemover) {
|
||||||
|
if (str != null) {
|
||||||
|
str = StringUtils.stripStart(str, strRemover);
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherStringEspacoDireita(String str, int tamanho) {
|
||||||
|
return preencherStringDireita(str, tamanho, StringUtils.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherStringEspacoEsquerda(String str, int tamanho) {
|
||||||
|
return preencherStringEsquerda(str, tamanho, StringUtils.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherZeroDireita(String str, int tamanho) {
|
||||||
|
return preencherStringDireita(str, tamanho, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherZeroEsquerda(String str, int tamanho) {
|
||||||
|
return preencherStringEsquerda(str, tamanho, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherStringDireita(String str, int tamanho, String preenchimento) {
|
||||||
|
if (str != null) {
|
||||||
|
if (str.length() > tamanho) {
|
||||||
|
str = str.substring(0, tamanho);
|
||||||
|
} else {
|
||||||
|
str = StringUtils.rightPad(str, tamanho, preenchimento);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return StringUtils.rightPad(StringUtils.EMPTY, tamanho, preenchimento);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherStringEsquerda(String str, int tamanho, String preenchimento) {
|
||||||
|
if (str != null) {
|
||||||
|
if (str.length() > tamanho) {
|
||||||
|
str = str.substring(0, tamanho);
|
||||||
|
} else {
|
||||||
|
str = StringUtils.leftPad(str, tamanho, preenchimento);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return StringUtils.leftPad(StringUtils.EMPTY, tamanho, preenchimento);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherPipeDireita(String str, int tamanho) {
|
||||||
|
if (str != null && !StringUtils.isEmpty(str)) {
|
||||||
|
if (str.length() > tamanho) {
|
||||||
|
str = str.substring(0, tamanho);
|
||||||
|
}
|
||||||
|
str = StringUtils.rightPad(str, str.length() + 1, "|");
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return "|";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String preencherPipeDireita(String str) {
|
||||||
|
if (str != null && !StringUtils.isEmpty(str)) {
|
||||||
|
str = StringUtils.rightPad(str, str.length() + 1, "|");
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return "|";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String divideEFormata(String str, int divisor) {
|
||||||
|
|
||||||
|
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
||||||
|
symbols.setDecimalSeparator(',');
|
||||||
|
DecimalFormat formatador = new DecimalFormat("0.00", symbols);
|
||||||
|
|
||||||
|
String valor = "0";
|
||||||
|
|
||||||
|
if (str != null) {
|
||||||
|
valor = new BigDecimal(str).divide(new BigDecimal(100)).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatador.format(new BigDecimal(valor));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean isNumeric(String str) {
|
||||||
|
return StringUtils.isNumeric(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -54,28 +54,24 @@ public class UtileriasFiscal {
|
||||||
|
|
||||||
return retorno;
|
return retorno;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// public static String formataDecimal(final String valor) {
|
public static String formataZeroDecimal(final BigDecimal valor, final int tamanho) {
|
||||||
// String retorno = valor;
|
|
||||||
//
|
String valorFommat = valor == null ? "" : valor.toString();
|
||||||
// if (retorno.contains(".") || retorno.contains(",")) {
|
valorFommat = valorFommat.toString().replace(".", "").replace(",", "");
|
||||||
// String[] v = {};
|
valorFommat = formataNumerico(valorFommat, valorFommat.length());
|
||||||
//
|
valorFommat = StringUtils.leftPad(valorFommat, (tamanho), "0");
|
||||||
// if (retorno.contains(".")) {
|
return valorFommat;
|
||||||
// v = valor.split("\\.");
|
}
|
||||||
// } else if (retorno.contains(",")) {
|
|
||||||
// v = valor.split(",");
|
public static String formataEspacosDecimal(final BigDecimal valor, final int tamanho) {
|
||||||
// }
|
|
||||||
//
|
String valorFommat = valor == null ? "" : valor.toString();
|
||||||
// if (v[1].length() < 2) {
|
valorFommat = valorFommat.toString().replace(".", "").replace(",", "");
|
||||||
// retorno = retorno + StringUtils.repeat("0", 2 - v[1].length());
|
valorFommat = UtileriasFiscal.formataNumerico(valorFommat, valorFommat.length());
|
||||||
// }
|
valorFommat = StringUtils.leftPad(valorFommat, (tamanho), " ");
|
||||||
// } else {
|
return valorFommat;
|
||||||
// retorno = retorno + "00";
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return retorno;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static BigDecimal arredondar(BigDecimal aNumber) {
|
public static BigDecimal arredondar(BigDecimal aNumber) {
|
||||||
return aNumber.setScale(DECIMALS, ROUNDING_MODE);
|
return aNumber.setScale(DECIMALS, ROUNDING_MODE);
|
||||||
|
|
|
@ -0,0 +1,235 @@
|
||||||
|
package com.rjconsultores.ventaboletos.vo.impressaofiscal;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ImportacionManualFiscalVO {
|
||||||
|
|
||||||
|
private String numImpressora;
|
||||||
|
private String coo;
|
||||||
|
private Long boletoId;
|
||||||
|
private Integer empresaId;
|
||||||
|
private String empresa;
|
||||||
|
private String dataEmissao;
|
||||||
|
private BigDecimal valorTotal;
|
||||||
|
private Integer origenId;
|
||||||
|
private String repTributado;
|
||||||
|
private BigDecimal valorItem;
|
||||||
|
private String tipoPassagem;
|
||||||
|
private String numItem;
|
||||||
|
private String codProduto;
|
||||||
|
private String serie;
|
||||||
|
private BigDecimal icms;
|
||||||
|
private BigDecimal porctributo;
|
||||||
|
private Integer estadoIdOrigen;
|
||||||
|
private Integer estadoIdDestino;
|
||||||
|
private BigDecimal importetaxaembarque;
|
||||||
|
private BigDecimal importepedagio;
|
||||||
|
private BigDecimal importeoutros;
|
||||||
|
private BigDecimal importeseguro;
|
||||||
|
private String subSerie;
|
||||||
|
private String aidf;
|
||||||
|
|
||||||
|
List<BigDecimal> itens;
|
||||||
|
|
||||||
|
public String getNumImpressora() {
|
||||||
|
return numImpressora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumImpressora(String numImpressora) {
|
||||||
|
this.numImpressora = numImpressora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCoo() {
|
||||||
|
return coo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoo(String coo) {
|
||||||
|
this.coo = coo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getBoletoId() {
|
||||||
|
return boletoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoletoId(Long boletoId) {
|
||||||
|
this.boletoId = boletoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getEmpresaId() {
|
||||||
|
return empresaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresaId(Integer empresaId) {
|
||||||
|
this.empresaId = empresaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmpresa() {
|
||||||
|
return empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresa(String empresa) {
|
||||||
|
this.empresa = empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataEmissao() {
|
||||||
|
return dataEmissao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataEmissao(String dataEmissao) {
|
||||||
|
this.dataEmissao = dataEmissao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getValorTotal() {
|
||||||
|
return valorTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValorTotal(BigDecimal valorTotal) {
|
||||||
|
this.valorTotal = valorTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrigenId() {
|
||||||
|
return origenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigenId(Integer origenId) {
|
||||||
|
this.origenId = origenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRepTributado() {
|
||||||
|
return repTributado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepTributado(String repTributado) {
|
||||||
|
this.repTributado = repTributado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getValorItem() {
|
||||||
|
return valorItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValorItem(BigDecimal valorItem) {
|
||||||
|
this.valorItem = valorItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTipoPassagem() {
|
||||||
|
return tipoPassagem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTipoPassagem(String tipoPassagem) {
|
||||||
|
this.tipoPassagem = tipoPassagem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumItem() {
|
||||||
|
return numItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumItem(String numItem) {
|
||||||
|
this.numItem = numItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodProduto() {
|
||||||
|
return codProduto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodProduto(String codProduto) {
|
||||||
|
this.codProduto = codProduto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSerie() {
|
||||||
|
return serie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSerie(String serie) {
|
||||||
|
this.serie = serie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getIcms() {
|
||||||
|
return icms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcms(BigDecimal icms) {
|
||||||
|
this.icms = icms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPorctributo() {
|
||||||
|
return porctributo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPorctributo(BigDecimal porctributo) {
|
||||||
|
this.porctributo = porctributo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getImportetaxaembarque() {
|
||||||
|
return importetaxaembarque;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImportetaxaembarque(BigDecimal importetaxaembarque) {
|
||||||
|
this.importetaxaembarque = importetaxaembarque;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getImportepedagio() {
|
||||||
|
return importepedagio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImportepedagio(BigDecimal importepedagio) {
|
||||||
|
this.importepedagio = importepedagio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getImporteoutros() {
|
||||||
|
return importeoutros;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImporteoutros(BigDecimal importeoutros) {
|
||||||
|
this.importeoutros = importeoutros;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getImporteseguro() {
|
||||||
|
return importeseguro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImporteseguro(BigDecimal importeseguro) {
|
||||||
|
this.importeseguro = importeseguro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BigDecimal> getItens() {
|
||||||
|
return itens;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItens(List<BigDecimal> itens) {
|
||||||
|
this.itens = itens;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getEstadoIdOrigen() {
|
||||||
|
return estadoIdOrigen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstadoIdOrigen(Integer estadoIdOrigen) {
|
||||||
|
this.estadoIdOrigen = estadoIdOrigen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getEstadoIdDestino() {
|
||||||
|
return estadoIdDestino;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstadoIdDestino(Integer estadoIdDestino) {
|
||||||
|
this.estadoIdDestino = estadoIdDestino;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubSerie() {
|
||||||
|
return subSerie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubSerie(String subSerie) {
|
||||||
|
this.subSerie = subSerie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAidf() {
|
||||||
|
return aidf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAidf(String aidf) {
|
||||||
|
this.aidf = aidf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue