bug #6772
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/Integracion/IntegracaoReceitaDespesa/trunk/IntegracaoReceitaDespesa@49941 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
a579c85543
commit
1cb9d6ae1c
|
@ -1,18 +1,17 @@
|
|||
package com.rjconsultores.integracaoreceitadespesa.dao;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.rjconsultores.integracaoreceitadespesa.Application;
|
||||
import com.rjconsultores.integracaoreceitadespesa.entidades.DespesaReceita;
|
||||
import com.rjconsultores.integracaoreceitadespesa.entidades.Empresa;
|
||||
import com.rjconsultores.integracaoreceitadespesa.entidades.PuntoVenta;
|
||||
|
@ -221,17 +220,24 @@ public class Totalbus {
|
|||
public List<DespesaReceita> getDepositos(Integer puntoventaId, Integer empresaId){
|
||||
List<DespesaReceita> depositos = new ArrayList<DespesaReceita>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Select fc.fecfechamento, fc.empresa_id, fc.puntoventa_id, fd.valor_pago, ");
|
||||
sb.append("(select valorconstante from constante where nombconstante = 'CODIGO_RECEITA_DESPESA_GLOBUS') as codigoReceitaDespesa ");
|
||||
sb.append("from fechamento_cntcorrente fc ");
|
||||
sb.append("inner join fechamento_cct_deposito fd on fd.fechamentocntcorrente_id = fc.fechamentocntcorrente_id ");
|
||||
sb.append("where fc.fecfechamento = :fecha and fd.activo <> 0 and fc.activo <> 0 ");
|
||||
sb.append("select i.instifinanceira_id, i.codigo, fdep.fechamentodeposito_id, fdep.valor, fdep.numdeposito, fdep.fecha_deposito ");
|
||||
sb.append("from fechamento_deposito fdep ");
|
||||
sb.append("inner join insti_financeira i on i.instifinanceira_id = fdep.instifinanceira_id ");
|
||||
sb.append("where fecha_deposito = :fecha and fdep.activo = 1 ");
|
||||
|
||||
|
||||
StringBuilder strFechamentos = new StringBuilder();
|
||||
strFechamentos.append("Select fc.fecfechamento, fc.empresa_id, fc.puntoventa_id, fd.valor_pago, ec.numagencia, ec.numconta ");
|
||||
strFechamentos.append("from fechamento_cct_deposito fd ");
|
||||
strFechamentos.append("inner join fechamento_cntcorrente fc on fc.fechamentocntcorrente_id = fd.fechamentocntcorrente_id ");
|
||||
strFechamentos.append("left join empresa_contabancaria ec on ec.empresa_id = fc.empresa_id and ec.instifinanceira_id = :instifinanceiraId and ec.activo = 1 ");
|
||||
strFechamentos.append("where fd.fechamentodeposito_id = :fechamentodepositoId and fd.activo <> 0 and fc.activo <> 0 ");
|
||||
|
||||
if (puntoventaId != null){
|
||||
sb.append("and fc.puntoventa_id = :puntoventaId ");
|
||||
strFechamentos.append(" and fc.puntoventa_id = " + puntoventaId);
|
||||
}
|
||||
if (empresaId != null){
|
||||
sb.append("and fc.empresa_id = :empresaId ");
|
||||
strFechamentos.append(" and fc.empresa_id = " + empresaId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -242,27 +248,54 @@ public class Totalbus {
|
|||
|
||||
try{
|
||||
pstmt = getConnection().prepareStatement(sb.toString());
|
||||
pstmt.setDate(1, new java.sql.Date(fecha.getTime()));
|
||||
if (puntoventaId != null){
|
||||
pstmt.setInt(2, puntoventaId);
|
||||
}
|
||||
if (empresaId != null){
|
||||
pstmt.setInt(3, empresaId);
|
||||
}
|
||||
pstmt.setDate(1, new java.sql.Date(fecha.getTime()));
|
||||
|
||||
rs = pstmt.executeQuery();
|
||||
Integer codigoReceitaDespesaGlobus = getCodigoReceitaDespesaGlobus();
|
||||
DecimalFormat df = new DecimalFormat("#0.00");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM/yy");
|
||||
|
||||
PreparedStatement pstmtFechamentos = getConnection().prepareStatement(strFechamentos.toString());
|
||||
|
||||
while (rs.next()){
|
||||
DespesaReceita deposito = new DespesaReceita();
|
||||
deposito.setCodigoEmpresa(rs.getInt(2));
|
||||
deposito.setCodigoReceitaDespesa(rs.getInt(5));
|
||||
deposito.setDataLancamento(rs.getDate(1));
|
||||
deposito.setDataMovimento(rs.getDate(1));
|
||||
deposito.setLocalArrecadação(rs.getInt(3));
|
||||
deposito.setValorLançamento(rs.getBigDecimal(4).toString());
|
||||
deposito.setIdentificadorReceitaDespesa("R");
|
||||
deposito.setCodigoReceitaDespesa(codigoReceitaDespesaGlobus);
|
||||
depositos.add(deposito);
|
||||
pstmtFechamentos.setInt(1, rs.getInt(1));
|
||||
pstmtFechamentos.setInt(2, rs.getInt(3));
|
||||
|
||||
ResultSet rsFechamentos = pstmtFechamentos.executeQuery();
|
||||
|
||||
Integer empId = null;
|
||||
Integer pvId = null;
|
||||
String banco = "Bco: " + DespesaReceita.lpad(rs.getString(2), "0", 3) ;
|
||||
String agencia = "";
|
||||
String contaCorrente = "";
|
||||
String numDep = " Dep: " + rs.getString(5);
|
||||
String valor = " R$ " + df.format(rs.getBigDecimal(4));
|
||||
String ref = " Ref: ";
|
||||
|
||||
Boolean podeAdicionar = false;
|
||||
|
||||
while (rsFechamentos.next()){
|
||||
podeAdicionar = true;
|
||||
if (empId == null ){ empId = rsFechamentos.getInt(2); }
|
||||
if (pvId == null){ pvId = rsFechamentos.getInt(3); }
|
||||
if (agencia.isEmpty()){ agencia = " Ag: " + rsFechamentos.getString(5); }
|
||||
if (contaCorrente.isEmpty()){ contaCorrente = " C/C: " + rsFechamentos.getString(6); }
|
||||
ref += ref.length() <= 6 ? sdf.format(rsFechamentos.getDate(1)) : ", " + sdf.format(rsFechamentos.getDate(1));
|
||||
|
||||
}
|
||||
|
||||
if (podeAdicionar){ // se não tiver dados da subquery não é um depósito válido.
|
||||
DespesaReceita deposito = new DespesaReceita();
|
||||
deposito.setCodigoEmpresa(empId);
|
||||
deposito.setDataLancamento(rs.getDate(6));
|
||||
deposito.setDataMovimento(rs.getDate(6));
|
||||
deposito.setLocalArrecadação(pvId);
|
||||
deposito.setValorLançamento(rs.getBigDecimal(4).toString());
|
||||
deposito.setIdentificadorReceitaDespesa("R");
|
||||
deposito.setCodigoReceitaDespesa(codigoReceitaDespesaGlobus);
|
||||
deposito.setDescricaoDetalhada(banco + agencia + contaCorrente + numDep + valor + ref);
|
||||
depositos.add(deposito);
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
log.error("", e);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class DespesaReceita {
|
|||
private final String numeroReciboTurismo = " ";// 108 010 Alfanumérico
|
||||
private final String formaPagamentoTurismo = "00";// 118 002 Numérico
|
||||
private final String tipoPagamentoTurismo = "00";// 120 002 Numérico
|
||||
private final String descricaoDetalhada = " ";// 122 100 Alfanumérico
|
||||
private String descricaoDetalhada = " ";// 122 100 Alfanumérico
|
||||
private final String documentoVenda = "000000";// 222 6 Numérico
|
||||
private final String tipoDocumentoVenda = " ";// 228 1 Alfanumérico
|
||||
private final String numerodocumentoCPG = "0000000000";// 229 10 Numérico
|
||||
|
@ -79,14 +79,24 @@ public class DespesaReceita {
|
|||
this.valorLançamento = lpad(valorLançamento.toString().replace(",", "").replace(".", ""), "0", 13);
|
||||
}
|
||||
|
||||
private static String lpad(String valueToPad, String filler, int size) {
|
||||
public void setDescricaoDetalhada(String desc){
|
||||
this.descricaoDetalhada = rpad(truncStr(desc, 100), " ", 100);
|
||||
}
|
||||
|
||||
private String truncStr(String str, int size){
|
||||
if (str.length() > size){
|
||||
return str.substring(0, size +1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
public static String lpad(String valueToPad, String filler, int size) {
|
||||
while (valueToPad.length() < size) {
|
||||
valueToPad = filler + valueToPad;
|
||||
}
|
||||
return valueToPad;
|
||||
}
|
||||
|
||||
private static String rpad(String valueToPad, String filler, int size) {
|
||||
public static String rpad(String valueToPad, String filler, int size) {
|
||||
while (valueToPad.length() < size) {
|
||||
valueToPad = valueToPad+filler;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue