1336 lines
50 KiB
C#
1336 lines
50 KiB
C#
|
|
|
|||
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data.Entity.Validation;
|
|||
|
|
using System.Data.Entity;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Web.Http;
|
|||
|
|
using ULA.Davivienda.PrendarioModel;
|
|||
|
|
using ULA.Davivienda.PrendarioModel.Prendario;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Commons;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.CotizadorServiceLayer;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Json;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFPrendarioSeguros;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFServiciosGenerales;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFServiciosApoyoConector;
|
|||
|
|
using Ultimus.Utilitarios;
|
|||
|
|
using System.Xml;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public class ReferenciaDeudaAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
Crypt crypt = new Crypt();
|
|||
|
|
LogFile log = new LogFile();
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<SituacionHistorica> ListarSituacionHistorica(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
List<SituacionHistorica> respuesta = new List<SituacionHistorica>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta = db.SituacionHistorica.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == idCliente).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<SituacionActual> ListarSituacionActual(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
List<SituacionActual> respuesta = new List<SituacionActual>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta = db.SituacionActual.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == idCliente).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public string ListarEscenariosCuotaEstresada(int Incidente, int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
string[] arrParametrosNombres = new string[7];
|
|||
|
|
string[] arrParametrosValores = new string[7];
|
|||
|
|
Cliente oCliente = new Cliente();
|
|||
|
|
string strXML = string.Empty;
|
|||
|
|
string respuesta = string.Empty;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
oCliente = db.Cliente.Where(t => t.IdCliente == idCliente).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (oCliente == null || string.IsNullOrEmpty(oCliente.Identificacion))
|
|||
|
|
throw new Exception(string.Format("No fue posible encontrar el número de identificación para el cliente {0}", idCliente));
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
arrParametrosNombres[0] = ""; arrParametrosValores[0] = "";
|
|||
|
|
arrParametrosNombres[1] = "@i_opcion"; arrParametrosValores[1] = "2";
|
|||
|
|
arrParametrosNombres[2] = "@i_incidente"; arrParametrosValores[2] = Incidente.ToString();
|
|||
|
|
arrParametrosNombres[3] = "@i_idsolicitud"; arrParametrosValores[3] = idSolicitud.ToString();
|
|||
|
|
arrParametrosNombres[4] = "@i_idcliente"; arrParametrosValores[4] = idCliente.ToString();
|
|||
|
|
arrParametrosNombres[5] = "@i_identificacion"; arrParametrosValores[5] = oCliente.Identificacion;
|
|||
|
|
arrParametrosNombres[6] = "@i_proceso"; arrParametrosValores[6] = "PrestamoPrendario";
|
|||
|
|
|
|||
|
|
using (ULA.Davivienda.PrestamoAutos.WCFServiciosApoyoConector.ConectorClient oClientServiciosApoyoConector = new ConectorClient())
|
|||
|
|
{
|
|||
|
|
strXML = oClientServiciosApoyoConector.EjecutarComandoSQLArreglo(
|
|||
|
|
"PrestamoPrendario",
|
|||
|
|
"BPMDATA",
|
|||
|
|
"usp_wf_sensibilizacion_deudas",
|
|||
|
|
arrParametrosNombres.ToList(),
|
|||
|
|
arrParametrosValores.ToList(),
|
|||
|
|
0
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (strXML != "<NewDataSet />")
|
|||
|
|
{
|
|||
|
|
//System.Xml.XmlDocument objXMLDocument = new System.Xml.XmlDocument();
|
|||
|
|
//objXMLDocument.LoadXml(strXML);
|
|||
|
|
|
|||
|
|
System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(strXML, System.Xml.Linq.LoadOptions.PreserveWhitespace);
|
|||
|
|
string jsonText = JsonConvert.SerializeXNode(doc);
|
|||
|
|
dynamic dyn = JsonConvert.DeserializeObject<System.Dynamic.ExpandoObject>(jsonText);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta = jsonText;
|
|||
|
|
|
|||
|
|
//System.IO.StringReader sReader = new System.IO.StringReader(objXMLDocument.InnerXml);
|
|||
|
|
//objDataSet.ReadXml(sReader);
|
|||
|
|
|
|||
|
|
//if (objDataSet.Tables.Count > 0)
|
|||
|
|
//{
|
|||
|
|
// this.grvDetalleCuotas.DataSource = objDataSet.Tables[0];
|
|||
|
|
// this.grvDetalleCuotas.DataBind();
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//if (objDataSet.Tables.Count > 1)
|
|||
|
|
//{
|
|||
|
|
// this.grvResumenCuotas.DataSource = objDataSet.Tables[1];
|
|||
|
|
// this.grvResumenCuotas.DataBind();
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//if (objDataSet.Tables.Count > 2)
|
|||
|
|
//{
|
|||
|
|
// this.grvDTIResumen.DataSource = objDataSet.Tables[2];
|
|||
|
|
// this.grvDTIResumen.DataBind();
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public Cliente ObtenerDataClienteReferenciaDeudas(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
Cliente respuesta = new Cliente();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta = db.Solicitante.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == idCliente).Select(c => c.Cliente).FirstOrDefault();
|
|||
|
|
respuesta.ComportamientoPagoHistorico = db.ComportamientoPagoHistorico.Where(t => t.IdComportamientoPagoHistorico == respuesta.IdComportamientoPagoHistorico).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public SituacionHistorica ObtenerSituacionHistorica(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
return db.SituacionHistorica.First(t => t.IdSituacionHistorica == id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public SituacionActual ObtenerSituacionActual(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
return db.SituacionActual.First(t => t.IdSituacionActual == id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public bool EliminarSituacionActual(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
SituacionActual item = db.SituacionActual.FirstOrDefault(s => s.IdSituacionActual == id);
|
|||
|
|
db.Entry(item).State = EntityState.Deleted;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public bool EliminarSituacionHistorica(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
SituacionHistorica item = db.SituacionHistorica.FirstOrDefault(s => s.IdSituacionHistorica == id);
|
|||
|
|
db.Entry(item).State = EntityState.Deleted;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public BaseJsonMetadata GuardarPuntajes(Cliente req)
|
|||
|
|
{
|
|||
|
|
BaseJsonMetadata resp = new BaseJsonMetadata();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (req.IdCliente == null || req.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = "Falta el id del cliente";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
Cliente _cliente = db.Cliente.Where(c => c.IdCliente == req.IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (req.CICPuntajeFinal != null) _cliente.CICPuntajeFinal = req.CICPuntajeFinal;
|
|||
|
|
if (!string.IsNullOrEmpty(req.IdComportamientoPagoHistorico)) _cliente.IdComportamientoPagoHistorico = req.IdComportamientoPagoHistorico;
|
|||
|
|
|
|||
|
|
db.Entry(_cliente).State = EntityState.Detached;
|
|||
|
|
db.Cliente.Attach(_cliente);
|
|||
|
|
db.Entry(_cliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return resp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonGuardarParticipanteResponse GuardarSituacionActual(SituacionActual s)
|
|||
|
|
{
|
|||
|
|
JsonGuardarParticipanteResponse r = new JsonGuardarParticipanteResponse();
|
|||
|
|
Cliente oCliente = new Cliente();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
oCliente = db.Cliente.Where(t => t.IdCliente == s.IdCliente).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (oCliente == null || string.IsNullOrEmpty(oCliente.Identificacion))
|
|||
|
|
throw new Exception(string.Format("No fue posible encontrar el número de identificación para el cliente {0}", s.IdCliente));
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (s.IdCliente == null || s.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = "Falta el id del deudor";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
SituacionActual _modelSituacionActualUpdate = null;
|
|||
|
|
SituacionActual oSituacionActual = new SituacionActual();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (s.IdSituacionActual == 0)
|
|||
|
|
{
|
|||
|
|
oSituacionActual = db.SituacionActual.Where(t => t.IdSolicitud == s.IdSolicitud).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (oSituacionActual != null)
|
|||
|
|
{
|
|||
|
|
s.IdSituacionActual = db.SituacionActual.Count() == 0 ? 1 : db.SituacionActual.Max(q => q.IdSituacionActual) + 1;
|
|||
|
|
s.Incidente = oSituacionActual.Incidente;
|
|||
|
|
s.Proceso = oSituacionActual.Proceso;
|
|||
|
|
s.Identificacion = oSituacionActual.Identificacion;
|
|||
|
|
s.EsDeudor = oSituacionActual.EsDeudor;
|
|||
|
|
s.Estado = oSituacionActual.Estado;
|
|||
|
|
db.SituacionActual.Add(s);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
s.IdSituacionActual = db.SituacionActual.Count() == 0 ? 1 : db.SituacionActual.Max(q => q.IdSituacionActual) + 1;
|
|||
|
|
s.Incidente = 0;
|
|||
|
|
s.Proceso = "PrestamoPrendario";
|
|||
|
|
s.Identificacion = oCliente.Identificacion.Replace("-", "");
|
|||
|
|
s.Estado = "C";
|
|||
|
|
if (s.Condicion == "DEUDOR")
|
|||
|
|
{
|
|||
|
|
s.EsDeudor = true;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
s.EsDeudor = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SituacionActual.Add(s);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//ALR 20-04-2017 --Se cambia la forma de guardar la información
|
|||
|
|
_modelSituacionActualUpdate = db.SituacionActual.Where(q => q.IdSolicitud == s.IdSolicitud && q.IdSituacionActual == s.IdSituacionActual).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (_modelSituacionActualUpdate != null)
|
|||
|
|
{
|
|||
|
|
//_modelSituacionActualUpdate.IdSituacionActual= s.IdSituacionActual;
|
|||
|
|
//_modelSituacionActualUpdate.IdSolicitud = s.IdSolicitud;
|
|||
|
|
//_modelSituacionActualUpdate.IdCliente = s.IdCliente;
|
|||
|
|
//_modelSituacionActualUpdate.Incidente = s.Incidente;
|
|||
|
|
//_modelSituacionActualUpdate.Proceso = s.Proceso;
|
|||
|
|
//_modelSituacionActualUpdate.Identificacion = s.Identificacion;
|
|||
|
|
//_modelSituacionActualUpdate.EsDeudor = s.EsDeudor;
|
|||
|
|
//_modelSituacionActualUpdate.Estado = s.Estado;
|
|||
|
|
_modelSituacionActualUpdate.IdOperacion = s.IdOperacion;
|
|||
|
|
_modelSituacionActualUpdate.Moneda = s.Moneda;
|
|||
|
|
_modelSituacionActualUpdate.FecVencimiento = s.FecVencimiento;
|
|||
|
|
_modelSituacionActualUpdate.TipoOperacion= s.TipoOperacion;
|
|||
|
|
_modelSituacionActualUpdate.Condicion = s.Condicion;
|
|||
|
|
_modelSituacionActualUpdate.EstadoOperacion= s.EstadoOperacion;
|
|||
|
|
_modelSituacionActualUpdate.DiasAtraso = s.DiasAtraso;
|
|||
|
|
_modelSituacionActualUpdate.EntidadAcreedora = s.EntidadAcreedora;
|
|||
|
|
_modelSituacionActualUpdate.Saldo= s.Saldo;
|
|||
|
|
_modelSituacionActualUpdate.CuotasEquivalente = s.CuotasEquivalente;
|
|||
|
|
_modelSituacionActualUpdate.MontoOriginal = s.MontoOriginal;
|
|||
|
|
_modelSituacionActualUpdate.FecInicio = s.FecInicio;
|
|||
|
|
_modelSituacionActualUpdate.MontoNoDesembolsado= s.MontoNoDesembolsado;
|
|||
|
|
_modelSituacionActualUpdate.CuotaCertificada = s.CuotaCertificada;
|
|||
|
|
// _modelSituacionActualUpdate.Cancela = s.Cancela;
|
|||
|
|
//_modelSituacionActualUpdate.CuotaPricipal = s.CuotaPrincipal;
|
|||
|
|
//_modelSituacionActualUpdate.CuotaInteres = s.CuotaInteres;
|
|||
|
|
// _modelSituacionActualUpdate.TipoTasa = s.TipoTasa;
|
|||
|
|
//_modelSituacionActualUpdate.TasaNominal= s.TasaNominal;
|
|||
|
|
//_modelSituacionActualUpdate.DTI_MiniEndeudamiento = s.DTI_MiniEndeudamiento;
|
|||
|
|
|
|||
|
|
db.Entry(_modelSituacionActualUpdate).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return r;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonGuardarParticipanteResponse GuardarSituacionHistorica(SituacionHistorica s)
|
|||
|
|
{
|
|||
|
|
JsonGuardarParticipanteResponse r = new JsonGuardarParticipanteResponse();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (s.IdCliente == null || s.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = "Falta el id del deudor";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
if (s.IdSituacionHistorica == 0)
|
|||
|
|
{
|
|||
|
|
s.IdSituacionHistorica = db.SituacionActual.Count() == 0 ? 1 : db.SituacionActual.Max(q => q.IdSituacionActual) + 1;
|
|||
|
|
db.SituacionHistorica.Add(s);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(s).State = EntityState.Detached;
|
|||
|
|
db.SituacionHistorica.Attach(s);
|
|||
|
|
db.Entry(s).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return r;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerMoneda(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "N - COLONES O UNIDADES DE DESARROLLO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "E - DIVISA EXTRANJERA"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerTipoOperacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "1 - 98 DIRECTA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "2 - CRÉDITO CON OBLIGACIÓN DE DESEMBOLSO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "3 - TARJETAS DE CRÉDITO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4",
|
|||
|
|
descripcion = "4 - LÍNEAS DE UTILIZACIÓN AUTOMÁTICA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "5",
|
|||
|
|
descripcion = "5 - LÍNEA DE CRÉDITO CON COMPROMISO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "6",
|
|||
|
|
descripcion = "6 - LÍNEA DE CRÉDITO SIN COMPROMISO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "7",
|
|||
|
|
descripcion = "7 - 99 CONTINGENCIA CREDITICIA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerCondicion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "DEUDOR",
|
|||
|
|
descripcion = "DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "CO-DEUDOR",
|
|||
|
|
descripcion = "CO-DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "FIADOR/AVALISTA",
|
|||
|
|
descripcion = "FIADOR/AVALISTA"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerEstadoOperacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VIGENTE",
|
|||
|
|
descripcion = "1 - VIGENTE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VENCIDA <= A 90 DÍAS",
|
|||
|
|
descripcion = "2 - VENCIDA <= A 90 DÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VENCIDA A > 90 DÍAS Y <= 180 DÍAS",
|
|||
|
|
descripcion = "3 - VENCIDA A > 90 DÍAS Y <= 180 DÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VENCIDA > A 180 DÍAS",
|
|||
|
|
descripcion = "4 - 94 VENCIDA > A 180 DÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "COBRO JUDICIAL",
|
|||
|
|
descripcion = "5 - 93 COBRO JUDICIAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "NORMAL",
|
|||
|
|
descripcion = "91 NORMAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "ARREGLO DE PAGO",
|
|||
|
|
descripcion = "92 - ARREGLO DE PAGO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "ADMINIStrACIÓN INTERVENCIÓN JUDICIAL",
|
|||
|
|
descripcion = "95 - ADMINIStrACIÓN INTERVENCIÓN JUDICIAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "ADMINIStrACIÓN INTERVENCIÓN SUGEF",
|
|||
|
|
descripcion = "96 - ADMINIStrACIÓN INTERVENCIÓN SUGEF"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "OPERACIONES CASTIGADAS",
|
|||
|
|
descripcion = "97 - OPERACIONES CASTIGADAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "OPERACIONES BACK TO BACK",
|
|||
|
|
descripcion = "99 - OPERACIONES BACK TO BACK"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerMotivoLiquidacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "0 - CANCELACIÓN MEDIANTE PAGO DEL DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "1 - CANCELACIÓN MEDIANTE PAGO DE FIADOR/AVALISTA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "2 - VENTA DE OPERACIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4",
|
|||
|
|
descripcion = "3 - REFINANCIAMIENTO TOTAL DE LA MISMA ENTIDAD"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "5",
|
|||
|
|
descripcion = "4 - NOVACIÓN DEL DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "6",
|
|||
|
|
descripcion = "5 - CONDONACIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "7",
|
|||
|
|
descripcion = "6 - DESCUENTO O CESIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "8",
|
|||
|
|
descripcion = "7 - ADJUDICACIÓN DE GARANTÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "9",
|
|||
|
|
descripcion = "8 - DACIÓN DE GARANTÍAS EN PAGOS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "10",
|
|||
|
|
descripcion = "9 - COMPENSACIÓN (BACK TO BACK)"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "11",
|
|||
|
|
descripcion = "10 - PASADO POR INCOBRABLE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "12",
|
|||
|
|
descripcion = "11 - MANDATO LEGAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "13",
|
|||
|
|
descripcion = "12 - PROGRAMAS DE PREMIOS DE LA ENTIDAD"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "14",
|
|||
|
|
descripcion = "13 - APLICACIÓN DE PÓLIZAS DE SEGURO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "15",
|
|||
|
|
descripcion = "14 - CAMBIO DE NÚMERO DE OPERACIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "16",
|
|||
|
|
descripcion = "15 - VENCIMIENTO DE LA OPERACIÓN CONTINGENTE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "17",
|
|||
|
|
descripcion = "16 - EJECUCIÓN DE LA OPERACIÓN CONTINGENTE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "18",
|
|||
|
|
descripcion = "17 - TRASLADO A UN FIDEICOMISO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "19",
|
|||
|
|
descripcion = "18 - REFINANCIAMIENTO POR OTRA ENTIDAD"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "20",
|
|||
|
|
descripcion = "19 - ENTIDAD DESINSCRITA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "21",
|
|||
|
|
descripcion = "20 - CANCELACIÓN MEDIANTE PAGO DE UN JUZGADO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "22",
|
|||
|
|
descripcion = "21 - MÚLTIMPLES MOTIVOS QUE IMPLIQUE CPH3 (>25,000)"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "23",
|
|||
|
|
descripcion = "22 - MÚLTIMPLES MOTIVOS QUE IMPLIQUE CPH3 (<25,000)"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "24",
|
|||
|
|
descripcion = "23 - CUALESQUIERA DOS O MAS MOTIVOS QUE NO IMPLIQUEN CPH3"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "25",
|
|||
|
|
descripcion = "98 - OPERACIÓN REACTIVADA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "26",
|
|||
|
|
descripcion = "99 - DESCONOCIDO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerPuntajeOperacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "1"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1.5",
|
|||
|
|
descripcion = "1.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "2"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2.5",
|
|||
|
|
descripcion = "2.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "3"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3.5",
|
|||
|
|
descripcion = "3.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4",
|
|||
|
|
descripcion = "4"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4.5",
|
|||
|
|
descripcion = "4.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "5",
|
|||
|
|
descripcion = "5"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerComportamientoPagoHistorico(string filtro = null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
List<ComportamientoPagoHistorico> list = new List<ComportamientoPagoHistorico>();
|
|||
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|||
|
|
list = db.ComportamientoPagoHistorico.ToList();
|
|||
|
|
else
|
|||
|
|
list = db.ComportamientoPagoHistorico.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true).ToList();
|
|||
|
|
foreach (var ele in list)
|
|||
|
|
{
|
|||
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|||
|
|
catalogo.codigo = Convert.ToString(ele.IdComportamientoPagoHistorico).Trim();
|
|||
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|||
|
|
ret.Add(catalogo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerSituacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "1 – Operación no reportada en ultimo envío"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "2 – Operación reportada en ultimo envío entidad inactiva"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "3 – Operación reportada en ultimo envío entidad activa"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerDeudasClienteResponse ObtenerDeudasCliente(int idSolicitud, int idCliente, int idMoneda, decimal tipoCambio, bool unificado)
|
|||
|
|
{
|
|||
|
|
JsonObtenerDeudasClienteResponse respuesta = null;
|
|||
|
|
List<JsonObtenerDeudasClienteResponse> listaDeudas = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
listaDeudas = new List<JsonObtenerDeudasClienteResponse>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta = new JsonObtenerDeudasClienteResponse()
|
|||
|
|
{
|
|||
|
|
IdCliente = idCliente,
|
|||
|
|
IdSolicitud = idSolicitud,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<Solicitante> _participantes = db.Solicitante.Where(p => p.IdSolicitud == idSolicitud).ToList();
|
|||
|
|
foreach (Solicitante item in _participantes)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (item.IdTipoSolicitante == 1 || item.IdTipoSolicitante == 2)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var _deuda = new JsonObtenerDeudasClienteResponse()
|
|||
|
|
{
|
|||
|
|
TotalDeudasColones = 0,
|
|||
|
|
TotalDeudasDolares = 0,
|
|||
|
|
TotalDeudas = 0,
|
|||
|
|
IdCliente = item.IdCliente,
|
|||
|
|
IdSolicitud = idSolicitud,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Colones
|
|||
|
|
var listaDeudasColones = db.SituacionActual.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == item.IdCliente && t.Moneda.Equals("N - COLONES O UNIDADES DE DESARROLLO") == true).ToList();
|
|||
|
|
foreach (var deuda in listaDeudasColones)
|
|||
|
|
{
|
|||
|
|
_deuda.TotalDeudasColones += StringtoDouble(deuda.CuotasEquivalente);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Dolares
|
|||
|
|
var listaDeudasDolares = db.SituacionActual.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == item.IdCliente && t.Moneda.Equals("E - DIVISA EXTRANJERA") == true).ToList();
|
|||
|
|
foreach (var deuda in listaDeudasDolares)
|
|||
|
|
{
|
|||
|
|
_deuda.TotalDeudasDolares += StringtoDouble(deuda.CuotasEquivalente);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
switch (idMoneda)
|
|||
|
|
{
|
|||
|
|
case 0: //COLONES
|
|||
|
|
_deuda.TotalDeudas = _deuda.TotalDeudasColones + (_deuda.TotalDeudasDolares * (double)tipoCambio);
|
|||
|
|
break;
|
|||
|
|
case 1: //DOLARES
|
|||
|
|
_deuda.TotalDeudas = _deuda.TotalDeudasDolares + (_deuda.TotalDeudasColones / (double)tipoCambio);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
throw new Exception("El código para la moneda no se encuentra configurado para realizar el cálculo de las deudas del deudor.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (item.IdCliente == idCliente)
|
|||
|
|
{
|
|||
|
|
respuesta = _deuda;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
listaDeudas.Add(_deuda);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (unificado)
|
|||
|
|
{
|
|||
|
|
var item = listaDeudas.Where(j => j.IdCliente != idCliente).FirstOrDefault();
|
|||
|
|
if (item != null)
|
|||
|
|
{
|
|||
|
|
respuesta.TotalDeudasColones += item.TotalDeudasColones;
|
|||
|
|
respuesta.TotalDeudasDolares += item.TotalDeudasDolares;
|
|||
|
|
respuesta.TotalDeudas += item.TotalDeudas;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private double StringtoDouble(string value)
|
|||
|
|
{
|
|||
|
|
double dblResult = 0d;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
double.TryParse(value, out dblResult);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
dblResult = 0;
|
|||
|
|
}
|
|||
|
|
return dblResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerDeudasClienteResponse ObtenerDeudasCIC(int IdCliente, string Identificacion, int Incidente, string Proceso, int IdSolicitud, decimal TipoCambio)
|
|||
|
|
{
|
|||
|
|
JsonObtenerDeudasClienteResponse respuesta = null;
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
ObtenerDatosCICBDResponse resp = null;
|
|||
|
|
StringBuilder sbXMLResultado = null;
|
|||
|
|
XmlNode rootXMLRefinanciar = null;
|
|||
|
|
XmlDocument xmlDoc = null;
|
|||
|
|
decimal SumaCuotaCalcColones = 0;
|
|||
|
|
decimal SumaCuotaCalcDolares = 0;
|
|||
|
|
decimal SumaCuotaCalcPrincipal = 0;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
xmlDoc = new XmlDocument();
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
respuesta = new JsonObtenerDeudasClienteResponse();
|
|||
|
|
|
|||
|
|
|
|||
|
|
Identificacion = Identificacion.Replace("-", "");
|
|||
|
|
if (Identificacion.Length == 10)
|
|||
|
|
{
|
|||
|
|
Identificacion = Identificacion.Substring(1, Identificacion.Length - 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
resp = interfaces.ObtenerDatosCICBD(new ObtenerDatosCICBDRequest()
|
|||
|
|
{
|
|||
|
|
idcliente = IdCliente,
|
|||
|
|
identificacion = Identificacion,
|
|||
|
|
incidente = Incidente.ToString(),
|
|||
|
|
opcion = "1",
|
|||
|
|
proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
solicitud = IdSolicitud.ToString()
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|||
|
|
{
|
|||
|
|
throw new Exception("No fue posible obtener el resultado de la consulta al sistema del CIC.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
xmlDoc.LoadXml(resp.resultado);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Informacion de la Fecha de Actualizacion del CIC
|
|||
|
|
string fechaActualizacion = string.Empty;
|
|||
|
|
string campo1 = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro1/Valor1").InnerText;
|
|||
|
|
|
|||
|
|
if (campo1.ToUpper() == "MONEDA")
|
|||
|
|
{
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor7") != null)
|
|||
|
|
{
|
|||
|
|
fechaActualizacion = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor7").InnerText;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor11") != null)
|
|||
|
|
{
|
|||
|
|
fechaActualizacion = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor11").InnerText;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.FechaActualizacionCIC = fechaActualizacion;
|
|||
|
|
|
|||
|
|
//Informacion de las Deudas a Refinanciar
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta3") != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
rootXMLRefinanciar = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta3");
|
|||
|
|
sbXMLResultado = new System.Text.StringBuilder();
|
|||
|
|
|
|||
|
|
sbXMLResultado.Append("<NewDataSet>");
|
|||
|
|
for (var i = 0; i < rootXMLRefinanciar.ChildNodes.Count; i++)
|
|||
|
|
{
|
|||
|
|
sbXMLResultado.Append("<Table>");
|
|||
|
|
sbXMLResultado.Append("<" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Entidad").Name + ">");
|
|||
|
|
sbXMLResultado.Append(rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Entidad").InnerText);
|
|||
|
|
sbXMLResultado.Append("</" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Entidad").Name + ">");
|
|||
|
|
|
|||
|
|
sbXMLResultado.Append("<" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Id.Operacion").Name + ">");
|
|||
|
|
sbXMLResultado.Append(rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Id.Operacion").InnerText);
|
|||
|
|
sbXMLResultado.Append("</" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Id.Operacion").Name + ">");
|
|||
|
|
sbXMLResultado.Append("</Table>");
|
|||
|
|
}
|
|||
|
|
sbXMLResultado.Append("</NewDataSet>");
|
|||
|
|
|
|||
|
|
respuesta.DeudasRefinanciarXmlCIC = sbXMLResultado.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4") != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string SumaCuotaCalcTotalColones = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/SumaCuotaCalcTotalColones").InnerText;
|
|||
|
|
string SumaCuotaCalcTotalDolares = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/SumaCuotaCalcTotalDolares").InnerText;
|
|||
|
|
SumaCuotaCalcColones = decimal.Parse(SumaCuotaCalcTotalColones);
|
|||
|
|
SumaCuotaCalcDolares = decimal.Parse(SumaCuotaCalcTotalDolares) * TipoCambio;
|
|||
|
|
SumaCuotaCalcPrincipal = SumaCuotaCalcColones + SumaCuotaCalcDolares;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
SumaCuotaCalcPrincipal = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Cliente _cliente = db.Cliente.Where(s => s.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
InformacionIngresosCliente _InformacionIngresosCliente = db.InformacionIngresosCliente.Where(s => s.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
if (_cliente != null)
|
|||
|
|
{
|
|||
|
|
//Datos actualizados
|
|||
|
|
_cliente.CICFeActualizacion = respuesta.FechaActualizacionCIC;
|
|||
|
|
_cliente.CICDeudasRefinanciar = respuesta.DeudasRefinanciarXmlCIC;
|
|||
|
|
|
|||
|
|
//Ejecucion de la actualizacion
|
|||
|
|
db.Entry(_cliente).State = EntityState.Detached;
|
|||
|
|
db.Cliente.Attach(_cliente);
|
|||
|
|
db.Entry(_cliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (_InformacionIngresosCliente != null)
|
|||
|
|
{
|
|||
|
|
_InformacionIngresosCliente.CargaMensualCSD = SumaCuotaCalcPrincipal;
|
|||
|
|
db.Entry(_InformacionIngresosCliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
else if (_InformacionIngresosCliente == null)
|
|||
|
|
{
|
|||
|
|
_InformacionIngresosCliente = new InformacionIngresosCliente();
|
|||
|
|
_InformacionIngresosCliente.IdCliente = IdCliente;
|
|||
|
|
_InformacionIngresosCliente.CargaMensualCSD = SumaCuotaCalcPrincipal;
|
|||
|
|
db.InformacionIngresosCliente.Add(_InformacionIngresosCliente);
|
|||
|
|
}
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerDeudasClienteResponse EvaluarDeudasCIC(int IdCliente, string Identificacion, int Incidente, string Proceso, int IdSolicitud, string Modo, string Juicios, string MalasReferencias)
|
|||
|
|
{
|
|||
|
|
JsonObtenerDeudasClienteResponse respuesta = null;
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
EvaluarCICResponse resp = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
respuesta = new JsonObtenerDeudasClienteResponse();
|
|||
|
|
|
|||
|
|
resp = interfaces.EvaluarCIC(new EvaluarCICRequest()
|
|||
|
|
{
|
|||
|
|
idCliente = IdCliente,
|
|||
|
|
identificacion = Identificacion,
|
|||
|
|
incidente = Incidente.ToString(),
|
|||
|
|
modo = Modo,
|
|||
|
|
proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
solicitud = IdSolicitud.ToString(),
|
|||
|
|
juicios = Juicios,
|
|||
|
|
malas_ref = MalasReferencias
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(resp.resultadoCIC))
|
|||
|
|
{
|
|||
|
|
throw new Exception("No fue posible obtener el resultado de la evaluación a las deudas cargadas del sistema CIC.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.ResultadoEvaluacionCIC = resp.resultadoCIC;
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|