368 lines
No EOL
13 KiB
JavaScript
368 lines
No EOL
13 KiB
JavaScript
//#region GLOBALES
|
|
$("#formLiquidacion").EnableValidationToolTip();
|
|
var tableItemsCondicionesTasa;
|
|
var IsReadOnlyForm = true;
|
|
var IsAplicaIntegracionConCartera = false;
|
|
//#endregion
|
|
|
|
//#region READY
|
|
jQuery(document).ready(function () {
|
|
|
|
tableItemsCondicionesTasa = $('#TableItemsCondicionesTasa').DataTable();
|
|
GetControlsSettings("Liquidacion", "Liquidacion", "formLiquidacion", true);
|
|
});
|
|
//#endregion
|
|
|
|
|
|
|
|
$("#TabsClienteCentrico li a").click(function (event) {
|
|
try {
|
|
//Si etapa está activa
|
|
if ($("#hiddenTaskStatus").val() == 1 && IsReadOnlyForm == false) {
|
|
|
|
event.preventDefault();
|
|
var thisHREF = this.attributes["href"].nodeValue;
|
|
|
|
//Si es la primera vez que quiere salir o no ha guardado antes de quere salir.
|
|
if ($("#hiddenFlagSalir").val() != "true" || $("#hiddenFlagGuardarDatos").val() != "true") {
|
|
|
|
//Activa el flag de salir
|
|
$("#hiddenFlagSalir").val("true");
|
|
|
|
//Indica al usuario que debe guardar
|
|
toastr.warning("Estimado usuario, debe guardar los datos antes de salir del formulario.", Message_Warning);
|
|
ENDREQUEST();
|
|
return;
|
|
}
|
|
document.location.href = thisHREF;
|
|
}
|
|
} catch (e) {
|
|
ENDREQUEST();
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
//#region getDataModel
|
|
this.getDataModel = function () {
|
|
|
|
$('#btnEnviarA').unbind('click');
|
|
$('#btnEnviarA').click(function () {
|
|
CargarDataCatalogoDecision();
|
|
});
|
|
|
|
$('#btnBuscar').unbind('click');
|
|
$('#btnBuscar').click(function () {
|
|
CargarDataCatalogoDecision();
|
|
});
|
|
|
|
$("#btnEnviar").click(function () {
|
|
if ($("#hiddenEnviarA").val() != "") {
|
|
if (!confirm("¿Enviar?"))
|
|
return;
|
|
Enviar();
|
|
}
|
|
else {
|
|
toastr.warning("Debe especificar a donde enviar la solicitud.");
|
|
return false;
|
|
}
|
|
});
|
|
|
|
var uri = 'api/CreaOperacionAPI/getDataModel?NoSolicitud=' + $("#hiddensol_co_solicitud").val() + '&etapa=' + $("#hiddenStep").val();
|
|
$.getJSON(server + uri).done(function (data) {
|
|
|
|
if (data != null) {
|
|
|
|
CrearOperacion = data;
|
|
|
|
IsAplicaIntegracionConCartera = CrearOperacion.Solicitud.AplicaIntegracionConCartera == null ? false : CrearOperacion.Solicitud.AplicaIntegracionConCartera;
|
|
|
|
//HistorialDecision
|
|
if (CrearOperacion.HistorialDecision != null)
|
|
{
|
|
HistorialDecision = CrearOperacion.HistorialDecision;
|
|
|
|
$("#hiddenEnviarA").val(HistorialDecision.Decision.IdDecision);
|
|
$("#txtEnviarA").val(HistorialDecision.Decision.Descripcion);
|
|
}
|
|
|
|
|
|
//DataFaseII
|
|
if (CrearOperacion.Solicitud.DataFaseII[0] != null)
|
|
{
|
|
var DataFaseII = CrearOperacion.Solicitud.DataFaseII;
|
|
|
|
//Tipo Operacion
|
|
if (DataFaseII[0].TipoOperacion != null)
|
|
$("#txtTipoOperacion").val(DataFaseII[0].TipoOperacion)
|
|
|
|
//Clasificacion
|
|
if (DataFaseII[0].Clasificacion != null)
|
|
$("#txtClasificacion").val(DataFaseII[0].Clasificacion);
|
|
|
|
//NoOperacion
|
|
$("#txtNoOperacion").val(DataFaseII[0].NoOperacion)
|
|
|
|
|
|
//Numero de Línea
|
|
if (DataFaseII[0].NLinea != null)
|
|
$("#txtNoLinea").val(DataFaseII[0].NLinea);
|
|
|
|
|
|
//Cuenta de Forma de Pago
|
|
if (DataFaseII[0].CuentasInternas != null)
|
|
{
|
|
if (DataFaseII[0].CuentasInternas.Ncuenta != null)
|
|
$("#txtCuentaNo").val(DataFaseII[0].CuentasInternas.Ncuenta)
|
|
|
|
}
|
|
|
|
//Forma de Pago
|
|
if (DataFaseII[0].FormaPago != null)
|
|
if (DataFaseII[0].FormaPago.Descripcion != null)
|
|
$("#txtFormaPago").val(DataFaseII[0].FormaPago.Descripcion)
|
|
|
|
|
|
//Instrucciones Especiales
|
|
if (DataFaseII[0].InstruccionesEspeciales != null)
|
|
$("#txtInstruccionesEspeciales").val(DataFaseII[0].InstruccionesEspeciales)
|
|
|
|
//Fecha Inicio Operacion
|
|
if (DataFaseII[0].FechaInicio != null)
|
|
$("#txtFechaInicio").val(moment(DataFaseII[0].FechaInicio).format("DD/MM/YYYY"));
|
|
|
|
//Fecha de Primer Pago de Interes
|
|
if (DataFaseII[0].FechaPrimerPagoInteres != null)
|
|
$("#txtPrimerPagoInt").val(moment(DataFaseII[0].FechaPrimerPagoInteres).format("DD/MM/YYYY"));
|
|
|
|
//Fecha de Primer Pago de Capital
|
|
if (DataFaseII[0].FechaPrimerPagoCapital != null)
|
|
$("#txtPrimerPagoCap").val(moment(DataFaseII[0].FechaPrimerPagoCapital).format("DD/MM/YYYY"));
|
|
|
|
//Numero de Cuotas
|
|
$("#txtNoCuotas").val(DataFaseII[0].NumCuotas);
|
|
}
|
|
|
|
|
|
|
|
//Solicitantes
|
|
$.each(CrearOperacion.Solicitud.Solicitante, function (key, item) {
|
|
|
|
if (item.IdTipoSolicitante == 1)
|
|
{
|
|
var _primerNombreDeudor = item.Cliente.PrimerNombre != null ? item.Cliente.PrimerNombre.trim() + " " : "";
|
|
var _segundoNombreDeudor = item.Cliente.SegundoNombre != null ? item.Cliente.SegundoNombre.trim() + " " : "";
|
|
var _primerApellidoDeudor = item.Cliente.PrimerApellido != null ? item.Cliente.PrimerApellido.trim() + " " : "";
|
|
var _segundoApellidoDeudor = item.Cliente.SegundoApellido != null ? item.Cliente.SegundoApellido.trim() + " " : "";
|
|
|
|
$("#txtCliente").val(_primerNombreDeudor + _segundoNombreDeudor + _primerApellidoDeudor + _segundoApellidoDeudor);
|
|
$("#txtDeudor").val(_primerNombreDeudor + _segundoNombreDeudor + _primerApellidoDeudor + _segundoApellidoDeudor);
|
|
$("#txtEmpresa").val(item.Cliente.InformacionLaboralCliente[0].NombreEmpresa);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
//Cotizacion
|
|
if (CrearOperacion.Solicitud.Cotizacion != null)
|
|
{
|
|
//Monto Prestamo
|
|
$("#txtMonto").val(CrearOperacion.Solicitud.Cotizacion.MontoPrestamo)
|
|
|
|
//Meses plazo del Credito
|
|
$("#txtPlazo").val(CrearOperacion.Solicitud.Cotizacion.PeriodoMesesCredito);
|
|
|
|
//Moneda
|
|
if (CrearOperacion.Solicitud.Cotizacion.Moneda != null)
|
|
$("#txtMoneda").val(CrearOperacion.Solicitud.Cotizacion.Moneda.Descripcion);
|
|
|
|
//Cuota del Prestamo
|
|
$("#txtCuotaPactada").val(ToMoney(CrearOperacion.Solicitud.Cotizacion.CuotaPrestamo));
|
|
|
|
//Ejecutivo de la Cotizacion
|
|
if (CrearOperacion.Solicitud.Cotizacion.EjecutivoCotizacion != null)
|
|
$("#txtOficial").val(CrearOperacion.Solicitud.Cotizacion.EjecutivoCotizacion.NombreEjecutivo)
|
|
|
|
//PolizaVehiculoGratis
|
|
$("#chk" + "PolizaVehiculoGratis").attr("checked", CrearOperacion.Solicitud.Cotizacion.AplicaPolizaVehiculoGratis != true ? false : true);
|
|
|
|
//PlazoMesesPolizaVehiculoGratis
|
|
$("#hidden" + "PlazoMesesPolizaVehiculoGratis").val(CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia == 0 ? '' : CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia);
|
|
$("#txt" + "PlazoMesesPolizaVehiculoGratis").val(CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia == 0 ? '' : CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia);
|
|
|
|
|
|
}
|
|
|
|
//Destino del Crédito
|
|
$("#txtDestino").val("Compra Vehículo");
|
|
|
|
|
|
//Sucursal
|
|
if (CrearOperacion.Solicitud.Sucursal != null)
|
|
$("#txtSucursal").val(CrearOperacion.Solicitud.Sucursal.Descripcion)
|
|
|
|
|
|
//CondicionesCredito
|
|
if (CrearOperacion.JsonProgramaCrediticio[0] != null) {
|
|
if (CrearOperacion.JsonProgramaCrediticio[0].Descripcion != null)
|
|
$("#txtProgCrediticio").val(CrearOperacion.JsonProgramaCrediticio[0].Descripcion);
|
|
|
|
var columnDefinition = [
|
|
{ "data": "Periodo" },
|
|
{ "data": "PlazoMeses" },
|
|
{ "data": "DescripcionTipoTasa" },
|
|
{ "data": "DescripcionTipoTasaReferencia" },
|
|
{ "data": "TasaInteresFinal" },
|
|
{ "data": "TasaMinima" },
|
|
{ "data": "DescripcionPeriodoReajuste" }
|
|
];
|
|
|
|
|
|
|
|
$('#TableItemsCondicionesTasa').TableInit(0, false, true, false, false, columnDefinition, CrearOperacion.JsonProgramaCrediticio[0].ProgramaCrediticioCondicionesTasaAdapted);
|
|
}
|
|
|
|
InicializarDesembolso();
|
|
|
|
$("#formLiquidacion").valid();
|
|
|
|
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|
|
|
}).then(function (value) {
|
|
SoloLectura();
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
//#endregion
|
|
|
|
this.CargarDataCatalogoDecision = function () {
|
|
var proceso = $("#hiddenProcess").val();
|
|
var etapa = $("#hiddenStep").val();
|
|
var usuario = $("#hiddenUserID").val();
|
|
var sol_co_cotizacion = $("#hiddensol_co_cotizacion").val();
|
|
var DireccionAPI = $('#btnEnviarA').attr("Direccion_API");
|
|
DireccionAPICatalogo = DireccionAPI;
|
|
SelectedCatalog = "EnviarA";
|
|
CargarDataCatalogo(DireccionAPI, $("#txtDescripcion").val(), proceso, etapa, usuario, sol_co_cotizacion);
|
|
}
|
|
|
|
this.Enviar = function ()
|
|
{
|
|
|
|
if (!$("#formLiquidacion").valid()) {
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|
return false;
|
|
}
|
|
|
|
//*****************************************
|
|
//Solo si aplica la integración con Cartera
|
|
//*****************************************
|
|
if (IsAplicaIntegracionConCartera == true) {
|
|
|
|
if (ValidarCuadreFormasDesembolso() == false) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
var Incident = "0";
|
|
if ($("#hiddenIncident").val() != "")
|
|
Incident = $("#hiddenIncident").val();
|
|
|
|
var JsonEnviarCotizacion =
|
|
{
|
|
IdCotizacion: $('#hiddensol_co_cotizacion').val(),
|
|
UserId: $("#hiddenUserID").val(),
|
|
TaskId: $("#hiddenTaskId").val(),
|
|
Process: $("#hiddenProcess").val(),
|
|
Step: $("#hiddenStep").val(),
|
|
Incident: Incident,
|
|
IdDecision: $("#hiddenEnviarA").val(),
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|
IdMotivo: $("#hiddenMotivoDevolucion").val()
|
|
}
|
|
|
|
var uri = 'api/LiquidacionAPI/Enviar/';
|
|
var DTO = JSON.stringify(JsonEnviarCotizacion);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: server + uri,
|
|
cache: false,
|
|
data: DTO,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (data.CodigoRespuesta == "EXITOSO") {
|
|
alert("Incidente enviado");
|
|
window.open('', '_self', ''); window.close();
|
|
}
|
|
else if (data.CodigoRespuesta == "ADVERTENCIA") {
|
|
toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|
}
|
|
|
|
try {
|
|
|
|
if (data.Alertas != null)
|
|
{
|
|
$.each(data.Alertas, function (key, item) {
|
|
if (item.trim() != "") {
|
|
toastr.warning(item, Message_Warning);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
catch (e)
|
|
{ }
|
|
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|
|
this.cargarDesembolso = function () {
|
|
LoadMessage();
|
|
$("#modalFormaDesembolso").modal("show");
|
|
ENDREQUEST();
|
|
}
|
|
|
|
|
|
|
|
this.SoloLectura = function () {
|
|
|
|
try {
|
|
|
|
$("divFechaRevision").attr("style", "display:none;");
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1) {
|
|
return;
|
|
}
|
|
|
|
FormReadOnly();
|
|
|
|
$("button[direccion_api]").remove();
|
|
$("#btnGuardar").remove();
|
|
$("#btnEnviar").remove();
|
|
|
|
|
|
$("#btnGuardarBitacoraComentario").remove();
|
|
|
|
IsReadOnlyForm = true;
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un problema al cargar el formulario. Vuela a intentarlo mas tarde", Message_Error);
|
|
}
|
|
}; |