1893 lines
No EOL
86 KiB
JavaScript
1893 lines
No EOL
86 KiB
JavaScript
//#region GLOBALES
|
|
$("#formCotizacion").EnableValidationToolTip();
|
|
|
|
var IsLoadedCotizacion = false;
|
|
var DataCatalogo;
|
|
var tableItemsCondicionesTasa;
|
|
var tableItemsPlanPago;
|
|
|
|
var _tasaRefTBP = 0;
|
|
var _tasaRefLibor = 0;
|
|
|
|
var infoProgramaCrediticio = {};
|
|
var infoProgramaCrediticioCondicionesTasa = {};
|
|
var infoProgramaCrediticioCondicionesTasaList = [];
|
|
|
|
var JsonCotizacionRequest = {};
|
|
var Cotizacion = {};
|
|
var JsonDatosCotizacion = {};
|
|
var JsonCotizacionResponse = {};
|
|
//#endregion
|
|
|
|
//#region READY
|
|
jQuery(document).ready(function () {
|
|
try {
|
|
|
|
tableItemsCondicionesTasa = $('#TableItemsCondicionesTasa').DataTable();
|
|
tableItemsPlanPago = $('#tableItemsPlanPago').DataTable();
|
|
|
|
$("#radioTipoPrimaMonto").attr("checked", true);
|
|
$("#radioTipoPrimaPorcentaje").attr("checked", false);
|
|
|
|
|
|
//$("#btnDetalleCotizacion").attr("style", "display:none");
|
|
$("#btnImprimir").attr("style", "display:none");
|
|
$("#liSolicitante").attr("style", "display:none");
|
|
|
|
GetControlsSettings("DatosGeneralesCotizacion", "DatosGeneralesCotizacion", "formCotizacion", true);
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al cargar el formulario. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
|
|
$("#btnCodOficial").click(function () {
|
|
if ($('#txtSucursal').val() === "") {
|
|
toastr.warning("Ingresar la Sucursal.");
|
|
return;
|
|
}
|
|
$('#modalOficial').modal('show');
|
|
|
|
});
|
|
|
|
$("#btnBuscarOficial").click(function () {
|
|
CargarOficialCobis($('#hiddenSucursal').val(), $('#txtOficialFiltro').val())
|
|
});
|
|
});
|
|
//#endregion
|
|
|
|
//#region EVENTOS
|
|
$("#chkEsColaborador").change(function () {
|
|
CargarDataCatalogoAdicional("EsColaborador", this.checked);
|
|
});
|
|
|
|
$("#radioTipoPrimaMonto").click(function () {
|
|
$("#radioTipoPrimaPorcentaje").attr("checked", false);
|
|
$("#txtPorcentajePrima").attr("disabled", true);
|
|
$("#txtMontoPrima").attr("disabled", false);
|
|
});
|
|
|
|
$("#radioTipoPrimaPorcentaje").click(function () {
|
|
$("#radioTipoPrimaMonto").attr("checked", false);
|
|
$("#txtMontoPrima").attr("disabled", true);
|
|
$("#txtPorcentajePrima").attr("disabled", false);
|
|
});
|
|
|
|
$("#btnDetalleCotizacion").click(function () {
|
|
$('#modalResultadoCotizacion').modal('show');
|
|
});
|
|
|
|
$('#btnPlazoMeses').unbind('click');
|
|
$("#btnPlazoMeses").click(function () {
|
|
|
|
try {
|
|
|
|
if (!jQuery.isEmptyObject(infoProgramaCrediticio)) {
|
|
DireccionAPICatalogo = "api/CotizacionAPI/ObtenerPeriodoCredito?filtro=" + infoProgramaCrediticio.PeriodoMesesCredito;
|
|
}
|
|
else {
|
|
DireccionAPICatalogo = "api/CotizacionAPI/ObtenerPeriodoCredito?filtro=";
|
|
}
|
|
|
|
SelectedCatalog = "PlazoMeses";
|
|
CargarCatalogo(DireccionAPICatalogo, SelectedCatalog);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
});
|
|
|
|
|
|
$('#btnPlazoMesesPolizaVehiculoGratis').unbind('click');
|
|
$('#btnPlazoMesesPolizaVehiculoGratis').click(function () {
|
|
|
|
try
|
|
{
|
|
if (!jQuery.isEmptyObject(infoProgramaCrediticio)) {
|
|
|
|
var _filtro = (infoProgramaCrediticio.MaximoPeriodoMesesGracia != 0 &&
|
|
infoProgramaCrediticio.MaximoPeriodoMesesGracia != null &&
|
|
typeof infoProgramaCrediticio.MaximoPeriodoMesesGracia !== 'undefined') ? infoProgramaCrediticio.MaximoPeriodoMesesGracia : infoProgramaCrediticio.PeriodoMesesGracia;
|
|
|
|
if (_filtro == 0) {
|
|
toastr.warning("El tipo de programa seleccionado no posee configuración de periodo de gracia para la póliza de vehículo", Message_Warning);
|
|
return false;
|
|
}
|
|
else {
|
|
DireccionAPICatalogo = "api/CotizacionAPI/ObtenerPeriodoGracia?filtro=" + _filtro;
|
|
SelectedCatalog = "PlazoMesesPolizaVehiculoGratis";
|
|
CargarCatalogo(DireccionAPICatalogo, SelectedCatalog);
|
|
}
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
});
|
|
|
|
|
|
|
|
$('#btnSubAgencia').unbind('click');
|
|
$("#btnSubAgencia").click(function () {
|
|
|
|
try {
|
|
|
|
var _id = $("#hiddenAgencia").val();
|
|
|
|
if (_id == "" || _id == "0") {
|
|
toastr.warning("Debe seleccionar una agencia de vehículo válida.", Message_Warning);
|
|
return false;
|
|
}
|
|
else {
|
|
|
|
DireccionAPICatalogo = "api/CotizacionAPI/ObtenerSubAgenciaVehiculo?filtro=" + _id;
|
|
SelectedCatalog = "SubAgencia";
|
|
CargarCatalogo(DireccionAPICatalogo, SelectedCatalog);
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#btnCotizar").click(function () {
|
|
|
|
GetControlsSettings("DatosGeneralesCotizacion", "DatosGeneralesCotizacion", "formCotizacion", false, false);
|
|
|
|
if (!$("#formCotizacion").valid()) {
|
|
toastr.warning("Ingresar todos los campos que son requeridos por el formulario", Message_Warning);
|
|
return false;
|
|
}
|
|
|
|
if ($("#hiddenTasaTipoCambio").val() == "0" || $("#hiddenTasaTipoCambio").val() == null) {
|
|
toastr.warning("Estimado usuario no es posible realizar la cotización sin el monto de tipo de cambio. Por favor valide con el Administrador del Sistema", Message_Warning);
|
|
return false;
|
|
}
|
|
|
|
if (parseFloat($("#txtValorAuto").autoNumeric('get')) <= 0) {
|
|
toastr.warning("Estimado usuario no es posible realizar la cotización sin el valor del vehículo.", Message_Warning);
|
|
return false;
|
|
}
|
|
|
|
if (parseFloat($("#txtMontoPrima").autoNumeric('get')) <= 0 && parseFloat(infoProgramaCrediticio.PorcPrimaMinima) > 0) {
|
|
toastr.warning("Estimado usuario no es posible realizar la cotización sin el monto de la prima.", Message_Warning);
|
|
return false;
|
|
}
|
|
|
|
|
|
if (jQuery.isEmptyObject(infoProgramaCrediticio)) {
|
|
toastr.warning("No es posible generar la cotización.No existen condiciones definidas para los parametros seleccionado", Message_Warning);
|
|
return false;
|
|
}
|
|
|
|
//#region Arma el objeto de seguros a enviar a cotizar
|
|
var listaRubros = [];
|
|
|
|
if ($("#chk" + "SeguroAuto").prop('checked')) {
|
|
var oTipoRubroSeguro = {
|
|
IdTipoRubroSeguro: 3,
|
|
IdRubroSeguro: $("#hidden" + "RubroSeguroAuto").val(),
|
|
Descripcion: "AUTO",
|
|
RubroSeguro: null
|
|
};
|
|
listaRubros.push(oTipoRubroSeguro);
|
|
}
|
|
|
|
if ($("#chk" + "SeguroDesempleo").prop('checked')) {
|
|
oTipoRubroSeguro = {
|
|
IdTipoRubroSeguro: 2,
|
|
IdRubroSeguro: $("#hidden" + "RubroSeguroDesempleo").val(),
|
|
Descripcion: "DESEMPLEO",
|
|
RubroSeguro: null
|
|
};
|
|
listaRubros.push(oTipoRubroSeguro);
|
|
}
|
|
|
|
if ($("#chk" + "SeguroVida").prop('checked')) {
|
|
oTipoRubroSeguro = {
|
|
IdTipoRubroSeguro: 1,
|
|
IdRubroSeguro: $("#hidden" + "RubroSeguroVida").val(),
|
|
Descripcion: "VIDA",
|
|
RubroSeguro: null
|
|
};
|
|
listaRubros.push(oTipoRubroSeguro);
|
|
}
|
|
//#endregion
|
|
|
|
//#region JsonCotizacionRequest
|
|
JsonCotizacionRequest = {
|
|
IdCotizacion: -1,
|
|
IdCampanna: infoProgramaCrediticio.IdCampanna,
|
|
IdProgramaCrediticio: infoProgramaCrediticio.IdProgramaCrediticio,
|
|
IdAgenciaVehiculo: $("#hiddenAgencia").val(),
|
|
IdSubAgenciaVehiculo: $("#hiddenSubAgencia").val(),
|
|
IdMarcaVehiculo: $("#hiddenMarcaVehiculo").val(),
|
|
IdEstiloVehiculo: $("#hiddenEstiloVehiculo").val(),
|
|
IdUsoVehiculo: $("#hiddenUsoVehiculo").val(),
|
|
IdMoneda: infoProgramaCrediticio.IdMoneda,
|
|
Moneda: infoProgramaCrediticio.Moneda,
|
|
IdFuenteIngreso: $("#hiddenFuenteIngreso").val(),
|
|
IdTipoVehiculo: infoProgramaCrediticio.IdTipoVehiculo,
|
|
TipoVehiculo: infoProgramaCrediticio.TipoVehiculo,
|
|
PorcComision: infoProgramaCrediticio.PorcComision,
|
|
PorcPrimaMinima: infoProgramaCrediticio.PorcIngresoMinReq,
|
|
PeriodoMesesCredito: $("#txtPlazoMeses").val(), //infoProgramaCrediticio.PeriodoMesesCredito,
|
|
PeriodoMesesGracia: $('#chkPolizaVehiculoGratis').prop('checked') == true ? $("#txtPlazoMesesPolizaVehiculoGratis").val() : 0, //infoProgramaCrediticio.PeriodoMesesGracia,
|
|
IdAnnoVehiculo: infoProgramaCrediticio.IdAnnoVehiculo,
|
|
ValorVehiculo: $("#txtValorAuto").autoNumeric('get'),
|
|
TipoCambio: $("#hiddenTasaTipoCambio").val(),
|
|
PorcPrima: $("#txtPorcentajePrima").autoNumeric('get'),
|
|
MontoPrima: $("#txtMontoPrima").autoNumeric('get'),
|
|
MontoComision: 0,
|
|
PorcIngresoMinReq: infoProgramaCrediticio.PorcIngresoMinReq,
|
|
IngresoMinReqCol: 0,
|
|
IngresoMInReqDol: 0,
|
|
MontoPrestamo: $("#txtValorAuto").autoNumeric('get'),
|
|
MontoPrestamoSinSeguros: 0,
|
|
MontoDesembolso: 0,
|
|
CondicionesTasaCotizacion: infoProgramaCrediticioCondicionesTasa,
|
|
Rubros: listaRubros,
|
|
EsColaborador: $("#chkEsColaborador").prop('checked'),
|
|
IdCarroceriaVehiculo: $("#hiddenCarroceriaVehiculo").val(),
|
|
EsSeguroAutoManual: false,
|
|
EsSeguroVidaManual: false,
|
|
EsSeguroDesempleoManual: false
|
|
};
|
|
//#endregion
|
|
|
|
var uri = 'api/CotizacionAPI/ObtenerCotizacion/';
|
|
var DTO = JSON.stringify(JsonCotizacionRequest);
|
|
|
|
$("button[type=button]").attr("disabled", true);
|
|
|
|
$.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") {
|
|
|
|
JsonCotizacionResponse = data;
|
|
|
|
|
|
//#region IngresoMinimoRequerido
|
|
$("#lblIngresoRequeridoCol").text(ToMoney(JsonCotizacionResponse.IngresogReqCol));
|
|
$("#lblIngresoRequeridoDol").text(ToMoney(JsonCotizacionResponse.IngresogReqDol));
|
|
//#endregion
|
|
|
|
//#region TipoCambio
|
|
$("#lblTipoCambioDol").text(ToMoney(JsonCotizacionResponse.TipoCambio));
|
|
//#endregion
|
|
|
|
//#region DesgloseCuota
|
|
$.each(JsonCotizacionResponse.DesgloseTabla, function (key, item) {
|
|
switch (item.Anno) {
|
|
case 1:
|
|
$("#lblCuotaSinSegPer1").text(ToMoney(item.CuotaSinSeguro));
|
|
$("#hiddenCuotaPeriodo1").val(item.CuotaSinSeguro);
|
|
$("#lblSegVehiculo1").text(ToMoney(item.CuotaSeguroVehiculo));
|
|
$("#lblCuotaTotal1").text(ToMoney(item.CuotaFinal));
|
|
$("#hiddenCuotaPrestamo").val(item.CuotaFinal);
|
|
//Si es solo 1 periodo entonces setea el
|
|
//Segundo Periodo y el Desgloce para Resto del Plazo
|
|
//igual que el primer periodo
|
|
if (JsonCotizacionResponse.DesgloseCuota.length == 1) {
|
|
|
|
//SegundoPeriodo
|
|
$("#lblCuotaSinSegPer2").text(ToMoney(item.CuotaSinSeguro));
|
|
$("#hiddenCuotaPeriodo2").val(item.CuotaSinSeguro);
|
|
$("#lblSegVehiculo2").text(ToMoney(item.CuotaSeguroVehiculo));
|
|
$("#lblCuotaTotal2").text(ToMoney(item.CuotaFinal));
|
|
|
|
//RestoPlazo
|
|
$("#lblCuotaSinSegPer3").text(ToMoney(item.CuotaSinSeguro));
|
|
$("#hiddenCuotaPeriodo3").val(item.CuotaSinSeguro);
|
|
$("#lblSegVehiculo3").text(ToMoney(item.CuotaSeguroVehiculo));
|
|
$("#lblCuotaTotal3").text(ToMoney(item.CuotaFinal));
|
|
}
|
|
break;
|
|
case 2:
|
|
$("#lblCuotaSinSegPer2").text(ToMoney(item.CuotaSinSeguro));
|
|
$("#hiddenCuotaPeriodo2").val(item.CuotaSinSeguro);
|
|
$("#lblSegVehiculo2").text(ToMoney(item.CuotaSeguroVehiculo));
|
|
$("#lblCuotaTotal2").text(ToMoney(item.CuotaFinal));
|
|
|
|
//Si son dos periodos entonces setea el Desgloce para Resto del Plazo
|
|
//iguak que el segundo periodo
|
|
if (JsonCotizacionResponse.DesgloseCuota.length == 2) {
|
|
//RestoPlazo
|
|
$("#lblCuotaSinSegPer3").text(ToMoney(item.CuotaSinSeguro));
|
|
$("#hiddenCuotaPeriodo3").val(item.CuotaSinSeguro);
|
|
$("#lblSegVehiculo3").text(ToMoney(item.CuotaSeguroVehiculo));
|
|
$("#lblCuotaTotal3").text(ToMoney(item.CuotaFinal));
|
|
}
|
|
break;
|
|
case 3:
|
|
$("#lblCuotaSinSegPer3").text(ToMoney(item.CuotaSinSeguro));
|
|
$("#hiddenCuotaPeriodo3").val(item.CuotaSinSeguro);
|
|
$("#lblSegVehiculo3").text(ToMoney(item.CuotaSeguroVehiculo));
|
|
$("#lblCuotaTotal3").text(ToMoney(item.CuotaFinal));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region PolizasAdicionales
|
|
$.each(JsonCotizacionResponse.Seguros, function (key, item) {
|
|
switch (item.RubroSeguro.TipoRubroSeguro.Descripcion.toUpperCase()) {
|
|
case "DESEMPLEO":
|
|
$("#lblMontoPolizaDesempleo").text(ToMoney(item.Monto));
|
|
break;
|
|
case "VIDA":
|
|
$("#lblMontoPolizaVida").text(ToMoney(item.Monto));
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region PolizasEnCotizacion
|
|
$("#lblMontoSegVehiculoResultCot").text("0.00");
|
|
$("#lblMontoSegDesempleoResultCot").text("0.00");
|
|
$("#lblMontoSegVidaResultCot").text("0.00");
|
|
|
|
$("#lblMontoTraspasoResultCot").text(ToMoney(JsonCotizacionResponse.MontoTraspaso));
|
|
$("#lblMontoConstPrendaResultCot").text(ToMoney(JsonCotizacionResponse.MontoConstitucionPrenda));
|
|
$("#lblMontoCotizacionResultCot").text(ToMoney(JsonCotizacionResponse.MontoCredito));
|
|
$("#lblMontoComisionResultCot").text(ToMoney(JsonCotizacionResponse.MontoComision));
|
|
$("#lblMontoDesembolsoResultCotizacion").text(ToMoney(JsonCotizacionResponse.MontoDesembolso));
|
|
|
|
$.each(JsonCotizacionResponse.SegurosEnCotizacion, function (key, item) {
|
|
|
|
switch (item.RubroSeguro.TipoRubroSeguro.Descripcion.toUpperCase()) {
|
|
case "AUTO":
|
|
$("#lblMontoSegVehiculoResultCot").text(ToMoney(item.Monto));
|
|
break;
|
|
case "DESEMPLEO":
|
|
$("#lblMontoSegDesempleoResultCot").text(ToMoney(item.Monto));
|
|
break;
|
|
case "VIDA":
|
|
$("#lblMontoSegVidaResultCot").text(ToMoney(item.Monto));
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region PlanPagos
|
|
tableItemsPlanPago.clear().draw();
|
|
$.each(JsonCotizacionResponse.planPago, function (key, item) {
|
|
tableItemsPlanPago.row.add([item.Periodo,
|
|
ToMoney(item.SaldoInicial),
|
|
ToMoney(item.PorcentajeInteresMensual),
|
|
ToMoney(item.InteresMensual),
|
|
ToMoney(item.Capital),
|
|
ToMoney(item.Mensualidad),
|
|
ToMoney(item.SaldoFinal)]).draw();
|
|
});
|
|
//#endregion
|
|
|
|
//COndicionesCredito
|
|
$("#txt" + "COndicionesCredito").val(JsonCotizacionResponse.EnunciadoCondiciones);
|
|
|
|
$('#modalResultadoCotizacion').modal('show');
|
|
|
|
$("#btnDetalleCotizacion").attr("style", "display:block");
|
|
$("#btnImprimir").attr("style", "display:block");
|
|
|
|
//Indica que las cotizacion fue cargada
|
|
IsLoadedCotizacion = true;
|
|
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
$("button[type=button]").attr("disabled", false);
|
|
$("#btnDetalleCotizacion").attr("style", "display:none");
|
|
$("#btnImprimir").attr("style", "display:none");
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
$("button[type=button]").attr("disabled", false);
|
|
});
|
|
});
|
|
|
|
$("#btnGuardar").click(function () {
|
|
GuardarDatosCotizacion(false);
|
|
});
|
|
|
|
$('#txtValorAuto').change(function () {
|
|
try {
|
|
|
|
//Indica que las condiciones de la cotizacion estan siendo elegidas/modificadas por el usuario
|
|
IsLoadedCotizacion = false;
|
|
|
|
|
|
if (jQuery.isEmptyObject(infoProgramaCrediticio)) {
|
|
this.value = "0.00";
|
|
toastr.warning("No se han obtenido los parámetros de cotización para relizar los cálculos", Message_Warning);
|
|
return false;
|
|
}
|
|
|
|
var result = calcularPrimaMinimaRequerida($('#txtValorAuto').autoNumeric('get'),
|
|
infoProgramaCrediticio.PorcPrimaMinima,
|
|
null,
|
|
"monto");
|
|
|
|
$('#txtPrimaMinima').autoNumeric('set', result);
|
|
$('#txtMontoPrima').autoNumeric('set', result);
|
|
$('#txtPorcentajePrima').autoNumeric('set', infoProgramaCrediticio.PorcPrimaMinima);
|
|
|
|
} catch (e) {
|
|
$('#txtPrimaMinima').autoNumeric('set', "0");
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
});
|
|
|
|
$('#txtPorcentajePrima').change(function () {
|
|
bError = false;
|
|
try {
|
|
//Indica que las condiciones de la cotizacion estan siendo elegidas/modificadas por el usuario
|
|
IsLoadedCotizacion = false;
|
|
|
|
//Si % Prima Mayor al 100%
|
|
if ($('#txtPorcentajePrima').autoNumeric('get') > 100) {
|
|
toastr.warning("El valor porcentual de la prima no puede ser superior al 100%", Message_Warning);
|
|
bError = true;
|
|
}
|
|
|
|
//Si % Prima Menor a los Previamente Parametrizado
|
|
if (parseFloat($('#txtPorcentajePrima').autoNumeric('get')) < parseFloat(infoProgramaCrediticio.PorcPrimaMinima)) {
|
|
toastr.warning("El valor porcentual de la prima no puede ser inferior al parametrizado para el programa de crédito", Message_Warning);
|
|
bError = true;
|
|
}
|
|
|
|
|
|
if (bError == true) {
|
|
var result = calcularPrimaMinimaRequerida($('#txtValorAuto').autoNumeric('get'),
|
|
infoProgramaCrediticio.PorcPrimaMinima,
|
|
null,
|
|
"monto");
|
|
|
|
$('#txtPrimaMinima').autoNumeric('set', result);
|
|
$('#txtMontoPrima').autoNumeric('set', result);
|
|
$('#txtPorcentajePrima').autoNumeric('set', infoProgramaCrediticio.PorcPrimaMinima);
|
|
return;
|
|
}
|
|
|
|
|
|
var result = calcularPrimaMinimaRequerida($('#txtValorAuto').autoNumeric('get'),
|
|
$('#txtPorcentajePrima').autoNumeric('get'),
|
|
null,
|
|
"monto");
|
|
|
|
$('#txtMontoPrima').autoNumeric('set', result);
|
|
|
|
} catch (e) {
|
|
$('#txtPorcentajePrima').autoNumeric('set', "0")
|
|
$('#txtMontoPrima').autoNumeric('set', "0")
|
|
}
|
|
});
|
|
|
|
$('#txtMontoPrima').change(function () {
|
|
|
|
bError = false;
|
|
try {
|
|
//Indica que las condiciones de la cotizacion estan siendo elegidas/modificadas por el usuario
|
|
IsLoadedCotizacion = false;
|
|
|
|
//Si Monto Prima Mayor a ValorAuto
|
|
if (parseFloat($('#txtMontoPrima').autoNumeric('get')) > parseFloat($('#txtValorAuto').autoNumeric('get'))) {
|
|
toastr.warning("El monto de la prima no puede ser superior al valor del vehículo", Message_Warning);
|
|
bError = true;
|
|
}
|
|
|
|
|
|
//Si Monto Prima Menor a Monto de Prima Minima
|
|
if (parseFloat($('#txtMontoPrima').autoNumeric('get')) < parseFloat($('#txtPrimaMinima').autoNumeric('get'))) {
|
|
toastr.warning("El monto de la prima no puede ser inferior al monto de la prima minima", Message_Warning);
|
|
bError = true;
|
|
}
|
|
|
|
if (bError == true) {
|
|
var result = calcularPrimaMinimaRequerida($('#txtValorAuto').autoNumeric('get'),
|
|
infoProgramaCrediticio.PorcPrimaMinima,
|
|
null,
|
|
"monto");
|
|
|
|
$('#txtPrimaMinima').autoNumeric('set', result);
|
|
$('#txtMontoPrima').autoNumeric('set', result);
|
|
$('#txtPorcentajePrima').autoNumeric('set', infoProgramaCrediticio.PorcPrimaMinima);
|
|
return;
|
|
}
|
|
|
|
|
|
var result = calcularPrimaMinimaRequerida($('#txtValorAuto').autoNumeric('get'),
|
|
null,
|
|
$('#txtMontoPrima').autoNumeric('get'),
|
|
"porcentaje");
|
|
|
|
$('#txtPorcentajePrima').autoNumeric('set', result);
|
|
} catch (e) {
|
|
$('#txtPorcentajePrima').autoNumeric('set', "0")
|
|
$('#txtMontoPrima').autoNumeric('set', "0")
|
|
}
|
|
});
|
|
|
|
$("#chkPolizasAdicionales").change(function () {
|
|
LlenarSeguros(false, false, false);
|
|
});
|
|
|
|
$('#chkSeguroVida').change(function () {
|
|
try {
|
|
var SeguroVida = this.checked;
|
|
LlenarSeguros(SeguroVida, null, null);
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
});
|
|
|
|
$('#chkSeguroDesempleo').change(function () {
|
|
try {
|
|
var SeguroDesempleo = this.checked;
|
|
LlenarSeguros(null, SeguroDesempleo, null);
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
});
|
|
|
|
$('#chkSeguroAuto').change(function () {
|
|
try {
|
|
var SeguroAuto = this.checked;
|
|
LlenarSeguros(null, null, SeguroAuto);
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
});
|
|
|
|
$("#btnBuscar").click(function () {
|
|
|
|
var IsPersonalized = false;
|
|
var filtro = $("#txtDescripcion").val();
|
|
var uri = "";
|
|
var control = "";
|
|
|
|
if (SelectedCatalog == "TipoPrograma") {
|
|
uri = "api/CotizacionAPI/ObtenerProgramaCrediticio?id=" + $("#hiddenCampanna").val() + (filtro == null ? "" : "&filtro=" + filtro);
|
|
control = "TipoPrograma";
|
|
IsPersonalized = true;
|
|
}
|
|
|
|
if (IsPersonalized)
|
|
CargarCatalogo(uri, control);
|
|
else
|
|
CargarDataCatalogo(DireccionAPICatalogo, $("#txtDescripcion").val());
|
|
|
|
});
|
|
|
|
$("#btnImprimir").click(function () {
|
|
Imprimir();
|
|
});
|
|
|
|
$("#btnEnviar").click(function () {
|
|
if (!confirm("¿Enviar?"))
|
|
return;
|
|
GuardarDatosCotizacion(true);
|
|
});
|
|
|
|
|
|
|
|
$('#chkPolizaVehiculoGratis').change(function () {
|
|
try {
|
|
var ConPolizaVehiculoGratis = this.checked;
|
|
|
|
$("#btnPlazoMesesPolizaVehiculoGratis").attr("disabled", !ConPolizaVehiculoGratis);
|
|
|
|
if (ConPolizaVehiculoGratis == false) {
|
|
$("#hiddenPlazoMesesPolizaVehiculoGratis").val('');
|
|
$("#txtPlazoMesesPolizaVehiculoGratis").val('');
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
});
|
|
|
|
//#endregion
|
|
|
|
//#region METODOS
|
|
this.Imprimir = function () {
|
|
try {
|
|
|
|
var colavorador = $("#chkEsColaborador").is(":checked")
|
|
var uri = "";
|
|
var Item = {};
|
|
var date;
|
|
|
|
if (infoProgramaCrediticio.FeCotiza != null) {
|
|
date = new Date(infoProgramaCrediticio.FeCotiza);
|
|
} else {
|
|
date = new Date();
|
|
}
|
|
|
|
var day = date.getDate();
|
|
var month = date.getMonth();
|
|
var year = date.getFullYear();
|
|
var fecha = day + "/" + (month + 1) + "/" + year
|
|
|
|
//#region ImprimirCotizacionAutoUsado
|
|
if (colavorador == false && $("#hiddenTipoAuto").val() == 2) {
|
|
uri = 'api/DocumentosAPI/ImprimirCotizacionAutoUsado/';
|
|
Item = {
|
|
condiciones_credito: $("#txtCOndicionesCredito").val(),
|
|
correo_ejecutivo: $("#txtEmailEjecutivo").val(),
|
|
desglose_cuota_seguro_vehiculo_1: $("#lblSegVehiculo1").text(),
|
|
desglose_cuota_seguro_vehiculo_2: $("#lblSegVehiculo2").text(),
|
|
desglose_cuota_sin_seguros_1: $("#lblCuotaSinSegPer1").text(),
|
|
desglose_cuota_sin_seguros_2: $("#lblCuotaSinSegPer2").text(),
|
|
desglose_cuota_total_1: $("#lblCuotaTotal1").text(),
|
|
desglose_cuota_total_2: $("#lblCuotaTotal2").text(),
|
|
detalles_deducciones_comision: $("#lblMontoComisionResultCot").text(),
|
|
detalles_deducciones_constitucion_prenda: $("#lblMontoConstPrendaResultCot").text(),
|
|
detalles_deducciones_desembolso_neto_ap: $("#lblMontoDesembolsoResultCotizacion").text(),
|
|
detalles_deducciones_seguro_desempleo: $("#lblMontoSegDesempleoResultCot").text(),
|
|
detalles_deducciones_seguro_primer_mes: $("#lblMontoSegVehiculoResultCot").text(),
|
|
detalles_deducciones_total_deducciones: 0.00,
|
|
detalles_deducciones_traspaso: $("#lblMontoTraspasoResultCot").text(),
|
|
ejecutivo: $("#txtNombreEjecutivo").val(),
|
|
fecha: fecha,
|
|
ingreso_requerido_colones: $("#lblIngresoRequeridoCol").text(),
|
|
ingreso_requerido_dolares: $("#lblIngresoRequeridoDol").text(),
|
|
modelo_vehiculo: $("#txtMarca").val(),
|
|
moneda: $("#txtMoneda").val(),
|
|
monto_credito: $("#lblMontoCotizacionResultCot").text(),
|
|
nombre_cliente: $("#txtNombre").val().toLocaleUpperCase() + " " + $("#txtSegundoNombre").val().toLocaleUpperCase() + " " + $("#txtPrimerApellido").val().toLocaleUpperCase() + " " + $("#txtSegundoApellido").val().toLocaleUpperCase(),
|
|
numero_cedula: obtener_identificacion('Identificacion'),
|
|
plazo_meses: $("#txtPlazoMeses").val(),
|
|
poliza_adicionales_desempleo: $("#lblMontoPolizaDesempleo").text(),
|
|
poliza_adicionales_vida: $("#lblMontoPolizaVida").text(),
|
|
prima: $("#txtMontoPrima").val(),
|
|
prima_minima: $("#txtPrimaMinima").val(),
|
|
tabla_pagos: JsonCotizacionResponse.planPago,
|
|
telefono: $("#txtTelefono").val(),
|
|
telefonos: "",
|
|
valor_vehiculo: $("#txtValorAuto").val()
|
|
}
|
|
//#endregion
|
|
|
|
//#region ImprimirCotizacionAutoNuevo
|
|
} else if (colavorador == false && $("#hiddenTipoAuto").val() == 1) {
|
|
uri = 'api/DocumentosAPI/ImprimirCotizacionAutoNuevo/';
|
|
Item = {
|
|
comision: $("#txtPorcComision").val(),
|
|
condiciones_credito: $("#txtCOndicionesCredito").val(),
|
|
correo_ejecutivo: $("#txtEmailEjecutivo").val(),
|
|
desglose_cuota_1: "Año 1",
|
|
desglose_cuota_2: "Año 2",
|
|
desglose_cuota_seguro_vehiculo_1: $("#lblSegVehiculo1").text(),
|
|
desglose_cuota_seguro_vehiculo_2: $("#lblSegVehiculo2").text(),
|
|
desglose_cuota_seguro_vehiculo_3: $("#lblSegVehiculo3").text(),
|
|
desglose_cuota_sin_seguros_1: $("#lblCuotaSinSegPer1").text(),
|
|
desglose_cuota_sin_seguros_2: $("#lblCuotaSinSegPer2").text(),
|
|
desglose_cuota_sin_seguros_3: $("#lblCuotaSinSegPer3").text(),
|
|
desglose_cuota_total_1: $("#lblCuotaTotal1").text(),
|
|
desglose_cuota_total_2: $("#lblCuotaTotal2").text(),
|
|
desglose_cuota_total_3: $("#lblCuotaTotal3").text(),
|
|
detalles_deducciones_comision: $("#lblMontoComisionResultCot").text(),
|
|
detalles_deducciones_desembolso_neto: $("#lblMontoDesembolsoResultCotizacion").text(),
|
|
detalles_deducciones_seguro_vehicuo: $("#lblMontoSegVehiculoResultCot").text(),
|
|
detalles_deducciones_seguros_adicionales: ToMoney(parseFloat($("#lblMontoSegDesempleoResultCot").text()) + parseFloat($("#lblMontoSegVidaResultCot").text())),
|
|
detalles_deducciones_traspaso: $("#lblMontoTraspasoResultCot").text(),
|
|
ejecutivo: $("#txtNombreEjecutivo").val(),
|
|
fecha: fecha,
|
|
ingreso_requerido_colones: $("#lblIngresoRequeridoCol").text(),
|
|
ingreso_requerido_dolares: $("#lblIngresoRequeridoDol").text(),
|
|
modalidad: $("#txtTipoAuto").val(),
|
|
moneda: $("#txtMoneda").val(),
|
|
monto_credito: $("#lblMontoCotizacionResultCot").text(),
|
|
nombre_cliente: $("#txtNombre").val().toLocaleUpperCase() + " " + $("#txtSegundoNombre").val().toLocaleUpperCase() + " " + $("#txtPrimerApellido").val().toLocaleUpperCase() + " " + $("#txtSegundoApellido").val().toLocaleUpperCase(),
|
|
numero_cedula: obtener_identificacion('Identificacion'),
|
|
plazo_meses: $("#txtPlazoMeses").val(),
|
|
poliza_adicionales_desempleo: $("#lblMontoPolizaDesempleo").text(),
|
|
poliza_adicionales_vida: $("#lblMontoPolizaVida").text(),
|
|
prima: $("#txtMontoPrima").val(),
|
|
prima_requerida: $("#txtPrimaMinima").val(),
|
|
programa: $("#txtTipoPrograma").val(),
|
|
tabla_pagos: JsonCotizacionResponse.planPago,
|
|
telefono: $("#txtTelefono").val(),
|
|
telefonos: "",
|
|
prima_minima: $("#txtPrimaMinima").val(),
|
|
valor_vehiculo: $("#txtValorAuto").val()
|
|
}
|
|
//#endregion
|
|
|
|
//#region ImprimirCotizacionAutoUsadoColaborador
|
|
} else if (colavorador == true && $("#hiddenTipoAuto").val() == 2) {
|
|
uri = 'api/DocumentosAPI/ImprimirCotizacionAutoUsadoColaborador/';
|
|
Item = {
|
|
condiciones_credito: $("#txtCOndicionesCredito").val(),
|
|
correo_ejecutivo: $("#txtEmailEjecutivo").val(),
|
|
desglose_cuota_seguro_vehiculo_1: $("#lblSegVehiculo1").text(),
|
|
desglose_cuota_seguro_vehiculo_2: $("#lblSegVehiculo2").text(),
|
|
desglose_cuota_sin_seguros_1: $("#lblCuotaSinSegPer1").text(),
|
|
desglose_cuota_sin_seguros_2: $("#lblCuotaSinSegPer2").text(),
|
|
desglose_cuota_total_1: $("#lblCuotaTotal1").text(),
|
|
desglose_cuota_total_2: $("#lblCuotaTotal2").text(),
|
|
detalles_deducciones_comision: $("#lblMontoComisionResultCot").text(),
|
|
detalles_deducciones_constitucion_prenda: $("#lblMontoConstPrendaResultCot").text(),
|
|
detalles_deducciones_desembolso_neto_ap: $("#lblMontoDesembolsoResultCotizacion").text(),
|
|
detalles_deducciones_seguro_desempleo: $("#lblMontoSegDesempleoResultCot").text(),
|
|
detalles_deducciones_seguro_primer_mes: $("#lblMontoSegVehiculoResultCot").text(),
|
|
detalles_deducciones_total_deducciones: 0.00,
|
|
detalles_deducciones_traspaso: $("#lblMontoTraspasoResultCot").text(),
|
|
ejecutivo: $("#txtNombreEjecutivo").val(),
|
|
fecha: fecha,
|
|
ingreso_requerido_colones: $("#lblIngresoRequeridoCol").text(),
|
|
ingreso_requerido_dolares: $("#lblIngresoRequeridoDol").text(),
|
|
modelo_vehiculo: $("#txtMarca").val(),
|
|
moneda: $("#txtMoneda").val(),
|
|
monto_credito: $("#lblMontoCotizacionResultCot").text(),
|
|
nombre_cliente: $("#txtNombre").val().toLocaleUpperCase() + " " + $("#txtSegundoNombre").val().toLocaleUpperCase() + " " + $("#txtPrimerApellido").val().toLocaleUpperCase() + " " + $("#txtSegundoApellido").val().toLocaleUpperCase(),
|
|
numero_cedula: obtener_identificacion('Identificacion'),
|
|
plazo_meses: $("#txtPlazoMeses").val(),
|
|
poliza_adicionales_desempleo: $("#lblMontoPolizaDesempleo").text(),
|
|
poliza_adicionales_vida: $("#lblMontoPolizaVida").text(),
|
|
prima: $("#txtMontoPrima").val(),
|
|
prima_minima: $("#txtPrimaMinima").val(),
|
|
tabla_pagos: JsonCotizacionResponse.planPago,
|
|
telefono: $("#txtTelefono").val(),
|
|
telefonos: "",
|
|
valor_vehiculo: $("#txtValorAuto").val()
|
|
}
|
|
//#endregion
|
|
|
|
//#region ImprimirCotizacionAutoNuevoColaborador
|
|
} else if (colavorador == true && $("#hiddenTipoAuto").val() == 1) {
|
|
uri = 'api/DocumentosAPI/ImprimirCotizacionAutoNuevoColaborador/';
|
|
Item = {
|
|
comision: $("#txtPorcComision").val(),
|
|
condiciones_credito: $("#txtCOndicionesCredito").val(),
|
|
correo_ejecutivo: $("#txtEmailEjecutivo").val(),
|
|
|
|
desglose_cuota_1: $("#lblCuotaSinSegPer1").text(),
|
|
desglose_cuota_2: $("#lblCuotaSinSegPer2").text(),
|
|
|
|
desglose_cuota_seguro_vehiculo_1: $("#lblSegVehiculo1").text(),
|
|
desglose_cuota_seguro_vehiculo_2: $("#lblSegVehiculo2").text(),
|
|
desglose_cuota_seguro_vehiculo_3: $("#lblSegVehiculo3").text(),
|
|
|
|
desglose_cuota_sin_seguros_1: $("#lblCuotaSinSegPer1").text(),
|
|
desglose_cuota_sin_seguros_2: $("#lblCuotaSinSegPer2").text(),
|
|
desglose_cuota_sin_seguros_3: $("#lblCuotaSinSegPer3").text(),
|
|
|
|
desglose_cuota_total_1: $("#lblCuotaTotal1").text(),
|
|
desglose_cuota_total_2: $("#lblCuotaTotal2").text(),
|
|
desglose_cuota_total_3: $("#lblCuotaTotal3").text(),
|
|
|
|
detalles_deducciones_monto_credito: $("#lblMontoCotizacionResultCot").text(),
|
|
detalles_deducciones_comision: $("#lblMontoComisionResultCot").text(),
|
|
detalles_deducciones_seguro_vehiculo: $("#lblMontoSegVehiculoResultCot").text(),
|
|
detalles_deducciones_seguro_desempleo: $("#lblMontoSegDesempleoResultCot").text(),
|
|
detalles_deducciones_desembolso_neto: $("#lblMontoDesembolsoResultCotizacion").text(),
|
|
|
|
|
|
|
|
detalles_deducciones_seguros_adicionales: ToMoney(parseFloat($("#lblMontoSegDesempleoResultCot").text()) + parseFloat($("#lblMontoSegVidaResultCot").text())),
|
|
detalles_deducciones_traspaso: $("#lblMontoTraspasoResultCot").text(),
|
|
ejecutivo: $("#txtNombreEjecutivo").val(),
|
|
fecha: fecha,
|
|
ingreso_requerido_colones: $("#lblIngresoRequeridoCol").text(),
|
|
ingreso_requerido_dolares: $("#lblIngresoRequeridoDol").text(),
|
|
modalidad: $("#txtTipoAuto").val(),
|
|
moneda: $("#txtMoneda").val(),
|
|
monto_credito: $("#lblMontoCotizacionResultCot").text(),
|
|
nombre_cliente: $("#txtNombre").val().toLocaleUpperCase() + " " + $("#txtSegundoNombre").val().toLocaleUpperCase() + " " + $("#txtPrimerApellido").val().toLocaleUpperCase() + " " + $("#txtSegundoApellido").val().toLocaleUpperCase(),
|
|
numero_cedula: obtener_identificacion('Identificacion'),
|
|
plazo_meses: $("#txtPlazoMeses").val(),
|
|
poliza_adicionales_desempleo: $("#lblMontoPolizaDesempleo").text(),
|
|
poliza_adicionales_vida: $("#lblMontoPolizaVida").text(),
|
|
prima: $("#txtMontoPrima").val(),
|
|
prima_minima: $("#txtPrimaMinima").val(),
|
|
programa: $("#txtTipoPrograma").val(),
|
|
tabla_pagos: JsonCotizacionResponse.planPago,
|
|
telefono: $("#txtTelefono").val(),
|
|
telefonos: "",
|
|
valor_vehiculo: $("#txtValorAuto").val()
|
|
}
|
|
|
|
}
|
|
//#endregion
|
|
|
|
var DTO = JSON.stringify(Item);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: server + uri,
|
|
cache: false,
|
|
data: DTO,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (data != null) {
|
|
if (data.CodigoRespuesta == "EXITOSO")
|
|
window.open(data.url);
|
|
else
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al intentar invocar el metodo de generación del documento para la cotización. Vuelva a intentarlo.");
|
|
}
|
|
}
|
|
|
|
this.GuardarDatosCotizacion = function (enviar) {
|
|
|
|
|
|
try {
|
|
|
|
GetControlsSettings("DatosGeneralesCotizacionGuardar", "DatosGeneralesCotizacion", "formCotizacion", false, false);
|
|
|
|
if (!$("#formCotizacion").valid()) {
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|
return false;
|
|
}
|
|
|
|
|
|
var objSegurosEnCotizacion = JsonCotizacionResponse.SegurosEnCotizacion;
|
|
if (objSegurosEnCotizacion === undefined) {
|
|
objSegurosEnCotizacion = JsonCotizacionResponse.SegurosCotizacion;
|
|
}
|
|
|
|
if (!enviar) {
|
|
if ($("#hiddenCuotaPrestamo").val() === "") {
|
|
toastr.warning(" Debe realizar la cotización, para guardar los cambios.");
|
|
return false;
|
|
}
|
|
} else if (enviar) {
|
|
if ($("#hiddenCuotaPrestamo").val() === "") {
|
|
toastr.warning(" Debe realizar la cotización, para enviar la etapa.");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (IsLoadedCotizacion == false) {
|
|
toastr.warning(" Estimado usuario, se ha detectado que las condiciones de la última cotización han cambiado.<br>Por favor realice nuevamente el cálculo de la cotización.");
|
|
return false;
|
|
}
|
|
|
|
|
|
JsonDatosCotizacion =
|
|
{
|
|
IdCotizacion: $('#hiddensol_co_cotizacion').val(),
|
|
Process: $("#hiddenProcess").val(),
|
|
IdCampanna: $("#hiddenCampanna").val(),
|
|
IdProgramaCrediticio: $("#hiddenTipoPrograma").val(),
|
|
IdAgenciaVehiculo: $("#hiddenAgencia").val(),
|
|
IdSubAgenciaVehiculo: $("#hiddenSubAgencia").val(),
|
|
IdMarcaVehiculo: $("#hiddenMarca").val(),
|
|
IdEstiloVehiculo: $("#hiddenEstilo").val(),
|
|
IdUsoVehiculo: $("#hiddenUsoVehiculo").val(),
|
|
IdMoneda: infoProgramaCrediticio.IdMoneda,
|
|
Moneda: infoProgramaCrediticio.Moneda,
|
|
IdTipoVehiculo: infoProgramaCrediticio.IdTipoVehiculo,
|
|
TipoVehiculo: infoProgramaCrediticio.TipoVehiculo,
|
|
EsColaborador: $("#chkEsColaborador").is(":checked"),
|
|
PorcComision: infoProgramaCrediticio.PorcComision,
|
|
PorcPrimaMinima: infoProgramaCrediticio.PorcPrimaMinima,
|
|
PeriodoMesesCredito: $("#txtPlazoMeses").val(),
|
|
PeriodoMesesGracia: $('#chkPolizaVehiculoGratis').prop('checked') == true ? $("#txtPlazoMesesPolizaVehiculoGratis").val() : 0,
|
|
IdAnnoVehiculo: $("#hiddenAnnoAuto").val(),
|
|
ValorVehiculo: $("#txtValorAuto").autoNumeric('get'),
|
|
TipoCambio: $("#hiddenTasaTipoCambio").val(),
|
|
PorcPrima: $("#txtPorcentajePrima").autoNumeric('get'),
|
|
MontoPrima: $("#txtMontoPrima").autoNumeric('get'),
|
|
MontoComision: JsonCotizacionResponse.MontoComision,
|
|
PorcIngresoMinReq: infoProgramaCrediticio.PorcIngresoMinReq,
|
|
IngresoMinReqCol: JsonCotizacionResponse.IngresogReqCol,
|
|
IngresoMInReqDol: JsonCotizacionResponse.IngresogReqDol,
|
|
IngresoRequeridoColones: JsonCotizacionResponse.IngresogReqCol,
|
|
IngresoRequeridoDolares: JsonCotizacionResponse.IngresogReqDol,
|
|
MontoPrestamo: JsonCotizacionResponse.MontoCredito,
|
|
MontoPrestamoSinSeguros: JsonCotizacionResponse.MontoCreditoSinSeguros,
|
|
MontoDesembolso: JsonCotizacionResponse.MontoDesembolso,
|
|
Identificacion: obtener_identificacion('Identificacion'),
|
|
IdTipoIdentificacion: obtener_tipo_identificacion('Identificacion'),
|
|
PrimerNombre: $("#txtNombre").val(),
|
|
SegundoNombre: $("#txtSegundoNombre").val(),
|
|
PrimerApellido: $("#txtPrimerApellido").val(),
|
|
SegundoApellido: $("#txtSegundoApellido").val(),
|
|
IdFuenteIngreso: $("#hiddenFuenteIngreso").val(),
|
|
Email: $("#txtEmail").val(),
|
|
SeguroAuto: true,
|
|
SeguroDesempleo: $("#chkSeguroDesempleo").prop('checked'),
|
|
SeguroVida: $("#chkSeguroVida").prop('checked'),
|
|
CuotaPrestamo: $("#hiddenCuotaPrestamo").val(),
|
|
CuotaSinSeguroPeriodo1: $("#hiddenCuotaPeriodo1").val(),
|
|
CuotaSinSeguroPeriodo2: $("#hiddenCuotaPeriodo2").val(),
|
|
CuotaSinSeguroPeriodo3: $("#hiddenCuotaPeriodo3").val(),
|
|
MontoTraspaso: JsonCotizacionResponse.MontoTraspaso,
|
|
MontoConstitucionPrenda: JsonCotizacionResponse.MontoConstitucionPrenda,
|
|
IdSucursal: $('#hiddenSucursal').val(),
|
|
SegurosCotizacion: objSegurosEnCotizacion,
|
|
AplicaCompraTasa: infoProgramaCrediticio.AplicaCompraTasa,
|
|
PorcCompraTasa: infoProgramaCrediticio.PorcCompraTasa,
|
|
TipoGracia: infoProgramaCrediticio.TipoGracia,
|
|
IdTipoGracia: infoProgramaCrediticio.IdTipoGracia,
|
|
AplicaPolizaVehiculoGratis: $('#chkPolizaVehiculoGratis').prop('checked'),
|
|
Promocion: $('#hiddenPromocion').val(),
|
|
EjecutivoCotizacion: {
|
|
IdCotizacion: $('#hiddensol_co_cotizacion').val(),
|
|
NombreEjecutivo: $("#txtNombreEjecutivo").val(),
|
|
CodOficial: $("#txtCodOficial").val(),
|
|
LoginEjecutivo: $("#hiddenLoginEjecutivo").val(),
|
|
Telefono: $("#txtTelefono").val(),
|
|
Email: $("#txtEmailEjecutivo").val()
|
|
},
|
|
Garantia: {
|
|
Chasis: $("#txtChasis").val(),
|
|
Motor: $("#txtMotor").val(),
|
|
Placa: $("#txtPlaca").val(),
|
|
Color: $("#txtColor").val(),
|
|
IdTipoTraccion: $("#hiddenTipoTraccion").val(),
|
|
PesoNeto: $("#txtPesoNeto").autoNumeric('get'),
|
|
IdTipoTransmision: $("#hiddenTipoTransmision").val(),
|
|
Cilindrada: $("#txtCilindrada").autoNumeric('get'),
|
|
NumCilindros: $("#txtNumCilindros").autoNumeric('get'),
|
|
IdTipoCombustible: $("#hiddenTipoCombustible").val(),
|
|
Capacidad: $("#txtCapacidad").autoNumeric('get'),
|
|
InscritoANombre: $("#txtInscritoANombre").val(),
|
|
IdCategoriaVehiculo: $("#hiddenCategoriaVehiculo").val(),
|
|
IdCarroceriaVehiculo: $("#hiddenCarroceriaVehiculo").val()
|
|
},
|
|
CondicionesTasaCotizacion: infoProgramaCrediticioCondicionesTasa
|
|
}
|
|
|
|
if (JsonDatosCotizacion.IdTipoIdentificacion == 0) {
|
|
ENDREQUEST();
|
|
toastr.warning("Ingresar el Tipo de Identificación.");
|
|
return false;
|
|
}
|
|
|
|
|
|
var uri = 'api/CotizacionAPI/GuardarDatosCotizacion/';
|
|
var DTO = JSON.stringify(JsonDatosCotizacion);
|
|
|
|
$.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") {
|
|
$('#hiddensol_co_cotizacion').val(data.IdCotizacion);
|
|
if (data.IdSolicitud != 0) {
|
|
LinkSolicitanteVisible(data.IdSolicitud, data.IdCotizacion);
|
|
LinkSolicitudesVisible(data.IdSolicitud, data.IdCotizacion);
|
|
}
|
|
|
|
if (data.Alertas != null) {
|
|
$.each(data.Alertas, function (index, value) {
|
|
toastr.warning(value, Message_Warning);
|
|
});
|
|
}
|
|
|
|
toastr.info('Información guardada con exito', 'Completado');
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
if (enviar)
|
|
|
|
Enviar();
|
|
|
|
|
|
else
|
|
ENDREQUEST();
|
|
});
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al intentar invocar el metodo de guardar. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
|
|
}
|
|
|
|
this.Enviar = function () {
|
|
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: "12",
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val()
|
|
}
|
|
|
|
var uri = 'api/GlobalAPI/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(format("Incidente generado: {0}", data.Incidente));
|
|
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);
|
|
}
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|
|
this.calcularPrimaMinimaRequerida = function (valor, porcentajeTasa, monto, modo) {
|
|
var montoPrimaRequerida = 0;
|
|
try {
|
|
switch (modo.trim().toLowerCase()) {
|
|
case "monto":
|
|
montoPrimaRequerida = parseFloat(valor) * (parseFloat(porcentajeTasa) / 100);
|
|
break;
|
|
case "porcentaje":
|
|
montoPrimaRequerida = (parseFloat(monto) / parseFloat(valor)) * (100);
|
|
break;
|
|
}
|
|
} catch (e) {
|
|
montoPrimaRequerida = 0;
|
|
}
|
|
return montoPrimaRequerida;
|
|
}
|
|
|
|
this.DataCatalogo = function (SelectedCatalog, controlId) {
|
|
|
|
var uri = "";
|
|
var control = "";
|
|
//Setea el controlador para el sub catalogo
|
|
if (SelectedCatalog == "Campanna") {
|
|
uri = "api/CotizacionAPI/ObtenerProgramaCrediticio?id=" + controlId.codigo + "&filtro=";
|
|
control = "TipoPrograma";
|
|
$("#hiddenTipoPrograma").val("");
|
|
$("#txtTipoPrograma").val("");
|
|
}
|
|
$('#btn' + control).off('click');
|
|
$('#btn' + control).click(function () {
|
|
CargarCatalogo(uri, control);
|
|
});
|
|
}
|
|
|
|
this.CargarCatalogo = function (Direccion, control) {
|
|
SelectedCatalog = control;
|
|
var uri = Direccion.trim();
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null) {
|
|
lista = data;
|
|
var Seleccionar = $("#ucBtnSeleccionar").html();
|
|
var columnDefinition = [
|
|
{ "data": null, className: "center", defaultContent: Seleccionar },
|
|
{ "data": "codigo" },
|
|
{ "data": "descripcion" }
|
|
];
|
|
$('#tableCatalogo').TableInit(0, false, true, false, false, columnDefinition, lista);
|
|
if ($.fn.DataTable.isDataTable('#tableCatalogo')) {
|
|
LoadMessage();
|
|
$('#tableCatalogo').DataTable().search('').draw();
|
|
$('#divmodalCatalogo').modal('show');
|
|
ENDREQUEST();
|
|
}
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
ENDREQUEST();
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|
|
this.CargarDataCatalogoAdicional = function (control) {
|
|
var uri = "";
|
|
try {
|
|
|
|
var controlsSeguros = ["RubroSeguroVida", "RubroSeguroDesempleo", "RubroSeguroAuto", "CarroceriaVehiculo", "PlazoMeses"];
|
|
if (jQuery.inArray(control, controlsSeguros) !== -1) {
|
|
|
|
//Indica que las condiciones de la cotizacion estan siendo elegidas/modificadas por el usuario
|
|
IsLoadedCotizacion = false;
|
|
}
|
|
|
|
if (control == "Agencia") {
|
|
$("#hiddenSubAgencia").val("");
|
|
$("#txtSubAgencia").val("");
|
|
}
|
|
|
|
var controls = ["TipoPrograma", "Campanna", "Moneda", "TipoAuto", "AnnoAuto", "EsColaborador"];
|
|
if (jQuery.inArray(control, controls) !== -1) {
|
|
//Indica que las condiciones de la cotizacion estan siendo elegidas/modificadas por el usuario
|
|
IsLoadedCotizacion = false;
|
|
|
|
var id = $("#hiddenTipoPrograma").val().trim();
|
|
var id2 = $("#hiddenCampanna").val().trim();
|
|
var id3 = $("#hiddenMoneda").val().trim();
|
|
var id4 = $("#hiddenTipoAuto").val().trim();
|
|
var id5 = $("#hiddenAnnoAuto").val().trim();
|
|
var id6 = $("#chkEsColaborador").is(":checked");
|
|
//var id7 = $("#txtPlazoMeses").val().trim();
|
|
|
|
var valueIds = [id, id2, id3, id4, id5, id6];
|
|
if (jQuery.inArray("", valueIds) == -1) {
|
|
var uri = "api/CotizacionAPI/ObtenerDetalleProgramaCrediticio?id=" + id +
|
|
"&id2=" + id2 +
|
|
"&id3=" + id3 +
|
|
"&id4=" + id4 +
|
|
"&id5=" + id5 +
|
|
"&id6=" + id6;
|
|
//"&id7=" + id7;
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null && data.length > 0) {
|
|
infoProgramaCrediticio = data[0];
|
|
infoProgramaCrediticioCondicionesTasa = infoProgramaCrediticio.ProgramaCrediticioCondicionesTasaAdapted;
|
|
//infoProgramaCrediticioCondicionesTasa = infoProgramaCrediticio.ProgramaCrediticioCondicionesTasa;
|
|
|
|
//Moneda
|
|
$("#hidden" + "Moneda").val(data[0].IdMoneda);
|
|
$("#txt" + "Moneda").val(data[0].DescripcionMoneda);
|
|
|
|
//TipoAuto
|
|
$("#hidden" + "TipoAuto").val(data[0].IdTipoVehiculo);
|
|
$("#txt" + "TipoAuto").val(data[0].DescripcionTipoVehiculo);
|
|
|
|
//AnnoVehiculo
|
|
$("#hidden" + "AnnoAuto").val(data[0].IdAnnoVehiculo);
|
|
$("#txt" + "AnnoAuto").val(data[0].DescripcionAnnoVehiculo);
|
|
|
|
//Campanna
|
|
$("#hiddenCampanna").val(data[0].IdCampanna);
|
|
$("#txt" + "Campanna").val(data[0].DescripcionCampanna);
|
|
|
|
|
|
|
|
|
|
//PorcComision
|
|
$("#txt" + "PorcComision").autoNumeric('set', data[0].PorcComision);
|
|
|
|
//PorcPrimaMinima
|
|
$("#txt" + "PorcentajePrima").autoNumeric('set', data[0].PorcPrimaMinima);
|
|
|
|
//PlazoMeses
|
|
$("#txt" + "PlazoMeses").val(data[0].PeriodoMesesCredito);
|
|
|
|
//TasaInteres
|
|
$("#txt" + "TasaInteres").autoNumeric('set', data[0].PeriodoMesesCredito);
|
|
|
|
//PlazoMesesPolizaVehiculoGratis
|
|
$("#hidden" + "PlazoMesesPolizaVehiculoGratis").val('');
|
|
$("#txt" + "PlazoMesesPolizaVehiculoGratis").val('');
|
|
|
|
//COndicionesCredito
|
|
$("#txt" + "COndicionesCredito").val(data[0].EnunciadoCondiciones);
|
|
|
|
//Promocion
|
|
$('#hiddenPromocion').val(data[0].Promocion);
|
|
|
|
var columnDefinition = [
|
|
{ "data": "Periodo" },
|
|
{ "data": "PlazoMeses" },
|
|
{ "data": "DescripcionTipoTasa" },
|
|
{ "data": "DescripcionTipoTasaReferencia" },
|
|
{ "data": "TasaInteresFinal" },
|
|
{ "data": "TasaMinima" },
|
|
{ "data": "DescripcionPeriodoReajuste" }
|
|
];
|
|
|
|
$('#TableItemsCondicionesTasa').TableInit(0, false, true, false, false, columnDefinition, infoProgramaCrediticioCondicionesTasa);
|
|
|
|
toastr.info("Las condiciones de crédito fueron obtenidas satisfatoriamente.", "Cotizacion");
|
|
|
|
|
|
//Valida los controles del formulario
|
|
$("#formCotizacion").valid();
|
|
}
|
|
else {
|
|
infoProgramaCrediticio = {};
|
|
infoProgramaCrediticioCondicionesTasa = {};
|
|
tableItemsCondicionesTasa.clear().draw();
|
|
toastr.warning("No existen condiciones definidas para los parametros seleccionado", Message_Warning);
|
|
return false;
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
ENDREQUEST();
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}).then(function (value) {
|
|
if (typeof getDataModel !== 'undefined' && $.isFunction(getDataModel)) {
|
|
if (DataModel == true) {
|
|
getDataModel();
|
|
ENDREQUEST();
|
|
}
|
|
else
|
|
ENDREQUEST();
|
|
}
|
|
else {
|
|
ENDREQUEST();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
|
|
this.getDataModel = function () {
|
|
CargarDefaultPolizasAdicionales();
|
|
}
|
|
|
|
this.CargarDefaultPolizasAdicionales = function () {
|
|
LoadMessage();
|
|
var uri = 'api/CotizacionAPI/CargarDefaultPolizasAdicionales';
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null) {
|
|
$("#hiddenRequeridoSeguroVida").val(data.SeguroVida);
|
|
$("#hiddenRequeridoSeguroDesempleo").val(data.SeguroDesempleo);
|
|
$("#hiddenRequeridoSeguroAuto").val(data.SeguroAuto);
|
|
$.each(data.SegurosCotizacion, function (key, item) {
|
|
switch (item.RubroSeguro.TipoRubroSeguro.Descripcion.trim()) {
|
|
case "AUTO":
|
|
$("#hiddenDefaultSeguroAutoId").val(item.RubroSeguro.IdRubroSeguro);
|
|
$("#hiddenDefaultSeguroAutoDesc").val(item.RubroSeguro.Descripcion);
|
|
break;
|
|
case "VIDA":
|
|
$("#hiddenDefaultSeguroVidaId").val(item.RubroSeguro.IdRubroSeguro);
|
|
$("#hiddenDefaultSeguroVidaDesc").val(item.RubroSeguro.Descripcion);
|
|
break;
|
|
case "DESEMPLEO":
|
|
$("#hiddenDefaultSeguroDesempleoId").val(item.RubroSeguro.IdRubroSeguro);
|
|
$("#hiddenDefaultSeguroDesempleoDesc").val(item.RubroSeguro.Descripcion);
|
|
break;
|
|
}
|
|
});
|
|
|
|
if ($('#hiddensol_co_cotizacion').val() == 0)
|
|
LlenarSeguros(data.SeguroVida, data.SeguroDesempleo, data.SeguroAuto);
|
|
else
|
|
CargarCotizacion();
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|
|
this.LlenarSeguros = function (SeguroVida, SeguroDesempleo, SeguroAuto) {
|
|
|
|
//Indica que las condiciones de la cotizacion estan siendo elegidas/modificadas por el usuario
|
|
IsLoadedCotizacion = false;
|
|
|
|
|
|
var PolizasAdicionales = $("#chk" + "PolizasAdicionales").prop('checked');
|
|
|
|
var idMoneda = $('#hiddenMoneda').val();
|
|
var montoCredito = 0;
|
|
if ($('#lblMontoCotizacionResultCot').val() == "")
|
|
montoCredito = $('#txtValorAuto').autoNumeric('get') - $('#txtMontoPrima').autoNumeric('get');//Es un aproximado, ya que aun no se ha calculado el prestamo
|
|
else
|
|
montoCredito = parseFloat($('#lblMontoCotizacionResultCot').val());
|
|
var DefaultLimiteCredito = parseFloat($('#hiddenDefaultLimiteCredito').val());
|
|
var DefaultLimiteCreditoIdMoneda = $('#hiddenDefaultLimiteCreditoIdMoneda').val();
|
|
|
|
|
|
//#region SeguroVida
|
|
if (SeguroVida != null) {
|
|
var requerido = $("#hiddenRequeridoSeguroVida").val();
|
|
if (requerido == "true") {
|
|
if ($("#hidden" + "RubroSeguroVida").val() == "") {
|
|
$("#chk" + "SeguroVida").attr("disabled", true);
|
|
$("#chk" + "SeguroVida").attr("checked", true);
|
|
$("#btn" + "RubroSeguroVida").attr("disabled", false);
|
|
|
|
if (idMoneda == DefaultLimiteCreditoIdMoneda && montoCredito >= DefaultLimiteCredito) {
|
|
$("#hidden" + "RubroSeguroVida").val($('#hiddenDefaultLimiteCreditoIdRubroVida').val());
|
|
$("#txt" + "RubroSeguroVida").val($('#hiddenDefaultLimiteCreditoDescRubroVida').val());
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroVida").val($("#hiddenDefaultSeguroVidaId").val());
|
|
$("#txt" + "RubroSeguroVida").val($("#hiddenDefaultSeguroVidaDesc").val());
|
|
}
|
|
|
|
$("#txt" + "RubroSeguroVida").attr("required", true);
|
|
}
|
|
}
|
|
else {
|
|
if (PolizasAdicionales) {
|
|
$("#chk" + "SeguroVida").attr("disabled", false);
|
|
$("#chk" + "SeguroVida").attr("checked", SeguroVida);
|
|
$("#btn" + "RubroSeguroVida").attr("disabled", !SeguroVida);
|
|
if (SeguroVida) {
|
|
if (idMoneda == DefaultLimiteCreditoIdMoneda && montoCredito >= DefaultLimiteCredito) {
|
|
$("#hidden" + "RubroSeguroVida").val($('#hiddenDefaultLimiteCreditoIdRubroVida').val());
|
|
$("#txt" + "RubroSeguroVida").val($('#hiddenDefaultLimiteCreditoDescRubroVida').val());
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroVida").val($("#hiddenDefaultSeguroVidaId").val());
|
|
$("#txt" + "RubroSeguroVida").val($("#hiddenDefaultSeguroVidaDesc").val());
|
|
}
|
|
$("#txt" + "RubroSeguroVida").attr("required", true);
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroVida").val("");
|
|
$("#txt" + "RubroSeguroVida").val("");
|
|
$("#txt" + "RubroSeguroVida").attr("required", false);
|
|
}
|
|
}
|
|
else {
|
|
$("#chk" + "SeguroVida").attr("disabled", true);
|
|
$("#chk" + "SeguroVida").attr("checked", false);
|
|
$("#btn" + "RubroSeguroVida").attr("disabled", true);
|
|
$("#hidden" + "RubroSeguroVida").val("");
|
|
$("#txt" + "RubroSeguroVida").val("");
|
|
$("#txt" + "RubroSeguroVida").attr("required", false);
|
|
}
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//#region SeguroDesempleo
|
|
if (SeguroDesempleo != null) {
|
|
var requerido = $("#hiddenRequeridoSeguroDesempleo").val();
|
|
if (requerido == "true") {
|
|
if ($("#hidden" + "RubroSeguroDesempleo").val() == "") {
|
|
$("#chk" + "SeguroDesempleo").attr("disabled", true);
|
|
$("#chk" + "SeguroDesempleo").attr("checked", true);
|
|
$("#btn" + "RubroSeguroDesempleo").attr("disabled", false);
|
|
|
|
if (idMoneda == DefaultLimiteCreditoIdMoneda && montoCredito >= DefaultLimiteCredito) {
|
|
$("#hidden" + "RubroSeguroDesempleo").val($('#hiddenDefaultLimiteCreditoIdRubroDesempleo').val());
|
|
$("#txt" + "RubroSeguroDesempleo").val($('#hiddenDefaultLimiteCreditoDescRubroDesempleo').val());
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroDesempleo").val($("#hiddenDefaultSeguroDesempleoId").val());
|
|
$("#txt" + "RubroSeguroDesempleo").val($("#hiddenDefaultSeguroDesempleoDesc").val());
|
|
}
|
|
|
|
$("#txt" + "RubroSeguroDesempleo").attr("required", true);
|
|
}
|
|
}
|
|
else {
|
|
if (PolizasAdicionales) {
|
|
$("#chk" + "SeguroDesempleo").attr("disabled", false);
|
|
$("#chk" + "SeguroDesempleo").attr("checked", SeguroDesempleo);
|
|
$("#btn" + "RubroSeguroDesempleo").attr("disabled", !SeguroDesempleo);
|
|
if (SeguroDesempleo) {
|
|
if (idMoneda == DefaultLimiteCreditoIdMoneda && montoCredito >= DefaultLimiteCredito) {
|
|
$("#hidden" + "RubroSeguroDesempleo").val($('#hiddenDefaultLimiteCreditoIdRubroDesempleo').val());
|
|
$("#txt" + "RubroSeguroDesempleo").val($('#hiddenDefaultLimiteCreditoDescRubroDesempleo').val());
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroDesempleo").val($("#hiddenDefaultSeguroDesempleoId").val());
|
|
$("#txt" + "RubroSeguroDesempleo").val($("#hiddenDefaultSeguroDesempleoDesc").val());
|
|
}
|
|
$("#txt" + "RubroSeguroDesempleo").attr("required", true);
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroDesempleo").val("");
|
|
$("#txt" + "RubroSeguroDesempleo").val("");
|
|
$("#txt" + "RubroSeguroDesempleo").attr("required", false);
|
|
}
|
|
}
|
|
else {
|
|
$("#chk" + "SeguroDesempleo").attr("disabled", true);
|
|
$("#chk" + "SeguroDesempleo").attr("checked", false);
|
|
$("#btn" + "RubroSeguroDesempleo").attr("disabled", true);
|
|
$("#hidden" + "RubroSeguroDesempleo").val("");
|
|
$("#txt" + "RubroSeguroDesempleo").val("");
|
|
$("#txt" + "RubroSeguroDesempleo").attr("required", false);
|
|
}
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//#region SeguroAuto
|
|
if (SeguroAuto != null) {
|
|
var requerido = $("#hiddenRequeridoSeguroAuto").val();
|
|
if (requerido == "true") {
|
|
if ($("#hidden" + "RubroSeguroAuto").val() == "") {
|
|
$("#chk" + "SeguroAuto").attr("disabled", true);
|
|
$("#chk" + "SeguroAuto").attr("checked", true);
|
|
$("#btn" + "RubroSeguroAuto").attr("disabled", false);
|
|
$("#hidden" + "RubroSeguroAuto").val($("#hiddenDefaultSeguroAutoId").val());
|
|
$("#txt" + "RubroSeguroAuto").val($("#hiddenDefaultSeguroAutoDesc").val());
|
|
$("#txt" + "RubroSeguroAuto").attr("required", true);
|
|
}
|
|
}
|
|
else {
|
|
if (PolizasAdicionales) {
|
|
$("#chk" + "SeguroAuto").attr("disabled", false);
|
|
$("#chk" + "SeguroAuto").attr("checked", SeguroAuto);
|
|
$("#btn" + "RubroSeguroAuto").attr("disabled", !SeguroAuto);
|
|
if (SeguroAuto) {
|
|
$("#hidden" + "RubroSeguroAuto").val($("#hiddenDefaultSeguroAutoId").val());
|
|
$("#txt" + "RubroSeguroAuto").val($("#hiddenDefaultSeguroAutoDesc").val());
|
|
$("#txt" + "RubroSeguroAuto").attr("required", true);
|
|
}
|
|
else {
|
|
$("#hidden" + "RubroSeguroAuto").val("");
|
|
$("#txt" + "RubroSeguroAuto").val("");
|
|
$("#txt" + "RubroSeguroAuto").attr("required", false);
|
|
}
|
|
}
|
|
else {
|
|
$("#chk" + "SeguroAuto").attr("disabled", true);
|
|
$("#chk" + "SeguroAuto").attr("checked", false);
|
|
$("#btn" + "RubroSeguroAuto").attr("disabled", true);
|
|
$("#hidden" + "RubroSeguroAuto").val("");
|
|
$("#txt" + "RubroSeguroAuto").val("");
|
|
$("#txt" + "RubroSeguroAuto").attr("required", false);
|
|
}
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
$("#formCotizacion").valid();
|
|
}
|
|
|
|
this.CargarCotizacion = function () {
|
|
LoadMessage();
|
|
var uri = 'api/CotizacionAPI/BusquedaCotizacionPorId?IdCotizacion=' + $('#hiddensol_co_cotizacion').val();
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null) {
|
|
|
|
infoProgramaCrediticio = data;
|
|
JsonCotizacionResponse = data;
|
|
infoProgramaCrediticioCondicionesTasa = infoProgramaCrediticio.CondicionesTasaCotizacionAdapted;
|
|
|
|
//TipoIdentificacion
|
|
impostar_tipo_identificacion('Identificacion', infoProgramaCrediticio.IdTipoIdentificacion);
|
|
|
|
//Identificacion
|
|
impostar_identificacion('Identificacion', infoProgramaCrediticio.Identificacion);
|
|
|
|
//PrimerNombre
|
|
$("#txt" + "Nombre").val(infoProgramaCrediticio.PrimerNombre);
|
|
|
|
//SegundoNombre
|
|
$("#txt" + "SegundoNombre").val(infoProgramaCrediticio.SegundoNombre);
|
|
|
|
//PrimerApellido
|
|
$("#txt" + "PrimerApellido").val(infoProgramaCrediticio.PrimerApellido);
|
|
|
|
//SegundoApellido
|
|
$("#txt" + "SegundoApellido").val(infoProgramaCrediticio.SegundoApellido);
|
|
|
|
//FuenteIngreso
|
|
$("#hidden" + "FuenteIngreso").val(infoProgramaCrediticio.IdFuenteIngreso);
|
|
$("#txt" + "FuenteIngreso").val(infoProgramaCrediticio.DescripcionTipoFuenteIngreso);
|
|
|
|
//Email
|
|
$("#txt" + "Email").val(infoProgramaCrediticio.Email);
|
|
|
|
//PolizaVehiculoGratis
|
|
$("#chk" + "PolizaVehiculoGratis").attr("checked", infoProgramaCrediticio.AplicaPolizaVehiculoGratis != true ? false : true);
|
|
|
|
//PlazoMesesPolizaVehiculoGratis
|
|
$("#hidden" + "PlazoMesesPolizaVehiculoGratis").val(infoProgramaCrediticio.PeriodoMesesGracia == 0 ? '' : infoProgramaCrediticio.PeriodoMesesGracia);
|
|
$("#txt" + "PlazoMesesPolizaVehiculoGratis").val(infoProgramaCrediticio.PeriodoMesesGracia == 0 ? '' : infoProgramaCrediticio.PeriodoMesesGracia);
|
|
$("#chkPolizaVehiculoGratis").change();
|
|
|
|
//EjecutivoCotizacion
|
|
if (infoProgramaCrediticio.EjecutivoCotizacion != null) {
|
|
$("#txt" + "NombreEjecutivo").val(infoProgramaCrediticio.EjecutivoCotizacion.NombreEjecutivo);
|
|
$("#hiddenLoginEjecutivo").val(infoProgramaCrediticio.EjecutivoCotizacion.LoginEjecutivo)
|
|
$("#txt" + "EmailEjecutivo").val(infoProgramaCrediticio.EjecutivoCotizacion.Email);
|
|
$("#txt" + "CodOficial").val(infoProgramaCrediticio.EjecutivoCotizacion.CodOficial);
|
|
$("#txt" + "Telefono").val(infoProgramaCrediticio.EjecutivoCotizacion.Telefono);
|
|
}
|
|
|
|
//Sucursal
|
|
$("#hidden" + "Sucursal").val(infoProgramaCrediticio.IdSucursal);
|
|
$("#txt" + "Sucursal").val(infoProgramaCrediticio.DescripcionSucursal);
|
|
|
|
//Campanna
|
|
$("#hidden" + "Campanna").val(infoProgramaCrediticio.IdCampanna);
|
|
$("#txt" + "Campanna").val(infoProgramaCrediticio.DescripcionCampanna);
|
|
|
|
DataCatalogo("Campanna", { codigo: infoProgramaCrediticio.IdCampanna });
|
|
|
|
//ProgramaCrediticio
|
|
$("#hidden" + "TipoPrograma").val(infoProgramaCrediticio.IdProgramaCrediticio);
|
|
$("#txt" + "TipoPrograma").val(infoProgramaCrediticio.DescripcionProgramaCrediticio);
|
|
|
|
//Moneda
|
|
$("#hidden" + "Moneda").val(infoProgramaCrediticio.IdMoneda);
|
|
$("#txt" + "Moneda").val(infoProgramaCrediticio.DescripcionMoneda);
|
|
|
|
//TipoAuto
|
|
$("#hidden" + "TipoAuto").val(infoProgramaCrediticio.IdTipoVehiculo);
|
|
$("#txt" + "TipoAuto").val(infoProgramaCrediticio.DescripcionTipoVehiculo);
|
|
|
|
//AnnoVehiculo
|
|
$("#hidden" + "AnnoAuto").val(infoProgramaCrediticio.IdAnnoVehiculo);
|
|
$("#txt" + "AnnoAuto").val(infoProgramaCrediticio.DescripcionAnnoVehiculo);
|
|
|
|
//EsColaborador
|
|
$("#chk" + "EsColaborador").attr("checked", infoProgramaCrediticio.EsColaborador);
|
|
|
|
//ValorAuto
|
|
$("#txt" + "ValorAuto").autoNumeric('set', infoProgramaCrediticio.ValorVehiculo);
|
|
|
|
//PorcComision
|
|
$("#txt" + "PorcComision").autoNumeric('set', infoProgramaCrediticio.PorcComision);
|
|
|
|
//PlazoMeses
|
|
$("#txt" + "PlazoMeses").val(infoProgramaCrediticio.PeriodoMesesCredito);
|
|
|
|
//Promocion
|
|
$('#hiddenPromocion').val(infoProgramaCrediticio.Promocion);
|
|
|
|
//MontoPrima
|
|
$("#txt" + "MontoPrima").autoNumeric('set', infoProgramaCrediticio.MontoPrima);
|
|
|
|
//PorcentajePrima
|
|
$("#txt" + "PorcentajePrima").autoNumeric('set', infoProgramaCrediticio.PorcPrima);
|
|
|
|
//PrimaMinima
|
|
var result = calcularPrimaMinimaRequerida(infoProgramaCrediticio.ValorVehiculo,
|
|
infoProgramaCrediticio.PorcPrimaMinima,
|
|
null,
|
|
"monto");
|
|
|
|
$("#txt" + "PrimaMinima").autoNumeric('set', result);
|
|
|
|
$("#lblMontoCotizacionResultCot").text(ToMoney(infoProgramaCrediticio.MontoPrestamo));
|
|
$("#lblMontoTraspasoResultCot").text(ToMoney(infoProgramaCrediticio.MontoTraspaso));
|
|
$("#lblMontoConstPrendaResultCot").text(ToMoney(infoProgramaCrediticio.MontoConstitucionPrenda));
|
|
$("#lblMontoComisionResultCot").text(ToMoney(infoProgramaCrediticio.MontoComision));
|
|
$("#lblMontoDesembolsoResultCotizacion").text(ToMoney(infoProgramaCrediticio.MontoDesembolso));
|
|
|
|
$("#lblCuotaSinSegPer1").text(ToMoney(infoProgramaCrediticio.CuotaSinSeguroPeriodo1));
|
|
$("#lblCuotaSinSegPer2").text(ToMoney(infoProgramaCrediticio.CuotaSinSeguroPeriodo2));
|
|
$("#lblCuotaSinSegPer3").text(ToMoney(infoProgramaCrediticio.CuotaSinSeguroPeriodo3));
|
|
|
|
var segVida = 0;
|
|
var segVehiculo = 0;
|
|
var segDesempleo = 0;
|
|
|
|
//PolizasAdicionales
|
|
$("#chk" + "PolizasAdicionales").attr("checked", false);
|
|
$("#chk" + "SeguroDesempleo").attr("disabled", true);
|
|
$("#chk" + "SeguroVida").attr("disabled", true);
|
|
$("#chk" + "SeguroAuto").attr("disabled", true);
|
|
if (infoProgramaCrediticio.SegurosCotizacion != null && infoProgramaCrediticio.SegurosCotizacion.length > 0) {
|
|
$.each(infoProgramaCrediticio.SegurosCotizacion, function (key, item) {
|
|
switch (item.RubroSeguro.TipoRubroSeguro.Descripcion.trim()) {
|
|
case "AUTO":
|
|
segVehiculo = item.Monto;
|
|
$("#lblSegVehiculo1").text(ToMoney(item.Monto));
|
|
$("#lblSegVehiculo2").text(ToMoney(item.Monto));
|
|
$("#lblSegVehiculo3").text(ToMoney(item.Monto));
|
|
$("#lblMontoSegVehiculoResultCot").text(ToMoney(item.Monto));
|
|
$("#chk" + "SeguroAuto").attr("checked", true);
|
|
$("#btn" + "RubroSeguroAuto").attr("disabled", false);
|
|
$("#hidden" + "RubroSeguroAuto").val(item.RubroSeguro.IdRubroSeguro);
|
|
$("#txt" + "RubroSeguroAuto").val(item.RubroSeguro.Descripcion);
|
|
if ($("#hiddenRequeridoSeguroAuto").val() == "false")
|
|
$("#chk" + "PolizasAdicionales").attr("checked", true);
|
|
break;
|
|
case "VIDA":
|
|
segVida = item.Monto;
|
|
$("#lblMontoSegVidaResultCot").text(ToMoney(item.Monto));
|
|
$("#chk" + "SeguroVida").attr("checked", true);
|
|
$("#btn" + "RubroSeguroVida").attr("disabled", false);
|
|
$("#hidden" + "RubroSeguroVida").val(item.RubroSeguro.IdRubroSeguro);
|
|
$("#txt" + "RubroSeguroVida").val(item.RubroSeguro.Descripcion);
|
|
if ($("#hiddenRequeridoSeguroVida").val() == "false")
|
|
$("#chk" + "PolizasAdicionales").attr("checked", true);
|
|
break;
|
|
case "DESEMPLEO":
|
|
segDesempleo = item.Monto;
|
|
$("#lblMontoSegDesempleoResultCot").text(ToMoney(item.Monto));
|
|
$("#chk" + "SeguroDesempleo").attr("checked", true);
|
|
$("#btn" + "RubroSeguroDesempleo").attr("disabled", false);
|
|
$("#hidden" + "RubroSeguroDesempleo").val(item.RubroSeguro.IdRubroSeguro);
|
|
$("#txt" + "RubroSeguroDesempleo").val(item.RubroSeguro.Descripcion);
|
|
if ($("#hiddenRequeridoSeguroDesempleo").val() == "false")
|
|
$("#chk" + "PolizasAdicionales").attr("checked", true);
|
|
break;
|
|
}
|
|
});
|
|
if ($("#chk" + "PolizasAdicionales").prop("checked")) {
|
|
$("#chk" + "SeguroDesempleo").attr("disabled", $("#hiddenRequeridoSeguroDesempleo").val() == "true");
|
|
$("#chk" + "SeguroVida").attr("disabled", $("#hiddenRequeridoSeguroVida").val() == "true");
|
|
$("#chk" + "SeguroAuto").attr("disabled", $("#hiddenRequeridoSeguroAuto").val() == "true");
|
|
}
|
|
}
|
|
|
|
$("#lblCuotaTotal1").text(ToMoney(infoProgramaCrediticio.CuotaSinSeguroPeriodo1 + segVehiculo + segVida + segDesempleo));
|
|
$("#lblCuotaTotal2").text(ToMoney(infoProgramaCrediticio.CuotaSinSeguroPeriodo2 + segVehiculo + segVida + segDesempleo));
|
|
$("#lblCuotaTotal3").text(ToMoney(infoProgramaCrediticio.CuotaSinSeguroPeriodo3 + segVehiculo + segVida + segDesempleo));
|
|
|
|
$("#lblIngresoRequeridoCol").text(ToMoney(infoProgramaCrediticio.IngresoMinReqCol));
|
|
$("#lblIngresoRequeridoDol").text(ToMoney(infoProgramaCrediticio.IngresoMInReqDol));
|
|
$("#lblTipoCambioDol").text(ToMoney(infoProgramaCrediticio.TipoCambio));
|
|
|
|
//CondicionesCredito
|
|
$("#txt" + "COndicionesCredito").val(infoProgramaCrediticio.EnunciadoCondiciones);
|
|
|
|
//AgenciaVehiculo
|
|
$("#hidden" + "Agencia").val(infoProgramaCrediticio.IdAgenciaVehiculo);
|
|
$("#txt" + "Agencia").val(infoProgramaCrediticio.DescripcionAgenciaVehiculo);
|
|
|
|
|
|
//SubAgenciaVehiculo
|
|
$("#hidden" + "SubAgencia").val(infoProgramaCrediticio.IdSubAgenciaVehiculo);
|
|
$("#txt" + "SubAgencia").val(infoProgramaCrediticio.DescripcionSubAgenciaVehiculo);
|
|
|
|
//MarcaVehiculo
|
|
$("#hidden" + "Marca").val(infoProgramaCrediticio.IdMarcaVehiculo);
|
|
$("#txt" + "Marca").val(infoProgramaCrediticio.DescripcionMarcaVehiculo);
|
|
|
|
//EstiloVehiculo
|
|
$("#hidden" + "Estilo").val(infoProgramaCrediticio.IdEstiloVehiculo);
|
|
$("#txt" + "Estilo").val(infoProgramaCrediticio.DescripcionEstiloVehiculo);
|
|
|
|
//UsoVehiculo
|
|
$("#hidden" + "UsoVehiculo").val(infoProgramaCrediticio.IdUsoVehiculo);
|
|
$("#txt" + "UsoVehiculo").val(infoProgramaCrediticio.DescripcionUsoVehiculo);
|
|
|
|
//CuotaSinSeguro
|
|
$("#hiddenCuotaPeriodo1").val(infoProgramaCrediticio.CuotaSinSeguroPeriodo1);
|
|
$("#hiddenCuotaPeriodo2").val(infoProgramaCrediticio.CuotaSinSeguroPeriodo2);
|
|
$("#hiddenCuotaPeriodo3").val(infoProgramaCrediticio.CuotaSinSeguroPeriodo3);
|
|
|
|
var infoGarantia = infoProgramaCrediticio.Garantia;
|
|
if (infoGarantia != null && infoGarantia != undefined) {
|
|
$("#txtChasis").val(infoGarantia.Chasis);
|
|
|
|
$("#txtMotor").val(infoGarantia.Motor);
|
|
|
|
$("#txtPlaca").val(infoGarantia.Placa);
|
|
|
|
$("#txtColor").val(infoGarantia.Color);
|
|
|
|
if (infoGarantia.TipoTraccion != null) {
|
|
$("#hiddenTipoTraccion").val(infoGarantia.IdTipoTraccion);
|
|
$("#txtTipoTraccion").val(infoGarantia.TipoTraccion.Descripcion);
|
|
}
|
|
|
|
$("#txtPesoNeto").val(infoGarantia.PesoNeto);
|
|
|
|
if (infoGarantia.TipoTransmision != null) {
|
|
$("#hiddenTipoTransmision").val(infoGarantia.IdTipoTransmision);
|
|
$("#txtTipoTransmision").val(infoGarantia.TipoTransmision.Descripcion);
|
|
}
|
|
|
|
$("#txtCilindrada").val(infoGarantia.Cilindrada);
|
|
|
|
$("#txtNumCilindros").val(infoGarantia.NumCilindros);
|
|
|
|
if (infoGarantia.TipoCombustible != null) {
|
|
$("#hiddenTipoCombustible").val(infoGarantia.IdTipoCombustible);
|
|
$("#txtTipoCombustible").val(infoGarantia.TipoCombustible.Descripcion);
|
|
}
|
|
|
|
$("#txtCapacidad").val(infoGarantia.Capacidad);
|
|
|
|
$("#txtInscritoANombre").val(infoGarantia.InscritoANombre);
|
|
|
|
if (infoGarantia.CategoriaVehiculo != null) {
|
|
$("#hiddenCategoriaVehiculo").val(infoGarantia.IdCategoriaVehiculo);
|
|
$("#txtCategoriaVehiculo").val(infoGarantia.CategoriaVehiculo.Descripcion);
|
|
}
|
|
|
|
if (infoGarantia.CarroceriaVehiculo != null) {
|
|
$("#hiddenCarroceriaVehiculo").val(infoGarantia.IdCarroceriaVehiculo);
|
|
$("#txtCarroceriaVehiculo").val(infoGarantia.CarroceriaVehiculo.Descripcion);
|
|
}
|
|
}
|
|
|
|
//Se llena el objeto JsonCotizacionResponse
|
|
$("#hiddenCuotaPrestamo").val(infoProgramaCrediticio.CuotaPrestamo);
|
|
JsonCotizacionResponse.CuotaPrestamo = infoProgramaCrediticio.CuotaPrestamo;
|
|
JsonCotizacionResponse.MontoComision = infoProgramaCrediticio.MontoComision;
|
|
JsonCotizacionResponse.IngresogReqCol = infoProgramaCrediticio.IngresoMinReqCol;
|
|
JsonCotizacionResponse.IngresogReqDol = infoProgramaCrediticio.IngresoMInReqDol;
|
|
JsonCotizacionResponse.MontoCredito = infoProgramaCrediticio.MontoPrestamo;
|
|
JsonCotizacionResponse.MontoCreditoSinSeguros = infoProgramaCrediticio.MontoPrestamoSinSeguros;
|
|
JsonCotizacionResponse.MontoDesembolso = infoProgramaCrediticio.MontoDesembolso;
|
|
JsonCotizacionResponse.MontoTraspaso = infoProgramaCrediticio.MontoTraspaso;
|
|
JsonCotizacionResponse.MontoConstitucionPrenda = infoProgramaCrediticio.MontoConstitucionPrenda;
|
|
|
|
//CondicionesTasa
|
|
tableItemsCondicionesTasa.clear().draw();
|
|
var columnDefinition = [
|
|
{ "data": "Periodo" },
|
|
{ "data": "PlazoMeses" },
|
|
{ "data": "DescripcionTipoTasa" },
|
|
{ "data": "DescripcionTipoTasaReferencia" },
|
|
{ "data": "TasaInteresFinal" },
|
|
{ "data": "TasaMinima" },
|
|
{ "data": "DescripcionPeriodoReajuste" }
|
|
];
|
|
|
|
$('#TableItemsCondicionesTasa').TableInit(0, false, true, false, false, columnDefinition, infoProgramaCrediticioCondicionesTasa);
|
|
|
|
if (infoProgramaCrediticio.IdSolicitud != 0) {
|
|
LinkSolicitanteVisible(infoProgramaCrediticio.IdSolicitud, infoProgramaCrediticio.IdCotizacion);
|
|
LinkSolicitudesVisible(infoProgramaCrediticio.IdSolicitud, infoProgramaCrediticio.IdCotizacion);
|
|
}
|
|
|
|
//Valida los controles del formulario
|
|
$("#formCotizacion").valid();
|
|
|
|
//Indica que las condiciones de cotizacion no tiene cambios(son las últimas)
|
|
IsLoadedCotizacion = true;
|
|
}
|
|
else {
|
|
infoProgramaCrediticio = {};
|
|
infoProgramaCrediticioCondicionesTasa = {};
|
|
tableItemsCondicionesTasa.clear().draw();
|
|
toastr.warning("No fue posible obtener la información de la cotización seleccionada", Message_Warning);
|
|
|
|
//Indica que las condiciones de la cotizacion no son las correcta
|
|
IsLoadedCotizacion = false;
|
|
return false;
|
|
}
|
|
|
|
if ($("#hiddenTaskStatus").val() == "3") {
|
|
FormReadOnly();
|
|
$("button[direccion_api]").remove();
|
|
$("#btnGuardar").remove();
|
|
$("#btnCotizar").remove();
|
|
$("#btnEnviar").remove();
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|
|
|
//Indica que las condiciones de la cotizacion no son las correcta
|
|
IsLoadedCotizacion = false;
|
|
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|
|
this.LinkSolicitanteVisible = function (IdSolicitud, IdCotizacion) {
|
|
$("#liSolicitante").attr("style", "display:block");
|
|
var href = $("#aSolicitante").attr("href");
|
|
href = href.replace("[$sol_co_solicitud]", IdSolicitud);
|
|
href = href.replace("[$sol_co_cotizacion]", IdCotizacion);
|
|
$("#hiddensol_co_solicitud").val(IdSolicitud);
|
|
$("#aSolicitante").attr("href", href);
|
|
}
|
|
|
|
this.LinkSolicitudesVisible = function (IdSolicitud, IdCotizacion) {
|
|
var href = $("#aSolicitudes").attr("href");
|
|
href = href.replace("[$sol_co_solicitud]", IdSolicitud);
|
|
href = href.replace("[$sol_co_cotizacion]", IdCotizacion);
|
|
$("#hiddensol_co_solicitud").val(IdSolicitud);
|
|
$("#aSolicitudes").attr("href", href);
|
|
}
|
|
//#endregion
|
|
|
|
this.CargarOficialCobis = function (IdSucursal, NombreOficial) {
|
|
try {
|
|
|
|
var uri = "api/GlobalAPI/ConsultarOficialNombre?IdSucursal=" + IdSucursal + "&NombreOficial=" + NombreOficial + "&Proceso=" + $("#hiddenProcess").val() + "&Usuario=" + $("#hiddenUserID").val().split("/")[1];
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null) {
|
|
lista = data.oficiales;
|
|
var Seleccionar = $("#ucSeleccionarOficial").html();
|
|
var columnDefinition = [
|
|
{ "data": null, className: "center", defaultContent: Seleccionar },
|
|
{ "data": "codigo" },
|
|
{ "data": "descripcion" }
|
|
];
|
|
$('#tableOficial').TableInit(0, false, true, false, false, columnDefinition, lista);
|
|
if ($.fn.DataTable.isDataTable('#tableCuentas')) {
|
|
LoadMessage();
|
|
$('#tableOficial').DataTable().search('').draw();
|
|
$('#modalOficial').modal('show');
|
|
ENDREQUEST();
|
|
}
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
ENDREQUEST();
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al intentar invocar el metodo que obtiene los oficiales cobis. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
|
|
}
|
|
|
|
$(document).on('click', '#tableOficial tbody td', function (event) {
|
|
var data = $('#tableOficial').DataTable().row($(this).parents('tr')).data();
|
|
$("#txtCodOficial").val(data.codigo);
|
|
$("#txtNombreEjecutivo").val(data.descripcion);
|
|
$("#hiddenLoginEjecutivo").val(data.login);
|
|
$('#modalOficial').modal('hide');
|
|
$("#formCotizacion").validateElement("#txtNombreEjecutivo");
|
|
$("#formCotizacion").validateElement("#txtCodOficial");
|
|
|
|
}); |