diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java index 0b1e19606..707500c3c 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java @@ -329,13 +329,15 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" b.importeseguro as importeseguro, "); sql.append(" 'C' as status, "); 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(" FROM fiscal_r4 r4 "); 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(" INNER JOIN fiscal_impressora fi ON fi.numserie20 = r4.numserie20 "); sql.append(" AND fi.fiscalimpressora_id = r5.fiscalimpressora_id "); sql.append(" INNER JOIN boleto b ON b.boleto_id = r4.boleto_id "); + sql.append(" INNER JOIN clase_servicio cs ON cs.claseservicio_id = b.claseservicio_id "); sql.append(" LEFT JOIN evento_extra ee on ee.boleto_id = b.boleto_id and ee.tipoeventoextra_id in (42) "); sql.append(" LEFT JOIN alias_servico ase ON ase.origen_id = b.origen_id "); sql.append(" and ase.destino_id = b.destino_id and ase.ruta_id = b.ruta_id and ase.activo = 1 and ase.corrida_id is null "); @@ -374,7 +376,8 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" b.preciopagado, "); sql.append(" b.importetaxaembarque, "); sql.append(" b.importepedagio, "); - sql.append(" b.importeseguro "); + sql.append(" b.importeseguro, "); + sql.append(" cs.descclase "); sql.append(" ORDER BY r4.datainicialemissao, "); sql.append(" r4.numserie20, "); sql.append(" r4.coo, "); @@ -410,6 +413,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" b.importetaxaembarque as importetaxaembarque, "); sql.append(" b.importepedagio as importepedagio, "); sql.append(" b.importeseguro as importeseguro, "); + sql.append(" cs.descclase as claseServicio, "); sql.append(" 'N' as status "); sql.append(" FROM fiscal_r4 r4 "); sql.append(" INNER JOIN fiscal_r5 r5 ON r4.numserie20 = r5.numserie20 AND r4.coo = r5.coo "); @@ -417,6 +421,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" INNER JOIN fiscal_impressora fi ON fi.numserie20 = r4.numserie20 "); sql.append(" AND fi.fiscalimpressora_id = r5.fiscalimpressora_id "); sql.append(" INNER JOIN boleto b ON b.boleto_id = r4.boleto_id "); + sql.append(" INNER JOIN clase_servicio cs ON cs.claseservicio_id = b.claseservicio_id "); sql.append(" LEFT JOIN alias_servico ase ON ase.origen_id = b.origen_id "); sql.append(" and ase.destino_id = b.destino_id and ase.ruta_id = b.ruta_id and ase.activo = 1 and ase.corrida_id is null "); sql.append(" INNER JOIN parada o ON coalesce(ase.aliasorigen_id, b.origen_id) = o.parada_id "); @@ -451,7 +456,8 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" b.preciopagado, "); sql.append(" b.importetaxaembarque, "); sql.append(" b.importepedagio, "); - sql.append(" b.importeseguro "); + sql.append(" b.importeseguro, "); + sql.append(" cs.descclase "); sql.append(" ORDER BY r4.datainicialemissao, "); sql.append(" r4.numserie20, "); sql.append(" r4.coo, "); @@ -499,6 +505,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl item.setModeloImpressora(rset.getString("modeloImpressora")); item.setNumCaixa(rset.getString("numCaixa")); item.setStatus(rset.getString("status")); + item.setClaseServicio(rset.getString("claseServicio")); if (isCancelados) { item.setMotivocancelacion(rset.getInt("motivocancelacion")); diff --git a/src/com/rjconsultores/ventaboletos/service/FiscalService.java b/src/com/rjconsultores/ventaboletos/service/FiscalService.java index 9cebbbfc2..1f7c5dec0 100644 --- a/src/com/rjconsultores/ventaboletos/service/FiscalService.java +++ b/src/com/rjconsultores/ventaboletos/service/FiscalService.java @@ -20,5 +20,15 @@ public interface FiscalService { public File importacionNaoFiscal(Date inicio, Date fim, Empresa empresa); public File importacionFiscalECFCancelados(Date inicio, Date fim, Empresa empresa); + + public File importacionFiscalECFXls(Empresa empresa, File arquivoTxt); + + public File importacionFiscalReducaoZXls(Empresa empresa, File arquivoTxt); + + public File importacionFiscalECFManualXls(Empresa empresa, File arquivoTxt); + + public File importacionNaoFiscalXls(Empresa empresa, File arquivoTxt); + + public File importacionFiscalECFCanceladosXls(Empresa empresa, File arquivoTxt); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java index 3bd203898..9800408d8 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java @@ -1,20 +1,28 @@ package com.rjconsultores.ventaboletos.service.impl; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.io.FileReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.SQLException; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -24,9 +32,10 @@ import com.rjconsultores.ventaboletos.dao.FiscalDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida; import com.rjconsultores.ventaboletos.service.FiscalService; +import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil; import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.utilerias.LocaleUtil; import com.rjconsultores.ventaboletos.utilerias.StringHelper; -import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UtileriasFiscal; import com.rjconsultores.ventaboletos.utilerias.archivointegracion.ArchivoIntegracionNaoFiscal; import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO; @@ -34,6 +43,7 @@ import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalVO; import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionManualFiscalVO; import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionNaoFiscalVO; import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO; +import com.rjconsultores.ventaboletos.vo.impressaofiscal.LeitorFiscalVO; import com.rjconsultores.ventaboletos.vo.impressaofiscal.SiglaMotivoCancelacion; import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria; import com.rjconsultores.ventaboletos.vo.impressaofiscal.SubItens; @@ -59,8 +69,8 @@ public class FiscalServiceImpl implements FiscalService { 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"); + String nomeArquivo = "fiscal_ecf_manual_" + DateUtil.getStringDate(Calendar.getInstance().getTime(), "yyyyMMddhhmmss"); + File arquivo = File.createTempFile(nomeArquivo, ".txt"); PrintWriter gravarArq = new PrintWriter(new OutputStreamWriter(new FileOutputStream(arquivo), Constantes.UTF_8)); @@ -134,6 +144,7 @@ public class FiscalServiceImpl implements FiscalService { String subSerie = StringHelper.preencherStringEspacoEsquerda(imf.getSubSerie(), 2); String aidf = StringHelper.preencherStringEspacoEsquerda(imf.getAidf(), 30); String status = StringHelper.preencherStringEspacoEsquerda(imf.getStatus(), 1); + String claseServicio = StringHelper.preencherStringEspacoDireita(imf.getClaseServicio(), 30); String brancos170 = StringHelper.preencherStringEspacoEsquerda(null, 170); seq++; @@ -143,7 +154,7 @@ public class FiscalServiceImpl implements FiscalService { filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, baseCalICMS, valorTotalICMS, valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origenUf, origen, destinoUf, destino, subSerie, - aidf, status, null, null, brancos170, sequencial); + aidf, status, null, null, brancos170, claseServicio, sequencial); gravarArq.print(header + QUEBRA_LINHA); for (String itemDoc : montarItensFiscaisManual(imf, imf.getSubItens(), seq)) { @@ -296,8 +307,8 @@ public class FiscalServiceImpl implements FiscalService { public File importacionFiscalReducaoZ(Date inicio, Date fim, Empresa empresa) { try { - String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() + "_" + "fiscal"; - File arquivo = File.createTempFile(nomeArquivo, ".tmp"); + String nomeArquivo = "fiscal_reducao_z_" + DateUtil.getStringDate(Calendar.getInstance().getTime(), "yyyyMMddhhmmss"); + File arquivo = File.createTempFile(nomeArquivo, ".txt"); PrintWriter gravarArq = new PrintWriter(new OutputStreamWriter(new FileOutputStream(arquivo), Constantes.UTF_8)); @@ -432,8 +443,8 @@ public class FiscalServiceImpl implements FiscalService { private File importacionFiscalECFGenerico(Date inicio, Date fim, Empresa empresa, boolean isCancelados) { try { - String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() + "_" + "fiscal"; - File arquivo = File.createTempFile(nomeArquivo, ".tmp"); + String nomeArquivo = "fiscal_ecf_" + DateUtil.getStringDate(Calendar.getInstance().getTime(), "yyyyMMddhhmmss"); + File arquivo = File.createTempFile(nomeArquivo, ".txt"); PrintWriter gravarArq = new PrintWriter(new OutputStreamWriter(new FileOutputStream(arquivo), Constantes.UTF_8)); @@ -523,12 +534,13 @@ public class FiscalServiceImpl implements FiscalService { seq++; String status = StringHelper.preencherStringEspacoEsquerda(item.getStatus(), 1); + String claseServicio = StringHelper.preencherStringEspacoDireita(item.getClaseServicio(), 30); String seqHeader = StringHelper.preencherZeroEsquerda(Integer.valueOf(seq).toString(), 6); header = headerDocumentoFiscal("1", data, cnpjFilial, coo, serie, especie, codigoCliente, filialCliente, condicaoPagamento, valorTotalDocumanto, valorItens, aliquota, imposto, valorPIS, valorCofins, valorCSLL, totalICMSIsento, totalICMSNaotributado, origenUf, origen, - destinoUf, destino, null, null, status, motivocancelacion, valorMulta, brancos, seqHeader); + destinoUf, destino, null, null, status, motivocancelacion, valorMulta, brancos, claseServicio, seqHeader); /* * Item da importacion Fiscal ECF @@ -884,7 +896,7 @@ public class FiscalServiceImpl implements FiscalService { String valorTotalDocumanto, String valorItens, String aliquota, String imposto, String valorPIS, String valorCofins, String valorCSLL, String totalICMSIsento, String totalICMSNaotributado, String origenUf, String origen, String destinoUf, String destino, String subSerie, String aidf, String status, - String motivocancelacion, String valorMulta, String brancos, String sequencial) { + String motivocancelacion, String valorMulta, String brancos, String claseServicio, String sequencial) { StringBuilder header = new StringBuilder(); header.append(identificador); @@ -915,6 +927,7 @@ public class FiscalServiceImpl implements FiscalService { header.append(motivocancelacion == null ? "" : motivocancelacion); header.append(valorMulta == null ? "" : valorMulta); header.append(brancos); + header.replace(226, 256, claseServicio); header.append(sequencial); return header.toString(); @@ -987,4 +1000,155 @@ public class FiscalServiceImpl implements FiscalService { return null; } + @Override + public File importacionFiscalECFXls(Empresa empresa, File arquivoTxt) { + return gerarArquivoEcfXlsGenerico(empresa, arquivoTxt); + } + + @Override + public File importacionFiscalReducaoZXls(Empresa empresa, File arquivoTxt) { + return null; + } + + @Override + public File importacionFiscalECFManualXls(Empresa empresa, File arquivoTxt) { + return null; + } + + @Override + public File importacionNaoFiscalXls(Empresa empresa, File arquivoTxt) { + return null; + } + + @Override + public File importacionFiscalECFCanceladosXls(Empresa empresa, File arquivoTxt) { + return gerarArquivoEcfXlsGenerico(empresa, arquivoTxt); + } + + private File gerarArquivoEcfXlsGenerico(Empresa empresa, File arquivoTxt) { + try { + List registros = carregarRegistros(empresa, arquivoTxt); + return gerarArquivoEcfXls(registros, arquivoTxt.getName()); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + return null; + } + + private File gerarArquivoEcfXls(List registros, String nomeArquivo) throws IOException { + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet firstSheet = workbook.createSheet(); + + int linha = 0; + + // Cabecalho + HSSFRow row = firstSheet.createRow(linha++); + row.createCell(0).setCellValue("DATA_EMISSAO"); + row.createCell(1).setCellValue("EMPRESA"); + row.createCell(2).setCellValue("UF_ORIGEM"); + row.createCell(3).setCellValue("UF_DESTINO"); + row.createCell(4).setCellValue("CLASSE"); + row.createCell(5).setCellValue("TARIFA"); + row.createCell(6).setCellValue("TX_EMBARQUE"); + row.createCell(7).setCellValue("PEDAGIO"); + row.createCell(8).setCellValue("SEGURO"); + row.createCell(9).setCellValue("MULTA"); + row.createCell(10).setCellValue("TOTAL"); + row.createCell(11).setCellValue("ALIQUOTA_ICMS"); + row.createCell(12).setCellValue("VALOR_ICMS"); + row.createCell(13).setCellValue("QTDE"); + + for (LeitorFiscalVO leitorFiscal : registros) { + row = firstSheet.createRow(linha++); + row.createCell(0).setCellValue(leitorFiscal.getDataEmissao()); + row.createCell(1).setCellValue(leitorFiscal.getNombempresa()); + row.createCell(2).setCellValue(leitorFiscal.getOrigenUf()); + row.createCell(3).setCellValue(leitorFiscal.getDestinoUf()); + row.createCell(4).setCellValue(leitorFiscal.getClaseServicio()); + row.createCell(5).setCellValue(leitorFiscal.getValorTarifa().doubleValue()); + row.createCell(6).setCellValue(leitorFiscal.getValorEmbarque().doubleValue()); + row.createCell(7).setCellValue(leitorFiscal.getValorPedagio().doubleValue()); + row.createCell(8).setCellValue(leitorFiscal.getValorSeguro().doubleValue()); + row.createCell(9).setCellValue(leitorFiscal.getValorMulta().doubleValue()); + row.createCell(10).setCellValue(leitorFiscal.getTotal().doubleValue()); + row.createCell(11).setCellValue(leitorFiscal.getAliquota().doubleValue()); + row.createCell(12).setCellValue(leitorFiscal.getValorTarifa().multiply(leitorFiscal.getAliquota().divide(CEM)).setScale(2, RoundingMode.HALF_UP).doubleValue()); + row.createCell(13).setCellValue(leitorFiscal.getQtdeItens()); + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + workbook.write(bos); + + nomeArquivo = "consolidado_" + nomeArquivo.split("\\.")[0]; + File arquivo = File.createTempFile(nomeArquivo, ".xls"); + + FileOutputStream fos = new FileOutputStream(arquivo); + fos.write(bos.toByteArray()); + fos.close(); + + return arquivo; + + } + + private List carregarRegistros(Empresa empresa, File arquivoTxt) throws Exception { + List registros = new ArrayList(); + BufferedReader br = new BufferedReader(new FileReader(arquivoTxt)); + String linha = br.readLine(); + while (linha != null) { + LeitorFiscalVO leitorFiscal = null; + int indice = -1; + if (linha.startsWith("1")) { + leitorFiscal = new LeitorFiscalVO(); + leitorFiscal.setEmpresaId(empresa.getEmpresaId()); + leitorFiscal.setNombempresa(empresa.getNombempresa()); + leitorFiscal.setDataEmissao(linha.substring(1, 9).trim()); + leitorFiscal.setOrigenUf(linha.substring(177, 179).trim()); + leitorFiscal.setDestinoUf(linha.substring(184, 186).trim()); + leitorFiscal.setClaseServicio(linha.substring(226, 256).trim()); + leitorFiscal.setAliquota(BigDecimalUtil.getStringToBigDecimal(linha.substring(79, 93).trim(), 2, LocaleUtil.getLocale())); + + if(registros.contains(leitorFiscal)) { + indice = registros.indexOf(leitorFiscal); + leitorFiscal = registros.get(indice); + } + + leitorFiscal.setQtdeItens(leitorFiscal.getQtdeItens() + 1); + linha = br.readLine(); + while (linha != null && linha.startsWith("2")) { + if (linha.indexOf("TA") >= 0) { + leitorFiscal.setValorTarifa(leitorFiscal.getValorTarifa().add(BigDecimalUtil.getStringToBigDecimal(linha.substring(47, 62).trim(), 2, LocaleUtil.getLocale()))); + } + + if (linha.indexOf("TX") >= 0) { + leitorFiscal.setValorEmbarque(leitorFiscal.getValorEmbarque().add(BigDecimalUtil.getStringToBigDecimal(linha.substring(47, 62).trim(), 2, LocaleUtil.getLocale()))); + } + + if (linha.indexOf("PE") >= 0) { + leitorFiscal.setValorPedagio(leitorFiscal.getValorPedagio().add(BigDecimalUtil.getStringToBigDecimal(linha.substring(47, 62).trim(), 2, LocaleUtil.getLocale()))); + } + + if (linha.indexOf("SE") >= 0) { + leitorFiscal.setValorSeguro(leitorFiscal.getValorSeguro().add(BigDecimalUtil.getStringToBigDecimal(linha.substring(47, 62).trim(), 2, LocaleUtil.getLocale()))); + } + + linha = br.readLine(); + } + } else { + linha = br.readLine(); + } + + if(leitorFiscal != null && indice > -1) { + registros.set(indice, leitorFiscal); + } else if (leitorFiscal != null) { + registros.add(leitorFiscal); + } + } + + br.close(); + + Collections.sort(registros); + + return registros; + } + } diff --git a/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java b/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java index bc5e81ddf..bbb4335a1 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java @@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.utilerias; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; @@ -36,4 +37,16 @@ public class BigDecimalUtil { return null; } + public static BigDecimal getStringToBigDecimal(String value, int qtdeCasasDecimais, Locale locale) throws ParseException { + if(value != null && StringUtils.isNotBlank(value)) { + DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(locale); + df.setMinimumFractionDigits(qtdeCasasDecimais); + df.setMaximumFractionDigits(qtdeCasasDecimais); + value = value.substring(0, value.length() - qtdeCasasDecimais).concat(df.getDecimalFormatSymbols().getDecimalSeparator()+"").concat(value.substring(value.length() - qtdeCasasDecimais, value.length())); + return new BigDecimal(df.parse(value).toString()); + } + + return null; + } + } diff --git a/src/com/rjconsultores/ventaboletos/utilerias/ZipUtil.java b/src/com/rjconsultores/ventaboletos/utilerias/ZipUtil.java new file mode 100644 index 000000000..f1c9917a5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/utilerias/ZipUtil.java @@ -0,0 +1,32 @@ +package com.rjconsultores.ventaboletos.utilerias; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ZipUtil { + + public static void compactarArquivos(File arquivoDeSaida, File... arquivosEOuPastas) throws IOException{ + if(arquivosEOuPastas != null && arquivoDeSaida != null) { + byte[] buf = new byte[1024]; + ZipOutputStream out = new ZipOutputStream(new FileOutputStream(arquivoDeSaida)); + + for (File f : arquivosEOuPastas) { + FileInputStream in = new FileInputStream(f.getPath()); + out.putNextEntry(new ZipEntry(f.getName())); + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + out.closeEntry(); + in.close(); + f.delete(); + } + out.close(); + } + } + +} diff --git a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionFiscalVO.java b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionFiscalVO.java index b73866308..5bbf4c005 100644 --- a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionFiscalVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionFiscalVO.java @@ -21,6 +21,7 @@ public class ImportacionFiscalVO { private String modeloImpressora; private String numCaixa; private String status; + private String claseServicio; private Integer motivocancelacion; private BigDecimal valorMulta; private BigDecimal valorTarifa; @@ -34,7 +35,7 @@ public class ImportacionFiscalVO { super(); } - public ImportacionFiscalVO(String numImpressora, String coo, Long boletoId, Integer empresaId, String dataEmissao, String cnpjCliente, String cnpjImpressora, Integer origenId, String origenUf, Integer destinoId, String destinoUf, String numpdv, String modeloImpressora, String numCaixa, String status, Integer motivocancelacion, BigDecimal valorMulta, BigDecimal valorTarifa, BigDecimal valorPedagio, BigDecimal valorEmbarque, BigDecimal valorSeguro) { + public ImportacionFiscalVO(String numImpressora, String coo, Long boletoId, Integer empresaId, String dataEmissao, String cnpjCliente, String cnpjImpressora, Integer origenId, String origenUf, Integer destinoId, String destinoUf, String numpdv, String modeloImpressora, String numCaixa, String status, Integer motivocancelacion, BigDecimal valorMulta, BigDecimal valorTarifa, BigDecimal valorPedagio, BigDecimal valorEmbarque, BigDecimal valorSeguro, String claseServicio) { super(); this.numImpressora = numImpressora; this.coo = coo; @@ -51,6 +52,7 @@ public class ImportacionFiscalVO { this.modeloImpressora = modeloImpressora; this.numCaixa = numCaixa; this.status = status; + this.claseServicio = claseServicio; this.motivocancelacion = motivocancelacion; this.valorMulta = valorMulta; this.valorTarifa = valorTarifa; @@ -275,4 +277,12 @@ public class ImportacionFiscalVO { this.valorSeguro = valorSeguro; } + public String getClaseServicio() { + return claseServicio; + } + + public void setClaseServicio(String claseServicio) { + this.claseServicio = claseServicio; + } + } diff --git a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionManualFiscalVO.java b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionManualFiscalVO.java index 3506048f2..ca518d80b 100644 --- a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionManualFiscalVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ImportacionManualFiscalVO.java @@ -36,6 +36,7 @@ public class ImportacionManualFiscalVO { private String modeloImpressora; private String numCaixa; private String status; + private String claseServicio; List subItens; @@ -295,4 +296,12 @@ public class ImportacionManualFiscalVO { this.status = status; } + public String getClaseServicio() { + return claseServicio; + } + + public void setClaseServicio(String claseServicio) { + this.claseServicio = claseServicio; + } + } diff --git a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ItemFiscalVO.java b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ItemFiscalVO.java index 12a423e62..0c19c704a 100644 --- a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ItemFiscalVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/ItemFiscalVO.java @@ -19,7 +19,7 @@ public class ItemFiscalVO extends ImportacionFiscalVO { item.getCnpjCliente(), item.getCnpjImpressora(), item.getOrigenId(), item.getOrigenUf(), item.getDestinoId(), item.getDestinoUf(), item.getNumpdv(), item.getModeloImpressora(), item.getNumCaixa(), item.getStatus(), item.getMotivocancelacion(), item.getValorMulta(), item.getValorTarifa(), item.getValorPedagio(), - item.getValorEmbarque(), item.getValorSeguro()); + item.getValorEmbarque(), item.getValorSeguro(), item.getClaseServicio()); } public String getNumItem() { diff --git a/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/LeitorFiscalVO.java b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/LeitorFiscalVO.java new file mode 100644 index 000000000..9a75fb9f6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/vo/impressaofiscal/LeitorFiscalVO.java @@ -0,0 +1,126 @@ +package com.rjconsultores.ventaboletos.vo.impressaofiscal; + +import java.math.BigDecimal; + +public class LeitorFiscalVO extends ImportacionFiscalVO implements Comparable { + + private String nombempresa; + private Integer qtdeItens; + private BigDecimal aliquota; + + public LeitorFiscalVO() { + super(); + qtdeItens = 0; + setValorEmbarque(BigDecimal.ZERO); + setValorMulta(BigDecimal.ZERO); + setValorPedagio(BigDecimal.ZERO); + setValorSeguro(BigDecimal.ZERO); + setValorTarifa(BigDecimal.ZERO); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getDataEmissao() == null) ? 0 : getDataEmissao().hashCode()); + result = prime * result + ((getEmpresaId() == null) ? 0 : getEmpresaId().hashCode()); + result = prime * result + ((getOrigenUf() == null) ? 0 : getOrigenUf().hashCode()); + result = prime * result + ((getDestinoUf() == null) ? 0 : getDestinoUf().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof LeitorFiscalVO)) + return false; + LeitorFiscalVO other = (LeitorFiscalVO) obj; + if (getDataEmissao() == null) { + if (other.getDataEmissao() != null) + return false; + } else if (!getDataEmissao().equals(other.getDataEmissao())) + return false; + if (getEmpresaId() == null) { + if (other.getEmpresaId() != null) + return false; + } else if (!getEmpresaId().equals(other.getEmpresaId())) + return false; + if (getOrigenUf() == null) { + if (other.getOrigenUf() != null) + return false; + } else if (!getOrigenUf().equals(other.getOrigenUf())) + return false; + if (getDestinoUf() == null) { + if (other.getDestinoUf() != null) + return false; + } else if (!getDestinoUf().equals(other.getDestinoUf())) + return false; + if (getClaseServicio() == null) { + if (other.getClaseServicio() != null) + return false; + } else if (!getClaseServicio().equals(other.getClaseServicio())) + return false; + if (getAliquota() == null) { + if (other.getAliquota() != null) + return false; + } else if (!getAliquota().equals(other.getAliquota())) + return false; + return true; + } + + public String getNombempresa() { + return nombempresa; + } + + public void setNombempresa(String nombempresa) { + this.nombempresa = nombempresa; + } + + public Integer getQtdeItens() { + return qtdeItens; + } + + public void setQtdeItens(Integer qtdeItens) { + this.qtdeItens = qtdeItens; + } + + public BigDecimal getAliquota() { + return aliquota; + } + + public void setAliquota(BigDecimal aliquota) { + this.aliquota = aliquota; + } + + public BigDecimal getTotal() { + BigDecimal total = BigDecimal.ZERO; + total = total.add(getValorEmbarque()) + .add(getValorMulta()) + .add(getValorPedagio()) + .add(getValorTarifa()) + .add(getValorSeguro()); + return total; + } + + @Override + public int compareTo(LeitorFiscalVO o) { + int retorno = getDataEmissao().compareTo(o.getDataEmissao()); + if(retorno == 0) { + retorno = getNombempresa().compareTo(o.getNombempresa()); + } + if(retorno == 0) { + retorno = getOrigenUf().compareTo(o.getOrigenUf()); + } + if(retorno == 0) { + retorno = getDestinoUf().compareTo(o.getDestinoUf()); + } + if(retorno == 0) { + retorno = getClaseServicio().compareTo(o.getClaseServicio()); + } + return retorno; + } + +}