diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java index 56377ab42..d2e151c0a 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java @@ -75,7 +75,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" end as importeoutros, "); sql.append(" case b.importeseguro when 0 then null else b.importeseguro "); sql.append(" end as importeseguro, "); - sql.append(" case when b.motivocancelacion_id is null then 'N' else 'C' end status "); + sql.append(" case when b.indstatusboleto = 'V' or b.motivocancelacion_id is null THEN 'N' ELSE 'C' END status "); sql.append("from boleto b "); sql.append(" left join fiscal_r4 r4 on b.boleto_id = r4.boleto_id "); sql.append(" left outer join fiscal_r5 r5 on r4.numserie20 = r5.numserie20 "); @@ -129,7 +129,8 @@ public class FiscalHibernateDAO extends GenericHibernateDAO impl sql.append(" r4.usuario_id, "); sql.append(" eo.cveestado, "); sql.append(" ed.cveestado, "); - sql.append(" b.motivocancelacion_id "); + sql.append(" b.motivocancelacion_id, "); + sql.append(" b.indstatusboleto "); List listManuais = new ArrayList(); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java index 8d1875661..a4dcc037e 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java @@ -533,7 +533,7 @@ public class FiscalServiceImpl implements FiscalService { String coo = StringHelper.preencherStringEspacoDireita(fiscal.getCoo(), 9); - BigDecimal valorTotal = fiscal.getValorTotal() == null ? BigDecimal.ZERO : fiscal.getValorTotal(); + BigDecimal valorTotal = valorTotalItensECF(item); String valorTotalDocumanto = StringHelper.preencherStringEspacoDireita(valorTotal.toString(), 14); String valorItens = StringHelper.preencherStringEspacoDireita(valorTotal.toString(), 14); @@ -614,6 +614,17 @@ public class FiscalServiceImpl implements FiscalService { return null; } + private BigDecimal valorTotalItensECF(ItemFiscalVO item) { + BigDecimal valorTotal = item.getValorTotal() == null ? BigDecimal.ZERO : item.getValorTotal(); + if (valorTotal.equals(BigDecimal.ZERO)) { + BigDecimal valorTarifa = item.getValorTarifa() == null ? BigDecimal.ZERO : item.getValorTarifa(); + BigDecimal valorPedagio = item.getValorPedagio() == null ? BigDecimal.ZERO : item.getValorPedagio(); + BigDecimal valorEmbarque = item.getValorEmbarque() == null ? BigDecimal.ZERO : item.getValorEmbarque(); + valorTotal = valorTotal.add(valorTarifa).add(valorPedagio).add(valorEmbarque); + } + return valorTotal; + } + private void grabarHeaderItens(PrintWriter gravarArq, String header, List itensDocs) { gravarArq.print(header + QUEBRA_LINHA);