atualização de fonte

master
Fabio Faria 2022-08-23 18:49:16 -03:00
parent fcabf5d108
commit ae4f0d486f
3 changed files with 97 additions and 25 deletions

View File

@ -125,7 +125,7 @@ public class BGMApplication {
File file = new File(fileName);
log.debug("gerando arquivo...");
Arquivo.GravaArquivo(file.getAbsolutePath(), totalbus.getDespesasReceitas(puntoVentaId, empresaId, cal.getTime(), incluiTipoPagamentoTurismoBGM));
Arquivo.GravaArquivo(file.getAbsolutePath(), totalbus.getDespesasReceitas(puntoVentaId, empresaId, cal.getTime(), incluiTipoPagamentoTurismoBGM, layoutNovo));
this.copiarArquivoExternamente(file, pathGravacaoExternaArquivos);

View File

@ -68,11 +68,11 @@ public class Totalbus {
loadPuntosVenta();
}
public List<String> getDespesasReceitas(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException{
public List<String> getDespesasReceitas(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM, boolean isLayoutNovo) throws IntegracaoReceitaDespesaException{
log.debug("gerando depósitos...");
List<DespesaReceita> despesasReceitas = getDepositos(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM);
List<DespesaReceita> despesasReceitas = getDepositos(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM, isLayoutNovo);
log.debug("gerando despesas...");
despesasReceitas.addAll(getDespesas(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM));
despesasReceitas.addAll(getDespesas(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM, isLayoutNovo));
log.debug("gerando despesas cartão...");
if (isReceitasDespesasComporte){
@ -81,9 +81,9 @@ public class Totalbus {
despesasReceitas.addAll(getReceitasComporte(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM));
}else {
despesasReceitas.addAll(getDespesaCartaoDebCred(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM));
despesasReceitas.addAll(getDespesaCartaoDebCred(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM, isLayoutNovo));
log.debug("gerando receitas...");
despesasReceitas.addAll(getReceitas(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM));
despesasReceitas.addAll(getReceitas(puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM, isLayoutNovo));
if(isReceitasDespesasOuroPrata) {
getContaCorrenteAgencia(despesasReceitas, puntoventaId, empresaId, fechaParam, incluiTipoPagamentoTurismoBGM);
}
@ -440,7 +440,7 @@ public class Totalbus {
return this.conn;
}
public List<DespesaReceita> getDespesaCartaoDebCred(final Integer puntoVentaId, final Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException{
public List<DespesaReceita> getDespesaCartaoDebCred(final Integer puntoVentaId, final Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM, boolean isLayoutNovo) throws IntegracaoReceitaDespesaException{
List<DespesaReceita> despesas = new ArrayList<DespesaReceita>();
StringBuilder sb = new StringBuilder();
sb.append(" select ");
@ -518,6 +518,13 @@ public class Totalbus {
despesa.setTipoPagamentoTurismo(rs.getString("tipoeventoextra_id"));
}
despesa.setFormaPagamentoId(rs.getString("formapagoId"));
if(isLayoutNovo) {
despesa.setTipoPagamentoTurismo("01");
despesa.setFormaPagamentoId("03");
despesa.setTipoDocumentoVenda("P");
}
despesas.add(despesa);
}
} catch (Exception e) {
@ -645,7 +652,7 @@ public class Totalbus {
}
}
public List<DespesaReceita> getReceitas(final Integer puntoVentaId, final Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException {
public List<DespesaReceita> getReceitas(final Integer puntoVentaId, final Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM, boolean isLayoutNovo) throws IntegracaoReceitaDespesaException {
List<DespesaReceita> despesas = new ArrayList<DespesaReceita>();
StringBuilder sb = new StringBuilder();
sb.append(" select ");
@ -657,13 +664,16 @@ public class Totalbus {
sb.append(" pv.numpuntoventa AS numpuntoventa, ");
sb.append(" ev.descinfo as descinfo, ");
sb.append(" ev.tipoeventoextra_id, ");
sb.append(" COALESCE(cdp.formapago_id,0) as formapagoId ");
sb.append(" COALESCE(cdp.formapago_id,0) as formapagoId, ");
sb.append(" tee.desctipoevento, ");
sb.append(" fp.tipo_pago ");
sb.append(" from ");
sb.append(" caja_diversos cd ");
sb.append(" left join evento_extra ev on ev.eventoextra_id = cd.eventoextra_id ");
sb.append(" left join empresa e on e.empresa_id = ev.empresa_id ");
sb.append(" left join punto_venta pv on pv.puntoventa_id = cd.puntoventa_id ");
sb.append(" left join caja_diversos_pago cdp on cdp.cajadiversos_id = cd.cajadiversos_id ");
sb.append(" left join forma_pago fp on cdp.formapago_id = fp.formapago_id ");
sb.append(" left join tipo_evento_extra tee on tee.tipoeventoextra_id = ev.tipoeventoextra_id ");
sb.append(" left join ptovta_integra pi on e.empresa_id = pi.empresa_id and pi.puntoventa_id = pv.puntoventa_id ");
sb.append(" where ");
@ -676,7 +686,7 @@ public class Totalbus {
sb.append(" e.empresa_id, pv.puntoventa_id, ");
sb.append(" tee.contacontabil, pv.numpuntoventa, ");
sb.append(" ev.descinfo, ev.tipoeventoextra_id, ");
sb.append(" cdp.formapago_id ");
sb.append(" cdp.formapago_id, tee.desctipoevento,fp.tipo_pago ");
PreparedStatement stmt = null;
ResultSet rs = null;
@ -708,13 +718,26 @@ public class Totalbus {
String desc =rs.getString(7);
desc = this.removerQuebraDeLinha(desc);
desc = this.removerQuebraDeLinha(desc);
receita.setDescricaoDetalhada(desc);
if (incluiTipoPagamentoTurismoBGM) {
receita.setTipoPagamentoTurismo(rs.getString("tipoeventoextra_id"));
}
receita.setFormaPagamentoId(rs.getString("formapagoId"));
if(isLayoutNovo) {
if( rs.getString("desctipoevento").matches("EXCESSO.BAGAGEM") ) {
receita.setTipoDocumentoVenda("E");
}else {
receita.setTipoDocumentoVenda("P");
}
receita.setTipoPagamentoTurismo("01");
receita.setFormaPagamentoId( converteFormaPagamentoLayoutNovo(rs.getString("tipo_pago")) );
}
despesas.add(receita);
}
} catch (Exception e) {
@ -734,7 +757,7 @@ public class Totalbus {
}
return despesas;
}
public List<DespesaReceita> getReceitasComporte(final Integer puntoVentaId, final Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException {
List<DespesaReceita> despesas = new ArrayList<DespesaReceita>();
StringBuilder sb = new StringBuilder();
@ -835,19 +858,19 @@ public class Totalbus {
return despesas;
}
public List<DespesaReceita> getDespesas(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException {
public List<DespesaReceita> getDespesas(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM, boolean isLayoutNovo ) throws IntegracaoReceitaDespesaException {
List<DespesaReceita> despesas = new ArrayList<DespesaReceita>();
StringBuilder sb = new StringBuilder();
sb.append(" select ");
sb.append(" cd.feccorte as feccorte, ");
sb.append(" e.empresa_id as empresa_id, ");
sb.append(" e.empresa_id as empresa_id, ");
sb.append(" pv.numpuntoventa as numpuntoventa, ");
sb.append(" cdp.importe as valor, ");
sb.append(" tee.contacontabil as contacontabil, ");
sb.append(" cdp.importe as valor, ");
sb.append(" tee.contacontabil as contacontabil, ");
sb.append(" ev.descinfo as descinfo, ");
sb.append(" ev.tipoeventoextra_id, ");
sb.append(" ev.tipoeventoextra_id, ");
sb.append(" cdp.formapago_id as formapagoId ");
sb.append(" from ");
sb.append(" from ");
sb.append(" caja_diversos cd ");
sb.append(" left join evento_extra ev on ev.eventoextra_id = cd.eventoextra_id ");
sb.append(" left join empresa e on e.empresa_id = ev.empresa_id ");
@ -861,7 +884,7 @@ public class Totalbus {
adicionaFiltroQuery(puntoventaId, sb, " and cd.puntoventa_id = ", puntoventaId != null && !puntoventaId.equals(-1));
adicionaFiltroQuery(empresaId, sb, " and e.empresa_id = ", empresaId != null);
sb.append(" and cd.activo = 1 ");
sb.append(" AND cdp.formapago_id not IN (2,3) ");
sb.append(" and cdp.formapago_id not IN (2,3) ");
sb.append(" and not exists (select ee.EVENTOEXTRA_ID from evento_extra ee where ev.EVENTOEXTRA_ID = ee.EVENTOEXTRACANC_ID) ");
sb.append(" and ev.EVENTOEXTRACANC_ID is null ");
@ -896,6 +919,13 @@ public class Totalbus {
despesa.setTipoPagamentoTurismo(rs.getString("tipoeventoextra_id"));
}
despesa.setFormaPagamentoId(rs.getString("formapagoId"));
if(isLayoutNovo) {
despesa.setTipoPagamentoTurismo("01");
despesa.setFormaPagamentoId("01");
despesa.setTipoDocumentoVenda("P");
}
despesas.add(despesa);
}
} catch (Exception e) {
@ -930,7 +960,7 @@ public class Totalbus {
return desc;
}
public List<DespesaReceita> getDepositos(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException {
public List<DespesaReceita> getDepositos(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM, boolean isLayoutNovo) throws IntegracaoReceitaDespesaException {
List<DespesaReceita> depositos = new ArrayList<DespesaReceita>();
StringBuilder strFechamentos = new StringBuilder();
@ -997,6 +1027,12 @@ public class Totalbus {
deposito.setIdentificadorReceitaDespesa("D");
deposito.setCodigoReceitaDespesa(codRecDesp);
deposito.setDescricaoDetalhada(banco + agencia + contaCorrente + numDep);
if(isLayoutNovo) {
deposito.setTipoPagamentoTurismo("01");
deposito.setFormaPagamentoId("04");
deposito.setTipoDocumentoVenda("P");
}
depositos.add(deposito);
soma = soma.add(rsFechamentos.getBigDecimal(1));
@ -1118,6 +1154,33 @@ public class Totalbus {
cal.add(Calendar.DAY_OF_MONTH, DAYS_AGO);
return cal.getTime();
}
private String converteFormaPagamentoLayoutNovo(String formaPago) {
//lista de tipos: com.rjconsultores.ventaboletos.enums.TipoFormapago
if(formaPago == null) {
return "";
}
Integer converted = new Integer( formaPago);
switch (converted) {
case 0:
return "01";
case 1:
return "03";
case 2:
return "03";
case 3:
return "05";
case 4:
return "05";
case 10:
return "02";
case 11:
return "04";
default:
return "";
}
}
public List<PuntoVenta> getPontosVenda() {
return pontosVenda;
@ -1138,6 +1201,7 @@ public class Totalbus {
public void setIsReceitasDespesasComporte(Boolean isReceitasDespesasComporte) {
this.isReceitasDespesasComporte = isReceitasDespesasComporte;
}
public static void amain(String[] args) {
System.out.println(new BigDecimal("0").signum());
}

View File

@ -24,7 +24,7 @@ public class DespesaReceita {
protected String tipoPagamentoTurismo = " ";// 120 002 Numerico
protected String descricaoDetalhada = "";// 122 80 Alfanumerico
protected final String documentoVenda = "000000";// 202 6 Numerico
protected final String tipoDocumentoVenda = " ";// 208 1 Alfanumerico
protected String tipoDocumentoVenda = " ";// 208 1 Alfanumerico
protected final String numerodocumentoCPG = "0000000000";// 209 10 Numerico
protected String formaPagamentoId = "0";// 218 Numerico
protected final String finalLinha = "*";// 239 1 Alfanumerico
@ -68,7 +68,7 @@ public class DespesaReceita {
sb.append(StringUtils.rightPad(dataLancamento.trim(), 10, " "));
sb.append(StringUtils.leftPad(codigoEmpresa.trim(), 3, "0"));
sb.append(StringUtils.leftPad(codigoFilial.trim(), 3, "0"));
sb.append(StringUtils.rightPad(localArrecadacao.toUpperCase().trim(), 5, " "));
sb.append(StringUtils.rightPad( truncStr(localArrecadacao.toUpperCase(), 5), 5, " "));
sb.append(StringUtils.rightPad(numeroDaGuia.trim(), 25, " "));
sb.append(StringUtils.rightPad(dataMovimento.trim(), 10, " "));
sb.append(StringUtils.rightPad(usuarioGlobus.trim(), 15, " "));
@ -78,12 +78,12 @@ public class DespesaReceita {
sb.append(StringUtils.leftPad(valorLancamento.trim(), 13, "0"));
sb.append(StringUtils.rightPad("", 10, " "));
sb.append(StringUtils.rightPad(numeroReciboTurismo.trim(), 10, " "));
sb.append(StringUtils.leftPad(getFormaPagamentoTurismo().trim(), 2, "0"));
sb.append(StringUtils.leftPad(getFormaPagamentoId().trim(), 2, "0"));
sb.append(StringUtils.leftPad(getTipoPagamentoTurismo().trim(), 2, "0"));
sb.append(StringUtils.rightPad(StringUtils.isNotEmpty(descricaoDetalhada) ? truncStr(descricaoDetalhada, 100) : "", 100, " "));
sb.append(StringUtils.leftPad(documentoVenda.trim(), 6, "0"));
sb.append(StringUtils.rightPad(tipoDocumentoVenda.trim(), 1, " "));
sb.append(StringUtils.rightPad("", 9, "0"));
sb.append(StringUtils.rightPad("", 10, "0"));
sb.append(finalLinha);
sb.append(System.getProperty("line.separator"));
rows.add(sb.toString());
@ -152,4 +152,12 @@ public class DespesaReceita {
return str;
}
public String getTipoDocumentoVenda() {
return tipoDocumentoVenda;
}
public void setTipoDocumentoVenda(String tipoDocumentoVenda) {
this.tipoDocumentoVenda = tipoDocumentoVenda;
}
}