1474 lines
No EOL
60 KiB
JavaScript
1474 lines
No EOL
60 KiB
JavaScript
$("#formInclusionDesembolso").EnableValidationToolTip();
|
|
$("#formDetalleOrdenCompra").EnableValidationToolTip();
|
|
$("#formDetalleAdelantoContraContrato").EnableValidationToolTip();
|
|
$("#form_Facturas").EnableValidationToolTip();
|
|
|
|
var model = {};
|
|
var ListaFacilidades = null;
|
|
var nConsecutivoFacturas = 0;
|
|
|
|
var TaskData_Global_VerificaTramite = false;
|
|
var TaskData_Global_VerificaRechazada = false;
|
|
var TaskData_Global_EtapaActivaVerificar = "";
|
|
|
|
var Etapas = {
|
|
DE_Inclu_Sol_Desembolso: ($("#hiddenStep").val() == "DE_Inclu_Sol_Desembolso" ? true : false),
|
|
DE_Apro_Casos_Info_Desactu: ($("#hiddenStep").val() == "DE_Apro_Casos_Info_Desactu" ? true : false),
|
|
DE_Ing_Caratula_Exep: ($("#hiddenStep").val() == "DE_Ing_Caratula_Exep" ? true : false),
|
|
DE_Asig_Caso: ($("#hiddenStep").val() == "DE_Asig_Caso" ? true : false),
|
|
DE_Rev_Info_Caso: ($("#hiddenStep").val() == "DE_Rev_Info_Caso" ? true : false),
|
|
DE_Ingr_Datos_Adicionales: ($("#hiddenStep").val() == "DE_Ingr_Datos_Adicionales" ? true : false),
|
|
DE_Inclu_Sol_Sistem_Transac: ($("#hiddenStep").val() == "DE_Inclu_Sol_Sistem_Transac" ? true : false),
|
|
DE_Gen_Doc_Legales: ($("#hiddenStep").val() == "DE_Gen_Doc_Legales" ? true : false),
|
|
DE_Rev_Doc: ($("#hiddenStep").val() == "DE_Rev_Doc" ? true : false),
|
|
DE_Enviar_Doc_Cliente: ($("#hiddenStep").val() == "DE_Enviar_Doc_Cliente" ? true : false)
|
|
|
|
};
|
|
|
|
jQuery(document).ready(function () {
|
|
|
|
$("#btnImprimirCaratulaLayout").hide();
|
|
$('#formDetalleOrdenCompra').hide();
|
|
$("#formDetalleAdelantoContraContrato").hide();
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
GetControlsSettings("Cathay_InclusionDesembolso", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", true);
|
|
else
|
|
GetControlsSettings("Cathay_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", true);
|
|
|
|
});
|
|
|
|
this.getDataModel = function () {
|
|
$("#btnBitacoraComentarioDevolucion").unbind();
|
|
$("#btnBitacoraComentarioDevolucion").click(function () {
|
|
//******************************************************************
|
|
//Inicializa y abre los comentarios de tipo devolucion de trámite
|
|
//******************************************************************
|
|
if (TaskData_Global_VerificaTramite == true || TaskData_Global_VerificaRechazada == true)
|
|
InicializarBitacoraComentariosInternos(TaskData_Global_EtapaActivaVerificar, EnumTipoComentario.ComentarioDevolucionTramite, true, BitacoraComentariosInternos_Show);
|
|
else
|
|
InicializarBitacoraComentariosInternos("", EnumTipoComentario.ComentarioDevolucionTramite, false, BitacoraComentariosInternos_Show);
|
|
});
|
|
|
|
ObtenerValoresEsquemaUltimus();
|
|
CargarConfiguraRelacionControles();
|
|
CargarFacilidades();
|
|
}
|
|
|
|
this.CargarConfiguraRelacionControles = function () {
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "FacilidadesCliente", valor: "Solicitud.DesembolsoDatosGenerales.IdTipoFacilidad" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoDesembolso", valor: "Solicitud.DesembolsoDatosGenerales.MontoDesembolso" });
|
|
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", {
|
|
IdControl: "MontoAprobadoLineaSAP", valor: "Solicitud.DesembolsoDatosGenerales.MontoAprobadoLineaSAP"
|
|
, GuardadoPersonalizado: function (valor) { return valor > 0 ? valor : 0; }
|
|
, CargaPersonalizada: function (valor) { return valor > 0 ? valor : 0; }
|
|
});
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", {
|
|
IdControl: "MontoDisponibleLinea", valor: "Solicitud.DesembolsoDatosGenerales.MontoDisponibleLinea"
|
|
, GuardadoPersonalizado: function (valor) { return valor > 0 ? valor : 0; }
|
|
, CargaPersonalizada: function (valor) { return valor > 0 ? valor : 0; }
|
|
});
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", {
|
|
IdControl: "MontoDisponibleSublimite", valor: "Solicitud.DesembolsoDatosGenerales.MontoDisponibleSublimite"
|
|
, GuardadoPersonalizado: function (valor) { return valor > 0 ? valor : 0; }
|
|
, CargaPersonalizada: function (valor) { return valor > 0 ? valor : 0; }
|
|
});
|
|
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "TipoMoneda", valor: "Solicitud.DesembolsoDatosGenerales.IdTipoMonedaDesembolso" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "Plazo", valor: "Solicitud.DesembolsoDatosGenerales.Plazo" });
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "FormaPago", valor: "Solicitud.DesembolsoDatosGenerales.IdFormaPago" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "IntruccionesDesposito", valor: "Solicitud.DesembolsoDatosGenerales.InstruccionesDesposito" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "NumeroLinea", valor: "Solicitud.DesembolsoDatosGenerales.NumeroLinea" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "FechaVencimientoLinea", valor: "Solicitud.DesembolsoDatosGenerales.FechaVencimientoLinea" });
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "ElaboradoPor", valor: "Solicitud.DesembolsoDatosGenerales.ElaboradoPor" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "ComentariosAdicionales", valor: "Solicitud.DesembolsoDatosGenerales.ComentariosAdicionales" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "NumeroCartaCreditoCancelar", valor: "Solicitud.DesembolsoDatosGenerales.NroCartaCreditoCancelar" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "PlazoCartaCredito", valor: "Solicitud.DesembolsoDatosGenerales.PlazoCartaCredito" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoAperturaCredito", valor: "Solicitud.DesembolsoDatosGenerales.MontoAperturaCartaCredito" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "Apertura_AFavorDe", valor: "Solicitud.DesembolsoDatosGenerales.Apertura_AFavorDe" });
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "Tasa", valor: "Solicitud.DesembolsoDatosGenerales.Tasa" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "Pagador", valor: "Solicitud.DesembolsoDatosGenerales.Pagador" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "ContactosVerificacion", valor: "Solicitud.DesembolsoDatosGenerales.ContactoVerificacion" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "ProcentajeAceptacion", valor: "Solicitud.DesembolsoDatosGenerales.ProcentajeAceptacion" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "Comision", valor: "Solicitud.DesembolsoDatosGenerales.Comision" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "NombreContratoOrdenCompra", valor: "Solicitud.DesembolsoDatosGenerales.NombreContrato_OrdenCompra" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "SaldoOrdenCompra", valor: "Solicitud.DesembolsoDatosGenerales.OrdenCompra_Saldo" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "TotalAdelantoContraContrato", valor: "Solicitud.DesembolsoDatosGenerales.AdelantoContrato_Total" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "TotalPorcentajeAdelantoContraContrato", valor: "Solicitud.DesembolsoDatosGenerales.PorcentajeAdelantoContrato_Total" });
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoAprobadoLinea", valor: "Solicitud.DesembolsoDatosGenerales.MontoAprobadoLineaSAP" });
|
|
//RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoAprobadoLinea", valor: "Solicitud.DesembolsoDatosGenerales.Linea_MontoAprobado" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoDesembolsoLinea", valor: "Solicitud.DesembolsoDatosGenerales.Linea_MontoDesembolso" });;
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoAprobadoSublimite", valor: "Solicitud.DesembolsoDatosGenerales.Sublimite_MontoAprobado" });
|
|
RelacionCamposFramework.AgregarRelacion("basico", { IdControl: "MontoDesembolsoSublimite", valor: "Solicitud.DesembolsoDatosGenerales.Sublimite_MontoDesembolso" });
|
|
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", {
|
|
IdControl: "EstadoCCSS", valor: "Solicitud.DesembolsoDatosGenerales.CCSS_Atrasado"
|
|
, GuardadoPersonalizado: function (valor) {
|
|
return valor[0].value == "1" ? true : false;
|
|
}
|
|
, CargaPersonalizada: function (valor) { return IsNullOrEmpty(valor) ? "" : (valor == true ? "1" : "2"); }
|
|
});
|
|
|
|
|
|
|
|
|
|
RelacionCamposFramework.AgregarRelacion("basico", {
|
|
IdControl: "EstadoOperaciones", valor: "Solicitud.DesembolsoDatosGenerales.Operaciones_Mora"
|
|
, GuardadoPersonalizado: function (valor) { return valor == "Atrasado" ? true : false; }
|
|
, CargaPersonalizada: function (valor) { return IsNullOrEmpty(valor) ? "" : (valor == true ? "Atrasado" : "Al día"); }
|
|
});
|
|
|
|
$("#txtFechaVencimientoLinea").disable();
|
|
|
|
$("#formInclusionDesembolso").valid();
|
|
$("#formInclusionDesembolso").validateElement("#txtNumeroBPCliente");
|
|
|
|
}
|
|
|
|
this.CargarFacilidades = function () {
|
|
|
|
Ultimus.AjaxGetData(server + "api/GlobalAPI/ObteneraTipoFacilidad", true, false, function (data) {
|
|
|
|
ListaFacilidades = data;
|
|
|
|
CargarFormulario();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.CargarFormulario = function () {
|
|
|
|
Ultimus.AjaxGetData(server + "api/DesembolsoAPI/Cargar?IdSolicitud=" + $("#hidden_co_solicitud").val(), true, false, function (data) {
|
|
|
|
model = data;
|
|
|
|
if ($("#hidden_co_solicitud").val() != 0)
|
|
CargarControlSettingsFormalarioFacilidad();
|
|
else
|
|
getDataModelComplete();
|
|
|
|
ToggleBitacoraComentariosDevolucion();
|
|
|
|
});
|
|
}
|
|
|
|
this.CargarControlSettingsFormalarioFacilidad = function () {
|
|
|
|
$("#btnImprimirCaratulaLayout").show();
|
|
$('#formDetalleOrdenCompra').hide();
|
|
$("#formDetalleAdelantoContraContrato").hide();
|
|
|
|
switch (model.Solicitud.DesembolsoDatosGenerales.IdTipoFacilidad) {
|
|
case 1:
|
|
case 2:
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
UpdateControlsSettings("Cathay_CapitalTrabajo", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
else
|
|
UpdateControlsSettings("Cathay_CapitalTrabajo_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
|
|
break;
|
|
case 3:
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
UpdateControlsSettings("Cathay_AperturaCartaCredito", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
else
|
|
UpdateControlsSettings("Cathay_AperturaCartaCredito_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
|
|
break;
|
|
case 4:
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
UpdateControlsSettings("Cathay_FinanciamientoCartaCredito", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
else
|
|
UpdateControlsSettings("Cathay_FinanciamientoCartaCredito_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
|
|
break;
|
|
case 5:
|
|
case 6:
|
|
case 7:
|
|
case 8:
|
|
case 11:
|
|
$('#DetalleOrdenCompra tbody td').die('click');
|
|
$('#DetalleAdelantoContraContrato tbody td').die('click');
|
|
$('#formDetalleOrdenCompra').show();
|
|
$("#formDetalleAdelantoContraContrato").show();
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
UpdateControlsSettings("Cathay_AdelantoContrato", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
else
|
|
UpdateControlsSettings("Cathay_AdelantoContrato_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
break;
|
|
case 9:
|
|
case 10:
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
UpdateControlsSettings("Cathay_DescuentoFacturas", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_ListaFacturas", "Cathay_ListaFacturasDesembolso", "form_Facturas", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
});
|
|
else
|
|
UpdateControlsSettings("Cathay_DescuentoFacturas_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_ListaFacturas_Disable", "Cathay_ListaFacturasDesembolso", "form_Facturas", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
});
|
|
|
|
break;
|
|
default:
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
UpdateControlsSettings("Cathay_DesembolsoVarios", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
else
|
|
UpdateControlsSettings("Cathay_DesembolsoVarios_Disable", "cathay_InclusionSolicitudDesembolso", "formInclusionDesembolso", function () {
|
|
UpdateControlsSettings("Cathay_Adjuntos", "Cathay_Adjuntos", "form_adjuntos", getDataModelComplete);
|
|
});
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
this.getDataModelComplete = function () {
|
|
|
|
$("#ddlFacilidadesCliente").change(function () {
|
|
|
|
ToggleEtiqueta();
|
|
ObtenerMontoDisponible();
|
|
toggleMontoSublimite();
|
|
});
|
|
|
|
$("#ddlTipoMoneda").change(function () {
|
|
ToggleTipoMoneda();
|
|
});
|
|
|
|
|
|
$("#ddlEstadoCCSS").change(function () {
|
|
ToggleEstadoCCSS();
|
|
});
|
|
|
|
|
|
$("#btnGuardar").click(function () {
|
|
|
|
if (!ValidateJustificacion()) return;
|
|
|
|
|
|
if (!$("#formInclusionDesembolso").valid()) {
|
|
toastr.warning("Debe completar los campos requeridos", Message_Warning);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
GuardarFormulario();
|
|
});
|
|
|
|
$("#btnBuscarLinea").click(function (event) {
|
|
|
|
if (IsNullOrEmpty($("#txtNumeroBPCliente").val())) {
|
|
toastr.warning("Debe indicar el Número BP", Message_Warning);
|
|
return;
|
|
}
|
|
|
|
BuscarSAP();
|
|
|
|
event.preventDefault();
|
|
return false;
|
|
|
|
});
|
|
|
|
$("#btnIncluirSolicitud").click(function () {
|
|
|
|
if (!$("#formInclusionDesembolso").valid()) {
|
|
toastr.warning("Debe completar los campos requeridos", Message_Warning);
|
|
return;
|
|
}
|
|
|
|
if (confirm("¿Desea iniciar la inclusión de desembolso, para esta línea?")) {
|
|
GuardarFormulario();
|
|
$("#btnIncluirSolicitud").disable();
|
|
}
|
|
|
|
});
|
|
|
|
//$("#ddlFacilidadesCliente").change(function () {
|
|
// toggleMontoSublimite();
|
|
// ToggleEtiqueta();
|
|
//});
|
|
|
|
$("#txtNumeroBPCliente").change(function () {
|
|
$("#btnIncluirSolicitud").disable();
|
|
});
|
|
|
|
$("#btnVerFacturas").click(function (event) {
|
|
|
|
if (IsNullOrEmpty($("#txtProcentajeAceptacion").autoNumeric('get')) || IsNullOrEmpty($("#ddlTipoMoneda").DropDownList("getselected").val()))
|
|
toastr.warning("Debe definir el porcentaje de aceptación y el tipo de moneda del desembolso", Message_Warning);
|
|
else
|
|
CargaFacturas();
|
|
|
|
event.preventDefault(event);
|
|
return false;
|
|
});
|
|
|
|
$("#ddlMonedaFactura").change(function () {
|
|
ToggleTipoMonedaFacturas();
|
|
});
|
|
|
|
$("#btnAgregarFactura").click(function () {
|
|
if (!$("#form_Facturas").valid()) {
|
|
toastr.warning("Debe completar los campos requeridos", Message_Warning);
|
|
return;
|
|
}
|
|
GuardarFactura();
|
|
});
|
|
|
|
$("#txtProcentajeAceptacion").keypress(function () {
|
|
|
|
});
|
|
|
|
$("#txtMontoFactura").keypress(function () {
|
|
var descuento = CalculaDescuentoMontoFactura($("#txtProcentajeAceptacion").autoNumeric('get'), $("#txtMontoFactura").autoNumeric('get'));
|
|
$("#txtMontoDescuento").autoNumeric('set', (descuento));
|
|
});
|
|
|
|
$("#txtMontoDesembolso").change(function () {
|
|
|
|
var _MontoDesembolso = parseFloat($("#txtMontoDesembolso").autoNumeric('get'));
|
|
_MontoDesembolso = isNaN(_MontoDesembolso) ? 0 : _MontoDesembolso;
|
|
|
|
$("#txtMontoDesembolsoLinea").autoNumeric('set', (_MontoDesembolso));
|
|
$("#txtMontoDesembolsoSublimite").autoNumeric('set', (_MontoDesembolso));
|
|
|
|
CalculaMontoDisponibleFuturo();
|
|
});
|
|
|
|
|
|
$("#txtMontoDesembolsoLinea").keypress(function () {
|
|
CalculaMontoDisponibleFuturo();
|
|
});
|
|
|
|
$("#txtMontoDesembolsoSublimite").keypress(function () {
|
|
CalculaMontoDisponibleFuturo();
|
|
});
|
|
|
|
CargarDatos();
|
|
|
|
//oculta los tabs mientras no a iniciado inclusion de la solicitud
|
|
if ($("#hidden_co_solicitud").val() == 0) {
|
|
$("#MenuBarTabs").children().each(function (id, item) {
|
|
if (id != 0)
|
|
$(this).hide();
|
|
});
|
|
}
|
|
|
|
|
|
if (Etapas.DE_Inclu_Sol_Desembolso)
|
|
$("#btnFinalizarTarea").hide();
|
|
|
|
}
|
|
|
|
|
|
this.ToggleEtiqueta = function () {
|
|
|
|
switch ($("#ddlFacilidadesCliente").DropDownList("getselected").val()) {
|
|
case "5":
|
|
case "6":
|
|
case "7":
|
|
case "8":
|
|
$("#titulo_sublimite").text("ADELANTOS");
|
|
break;
|
|
case "9":
|
|
case "10":
|
|
$("#titulo_sublimite").text("DESCUENTOS");
|
|
break;
|
|
}
|
|
}
|
|
|
|
this.ObtenerMontoDisponible = function () {
|
|
var tipofacilidad = $("#ddlFacilidadesCliente").DropDownList("getselected").val();
|
|
|
|
if (tipofacilidad != "")
|
|
Ultimus.AjaxGetData(server + "api/DesembolsoAPI/ObtenerMontoDisponibleSublimite?IdTipoFacilidad=" + tipofacilidad + "&CodigoBP=" + $("#txtNumeroBPCliente").val(), true, false, function (data) {
|
|
|
|
$("#txtMontoDisponibleSublimite").autoNumeric('set', data);
|
|
ENDREQUEST();
|
|
});
|
|
|
|
}
|
|
|
|
|
|
this.CargarDatos = function () {
|
|
|
|
$("#ddlFacilidadesCliente").DropDownList("clear");
|
|
|
|
if ($("#hidden_co_solicitud").val() != 0 && ListaFacilidades != null && ListaFacilidades.length > 0) {
|
|
|
|
$.each(ListaFacilidades, function (id, item) {
|
|
$("#ddlFacilidadesCliente").DropDownList("add", {
|
|
value: item.codigo, text: item.descripcion
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
RelacionCamposFramework.Cargar(model);
|
|
|
|
var solicitante = null;
|
|
|
|
if (model.Solicitud != null && model.Solicitud.Solicitante != null && model.Solicitud.Solicitante.length > 0) {
|
|
solicitante = model.Solicitud.Solicitante[0];
|
|
}
|
|
|
|
var Cliente = solicitante == null || solicitante.Cliente == null ? {} : solicitante.Cliente;
|
|
|
|
$("#txtNumeroBPCliente").val(Cliente.CodigoBP);
|
|
$("#txtNumeroIdentificacion").val(Cliente.NumeroIdentificacion);
|
|
|
|
if (Cliente.IdTipoCliente == 1)
|
|
$("#txtNombreCliente").val(format("{0} {1} {2}", Cliente.PrimerNombre, Cliente.PrimerApellido, Cliente.SegundoApellido));
|
|
else
|
|
$("#txtNombreCliente").val(Cliente.RazonSocial);
|
|
|
|
|
|
$("#ddlTipoIdentificacion").DropDownList("setselected", Cliente.IdTipoIdentificacion);
|
|
|
|
if (Cliente.Ejecutivo != null)
|
|
$("#txtFormalizador").val(Cliente.Ejecutivo.FormalizadorAsignado_FullName);
|
|
|
|
if (Etapas.DE_Inclu_Sol_Desembolso)
|
|
$("#txtElaboradoPor").val($("#hiddenUserFullName").val());
|
|
|
|
if (model.Solicitud != null && model.Solicitud.DesembolsoDatosGenerales != null) {
|
|
|
|
$("#txtMontoAprobadoLinea").autoNumeric('update', { aSign: model.Solicitud.DesembolsoDatosGenerales.MonedaLinea == "CRC" ? '₡' : '$' });
|
|
$("#txtMontoAprobadoLineaSAP").autoNumeric('update', { aSign: model.Solicitud.DesembolsoDatosGenerales.MonedaLinea == "CRC" ? '₡' : '$' });
|
|
$("#txtMontoDisponibleLinea").autoNumeric('update', { aSign: model.Solicitud.DesembolsoDatosGenerales.MonedaLinea == "CRC" ? '₡' : '$' });
|
|
$("#txtMontoDisponibleSublimite").autoNumeric('update', { aSign: model.Solicitud.DesembolsoDatosGenerales.MonedaLinea == "CRC" ? '₡' : '$' });
|
|
|
|
$("#txtMontoDisponibleLineaActual").autoNumeric('set', Math.abs(model.Solicitud.DesembolsoDatosGenerales.MontoDisponibleLinea));
|
|
$("#txtMontoDisponibleSublimiteActual").autoNumeric('set', Math.abs(model.Solicitud.DesembolsoDatosGenerales.MontoDisponibleSublimite));
|
|
|
|
}
|
|
|
|
$('#btnAdjuntarFacturas').click(function () {
|
|
GuardarFormulario();
|
|
CargarAdjuntos(model.Solicitud.DesembolsoDatosGenerales.IdDocumentoFacturasAdjuntadas, "FacturasDesembolso", function (resp) {
|
|
model.Solicitud.DesembolsoDatosGenerales.IdDocumentoFacturasAdjuntadas = resp.CodDocumento;
|
|
model.Solicitud.DesembolsoDatosGenerales.RutaFisicaFacturasAdjuntadas = resp.RutaFisica;
|
|
}, true, true, "20");
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
DisableAttachment(false, false);
|
|
else
|
|
DisableAttachment(true, true);
|
|
});
|
|
|
|
|
|
$('#btnAdjuntarSolDesembolso').click(function () {
|
|
GuardarFormulario();
|
|
CargarAdjuntos(model.Solicitud.DesembolsoDatosGenerales.IdDocumentoSolicitudDesembolsoAdjuntadas, "SolicitudDesembolso", function (resp) {
|
|
model.Solicitud.DesembolsoDatosGenerales.IdDocumentoSolicitudDesembolsoAdjuntadas = resp.CodDocumento;
|
|
model.Solicitud.DesembolsoDatosGenerales.RutaFisicaSolicitudDesembolsoAdjuntadas = resp.RutaFisica;
|
|
}, true, true, "21");
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso)
|
|
DisableAttachment(false, false);
|
|
else
|
|
DisableAttachment(true, true);
|
|
});
|
|
|
|
|
|
|
|
|
|
ToggleTipoMoneda();
|
|
CargarDetalleOrdenCompra();
|
|
CargarDetalleAdelanto();
|
|
|
|
ToggleBitacoraComentariosDevolucion();
|
|
ToggleEtiqueta();
|
|
validalinea();
|
|
|
|
CalculaMontoDisponibleFuturo();
|
|
|
|
|
|
ENDREQUEST();
|
|
|
|
$("#formInclusionDesembolso").valid();
|
|
$("#formInclusionDesembolso").validateElement("#txtNumeroBPCliente");
|
|
|
|
$("#formDetalleOrdenCompra").valid();
|
|
$("#formDetalleAdelantoContraContrato").valid();
|
|
|
|
}
|
|
|
|
|
|
this.ToggleBitacoraComentariosDevolucion = function () {
|
|
$("#btnBitacoraComentarioDevolucion").attr("style", "display:none;");
|
|
}
|
|
|
|
|
|
this.ToggleEstadoCCSS = function () {
|
|
|
|
var estadoCCSS = $("#ddlEstadoCCSS").DropDownList("getselected").val();
|
|
|
|
if (estadoCCSS == "1") {
|
|
$("#txtComentariosAdicionales").required();
|
|
toastr.warning("Debe registrar una justificación por atraso en la CCSS dentro de los comentarios adicionales.");
|
|
}
|
|
else
|
|
$("#txtComentariosAdicionales").noRequired();
|
|
}
|
|
|
|
|
|
this.ToggleTipoMoneda = function () {
|
|
var tipo = $("#ddlTipoMoneda").DropDownList("getselected").val() == "0" ? '₡' : '$';
|
|
|
|
$("#txtMontoDesembolso").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoAperturaCredito").autoNumeric('update', { aSign: tipo });
|
|
|
|
$("#txtComision").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoAprobadoLinea").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoAprobadoSublimite").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoDisponibleLineaActual").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoDisponibleSublimiteActual").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoDesembolsoLinea").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoDesembolsoSublimite").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoDisponibleLineaFuturo").autoNumeric('update', { aSign: tipo });
|
|
$("#txtMontoDisponibleSublimiteFuturo").autoNumeric('update', { aSign: tipo });
|
|
|
|
RefrescaOrdenCompra();
|
|
}
|
|
|
|
|
|
this.CargarFacilidadesCliente = function () {
|
|
|
|
var Sublimites = null;
|
|
if (model.LineaCliente != null && model.LineaCliente.Sublimites != null)
|
|
Sublimites = $.grep(model.LineaCliente.Sublimites, function (item, id) {
|
|
return !IsNullOrEmpty(item.Numcaratula);
|
|
});
|
|
|
|
$("#ddlFacilidadesCliente").DropDownList("clear");
|
|
|
|
if (ListaFacilidades != null && ListaFacilidades.length > 0 && Sublimites != null && Sublimites.length > 0) {
|
|
$('#ddlFacilidadesCliente').append($("<option></option>")
|
|
.attr("value", "")
|
|
.text(""));
|
|
$.each(Sublimites, function (id, item) {
|
|
var facilidad = $.grep(ListaFacilidades, function (item_facilidad, id_facilidad) { return item_facilidad.CodigoSAP == item.Clasesublimite; });
|
|
|
|
if (facilidad != null && facilidad.length > 0) {
|
|
$.each(facilidad, function (id2, item2) {
|
|
$("#ddlFacilidadesCliente").DropDownList("add", {
|
|
value: item2.codigo, text: item2.descripcion
|
|
});
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
$("#formInclusionDesembolso").valid();
|
|
$("#formInclusionDesembolso").validateElement("#txtNumeroBPCliente");
|
|
|
|
toggleMontoSublimite();
|
|
|
|
}
|
|
|
|
|
|
this.GuardarDatos = function () {
|
|
|
|
model = LeerControlesUltimus(model);
|
|
model = RelacionCamposFramework.Guardar(model);
|
|
|
|
model.Solicitud = model.Solicitud == null ? {} : model.Solicitud;
|
|
model.Solicitud.IdSolicitud = $("#hidden_co_solicitud").val();
|
|
|
|
model.Solicitud.Solicitante = model.Solicitud == null || model.Solicitud.Solicitante == null ? new Array() : model.Solicitud.Solicitante;
|
|
|
|
var solicitante = null;
|
|
if (model.Solicitud.Solicitante.length > 0)
|
|
solicitante = model.Solicitud.Solicitante[0];
|
|
|
|
solicitante = solicitante == null ? {} : solicitante;
|
|
solicitante.IdSolicitud = $("#hidden_co_solicitud").val();
|
|
solicitante.EsPrincipal = true;
|
|
solicitante.IdTipoSolicitante = 1;
|
|
|
|
var Cliente = solicitante == null || solicitante.Cliente == null ? {} : solicitante.Cliente;
|
|
|
|
Cliente.CodigoBP = $("#txtNumeroBPCliente").val();
|
|
Cliente.NumeroIdentificacion = $("#txtNumeroIdentificacion").val();
|
|
|
|
var nMax = $("#txtNombreCliente").val().length > 50 ? 50 : $("#txtNombreCliente").val().length;
|
|
Cliente.PrimerNombre = $("#txtNombreCliente").val().substring(0, nMax);
|
|
Cliente.IdTipoTramite = 5;
|
|
Cliente.IdTipoIdentificacion = $("#ddlTipoIdentificacion").DropDownList("getselected").val();
|
|
|
|
solicitante.Cliente = Cliente;
|
|
|
|
model.Solicitud.Solicitante = [solicitante];
|
|
|
|
if ($("#btnVerFacturas").is(":visible") && Etapas.DE_Inclu_Sol_Desembolso)
|
|
GuardarFacturaModelo();
|
|
|
|
if ($("#divDetalleOrdenCompra").is(":visible") && Etapas.DE_Inclu_Sol_Desembolso)
|
|
GuardaOrdenCompraModelo();
|
|
|
|
if ($("#divDetalleAdelantoContraContrato").is(":visible") && Etapas.DE_Inclu_Sol_Desembolso)
|
|
GuardaAdelantoContratoModelo();
|
|
|
|
}
|
|
|
|
this.GuardarFormulario = function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GuardarDatos();
|
|
|
|
Ultimus.AjaxPostData(server + "api/DesembolsoAPI/Guardar", model, true, ($("#hidden_co_solicitud").val() == 0 ? false : true), function (data) {
|
|
|
|
model = data;
|
|
|
|
if ($("#hidden_co_solicitud").val() == 0 && model.CodigoRespuesta == "ADVERTENCIA") {
|
|
toastr.warning(model.DescripcionRespuesta, Message_Warning);
|
|
ENDREQUEST();
|
|
return;
|
|
}
|
|
|
|
if ($("#hidden_co_solicitud").val() == 0 && model.Solicitud != null && model.Solicitud.IdSolicitud > 0) {
|
|
var _IdSolicitud = Encrypt(model.Solicitud.IdSolicitud);
|
|
window.location = Ultimus.UpdateRequestParam("sol_co_solicitud", _IdSolicitud);
|
|
}
|
|
else
|
|
ENDREQUEST();
|
|
|
|
}, "ADVERTENCIA", "Información guardada correctamente");
|
|
|
|
}
|
|
|
|
this.BuscarSAP = function () {
|
|
|
|
GuardarDatos();
|
|
|
|
Ultimus.AjaxPostData(server + "api/DesembolsoAPI/BuscarLinea", model, true, true, function (data) {
|
|
|
|
$("#formInclusionDesembolso").reset();
|
|
|
|
model = data;
|
|
|
|
CargarDatos();
|
|
CargarFacilidadesCliente();
|
|
|
|
$("#formInclusionDesembolso").valid();
|
|
$("#formInclusionDesembolso").validateElement("#txtNumeroBPCliente");
|
|
|
|
ENDREQUEST();
|
|
|
|
validalinea();
|
|
|
|
}, "EXITOSO", "Busqueda exitosa");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.toggleMontoSublimite = function () {
|
|
$("#txtMontoDisponibleSublimite").autoNumeric('set', null);
|
|
$("#btnIncluirSolicitud").disable();
|
|
|
|
var Sublimites = null;
|
|
var facilidad = null;
|
|
|
|
if (ListaFacilidades != null && ListaFacilidades.length > 0) {
|
|
facilidad = $.grep(ListaFacilidades, function (item, id) {
|
|
return item.codigo == $("#ddlFacilidadesCliente").DropDownList("getselected").val();
|
|
})[0];
|
|
}
|
|
|
|
if (facilidad != null && model.LineaCliente != null && model.LineaCliente.Sublimites != null) {
|
|
Sublimites = $.grep(model.LineaCliente.Sublimites, function (item, id) {
|
|
return item.Clasesublimite == facilidad.CodigoSAP;
|
|
});
|
|
}
|
|
|
|
if (Sublimites != null && Sublimites.length > 0) {
|
|
Sublimites = Sublimites[0];
|
|
|
|
if (model.Solicitud != null && model.Solicitud.DesembolsoDatosGenerales != null) {
|
|
model.Solicitud.DesembolsoDatosGenerales.MontoDisponibleSublimite = Sublimites.Montomaxlimite;
|
|
model.Solicitud.DesembolsoDatosGenerales.NroCaratulaSublimite = Sublimites.Numcaratula;
|
|
model.Solicitud.DesembolsoDatosGenerales.CodigoSublimite = Sublimites.Clasesublimite;
|
|
}
|
|
|
|
//$("#txtMontoDisponibleSublimite").autoNumeric('set', Sublimites.Montomaxlimite);
|
|
|
|
}
|
|
validalinea();
|
|
}
|
|
|
|
this.validalinea = function () {
|
|
|
|
if ($("#hidden_co_solicitud").val() != 0) return;
|
|
|
|
var montolinea = $("#txtMontoDisponibleLinea").autoNumeric('get');
|
|
var montosublimite = $("#txtMontoDisponibleSublimite").autoNumeric('get');
|
|
var mensaje = "";
|
|
|
|
|
|
var Sublimites = null;
|
|
if (model.LineaCliente != null && model.LineaCliente.Sublimites != null)
|
|
Sublimites = $.grep(model.LineaCliente.Sublimites, function (item, id) {
|
|
return !IsNullOrEmpty(item.Numcaratula);
|
|
});
|
|
|
|
if (Sublimites == null || Sublimites.length == 0)
|
|
mensaje += "</br>-La línea no tiene sublimite disponible";
|
|
|
|
if (montolinea <= 0 && montosublimite <= 0)
|
|
mensaje += "</br>-No hay monto disponible para el desembolso";
|
|
|
|
if (!IsNullOrEmpty(mensaje) && !IsNullOrEmpty($("#txtNumeroLinea").val())) {
|
|
|
|
toastr.warning(mensaje, Message_Warning);
|
|
$("#btnIncluirSolicitud").disable();
|
|
}
|
|
else if (!IsNullOrEmpty($("#txtNumeroLinea").val())) {
|
|
$("#btnIncluirSolicitud").enable();
|
|
}
|
|
}
|
|
|
|
//#region FACTURAS
|
|
this.CargaFacturas = function () {
|
|
$("#form_Facturas").reset();
|
|
$('#txtNumeroFactura').attr('readonly', false);
|
|
|
|
$("#ListaFacturas").Grid("Set", {
|
|
setCustomSettings: function (Settings) {
|
|
var total = 0;
|
|
var totalDesc = 0;
|
|
|
|
if (Settings.data.length > 0)
|
|
$.each(Settings.data, function (id, item) {
|
|
|
|
item.IdTipoMoneda = $("#ddlTipoMoneda").DropDownList("getselected").val();
|
|
item.DescuentoMonto = CalculaDescuentoMontoFactura($("#txtProcentajeAceptacion").autoNumeric('get'), item.Monto);
|
|
item.CMonto = Ultimus.CustomNumberFormat(item.Monto, 2, (item.IdTipoMoneda == "0" ? '₡' : '$'), ",", ".");
|
|
item.CDescuentoMonto = Ultimus.CustomNumberFormat(item.DescuentoMonto, 2, (item.IdTipoMoneda == "0" ? '₡' : '$'), ",", ".");
|
|
|
|
if ($("#hiddenTaskStatus").val() == 1 && Etapas.DE_Inclu_Sol_Desembolso) {
|
|
item.opciones = '<span id="Editar" class="fa fa-2x fa-edit HandCursor"></span> '
|
|
item.opciones += '<span id="Eliminar" class="fa fa-2x fa-trash HandCursor"></span>'
|
|
}
|
|
else {
|
|
item.opciones = '';
|
|
}
|
|
|
|
total += parseFloat(item.Monto);
|
|
totalDesc += parseFloat(item.DescuentoMonto);
|
|
});
|
|
|
|
total = Ultimus.CustomNumberFormat(total, 2, ($("#ddlTipoMoneda").DropDownList("getselected").val() == "0" ? '₡' : '$'), ",", ".");
|
|
totalDesc = Ultimus.CustomNumberFormat(totalDesc, 2, ($("#ddlTipoMoneda").DropDownList("getselected").val() == "0" ? '₡' : '$'), ",", ".");
|
|
|
|
$("[id='lblTotalFacturas']").text(total);
|
|
$("[id='lblTotalDescuento']").text(totalDesc);
|
|
|
|
return Settings;
|
|
},
|
|
RowEvent: function (IdControl, DataRow) {
|
|
|
|
if (IdControl == "Editar") {
|
|
EditarFactura(DataRow);
|
|
}
|
|
else if (IdControl == "Eliminar" && confirm("¿Esta seguro que desea eliminar la factura?")) {
|
|
EliminarFactura(DataRow);
|
|
}
|
|
}
|
|
});
|
|
|
|
if (model.Solicitud != null && model.Solicitud.DesembolsoDatosGenerales != null)
|
|
$("#ListaFacturas").Grid('RenderGrid', model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas);
|
|
|
|
$("#ddlMonedaFactura").DropDownList("setselected", $("#ddlTipoMoneda").DropDownList("getselected").val());
|
|
|
|
ToggleTipoMonedaFacturas();
|
|
|
|
$("#modal_facturas").modal('show');
|
|
|
|
$("#form_Facturas").valid();
|
|
|
|
|
|
ENDREQUEST();
|
|
}
|
|
|
|
this.ToggleTipoMonedaFacturas = function () {
|
|
$("#txtMontoFactura").autoNumeric('update', { aSign: $("#ddlMonedaFactura").DropDownList("getselected").val() == "0" ? '₡' : '$' });
|
|
$("#txtMontoDescuento").autoNumeric('update', { aSign: $("#ddlMonedaFactura").DropDownList("getselected").val() == "0" ? '₡' : '$' });
|
|
|
|
$("#ListaFacturas").Grid('Refresh');
|
|
|
|
}
|
|
|
|
this.GuardarFactura = function () {
|
|
|
|
var DesembolsoFacturas = {};
|
|
|
|
if (parseFloat($("#hiddenIdDesembolsoFacturas").val()) == 0)
|
|
nConsecutivoFacturas--;
|
|
|
|
DesembolsoFacturas.IdDesembolsoFacturas = parseFloat($("#hiddenIdDesembolsoFacturas").val()) == 0 ? nConsecutivoFacturas : $("#hiddenIdDesembolsoFacturas").val();
|
|
DesembolsoFacturas.IdSolicitud = $("#hidden_co_solicitud").val();
|
|
DesembolsoFacturas.NumeroFactura = $("#txtNumeroFactura").val();
|
|
DesembolsoFacturas.Monto = $("#txtMontoFactura").autoNumeric('get');
|
|
DesembolsoFacturas.DescuentoMonto = $("#txtMontoDescuento").autoNumeric('get');
|
|
DesembolsoFacturas.IdTipoMoneda = $("#ddlMonedaFactura").DropDownList("getselected").val();
|
|
|
|
if (!$('#txtNumeroFactura').is('[readonly]')) {
|
|
|
|
var exist = $.grep(model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas, function (item, id) {
|
|
return (item.IdSolicitud == DesembolsoFacturas.IdSolicitud && DesembolsoFacturas.NumeroFactura == item.NumeroFactura && DesembolsoFacturas.IdDesembolsoFacturas != item.IdDesembolsoFacturas);
|
|
});
|
|
|
|
if (exist != null && exist.length > 0) {
|
|
toastr.warning("ya existe el número de factura: <strong>" + DesembolsoFacturas.NumeroFactura + "</strong>", Message_Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas = model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas == null ? new Array() : model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas;
|
|
|
|
//lo remueve y luego lo vuelve a agregar
|
|
model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas = $.grep(model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas, function (item, id) {
|
|
return !(item.IdSolicitud == DesembolsoFacturas.IdSolicitud && DesembolsoFacturas.IdDesembolsoFacturas == item.IdDesembolsoFacturas);
|
|
});
|
|
|
|
model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas.push(DesembolsoFacturas);
|
|
|
|
$("#ListaFacturas").Grid('RenderGrid', model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas);
|
|
|
|
$("#form_Facturas").reset();
|
|
$("#hiddenIdDesembolsoFacturas").val('0');
|
|
$("#ddlMonedaFactura").DropDownList("setselected", $("#ddlTipoMoneda").DropDownList("getselected").val());
|
|
|
|
$('#txtNumeroFactura').attr('readonly', false);
|
|
$("#form_Facturas").valid();
|
|
|
|
|
|
}
|
|
|
|
this.EditarFactura = function (DesembolsoFacturas) {
|
|
|
|
//$('#txtNumeroFactura').attr('readonly', true);
|
|
|
|
|
|
$("#hiddenIdDesembolsoFacturas").val(DesembolsoFacturas.IdDesembolsoFacturas);
|
|
$("#txtNumeroFactura").val(DesembolsoFacturas.NumeroFactura);
|
|
$("#txtMontoFactura").autoNumeric('set', DesembolsoFacturas.Monto);
|
|
$("#txtMontoDescuento").autoNumeric('set', DesembolsoFacturas.DescuentoMonto);
|
|
$("#ddlMonedaFactura").DropDownList("setselected", DesembolsoFacturas.IdTipoMoneda);
|
|
|
|
$("#form_Facturas").valid();
|
|
|
|
}
|
|
|
|
this.EliminarFactura = function (DesembolsoFacturas) {
|
|
|
|
var lista = $.grep($("#ListaFacturas").Grid('Get'), function (item, id) {
|
|
item.opciones = null;
|
|
return !(item.IdSolicitud == DesembolsoFacturas.IdSolicitud && DesembolsoFacturas.IdDesembolsoFacturas == item.IdDesembolsoFacturas);
|
|
});
|
|
|
|
model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas = lista;
|
|
|
|
$("#ListaFacturas").Grid('RenderGrid', model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas);
|
|
|
|
}
|
|
|
|
this.CalculaDescuentoMontoFactura = function (porcentaje, monto) {
|
|
|
|
return ((parseFloat(porcentaje) / 100) * parseFloat(monto));
|
|
|
|
}
|
|
|
|
this.GuardarFacturaModelo = function () {
|
|
|
|
var lista = model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas;
|
|
|
|
//limpia variables virutales
|
|
$.each(lista, function (id, item) {
|
|
item.IdDesembolsoFacturas = item.IdDesembolsoFacturas > 0 ? item.IdDesembolsoFacturas : 0;
|
|
item.CMonto = null;
|
|
item.opciones = null;
|
|
item.CDescuentoMonto = null;
|
|
item.IdTipoMoneda = $("#ddlTipoMoneda").DropDownList("getselected").val();
|
|
item.DescuentoMonto = CalculaDescuentoMontoFactura($("#txtProcentajeAceptacion").autoNumeric('get'), item.Monto);
|
|
});
|
|
|
|
model.Solicitud.DesembolsoDatosGenerales.DesembolsoFacturas = lista;
|
|
|
|
}
|
|
|
|
//#endregion
|
|
|
|
//#region ORDEN COMPRA
|
|
this.CargarDetalleOrdenCompra = function () {
|
|
|
|
$("#DetalleOrdenCompra").Grid("Set", {
|
|
setCustomSettings: function (Settings) {
|
|
|
|
var readonly = Etapas.DE_Inclu_Sol_Desembolso && $("#hiddenTaskStatus").val() == 1 && $("#divDetalleOrdenCompra").is(":visible") ? false : true;
|
|
|
|
if (Settings.data.length > 0)
|
|
$.each(Settings.data, function (id, item) {
|
|
item.id = id;
|
|
|
|
|
|
item.NumeroLicitacion = item.NumeroLicitacion == null ? "" : item.NumeroLicitacion;
|
|
item.Monto = isNaN(item.Monto) || item.Monto == null ? "" : item.Monto;
|
|
item.Plazo = isNaN(item.Plazo) || item.Plazo == null ? "" : item.Plazo;
|
|
item.PorcentajeAdelanto = isNaN(item.PorcentajeAdelanto) || item.PorcentajeAdelanto == null ? "" : item.PorcentajeAdelanto;
|
|
item.Pagador = isNaN(item.Pagador) || item.Pagador == null ? "" : item.Pagador;
|
|
|
|
|
|
item.CNumeroLicitacion = '<input value="' + item.NumeroLicitacion + '" type="text" id="txtNumeroLicitacion' + id + '" name="txtNumeroLicitacion' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
item.CMonto = '<input value="' + item.Monto + '" type="text" id="txtMonto' + id + '" name="txtMonto' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
item.CPlazo = '<input value="' + item.Plazo + '" type="text" id="txtPlazo' + id + '" name="txtPlazo' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
item.CPorcentajeAdelanto = '<input value="' + item.PorcentajeAdelanto + '" type="text" id="txtPorcentajeAdelanto' + id + '" name="txtPorcentajeAdelanto' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
item.CPagador = '<input value="' + item.Pagador + '" type="text" id="txtPagador' + id + '" name="txtPagador' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly" ' : 'required="required"') + ' >'
|
|
item.opciones = "";
|
|
|
|
if (!readonly) {
|
|
|
|
if ((Settings.data.length - 1) == id)
|
|
item.opciones += ' <span id="Agregar" class="fa fa-2x fa-plus HandCursor"></span>'
|
|
else
|
|
item.opciones += '<span id="Eliminar" class="fa fa-2x fa-trash HandCursor"></span>'
|
|
}
|
|
});
|
|
|
|
return Settings;
|
|
},
|
|
RowEvent: function (IdControl, DataRow) {
|
|
|
|
if (IdControl == "Agregar") {
|
|
AgregarOrdenCompra(DataRow);
|
|
|
|
}
|
|
else if (IdControl == "Eliminar" && confirm("¿Esta seguro que desea eliminar la orden?")) {
|
|
var lista = LeerControlesOrdenCompra();
|
|
|
|
lista = $.grep(lista, function (item, id) {
|
|
return item.id != DataRow.id;
|
|
});
|
|
|
|
RefrescaOrdenCompra(lista);
|
|
|
|
if (lista.length == 0)
|
|
AgregarOrdenCompra(DataRow);
|
|
|
|
TotalizarOrdenCompraContrato(lista);
|
|
|
|
}
|
|
|
|
|
|
var lista = LeerControlesAdelantoContrato();
|
|
lista = $.grep(lista, function (item, id) {
|
|
ToggleMontoAprobadoAdelantoContrato(id);
|
|
});
|
|
|
|
lista = LeerControlesAdelantoContrato();
|
|
TotalizarAdelantoContrato(lista);
|
|
|
|
|
|
}
|
|
});
|
|
|
|
if (model.Solicitud != null && model.Solicitud.DesembolsoDatosGenerales != null)
|
|
RefrescaOrdenCompra(model.Solicitud.DesembolsoDatosGenerales.DesemboloDetalleOrdenCompra);
|
|
|
|
if ($("#DetalleOrdenCompra").Grid("Get").length == 0 && ($("#divDetalleOrdenCompra").is(":visible") && Etapas.DE_Inclu_Sol_Desembolso))
|
|
AgregarOrdenCompra();
|
|
}
|
|
|
|
this.AgregarOrdenCompra = function (DataRow) {
|
|
|
|
var lista = LeerControlesOrdenCompra();
|
|
|
|
if (DataRow != null) {
|
|
|
|
var itemValidacion = $.grep(lista, function (item, id) {
|
|
return item.id == DataRow.id;
|
|
})[0];
|
|
|
|
var msg = "";
|
|
if (IsNullOrEmpty(itemValidacion.NumeroLicitacion)) msg += "- Número licitación<br>";
|
|
if (IsNullOrEmpty(itemValidacion.Monto)) msg += "- Monto<br>";
|
|
if (IsNullOrEmpty(itemValidacion.Plazo)) msg += "- Plazo<br>";
|
|
if (IsNullOrEmpty(itemValidacion.PorcentajeAdelanto)) msg += "- Porcentaje adelanto<br>";
|
|
if (IsNullOrEmpty(itemValidacion.Pagador)) msg += "- Pagador<br>";
|
|
|
|
if (!IsNullOrEmpty(msg)) {
|
|
toastr.warning("Debe registrar los campos requeridos:<br>" + msg);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
lista = lista == null ? new Array() : lista;
|
|
var id = lista.length;
|
|
|
|
var OrdenCompra = {
|
|
id: id
|
|
, IdSolicitud: $("#hidden_co_solicitud").val()
|
|
, NumeroLicitacion: ""
|
|
, Monto: ""
|
|
, Plazo: ""
|
|
, PorcentajeAdelanto: ""
|
|
, Pagador: ""
|
|
, IdMoneda: $("#ddlTipoMoneda").DropDownList("getselected").val()
|
|
};
|
|
|
|
lista.push(OrdenCompra);
|
|
|
|
RefrescaOrdenCompra(lista);
|
|
|
|
TotalizarOrdenCompraContrato(lista);
|
|
|
|
|
|
}
|
|
|
|
|
|
this.TotalizarOrdenCompraContrato = function (lista) {
|
|
|
|
var result = 0;
|
|
|
|
$.each(lista, function (id, item) {
|
|
result += parseFloat(item.Monto == "" ? 0 : item.Monto);
|
|
});
|
|
|
|
$("#txtSaldoOrdenCompra").autoNumeric('set', isNaN(result) || result == null ? "0" : result);
|
|
}
|
|
|
|
|
|
this.TotalizarAdelantoContrato = function (lista) {
|
|
|
|
var result = 0;
|
|
var porc = 0;
|
|
|
|
$.each(lista, function (id, item) {
|
|
result += parseFloat(item.MontoAprobado == "" ? 0 : item.MontoAprobado);
|
|
porc += parseFloat(item.Porcentaje == "" ? 0 : item.Porcentaje);
|
|
});
|
|
|
|
$("#txtTotalAdelantoContraContrato").autoNumeric('set', isNaN(result) || result == null ? "0" : result);
|
|
$("#txtTotalPorcentajeAdelantoContraContrato").autoNumeric('set', isNaN(porc) || porc == null ? "0" : porc);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.RefrescaOrdenCompra = function (lista) {
|
|
lista = lista == null ? LeerControlesOrdenCompra() : lista;
|
|
|
|
$("#DetalleOrdenCompra").Grid("RenderGrid", lista);
|
|
|
|
$.each(lista, function (id, item) {
|
|
setTypeNumeric({ id: '#txtMonto' + item.id, type: "currency" });
|
|
setTypeNumeric({ id: '#txtPorcentajeAdelanto' + item.id, type: "percent" });
|
|
$("#txtMonto" + item.id).autoNumeric('update', { aSign: item.IdMoneda == "0" ? '₡' : '$' });
|
|
|
|
});
|
|
|
|
$("#formInclusionDesembolso").valid();
|
|
$("#formInclusionDesembolso").validateElement("#txtNumeroBPCliente");
|
|
|
|
$("#formDetalleOrdenCompra").valid();
|
|
}
|
|
|
|
this.LeerControlesOrdenCompra = function (lista) {
|
|
|
|
lista = lista == null ? $("#DetalleOrdenCompra").Grid("Get") : lista;
|
|
|
|
$.each(lista, function (id, item) {
|
|
|
|
item.IdSolicitud = $("#hidden_co_solicitud").val();
|
|
item.NumeroLicitacion = $("#txtNumeroLicitacion" + item.id).val();
|
|
item.Monto = $("#txtMonto" + item.id).autoNumeric('get');
|
|
item.Plazo = $("#txtPlazo" + item.id).val();
|
|
item.PorcentajeAdelanto = $("#txtPorcentajeAdelanto" + item.id).autoNumeric('get');
|
|
item.Pagador = $("#txtPagador" + item.id).val();
|
|
item.IdMoneda = $("#ddlTipoMoneda").DropDownList("getselected").val();
|
|
|
|
});
|
|
|
|
return lista;
|
|
}
|
|
|
|
this.GuardaOrdenCompraModelo = function () {
|
|
|
|
var lista = LeerControlesOrdenCompra();
|
|
|
|
$.each(lista, function (id, item) {
|
|
|
|
item.CNumeroLicitacion = null;
|
|
item.CMonto = null;
|
|
item.CPlazo = 0;
|
|
item.CPorcentajeAdelanto = 0;
|
|
item.CPagador = null;
|
|
item.opciones = null;
|
|
|
|
});
|
|
|
|
model.Solicitud.DesembolsoDatosGenerales.DesemboloDetalleOrdenCompra = lista;
|
|
}
|
|
//#endregion
|
|
|
|
//#region ADELANTO CONTRATO
|
|
this.CargarDetalleAdelanto = function () {
|
|
|
|
$("#DetalleAdelantoContraContrato").Grid("Set", {
|
|
setCustomSettings: function (Settings) {
|
|
|
|
var readonly = Etapas.DE_Inclu_Sol_Desembolso && $("#hiddenTaskStatus").val() == 1 && $("#divDetalleAdelantoContraContrato").is(":visible") ? false : true;
|
|
|
|
if (Settings.data.length > 0)
|
|
$.each(Settings.data, function (id, item) {
|
|
|
|
item.id = id;
|
|
//item.CLinea = '<input value="' + item.Linea + '" type="text" id="txtLinea' + id + '" name="txtLinea' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
//item.CMontoAprobado = '<input value="' + item.MontoAprobado + '" type="text" id="txtMontoAprobado' + id + '" name="txtMontoAprobado' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
//item.CPorcentaje = '<input value="' + item.Porcentaje + '" type="text" id="txtPorcentaje' + id + '" name="txtPorcentaje' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
//item.CMontoUtilizado = '<input value="' + item.MontoUtilizado + '" type="text" id="txtMontoUtilizado' + id + '" name="txtMontoUtilizado' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
//item.CMontoDisponible = '<input value="' + item.MontoDisponible + '" type="text" id="txtMontoDisponible' + id + '" name="txtMontoDisponible' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly" ' : 'required="required"') + ' >'
|
|
|
|
|
|
item.Linea = item.Linea == null ? "" : item.Linea;
|
|
item.MontoAprobado = isNaN(item.MontoAprobado) || item.MontoAprobado == null ? "" : item.MontoAprobado;
|
|
item.Porcentaje = isNaN(item.Porcentaje) || item.Porcentaje == null ? "" : item.Porcentaje;
|
|
item.MontoUtilizado = isNaN(item.MontoUtilizado) || item.MontoUtilizado == null ? "" : item.MontoUtilizado;
|
|
item.MontoDisponible = isNaN(item.MontoDisponible) || item.MontoDisponible == null ? "" : item.MontoDisponible;
|
|
|
|
|
|
item.CLinea = '<input value="' + item.Linea + '" type="text" id="txtLinea' + id + '" name="txtLinea' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
item.CMontoAprobado = '<input value="' + item.MontoAprobado + '" type="text" id="txtMontoAprobado' + id + '" name="txtMontoAprobado' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' onchange="ToggleMontoAprobadoAdelantoContrato(' + id + ')" >'
|
|
item.CPorcentaje = '<input value="' + item.Porcentaje + '" type="text" id="txtPorcentaje' + id + '" name="txtPorcentaje' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'readonly="readonly"') + ' >'
|
|
item.CMontoUtilizado = '<input value="' + item.MontoUtilizado + '" type="text" id="txtMontoUtilizado' + id + '" name="txtMontoUtilizado' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly"' : 'required="required"') + ' >'
|
|
item.CMontoDisponible = '<input value="' + item.MontoDisponible + '" type="text" id="txtMontoDisponible' + id + '" name="txtMontoDisponible' + id + '" placeholder="" class="form-control imput-xs TextBoxFramework" ' + (readonly ? 'readonly="readonly" ' : 'required="required"') + ' >'
|
|
|
|
item.opciones = "";
|
|
|
|
if (!readonly) {
|
|
|
|
|
|
if ((Settings.data.length - 1) == id)
|
|
item.opciones += ' <span id="Agregar" class="fa fa-2x fa-plus HandCursor"></span>'
|
|
else
|
|
item.opciones += '<span id="Eliminar" class="fa fa-2x fa-trash HandCursor"></span>'
|
|
}
|
|
});
|
|
|
|
return Settings;
|
|
},
|
|
RowEvent: function (IdControl, DataRow) {
|
|
|
|
if (IdControl == "Agregar") {
|
|
AgregarAdelantoContrato(DataRow);
|
|
}
|
|
else if (IdControl == "Eliminar" && confirm("¿Esta seguro que desea eliminar el adelanto?")) {
|
|
var lista = LeerControlesAdelantoContrato();
|
|
|
|
lista = $.grep(lista, function (item, id) {
|
|
return item.id != DataRow.id;
|
|
});
|
|
|
|
RefrescaAdelantoContrato(lista);
|
|
|
|
if (lista.length == 0)
|
|
AgregarAdelantoContrato(DataRow);
|
|
|
|
TotalizarAdelantoContrato(lista);
|
|
}
|
|
}
|
|
});
|
|
|
|
if (model.Solicitud != null && model.Solicitud.DesembolsoDatosGenerales != null)
|
|
RefrescaAdelantoContrato(model.Solicitud.DesembolsoDatosGenerales.DesembolsoDetalleAdelantosContraContrato);
|
|
|
|
if ($("#DetalleAdelantoContraContrato").Grid("Get").length == 0 && ($("#divDetalleAdelantoContraContrato").is(":visible") && Etapas.DE_Inclu_Sol_Desembolso))
|
|
AgregarAdelantoContrato();
|
|
}
|
|
|
|
|
|
this.ToggleMontoAprobadoAdelantoContrato = function (id) {
|
|
var _porcentahe = 0;
|
|
|
|
try {
|
|
var _SaldoOrdenCompra = parseFloat($("#txtSaldoOrdenCompra").autoNumeric('get'));
|
|
var _MontoAprobado = parseFloat($("#txtMontoAprobado" + id).autoNumeric('get'));
|
|
|
|
|
|
_SaldoOrdenCompra = isNaN(_SaldoOrdenCompra) ? 0 : _SaldoOrdenCompra;
|
|
_MontoAprobado = isNaN(_MontoAprobado) ? 0 : _MontoAprobado;
|
|
|
|
if (_SaldoOrdenCompra > 0) {
|
|
_porcentahe = (_MontoAprobado / _SaldoOrdenCompra) * 100;
|
|
_porcentahe = isNaN(_porcentahe) ? 0 : _porcentahe;
|
|
}
|
|
|
|
$("#txtPorcentaje" + id).autoNumeric('set', (_porcentahe));
|
|
|
|
} catch (e) {
|
|
$("#txtPorcentaje" + id).autoNumeric('set', (_porcentahe));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.AgregarAdelantoContrato = function (DataRow) {
|
|
|
|
|
|
|
|
var lista = LeerControlesAdelantoContrato();
|
|
|
|
if (DataRow != null) {
|
|
|
|
var itemValidacion = $.grep(lista, function (item, id) {
|
|
return item.id == DataRow.id;
|
|
})[0];
|
|
|
|
var msg = "";
|
|
if (IsNullOrEmpty(itemValidacion.Linea)) msg += "- Rubro<br>";
|
|
if (IsNullOrEmpty(itemValidacion.MontoAprobado)) msg += "- Monto aprobado<br>";
|
|
if (IsNullOrEmpty(itemValidacion.Porcentaje)) msg += "- Porcentaje<br>";
|
|
if (IsNullOrEmpty(itemValidacion.MontoUtilizado)) msg += "- Monto utilizado<br>";
|
|
if (IsNullOrEmpty(itemValidacion.MontoDisponible)) msg += "- Monto disponible<br>";
|
|
|
|
if (!IsNullOrEmpty(msg)) {
|
|
toastr.warning("Debe registrar los campos requeridos:<br>" + msg);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
lista = lista == null ? new Array() : lista;
|
|
var id = lista.length;
|
|
|
|
var adelanto = {
|
|
id: id
|
|
, IdSolicitud: $("#hidden_co_solicitud").val()
|
|
, IdAdelanto: 0
|
|
, Linea: ""
|
|
, MontoAprobado: ""
|
|
, Porcentaje: ""
|
|
, MontoUtilizado: ""
|
|
, MontoDisponible: ""
|
|
};
|
|
|
|
lista.push(adelanto);
|
|
|
|
RefrescaAdelantoContrato(lista);
|
|
|
|
TotalizarAdelantoContrato(lista);
|
|
|
|
}
|
|
|
|
this.RefrescaAdelantoContrato = function (lista) {
|
|
lista = lista == null ? LeerControlesAdelantoContrato() : lista;
|
|
|
|
$("#DetalleAdelantoContraContrato").Grid("RenderGrid", lista);
|
|
|
|
var IdMoneda = $("#ddlTipoMoneda").DropDownList("getselected").val();
|
|
|
|
$.each(lista, function (id, item) {
|
|
setTypeNumeric({ id: '#txtMontoAprobado' + item.id, type: "currency" });
|
|
setTypeNumeric({ id: '#txtMontoUtilizado' + item.id, type: "currency" });
|
|
setTypeNumeric({ id: '#txtMontoDisponible' + item.id, type: "currency" });
|
|
setTypeNumeric({ id: '#txtPorcentaje' + item.id, type: "percent" });
|
|
|
|
|
|
$("#txtMontoAprobado" + item.id).autoNumeric('update', { aSign: IdMoneda == "0" ? '₡' : '$' });
|
|
$("#txtMontoUtilizado" + item.id).autoNumeric('update', { aSign: IdMoneda == "0" ? '₡' : '$' });
|
|
$("#txtMontoDisponible" + item.id).autoNumeric('update', { aSign: IdMoneda == "0" ? '₡' : '$' });
|
|
|
|
});
|
|
|
|
$("#formInclusionDesembolso").valid();
|
|
$("#formInclusionDesembolso").validateElement("#txtNumeroBPCliente");
|
|
|
|
$("#formDetalleAdelantoContraContrato").valid();
|
|
}
|
|
|
|
this.LeerControlesAdelantoContrato = function (lista) {
|
|
|
|
lista = lista == null ? $("#DetalleAdelantoContraContrato").Grid("Get") : lista;
|
|
debugger
|
|
$.each(lista, function (id, item) {
|
|
item.IdSolicitud = $("#hidden_co_solicitud").val();
|
|
item.Linea = $("#txtLinea" + item.id).val();
|
|
item.MontoAprobado = $("#txtMontoAprobado" + item.id).autoNumeric('get');
|
|
item.Porcentaje = $("#txtPorcentaje" + item.id).autoNumeric('get');
|
|
item.MontoUtilizado = $("#txtMontoUtilizado" + item.id).autoNumeric('get');
|
|
item.MontoDisponible = $("#txtMontoDisponible" + item.id).autoNumeric('get');
|
|
debugger
|
|
});
|
|
|
|
return lista;
|
|
}
|
|
|
|
this.GuardaAdelantoContratoModelo = function () {
|
|
|
|
var lista = LeerControlesAdelantoContrato();
|
|
|
|
$.each(lista, function (id, item) {
|
|
|
|
item.CLinea = null;
|
|
item.CMontoAprobado = null;
|
|
item.CPorcentaje = 0;
|
|
item.CPorcentajeAdelanto = 0;
|
|
item.CMontoUtilizado = null;
|
|
item.CMontoDisponible = null;
|
|
item.opciones = null;
|
|
|
|
});
|
|
|
|
model.Solicitud.DesembolsoDatosGenerales.DesembolsoDetalleAdelantosContraContrato = lista;
|
|
}
|
|
|
|
this.ValidateJustificacion = function () {
|
|
var resp = true;
|
|
|
|
if ($("#txtComentariosAdicionales").val().trim() == "") {
|
|
var estadoCCSS = $("#ddlEstadoCCSS").DropDownList("getselected").val();
|
|
if (estadoCCSS == "1") {
|
|
$("#txtComentariosAdicionales").required();
|
|
toastr.warning("Debe registrar una justificación por atraso en la CCSS dentro de los comentarios adicionales.");
|
|
resp = false;
|
|
}
|
|
|
|
|
|
if ($("#txtEstadoOperaciones").val() == "Atrasado") {
|
|
$("#txtComentariosAdicionales").required();
|
|
toastr.warning("Debe registrar una justificación por atraso en las Operaciones dentro de los comentarios adicionales.");
|
|
resp = false;
|
|
}
|
|
}
|
|
|
|
return resp;
|
|
}
|
|
|
|
|
|
|
|
this.CalculaMontoDisponibleFuturo = function () {
|
|
var _MontoDesembolsoLinea = parseFloat($("#txtMontoDesembolsoLinea").autoNumeric('get'));
|
|
var _MontoDesembolsoSublimite = parseFloat($("#txtMontoDesembolsoSublimite").autoNumeric('get'));
|
|
|
|
_MontoDesembolsoLinea = isNaN(_MontoDesembolsoLinea) ? 0 : _MontoDesembolsoLinea;
|
|
_MontoDesembolsoSublimite = isNaN(_MontoDesembolsoSublimite) ? 0 : _MontoDesembolsoSublimite;
|
|
|
|
var descuento = parseFloat($("#txtMontoDisponibleLineaActual").autoNumeric('get')) - _MontoDesembolsoLinea
|
|
$("#txtMontoDisponibleLineaFuturo").autoNumeric('set', (descuento));
|
|
|
|
|
|
var descuento2 = parseFloat($("#txtMontoDisponibleSublimiteActual").autoNumeric('get')) - _MontoDesembolsoSublimite;
|
|
$("#txtMontoDisponibleSublimiteFuturo").autoNumeric('set', (descuento2));
|
|
|
|
|
|
}
|
|
//#endregion
|
|
|
|
this.ObtenerValoresEsquemaUltimus = function () {
|
|
|
|
|
|
if (Etapas.DE_Inclu_Sol_Desembolso == true ) {
|
|
Ultimus.LoadMessage();
|
|
|
|
var modeloGetNodeValueEsquema = {
|
|
ListaVariables: [
|
|
{ Nombre: "TaskData.Global.VerificaTramite", Valor: "" },
|
|
{ Nombre: "TaskData.Global.VerificaRechazada", Valor: "" },
|
|
{ Nombre: "TaskData.Global.EtapaActivaVerificar", Valor: "" }
|
|
]
|
|
}
|
|
|
|
modeloGetNodeValueEsquema = LeerControlesUltimus(modeloGetNodeValueEsquema);
|
|
|
|
Ultimus.AjaxPostData(server + "api/GlobalAPI/ObtenerVariableEsquemaUltimus", modeloGetNodeValueEsquema, false, false, function (data) {
|
|
|
|
if (data != null && data.CodigoRespuesta == "EXITOSO") {
|
|
$.each(data.ListaVariables, function (id, item) {
|
|
|
|
switch (item.Nombre) {
|
|
case "TaskData.Global.VerificaTramite":
|
|
TaskData_Global_VerificaTramite = (item.Valor.toLowerCase().trim() == "true" ? true : false);
|
|
|
|
|
|
break;
|
|
case "TaskData.Global.VerificaRechazada":
|
|
TaskData_Global_VerificaRechazada = (item.Valor.toLowerCase().trim() == "true" ? true : false);
|
|
|
|
|
|
break;
|
|
case "TaskData.Global.EtapaActivaVerificar":
|
|
TaskData_Global_EtapaActivaVerificar = item.Valor.trim();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
else
|
|
toastr.error(data.DescripcionRespuesta);
|
|
|
|
|
|
ENDREQUEST();
|
|
|
|
}, "ERROR");
|
|
}
|
|
}
|
|
|
|
this.ToggleBitacoraComentariosDevolucion = function () {
|
|
|
|
|
|
if (TaskData_Global_VerificaTramite == true || TaskData_Global_VerificaRechazada == true) {
|
|
|
|
//******************************************************************
|
|
//Inicializa y abre los comentarios de tipo devolucion de trámite
|
|
//******************************************************************
|
|
InicializarBitacoraComentariosInternos(TaskData_Global_EtapaActivaVerificar, EnumTipoComentario.ComentarioDevolucionTramite, true, BitacoraComentariosInternos_Show);
|
|
}
|
|
else {
|
|
$("#btnBitacoraComentarioDevolucion").attr("style", "display:none;");
|
|
}
|
|
} |