1075 lines
48 KiB
C#
1075 lines
48 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.Xml;
|
|||
|
|
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 Ultimus.Utilitarios;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|||
|
|
{
|
|||
|
|
public class JsonInfoLaboral : JsonResponseBase
|
|||
|
|
{
|
|||
|
|
public List<InformacionLaboralCliente> InformacionLaboralClienteList { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class JsonInfoLaboralDetalle : JsonResponseBase
|
|||
|
|
{
|
|||
|
|
public InformacionLaboralCliente InformacionLaboralCliente { get; set; }
|
|||
|
|
public InformacionIngresosCliente InformacionIngresosCliente { get; set; }
|
|||
|
|
public Cliente Cliente { get; set; }
|
|||
|
|
|
|||
|
|
public TelefonoCliente Telefono { get; set; }
|
|||
|
|
public TelefonoCliente Fax { get; set; }
|
|||
|
|
public EmailCliente Email { get; set; }
|
|||
|
|
public DireccionCliente Direccion { get; set; }
|
|||
|
|
public Provincia Provincia { get; set; }
|
|||
|
|
public Canton Canton { get; set; }
|
|||
|
|
public Distrito Distrito { get; set; }
|
|||
|
|
public TipoMacrosector TipoMacrosector { get; set; }
|
|||
|
|
public TipoActividad TipoActividad { get; set; }
|
|||
|
|
|
|||
|
|
public decimal TotalIngresosNetosColones
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
decimal ret = 0;
|
|||
|
|
if (InformacionIngresosCliente != null)
|
|||
|
|
{
|
|||
|
|
if (InformacionIngresosCliente.SalarioNetoCol != null)
|
|||
|
|
ret += InformacionIngresosCliente.SalarioNetoCol.Value;
|
|||
|
|
if (InformacionIngresosCliente.VariableNetoCol != null)
|
|||
|
|
ret += InformacionIngresosCliente.VariableNetoCol.Value;
|
|||
|
|
if (InformacionIngresosCliente.OffShoreNetoCol != null)
|
|||
|
|
ret += InformacionIngresosCliente.OffShoreNetoCol.Value;
|
|||
|
|
if (InformacionIngresosCliente.OtrosNetoCol != null)
|
|||
|
|
ret += InformacionIngresosCliente.OtrosNetoCol.Value;
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public decimal TotalIngresosNetosDolares
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
decimal ret = 0;
|
|||
|
|
if (InformacionIngresosCliente != null)
|
|||
|
|
{
|
|||
|
|
if (InformacionIngresosCliente.SalarioNetoDol != null)
|
|||
|
|
ret += InformacionIngresosCliente.SalarioNetoDol.Value;
|
|||
|
|
if (InformacionIngresosCliente.VariableNetoDol != null)
|
|||
|
|
ret += InformacionIngresosCliente.VariableNetoDol.Value;
|
|||
|
|
if (InformacionIngresosCliente.OffShoreNetoDol != null)
|
|||
|
|
ret += InformacionIngresosCliente.OffShoreNetoDol.Value;
|
|||
|
|
if (InformacionIngresosCliente.OtrosNetoDol != null)
|
|||
|
|
ret += InformacionIngresosCliente.OtrosNetoDol.Value;
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public decimal TotalIngresosNetos
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
decimal ret = 0;
|
|||
|
|
if (InformacionIngresosCliente != null)
|
|||
|
|
{
|
|||
|
|
if (TasaTipoCambioDolar > 0)
|
|||
|
|
{
|
|||
|
|
switch (IdMoneda)
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
ret += TotalIngresosNetosColones + (TotalIngresosNetosDolares * TasaTipoCambioDolar);
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
ret += TotalIngresosNetosDolares + (TotalIngresosNetosColones / TasaTipoCambioDolar);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
ret += TotalIngresosNetosColones + (TotalIngresosNetosDolares * TasaTipoCambioDolar);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public decimal TasaTipoCambioDolar { get; set; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
public int? IdMoneda { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class InfoLaboralAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
Crypt crypt = new Crypt();
|
|||
|
|
LogFile log = new LogFile();
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonInfoLaboralDetalle GuardarInfoLaboralDetalle([FromBody] JsonInfoLaboralDetalle Model)
|
|||
|
|
{
|
|||
|
|
JsonInfoLaboralDetalle respuesta = new JsonInfoLaboralDetalle();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
if (Model.InformacionLaboralCliente != null)
|
|||
|
|
{
|
|||
|
|
Model.InformacionLaboralCliente.Valido = Model.InformacionLaboralCliente.Valido == null ? false : Model.InformacionLaboralCliente.Valido;
|
|||
|
|
InformacionLaboralCliente ilc = db.InformacionLaboralCliente.Where(q => q.IdInfoLaboral == Model.InformacionLaboralCliente.IdInfoLaboral && q.IdCliente == Model.InformacionLaboralCliente.IdCliente).FirstOrDefault();
|
|||
|
|
if (ilc == null)
|
|||
|
|
{
|
|||
|
|
int IdInfoLaboral = 1;
|
|||
|
|
if (db.InformacionLaboralCliente.Count() > 0)
|
|||
|
|
IdInfoLaboral = db.InformacionLaboralCliente.Max(q => q.IdInfoLaboral) + 1;
|
|||
|
|
Model.InformacionLaboralCliente.IdInfoLaboral = IdInfoLaboral;
|
|||
|
|
db.InformacionLaboralCliente.Add(Model.InformacionLaboralCliente);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(ilc).State = EntityState.Detached;
|
|||
|
|
db.InformacionLaboralCliente.Attach(Model.InformacionLaboralCliente);
|
|||
|
|
db.Entry(Model.InformacionLaboralCliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Model.InformacionIngresosCliente != null)
|
|||
|
|
{
|
|||
|
|
InformacionIngresosCliente iic = db.InformacionIngresosCliente.Where(q => q.IdCliente == Model.InformacionIngresosCliente.IdCliente).FirstOrDefault();
|
|||
|
|
if (iic == null)
|
|||
|
|
{
|
|||
|
|
db.InformacionIngresosCliente.Add(Model.InformacionIngresosCliente);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(Model.InformacionIngresosCliente.RubrosModeloSalario))
|
|||
|
|
{
|
|||
|
|
Model.InformacionIngresosCliente.RubrosModeloSalario = iic.RubrosModeloSalario;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.Entry(iic).State = EntityState.Detached;
|
|||
|
|
db.InformacionIngresosCliente.Attach(Model.InformacionIngresosCliente);
|
|||
|
|
db.Entry(Model.InformacionIngresosCliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
throw new Exception("No fue posible obtener el parámetro de entrada de la información laboral");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
bool nuevo = false;
|
|||
|
|
int idCliente = 0;
|
|||
|
|
int idTelefono = 0;
|
|||
|
|
|
|||
|
|
if (Model.Telefono != null)
|
|||
|
|
{
|
|||
|
|
nuevo = false;
|
|||
|
|
idCliente = Model.InformacionLaboralCliente.IdCliente;
|
|||
|
|
TelefonoCliente t1 = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == idCliente && t.IdTipoTelefono == "DC");
|
|||
|
|
idTelefono = db.TelefonoCliente.Where(t => t.IdCliente == idCliente).Select(t => t.IdTelefono).DefaultIfEmpty(0).Max() + 1;
|
|||
|
|
|
|||
|
|
if (t1 == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
t1 = new TelefonoCliente();
|
|||
|
|
t1.IdCliente = idCliente;
|
|||
|
|
t1.IdTipoTelefono = "DC";
|
|||
|
|
t1.IdTelefono = idTelefono++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Model.Telefono.Secuencial != null) t1.Secuencial = Model.Telefono.Secuencial;
|
|||
|
|
if (Model.Telefono.CodigoArea != null) t1.CodigoArea = Model.Telefono.CodigoArea;
|
|||
|
|
t1.Telefono = Model.Telefono.Telefono;
|
|||
|
|
t1.Extension = Model.Telefono.Extension;
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.TelefonoCliente.Add(t1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(t1).State = EntityState.Detached;
|
|||
|
|
db.TelefonoCliente.Attach(t1);
|
|||
|
|
db.Entry(t1).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (Model.Fax != null)
|
|||
|
|
{
|
|||
|
|
nuevo = false;
|
|||
|
|
TelefonoCliente t2 = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == idCliente && t.IdTipoTelefono == "DCF");
|
|||
|
|
|
|||
|
|
if (t2 == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
t2 = new TelefonoCliente();
|
|||
|
|
t2.IdCliente = idCliente;
|
|||
|
|
t2.IdTipoTelefono = "DCF";
|
|||
|
|
t2.IdTelefono = idTelefono++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Model.Fax.Secuencial != null) t2.Secuencial = Model.Fax.Secuencial;
|
|||
|
|
if (Model.Fax.CodigoArea != null) t2.CodigoArea = Model.Fax.CodigoArea;
|
|||
|
|
t2.Telefono = Model.Fax.Telefono;
|
|||
|
|
t2.Extension = Model.Fax.Extension;
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.TelefonoCliente.Add(t2);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(t2).State = EntityState.Detached;
|
|||
|
|
db.TelefonoCliente.Attach(t2);
|
|||
|
|
db.Entry(t2).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (Model.Email != null)
|
|||
|
|
{
|
|||
|
|
nuevo = false;
|
|||
|
|
EmailCliente e = db.EmailCliente.FirstOrDefault(t => t.IdCliente == idCliente && t.IdTipoEmail == 2);
|
|||
|
|
|
|||
|
|
if (e == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
e = new EmailCliente();
|
|||
|
|
e.IdCliente = idCliente;
|
|||
|
|
e.IdTipoEmail = 2;
|
|||
|
|
e.IdEmail = db.EmailCliente.Where(t => t.IdCliente == idCliente).Select(t => t.IdEmail).DefaultIfEmpty(0).Max() + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Model.Email.Secuencial != null) e.Secuencial = Model.Email.Secuencial;
|
|||
|
|
e.Email = string.IsNullOrEmpty(Model.Email.Email) ? Model.Email.Email : Model.Email.Email.ToLower();
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.EmailCliente.Add(e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(e).State = EntityState.Detached;
|
|||
|
|
db.EmailCliente.Attach(e);
|
|||
|
|
db.Entry(e).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (Model.Direccion != null)
|
|||
|
|
{
|
|||
|
|
nuevo = false;
|
|||
|
|
DireccionCliente d = db.DireccionCliente.FirstOrDefault(t => t.IdCliente == idCliente && t.IdTipoDireccion == "DC");
|
|||
|
|
|
|||
|
|
if (d == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
d = new DireccionCliente();
|
|||
|
|
d.IdCliente = idCliente;
|
|||
|
|
d.IdTipoDireccion = "DC";
|
|||
|
|
d.IdDireccion = db.DireccionCliente.Where(t => t.IdCliente == idCliente).Select(t => t.IdDireccion).DefaultIfEmpty(0).Max() + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Model.Direccion.Secuencial != null) d.Secuencial = Model.Direccion.Secuencial;
|
|||
|
|
d.IdProvincia = Model.Direccion.IdProvincia;
|
|||
|
|
d.IdCanton = Model.Direccion.IdCanton;
|
|||
|
|
d.IdDistrito = Model.Direccion.IdDistrito;
|
|||
|
|
d.DirExacta = string.IsNullOrEmpty(Model.Direccion.DirExacta) ? Model.Direccion.DirExacta : Model.Direccion.DirExacta.ToUpper();
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.DireccionCliente.Add(d);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(d).State = EntityState.Detached;
|
|||
|
|
db.DireccionCliente.Attach(d);
|
|||
|
|
db.Entry(d).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
respuesta.InformacionLaboralCliente = Model.InformacionLaboralCliente;
|
|||
|
|
}
|
|||
|
|
respuesta.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);
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex.InnerException);
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInfoLaboral ObtenerInfoLaboral(int IdCliente)
|
|||
|
|
{
|
|||
|
|
JsonInfoLaboral respuesta = new JsonInfoLaboral();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionLaboralClienteList = db.InformacionLaboralCliente.Where(q => q.IdCliente == IdCliente).ToList();
|
|||
|
|
}
|
|||
|
|
respuesta.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);
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInfoLaboralDetalle ObtenerInfoLaboralDetalle(int IdInfoLaboral, int IdCliente, int IdSolicitud, decimal TipoCambio)
|
|||
|
|
{
|
|||
|
|
JsonInfoLaboralDetalle respuesta = new JsonInfoLaboralDetalle();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta.Cliente = db.Cliente
|
|||
|
|
.Include(j => j.Solicitante)
|
|||
|
|
.Where(c => c.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
Solicitud sol = db.Solicitud
|
|||
|
|
.Include(p => p.Cotizacion)
|
|||
|
|
.Where(s => s.IdSolicitud == IdSolicitud).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.TasaTipoCambioDolar = TipoCambio;
|
|||
|
|
respuesta.IdMoneda = sol.Cotizacion.IdMoneda;
|
|||
|
|
|
|||
|
|
respuesta.InformacionLaboralCliente = db.InformacionLaboralCliente
|
|||
|
|
.Include(q => q.TipoFuenteIngreso)
|
|||
|
|
.Include(q => q.TipoEmpleador)
|
|||
|
|
.Include(q => q.PuestoActual)
|
|||
|
|
.Include(q => q.TipoMacrosector)
|
|||
|
|
.Include(q => q.TipoActividad)
|
|||
|
|
.Include(q => q.DeclaraRenta)
|
|||
|
|
.Where(q => q.IdInfoLaboral == IdInfoLaboral).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (respuesta.InformacionLaboralCliente == null)
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionLaboralCliente = new InformacionLaboralCliente();
|
|||
|
|
respuesta.InformacionLaboralCliente.IdInfoLaboral = IdInfoLaboral;
|
|||
|
|
respuesta.InformacionLaboralCliente.IdCliente = IdCliente;
|
|||
|
|
respuesta.InformacionLaboralCliente.TipoFuenteIngreso = new TipoFuenteIngreso();
|
|||
|
|
respuesta.InformacionLaboralCliente.TipoEmpleador = new TipoEmpleador();
|
|||
|
|
respuesta.InformacionLaboralCliente.PuestoActual = new PuestoActual();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionLaboralCliente.PuestoActual = db.PuestoActual.Where(x => x.IdPuestoActual == respuesta.InformacionLaboralCliente.IdPuestoActual).FirstOrDefault();
|
|||
|
|
respuesta.InformacionLaboralCliente.TipoMacrosector = db.TipoMacrosector.Where(x => x.IdMacroSector == respuesta.InformacionLaboralCliente.IdMacroSector).FirstOrDefault();
|
|||
|
|
respuesta.InformacionLaboralCliente.TipoActividad = db.TipoActividad.Where(x => x.IdActividad== respuesta.InformacionLaboralCliente.IdActividad).FirstOrDefault();
|
|||
|
|
respuesta.InformacionLaboralCliente.DeclaraRenta = db.DeclaraRenta.Where(x => x.IdDeclaraRenta == respuesta.InformacionLaboralCliente.IdDeclaraRenta).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.Telefono = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == IdCliente && t.IdTipoTelefono == "DC");
|
|||
|
|
respuesta.Fax = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == IdCliente && t.IdTipoTelefono == "DCF");
|
|||
|
|
respuesta.Email = db.EmailCliente.FirstOrDefault(t => t.IdCliente == IdCliente && t.IdTipoEmail == 2);
|
|||
|
|
respuesta.Direccion = db.DireccionCliente.FirstOrDefault(t => t.IdCliente == IdCliente && t.IdTipoDireccion == "DC");
|
|||
|
|
|
|||
|
|
if (respuesta.Direccion != null)
|
|||
|
|
{
|
|||
|
|
respuesta.Provincia = db.Provincia.FirstOrDefault(t => t.IdProvincia == respuesta.Direccion.IdProvincia);
|
|||
|
|
respuesta.Canton = db.Canton.FirstOrDefault(t => t.IdCanton == respuesta.Direccion.IdCanton);
|
|||
|
|
respuesta.Distrito = db.Distrito.FirstOrDefault(t => t.IdDistrito == respuesta.Direccion.IdDistrito && t.IdCanton == respuesta.Direccion.IdCanton);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente = db.InformacionIngresosCliente.Where(q => q.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (respuesta.InformacionIngresosCliente == null)
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionIngresosCliente = new InformacionIngresosCliente();
|
|||
|
|
respuesta.InformacionIngresosCliente.IdCliente = IdCliente;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
respuesta.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);
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInfoLaboralDetalle ObtenerSalario(int IdCliente, string Identificacion, int Incidente, string Proceso, int Solicitud, decimal TipoCambio)
|
|||
|
|
{
|
|||
|
|
JsonInfoLaboralDetalle respuesta = null;
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
ObtenerDatosCICBDResponse resp = null;
|
|||
|
|
ObtenerEstratoSocialResponse respEstratoSocial = null;
|
|||
|
|
XmlDocument xmlDoc = null;
|
|||
|
|
StringBuilder sbXmlDatos = new StringBuilder();
|
|||
|
|
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
xmlDoc = new XmlDocument();
|
|||
|
|
|
|||
|
|
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
|
|||
|
|
respuesta = new JsonInfoLaboralDetalle()
|
|||
|
|
{
|
|||
|
|
TasaTipoCambioDolar = TipoCambio
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente = new InformacionIngresosCliente()
|
|||
|
|
{
|
|||
|
|
IdCliente = IdCliente,
|
|||
|
|
SalarioBrutoCol = 0,
|
|||
|
|
SalarioBrutoDol = 0,
|
|||
|
|
SalarioNetoCol = 0,
|
|||
|
|
SalarioNetoDol = 0,
|
|||
|
|
VariableBrutoCol = 0,
|
|||
|
|
VariableBrutoDol = 0,
|
|||
|
|
VariableNetoCol = 0,
|
|||
|
|
VariableNetoDol = 0,
|
|||
|
|
OffShoreNetoCol = 0,
|
|||
|
|
OffShoreNetoDol = 0,
|
|||
|
|
OtrosNetoCol = 0,
|
|||
|
|
OtrosNetoDol = 0,
|
|||
|
|
EstratoSocial = "D",
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
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 = "2",
|
|||
|
|
proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
solicitud = Solicitud.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);
|
|||
|
|
|
|||
|
|
string ing_CPA_bruto_col = string.Empty;
|
|||
|
|
string ing_CPA_neto_col = string.Empty;
|
|||
|
|
string cons_sal_neto_col = string.Empty;
|
|||
|
|
string cons_sal_bruto_col = string.Empty;
|
|||
|
|
string cons_otros_ingresos_col = string.Empty;
|
|||
|
|
|
|||
|
|
string ing_CPA_bruto_dol = string.Empty;
|
|||
|
|
string ing_CPA_neto_dol = string.Empty;
|
|||
|
|
string cons_sal_neto_dol = string.Empty;
|
|||
|
|
string cons_sal_bruto_dol = string.Empty;
|
|||
|
|
string cons_otros_ingresos_dol = string.Empty;
|
|||
|
|
|
|||
|
|
string sal_trasanterior = string.Empty;
|
|||
|
|
string sal_anterior = string.Empty;
|
|||
|
|
string sal_actual = string.Empty;
|
|||
|
|
|
|||
|
|
|
|||
|
|
string tipo_cliente_cic = string.Empty;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//**********************************************************
|
|||
|
|
//Informacion de los Rubros para Calculo de Salario Modelo
|
|||
|
|
//**********************************************************
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5") != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//Colones
|
|||
|
|
ing_CPA_bruto_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/IngBrutoCPA").InnerText;
|
|||
|
|
ing_CPA_neto_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/IngNetoCPA").InnerText;
|
|||
|
|
cons_sal_neto_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Constancia_Sal_Neto").InnerText;
|
|||
|
|
cons_sal_bruto_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Constancia_Sal_Bruto").InnerText;
|
|||
|
|
cons_otros_ingresos_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Constancia_Otros_Ing").InnerText;
|
|||
|
|
|
|||
|
|
//Dolares
|
|||
|
|
ing_CPA_bruto_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/IngBrutoCPA_Dol").InnerText;
|
|||
|
|
ing_CPA_neto_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/IngNetoCPA_Dol").InnerText;
|
|||
|
|
cons_sal_neto_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Constancia_Sal_Neto_Dol").InnerText;
|
|||
|
|
cons_sal_bruto_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Constancia_Sal_Bruto_Dol").InnerText;
|
|||
|
|
cons_otros_ingresos_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Constancia_Otros_Ing_Dol").InnerText;
|
|||
|
|
|
|||
|
|
sal_trasanterior = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/TransAnterior").InnerText;
|
|||
|
|
sal_anterior = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Anterior").InnerText;
|
|||
|
|
sal_actual = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/Actual").InnerText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
tipo_cliente_cic = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta5/TipoCliente").InnerText; //1=Asalariado|2=Independiente|3=Mixto
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
string cic = string.Empty;
|
|||
|
|
string pago_historico = string.Empty;
|
|||
|
|
string modelo_salario = string.Empty;
|
|||
|
|
string nivel_endeudamiento = string.Empty;
|
|||
|
|
|
|||
|
|
string modelo_sal_brut_col = string.Empty;
|
|||
|
|
string modelo_sal_neto_col = string.Empty;
|
|||
|
|
|
|||
|
|
string modelo_sal_brut_dol = string.Empty;
|
|||
|
|
string modelo_sal_neto_dol = string.Empty;
|
|||
|
|
|
|||
|
|
string cuota_universal_col = string.Empty;
|
|||
|
|
string cuota_universal_dol = string.Empty;
|
|||
|
|
string cuota_universal_UDES = string.Empty;
|
|||
|
|
|
|||
|
|
//Informacion del Salario Modelo
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4") != null)
|
|||
|
|
{
|
|||
|
|
cic = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/CIC").InnerText;
|
|||
|
|
pago_historico = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Pago_Historico").InnerText;
|
|||
|
|
nivel_endeudamiento = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Nivel_Endeudamiento").InnerText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
modelo_sal_brut_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/tot_salario_bru").InnerText;
|
|||
|
|
modelo_sal_neto_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Modelo_Salario").InnerText;
|
|||
|
|
|
|||
|
|
modelo_sal_brut_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/tot_salario_bru_Dol").InnerText;
|
|||
|
|
modelo_sal_neto_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Modelo_Salario_Dol").InnerText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
cuota_universal_col = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Cuota_Universal").InnerText;
|
|||
|
|
cuota_universal_dol = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Cuota_Universal_Dol").InnerText;
|
|||
|
|
cuota_universal_UDES = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta4/Cuota_Universal_UDS").InnerText;
|
|||
|
|
|
|||
|
|
if (tipo_cliente_cic != "1" && tipo_cliente_cic != "2" && tipo_cliente_cic != "3")
|
|||
|
|
throw new Exception("El tipo de deudor obtenido no se encuentra parametrizado en el sistema.");
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//*********************************************
|
|||
|
|
//Si es Asalariado o posee Ingresos Mixtos
|
|||
|
|
//*********************************************
|
|||
|
|
if (tipo_cliente_cic == "1" || tipo_cliente_cic == "3")
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioBrutoCol = ToDecimal(modelo_sal_brut_col);
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioNetoCol = ToDecimal(modelo_sal_neto_col);
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioBrutoDol = ToDecimal(modelo_sal_brut_dol);
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioNetoDol = ToDecimal(modelo_sal_neto_dol);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//*********************************************
|
|||
|
|
//Si es Independiente o posee Ingresos Mixtos
|
|||
|
|
//*********************************************
|
|||
|
|
if (tipo_cliente_cic == "2" || tipo_cliente_cic == "3")
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableBrutoCol = ToDecimal(ing_CPA_bruto_col);
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableNetoCol = ToDecimal(ing_CPA_neto_col);
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableBrutoDol = ToDecimal(ing_CPA_bruto_dol);
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableNetoDol = ToDecimal(ing_CPA_neto_dol);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//**************************************************
|
|||
|
|
//Rubros de como se calculo el modelo de salario.
|
|||
|
|
//**************************************************
|
|||
|
|
StringBuilder sbValores = new StringBuilder();
|
|||
|
|
StringBuilder sbRubros = new StringBuilder();
|
|||
|
|
|
|||
|
|
//Colones
|
|||
|
|
sbRubros.Append("Constancia Salario Bruto Colones|");
|
|||
|
|
sbRubros.Append("Constancia Otros Ingresos Colones|");
|
|||
|
|
sbRubros.Append("Constancia Salario Neto Colones|");
|
|||
|
|
sbRubros.Append("Orden Salario Trasanterior Colones|");
|
|||
|
|
sbRubros.Append("Orden Salario Anterior Colones|");
|
|||
|
|
sbRubros.Append("Orden Salario Actual Colones|");
|
|||
|
|
sbRubros.Append("Ingreso Bruto CPA Colones|");
|
|||
|
|
sbRubros.Append("Ingreso Neto CPA Colones|");
|
|||
|
|
sbRubros.Append("Modelo Salario Bruto Colones|");
|
|||
|
|
sbRubros.Append("Modelo Salario Neto Colones|");
|
|||
|
|
|
|||
|
|
//Dolares
|
|||
|
|
sbRubros.Append("Constancia Salario Bruto Dolares|");
|
|||
|
|
sbRubros.Append("Constancia Otros Ingresos Dolares|");
|
|||
|
|
sbRubros.Append("Constancia Salario Neto Dolares|");
|
|||
|
|
sbRubros.Append("Orden Salario Trasanterior Dolares|");
|
|||
|
|
sbRubros.Append("Orden Salario Anterior Dolares|");
|
|||
|
|
sbRubros.Append("Orden Salario Actual Dolares|");
|
|||
|
|
sbRubros.Append("Ingreso Bruto CPA Dolares|");
|
|||
|
|
sbRubros.Append("Ingreso Neto CPA Dolares|");
|
|||
|
|
sbRubros.Append("Modelo Salario Bruto Dolares|");
|
|||
|
|
sbRubros.Append("Modelo Salario Neto Dolares");
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
///Colones
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", cons_sal_bruto_col, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", cons_otros_ingresos_col, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", cons_sal_neto_col, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", sal_trasanterior, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", sal_anterior, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", sal_actual, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", ing_CPA_bruto_col, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", ing_CPA_neto_col, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", modelo_sal_brut_col, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", modelo_sal_neto_col, "|"));
|
|||
|
|
|
|||
|
|
//Dolares
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", cons_sal_bruto_dol, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", cons_otros_ingresos_dol, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", cons_sal_neto_dol, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", 0, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", 0, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", 0, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", ing_CPA_bruto_dol, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", ing_CPA_neto_dol, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}{1}", modelo_sal_brut_dol, "|"));
|
|||
|
|
sbValores.Append(string.Format("{0}", modelo_sal_neto_dol));
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
var mtzRubros = sbRubros.ToString().Split(new char[] { '|' });
|
|||
|
|
var mtzValores = sbValores.ToString().Split(new char[] { '|' });
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
for (int i = 0; i < mtzRubros.Length; i++)
|
|||
|
|
{
|
|||
|
|
string strDato = !GlobalAPIController.IsNumeric(mtzValores[i]) ? "0.00" : GlobalAPIController.StringToDecimal(mtzValores[i]).Value.ToString("##,###.#0");
|
|||
|
|
sbXmlDatos.Append(mtzRubros[i]);
|
|||
|
|
sbXmlDatos.Append("|");
|
|||
|
|
sbXmlDatos.Append(strDato);
|
|||
|
|
sbXmlDatos.Append("|");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
sbRubros.Clear();
|
|||
|
|
sbValores.Clear();
|
|||
|
|
|
|||
|
|
sbRubros = null;
|
|||
|
|
sbValores = null;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente.RubrosModeloSalario = sbXmlDatos.ToString();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region EstratoSocial
|
|||
|
|
respEstratoSocial = interfaces.ObtenerEstratoSocial(new ObtenerEstratoSocialRequest()
|
|||
|
|
{
|
|||
|
|
Proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
TasaCambio = TipoCambio,
|
|||
|
|
TotalIngresoBrutoCol = respuesta.TotalIngresosNetosColones,
|
|||
|
|
TotalIngresoBrutoDol = respuesta.TotalIngresosNetosDolares
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (respEstratoSocial.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(respEstratoSocial.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente.EstratoSocial = respEstratoSocial.EstratoSocial;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
sbXmlDatos.Clear();
|
|||
|
|
sbXmlDatos = null;
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInfoLaboral EliminarInfoLaboral(int IdInfoLaboral)
|
|||
|
|
{
|
|||
|
|
JsonInfoLaboral respuesta = new JsonInfoLaboral();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
InformacionLaboralCliente ele = db.InformacionLaboralCliente.Where(q => q.IdInfoLaboral == IdInfoLaboral).FirstOrDefault();
|
|||
|
|
if (ele != null)
|
|||
|
|
{
|
|||
|
|
db.InformacionLaboralCliente.Remove(ele);
|
|||
|
|
}
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
respuesta.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);
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInfoLaboralDetalle ObtenerInfoIngresosClinte(int IdSolicitud, int IdCliente, decimal TipoCambio, int? IdMoneda, bool Unificado)
|
|||
|
|
{
|
|||
|
|
List<JsonInfoLaboralDetalle> ListInfoIngresos = null;
|
|||
|
|
JsonInfoLaboralDetalle respuesta = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
ListInfoIngresos = new List<JsonInfoLaboralDetalle>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (Unificado)
|
|||
|
|
{
|
|||
|
|
List<Solicitante> _participantes = db.Solicitante.Where(p => p.IdSolicitud == IdSolicitud).ToList();
|
|||
|
|
foreach (Solicitante item in _participantes)
|
|||
|
|
{
|
|||
|
|
if (item.IdTipoSolicitante == 1 || item.IdTipoSolicitante == 2)
|
|||
|
|
{
|
|||
|
|
JsonInfoLaboralDetalle infoLaboral = new JsonInfoLaboralDetalle()
|
|||
|
|
{
|
|||
|
|
TasaTipoCambioDolar = TipoCambio,
|
|||
|
|
IdMoneda = IdMoneda
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
infoLaboral.InformacionIngresosCliente = db.InformacionIngresosCliente.Where(q => q.IdCliente == item.IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (infoLaboral.InformacionIngresosCliente != null)
|
|||
|
|
ListInfoIngresos.Add(infoLaboral);
|
|||
|
|
|
|||
|
|
if (item.IdCliente == IdCliente)
|
|||
|
|
{
|
|||
|
|
respuesta = infoLaboral;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
respuesta = new JsonInfoLaboralDetalle()
|
|||
|
|
{
|
|||
|
|
TasaTipoCambioDolar = TipoCambio,
|
|||
|
|
IdMoneda = IdMoneda
|
|||
|
|
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente = db.InformacionIngresosCliente.Where(q => q.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (Unificado)
|
|||
|
|
{
|
|||
|
|
var item = ListInfoIngresos.Where(j => j.InformacionIngresosCliente.IdCliente != IdCliente).FirstOrDefault();
|
|||
|
|
if (item != null)
|
|||
|
|
{
|
|||
|
|
respuesta.InformacionIngresosCliente.OffShoreNetoCol += item.InformacionIngresosCliente.OffShoreNetoCol;
|
|||
|
|
respuesta.InformacionIngresosCliente.OffShoreNetoDol += item.InformacionIngresosCliente.OffShoreNetoDol;
|
|||
|
|
respuesta.InformacionIngresosCliente.OtrosNetoCol += item.InformacionIngresosCliente.OtrosNetoCol;
|
|||
|
|
respuesta.InformacionIngresosCliente.OtrosNetoDol += item.InformacionIngresosCliente.OtrosNetoDol;
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioBrutoCol += item.InformacionIngresosCliente.SalarioBrutoCol;
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioBrutoDol += item.InformacionIngresosCliente.SalarioBrutoDol;
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioNetoCol += item.InformacionIngresosCliente.SalarioNetoCol;
|
|||
|
|
respuesta.InformacionIngresosCliente.SalarioNetoDol += item.InformacionIngresosCliente.SalarioNetoDol;
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableBrutoCol += item.InformacionIngresosCliente.VariableBrutoCol;
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableBrutoDol += item.InformacionIngresosCliente.VariableBrutoDol;
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableNetoCol += item.InformacionIngresosCliente.VariableNetoCol;
|
|||
|
|
respuesta.InformacionIngresosCliente.VariableNetoDol += item.InformacionIngresosCliente.VariableNetoDol;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente = db.InformacionIngresosCliente.Where(q => q.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region ObtenerSalarioNeto
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerSalarioNetoResponse ObtenerSalarioNeto(decimal SalarioBrutoColones, decimal SalarioBrutoDolares, int IdMoneda, decimal TipoCambio)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
JsonObtenerSalarioNetoResponse respuesta = null;
|
|||
|
|
InterfacesAPIController oInterface = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
respuesta = new JsonObtenerSalarioNetoResponse();
|
|||
|
|
var resp = oInterface.ObtenerSalarioNeto(new ObtenerSalarioNetoRequest()
|
|||
|
|
{
|
|||
|
|
IdMoneda = IdMoneda,
|
|||
|
|
SalarioBrutoCol = SalarioBrutoColones,
|
|||
|
|
SalarioBrutoDol = SalarioBrutoDolares,
|
|||
|
|
TasaCambio = TipoCambio,
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.SalarioNetoColones = resp.SalarioNetoColones;
|
|||
|
|
respuesta.SalarioNetoDolares = resp.SalarioNetoDolares;
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region CalcularTotalCuadroIngresos
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonInfoLaboralDetalle CalcularTotalCuadroIngresos(JsonInfoLaboralDetalle req)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
JsonInfoLaboralDetalle respuesta = null;
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
ObtenerEstratoSocialResponse respEstratoSocial = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
|
|||
|
|
respuesta = new JsonInfoLaboralDetalle()
|
|||
|
|
{
|
|||
|
|
TasaTipoCambioDolar = req.TasaTipoCambioDolar,
|
|||
|
|
IdMoneda = req.IdMoneda
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente = new InformacionIngresosCliente()
|
|||
|
|
{
|
|||
|
|
OffShoreNetoCol = req.InformacionIngresosCliente.OffShoreNetoCol,
|
|||
|
|
OffShoreNetoDol = req.InformacionIngresosCliente.OffShoreNetoDol,
|
|||
|
|
OtrosNetoCol = req.InformacionIngresosCliente.OtrosNetoCol,
|
|||
|
|
OtrosNetoDol = req.InformacionIngresosCliente.OtrosNetoDol,
|
|||
|
|
SalarioBrutoCol = req.InformacionIngresosCliente.SalarioBrutoCol,
|
|||
|
|
SalarioBrutoDol = req.InformacionIngresosCliente.SalarioBrutoDol,
|
|||
|
|
SalarioNetoCol = req.InformacionIngresosCliente.SalarioNetoCol,
|
|||
|
|
SalarioNetoDol = req.InformacionIngresosCliente.SalarioNetoDol,
|
|||
|
|
VariableBrutoCol = req.InformacionIngresosCliente.VariableBrutoCol,
|
|||
|
|
VariableBrutoDol = req.InformacionIngresosCliente.VariableBrutoDol,
|
|||
|
|
VariableNetoCol = req.InformacionIngresosCliente.VariableNetoCol,
|
|||
|
|
VariableNetoDol = req.InformacionIngresosCliente.VariableNetoDol
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#region EstratoSocial
|
|||
|
|
respEstratoSocial = interfaces.ObtenerEstratoSocial(new ObtenerEstratoSocialRequest()
|
|||
|
|
{
|
|||
|
|
Proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
TasaCambio = req.TasaTipoCambioDolar,
|
|||
|
|
TotalIngresoBrutoCol = respuesta.TotalIngresosNetosColones,
|
|||
|
|
TotalIngresoBrutoDol = respuesta.TotalIngresosNetosDolares
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (respEstratoSocial.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(respEstratoSocial.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.InformacionIngresosCliente.EstratoSocial = respEstratoSocial.EstratoSocial;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
private decimal ToDecimal(string val)
|
|||
|
|
{
|
|||
|
|
decimal decResult = 0;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
decResult = IsNumeric(val) ? decimal.Parse(val) : 0;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
decResult = 0;
|
|||
|
|
}
|
|||
|
|
return decResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool IsNumeric(string val)
|
|||
|
|
{
|
|||
|
|
decimal decResult = 0;
|
|||
|
|
bool bResult = true;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
decResult = decimal.Parse(val);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
bResult = false;
|
|||
|
|
}
|
|||
|
|
return bResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|