526 lines
32 KiB
VB.net
526 lines
32 KiB
VB.net
Imports ULA.Davivienda.WCFServiciosGenerales.Entidades
|
|
Imports ULA.Davivienda.WCFServiciosGenerales.DAL
|
|
Imports System.Xml
|
|
|
|
Public Class UtilitarioSensibilizacionBL
|
|
|
|
|
|
#Region "Publicos"
|
|
|
|
Public Shared Sub GuardaCalculoSensibilizacion(ByVal proceso As String,
|
|
ByVal incidente As String,
|
|
ByVal solicitud As String,
|
|
ByVal identificacion As String,
|
|
ByVal tipo_cliente As String,
|
|
ByVal idcliente As Integer,
|
|
ByVal valores As Hashtable)
|
|
|
|
Dim NombreFuenteDatos As String = String.Empty
|
|
Dim strSQL As String = String.Empty
|
|
Dim strXML As String = String.Empty
|
|
Dim arrParametrosNombres(33), arrParametrosValores(33) As String
|
|
|
|
Try
|
|
|
|
If proceso = Enumerador.ProcesoUltimus.PrestamoPrendario.ToString() Then
|
|
NombreFuenteDatos = Enumerador.FuenteDatosUltimus.BPMPRENDARIO.ToString()
|
|
End If
|
|
|
|
|
|
strSQL = "usp_cp_sensibilizacion"
|
|
arrParametrosNombres(0) = "" : arrParametrosValores(0) = ""
|
|
arrParametrosNombres(1) = "@i_opcion" : arrParametrosValores(1) = "2"
|
|
arrParametrosNombres(2) = "@i_incidente" : arrParametrosValores(2) = incidente
|
|
arrParametrosNombres(3) = "@i_solicitud" : arrParametrosValores(3) = solicitud
|
|
arrParametrosNombres(4) = "@i_identificacion" : arrParametrosValores(4) = identificacion
|
|
arrParametrosNombres(5) = "@i_co_tipoparticipante" : arrParametrosValores(5) = tipo_cliente
|
|
'''*****************************************************************************************
|
|
'''Escenario Leve
|
|
'''*****************************************************************************************
|
|
arrParametrosNombres(6) = "@i_esc1_cuota" : arrParametrosValores(6) = SubCadena(valores("esc1_cuota").ToString(), 0, 19)
|
|
arrParametrosNombres(7) = "@i_esc1_ingnetos" : arrParametrosValores(7) = SubCadena(valores("esc1_ingresosnetos").ToString(), 0, 19)
|
|
arrParametrosNombres(8) = "@i_esc1_cuotaingreso" : arrParametrosValores(8) = SubCadena(valores("esc1_cuotaingreso").ToString(), 0, 19)
|
|
arrParametrosNombres(9) = "@i_esc1_endeudamiento" : arrParametrosValores(9) = SubCadena(valores("esc1_endeudamiento").ToString(), 0, 19)
|
|
arrParametrosNombres(10) = "@i_esc1_tasa" : arrParametrosValores(10) = SubCadena(valores("esc1_tasa").ToString(), 0, 19)
|
|
arrParametrosNombres(11) = "@i_esc1_tipocambio_esp" : arrParametrosValores(11) = SubCadena(valores("esc1_tipocambio_esp").ToString(), 0, 19)
|
|
|
|
'''*****************************************************************************************
|
|
'''Escenario Moderado
|
|
'''*****************************************************************************************
|
|
arrParametrosNombres(12) = "@i_esc2_cuota" : arrParametrosValores(12) = SubCadena(valores("esc2_cuota").ToString(), 0, 19)
|
|
arrParametrosNombres(13) = "@i_esc2_ingnetos" : arrParametrosValores(13) = SubCadena(valores("esc2_ingresosnetos").ToString(), 0, 19)
|
|
arrParametrosNombres(14) = "@i_esc2_cuotaingreso" : arrParametrosValores(14) = SubCadena(valores("esc2_cuotaingreso").ToString(), 0, 19)
|
|
arrParametrosNombres(15) = "@i_esc2_endeudamiento" : arrParametrosValores(15) = SubCadena(valores("esc2_endeudamiento").ToString(), 0, 19)
|
|
arrParametrosNombres(16) = "@i_esc2_tasa" : arrParametrosValores(16) = SubCadena(valores("esc2_tasa").ToString(), 0, 19)
|
|
arrParametrosNombres(17) = "@i_esc2_tipocambio_esp" : arrParametrosValores(17) = SubCadena(valores("esc2_tipocambio_esp").ToString(), 0, 19)
|
|
'''*****************************************************************************************
|
|
'''Escenario Severo
|
|
'''*****************************************************************************************
|
|
arrParametrosNombres(18) = "@i_esc3_cuota" : arrParametrosValores(18) = SubCadena(valores("esc3_cuota").ToString(), 0, 19)
|
|
arrParametrosNombres(19) = "@i_esc3_ingnetos" : arrParametrosValores(19) = SubCadena(valores("esc3_ingresosnetos").ToString(), 0, 19)
|
|
arrParametrosNombres(20) = "@i_esc3_cuotaingreso" : arrParametrosValores(20) = SubCadena(valores("esc3_cuotaingreso").ToString(), 0, 19)
|
|
arrParametrosNombres(21) = "@i_esc3_endeudamiento" : arrParametrosValores(21) = SubCadena(valores("esc3_endeudamiento").ToString(), 0, 19)
|
|
arrParametrosNombres(22) = "@i_esc3_tasa" : arrParametrosValores(22) = SubCadena(valores("esc3_tasa").ToString(), 0, 19)
|
|
arrParametrosNombres(23) = "@i_esc3_tipocambio_esp" : arrParametrosValores(23) = SubCadena(valores("esc3_tipocambio_esp").ToString(), 0, 19)
|
|
|
|
arrParametrosNombres(24) = "@i_co_tipo_tasa" : arrParametrosValores(24) = ""
|
|
arrParametrosNombres(25) = "@i_proceso" : arrParametrosValores(25) = proceso
|
|
arrParametrosNombres(26) = "@i_tipocambio" : arrParametrosValores(26) = valores("TipoCambio").ToString()
|
|
arrParametrosNombres(27) = "@i_idcliente" : arrParametrosValores(27) = idcliente.ToString()
|
|
|
|
'''*****************************************************************************************
|
|
'''Escenario Normal
|
|
'''*****************************************************************************************
|
|
arrParametrosNombres(28) = "@i_esc0_cuota" : arrParametrosValores(28) = SubCadena(valores("esc0_cuota").ToString(), 0, 19)
|
|
arrParametrosNombres(29) = "@i_esc0_ingnetos" : arrParametrosValores(29) = SubCadena(valores("esc0_ingresosnetos").ToString(), 0, 19)
|
|
arrParametrosNombres(30) = "@i_esc0_cuotaingreso" : arrParametrosValores(30) = SubCadena(valores("esc0_cuotaingreso").ToString(), 0, 19)
|
|
arrParametrosNombres(31) = "@i_esc0_endeudamiento" : arrParametrosValores(31) = SubCadena(valores("esc0_endeudamiento").ToString(), 0, 19)
|
|
arrParametrosNombres(32) = "@i_esc0_tasa" : arrParametrosValores(32) = SubCadena(valores("esc0_tasa").ToString(), 0, 19)
|
|
arrParametrosNombres(33) = "@i_esc0_tipocambio_esp" : arrParametrosValores(33) = SubCadena(valores("esc0_tipocambio_esp").ToString(), 0, 19)
|
|
|
|
strXML = outConector.EjecutarComandoSQLArreglo(proceso, NombreFuenteDatos, strSQL, arrParametrosNombres, arrParametrosValores, 0)
|
|
|
|
Catch ex As Exception
|
|
Throw ex
|
|
End Try
|
|
End Sub
|
|
|
|
Private Shared Function SubCadena(ByVal Parametro As String, ByVal Inicio As Integer, ByVal MaxLongitud As Integer) As String
|
|
Dim Retorno As String
|
|
|
|
Try
|
|
|
|
If ((Parametro.Length) < MaxLongitud) Then
|
|
MaxLongitud = (Parametro.Length)
|
|
End If
|
|
|
|
Retorno = Parametro.Substring(Inicio, MaxLongitud)
|
|
|
|
Catch ex As Exception
|
|
Retorno = Parametro
|
|
End Try
|
|
|
|
Return Retorno
|
|
|
|
End Function
|
|
|
|
|
|
Public Shared Sub CargarValoresSensibilizacion(ByRef valores As Hashtable, _
|
|
ByVal Moneda As String, _
|
|
ByVal IngNetoDol As String, _
|
|
ByVal IngNetoCol As String, _
|
|
ByVal TipoCambio As String, _
|
|
ByVal Proceso As String, _
|
|
ByVal TasaPrestamo As String, _
|
|
ByVal PlazoPrestamo As String, _
|
|
ByVal MontoPrestamo As String, _
|
|
ByVal Seguro As String, _
|
|
ByVal TotalCompromiso As String, _
|
|
ByVal CuotaPrestamo As String)
|
|
Try
|
|
|
|
Select Case Moneda
|
|
Case "0" 'COLONES
|
|
valores.Add("IngresoNeto", Double.Parse(IngNetoCol) + (Double.Parse(IngNetoDol) * Double.Parse(TipoCambio)))
|
|
valores.Add("esc0_ingresosnetos", Double.Parse(IngNetoCol) + (Double.Parse(IngNetoDol) * Double.Parse(TipoCambio)))
|
|
valores.Add("esc1_ingresosnetos", Double.Parse(IngNetoCol) + (Double.Parse(IngNetoDol) * (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp1"))))))
|
|
valores.Add("esc2_ingresosnetos", Double.Parse(IngNetoCol) + (Double.Parse(IngNetoDol) * (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp2"))))))
|
|
valores.Add("esc3_ingresosnetos", Double.Parse(IngNetoCol) + (Double.Parse(IngNetoDol) * (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp3"))))))
|
|
Case "1" 'DOLARES
|
|
valores.Add("IngresoNeto", Double.Parse(IngNetoDol) + (Double.Parse(IngNetoCol) / Double.Parse(TipoCambio)))
|
|
valores.Add("esc0_ingresosnetos", Double.Parse(IngNetoDol) + (Double.Parse(IngNetoCol) / Double.Parse(TipoCambio)))
|
|
valores.Add("esc1_ingresosnetos", Double.Parse(IngNetoDol) + (Double.Parse(IngNetoCol) / (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp1"))))))
|
|
valores.Add("esc2_ingresosnetos", Double.Parse(IngNetoDol) + (Double.Parse(IngNetoCol) / (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp2"))))))
|
|
valores.Add("esc3_ingresosnetos", Double.Parse(IngNetoDol) + (Double.Parse(IngNetoCol) / (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp3"))))))
|
|
|
|
Case Else
|
|
valores.Add("IngresoNeto", 0)
|
|
valores.Add("esc0_ingresosnetos", 0)
|
|
valores.Add("esc1_ingresosnetos", 0)
|
|
valores.Add("esc2_ingresosnetos", 0)
|
|
valores.Add("esc3_ingresosnetos", 0)
|
|
End Select
|
|
|
|
'Escenario 0
|
|
valores.Add("esc0_tasa", (Double.Parse(TasaPrestamo)) / 100)
|
|
PmtEscenarios(0, PlazoPrestamo, MontoPrestamo, Seguro, TotalCompromiso, TipoCambio, CuotaPrestamo, Proceso, valores)
|
|
|
|
'Escenario 1
|
|
valores.Add("esc1_tasa", (Double.Parse(TasaPrestamo) + (valores("tasa_minimo") / 100)) / 100)
|
|
PmtEscenarios(1, PlazoPrestamo, MontoPrestamo, Seguro, TotalCompromiso, TipoCambio, CuotaPrestamo, Proceso, valores)
|
|
|
|
'Escenario 2
|
|
valores.Add("esc2_tasa", (Double.Parse(TasaPrestamo) + (valores("tasa_promedio") / 100)) / 100)
|
|
PmtEscenarios(2, PlazoPrestamo, MontoPrestamo, Seguro, TotalCompromiso, TipoCambio, CuotaPrestamo, Proceso, valores)
|
|
|
|
'Escenario 3
|
|
valores.Add("esc3_tasa", (Double.Parse(TasaPrestamo) + (valores("tasa_maximo") / 100)) / 100)
|
|
PmtEscenarios(3, PlazoPrestamo, MontoPrestamo, Seguro, TotalCompromiso, TipoCambio, CuotaPrestamo, Proceso, valores)
|
|
|
|
|
|
Catch ex As Exception
|
|
Throw ex
|
|
End Try
|
|
End Sub
|
|
|
|
Public Shared Function ArmarRespuestaSensibilizacion(ByVal valores As Hashtable, ByVal Mode As Integer) As String
|
|
Dim respuestaXml As String = ""
|
|
Try
|
|
respuestaXml = "<Respuesta><Error></Error>"
|
|
respuestaXml += "<Proceso>" + valores("Proceso").ToString() + "</Proceso>"
|
|
respuestaXml += "<Incidente>" + valores("Incidente").ToString() + "</Incidente>"
|
|
respuestaXml += "<Solicitud>" + valores("Solicitud").ToString() + "</Solicitud>"
|
|
respuestaXml += "<Identificacion>" + valores("Identificacion").ToString() + "</Identificacion>"
|
|
respuestaXml += "<TipoCliente>" + valores("TipoCliente").ToString() + "</TipoCliente>"
|
|
respuestaXml += "<TipoTasa>" + valores("TipoTasa").ToString() + "</TipoTasa>"
|
|
respuestaXml += "<TasaPrestamo>" + valores("TasaPrestamo").ToString() + "</TasaPrestamo>"
|
|
respuestaXml += "<Moneda>" + valores("Moneda").ToString() + "</Moneda>"
|
|
respuestaXml += "<MontoPrestamo>" + valores("MontoPrestamo").ToString() + "</MontoPrestamo>"
|
|
respuestaXml += "<CuotaPrestamo>" + valores("CuotaPrestamo").ToString() + "</CuotaPrestamo>"
|
|
respuestaXml += "<PlazoPrestamo>" + valores("PlazoPrestamo").ToString() + "</PlazoPrestamo>"
|
|
respuestaXml += "<TipoCambio>" + valores("TipoCambio").ToString() + "</TipoCambio>"
|
|
respuestaXml += "<TotalCompromiso>" + valores("TotalCompromiso").ToString() + "</TotalCompromiso>"
|
|
respuestaXml += "<IngresoNeto>" + valores("IngresoNeto").ToString() + "</IngresoNeto>"
|
|
respuestaXml += "<SoloLectura>" + valores("SoloLectura").ToString() + "</SoloLectura>"
|
|
respuestaXml += "<Seguro>" + valores("Seguro").ToString() + "</Seguro>"
|
|
respuestaXml += "<IngNetoCol>" + valores("IngNetoCol").ToString() + "</IngNetoCol>"
|
|
respuestaXml += "<IngNetoDol>" + valores("IngNetoDol").ToString() + "</IngNetoDol>"
|
|
respuestaXml += "<tasa_minimo>" + valores("tasa_minimo").ToString() + "</tasa_minimo>"
|
|
respuestaXml += "<tasa_promedio>" + valores("tasa_promedio").ToString() + "</tasa_promedio>"
|
|
respuestaXml += "<tasa_maximo>" + valores("tasa_maximo").ToString() + "</tasa_maximo>"
|
|
respuestaXml += "<porc_devesp>" + valores("porc_devesp").ToString() + "</porc_devesp>"
|
|
|
|
|
|
respuestaXml += "<Escenario_Normal>"
|
|
|
|
Select Case Mode
|
|
Case 0
|
|
respuestaXml += "<esc_normal_cuota>" + valores("CuotaPrestamo").ToString() + "</esc_normal_cuota>"
|
|
respuestaXml += "<esc_normal_cuotaingreso>" + (Double.Parse(valores("CuotaPrestamo")) / Double.Parse(valores("IngresoNeto"))).ToString() + "</esc_normal_cuotaingreso>"
|
|
respuestaXml += "<esc_normal_endeudamiento>" + ((Double.Parse(valores("CuotaPrestamo")) + Double.Parse(valores("TotalCompromiso"))) / valores("IngresoNeto")).ToString() + "</esc_normal_endeudamiento>"
|
|
respuestaXml += "<esc_normal_tasa>" + (Double.Parse(valores("TasaPrestamo")) / 100).ToString() + "</esc_normal_tasa>"
|
|
respuestaXml += "<esc_tipocambio_esp>" + (valores("TipoCambio") * (1 + (1 / 100))).ToString() + "</esc_tipocambio_esp>"
|
|
Case 1
|
|
respuestaXml += "<esc_normal_cuota>" + valores("esc0_cuota").ToString() + "</esc_normal_cuota>"
|
|
respuestaXml += "<esc_normal_cuotaingreso>" + valores("esc0_cuotaingreso").ToString() + "</esc_normal_cuotaingreso>"
|
|
respuestaXml += "<esc_normal_endeudamiento>" + valores("esc0_endeudamiento").ToString() + "</esc_normal_endeudamiento>"
|
|
respuestaXml += "<esc_normal_tasa>" + (Double.Parse(valores("esc0_tasa")) / 100).ToString() + "</esc_normal_tasa>"
|
|
respuestaXml += "<esc_tipocambio_esp>" + valores("esc0_tipocambio_esp").ToString() + "</esc_tipocambio_esp>"
|
|
respuestaXml += "<esc_normal_ingresosnetos>" + valores("esc0_ingresosnetos").ToString() + "</esc_normal_ingresosnetos>"
|
|
End Select
|
|
|
|
respuestaXml += "</Escenario_Normal>"
|
|
|
|
|
|
For i As Integer = 1 To 3 Step 1
|
|
respuestaXml += "<Escenario_" + i.ToString() + ">"
|
|
respuestaXml += "<esc" + i.ToString() + "_cuota>" + valores("esc" + i.ToString() + "_cuota").ToString() + "</esc" + i.ToString() + "_cuota>"
|
|
respuestaXml += "<inc_devesp" + i.ToString() + ">" + valores("inc_devesp" + i.ToString()).ToString() + "</inc_devesp" + i.ToString() + ">"
|
|
respuestaXml += "<esc" + i.ToString() + "_cuotaingreso>" + valores("esc" + i.ToString() + "_cuotaingreso").ToString() + "</esc" + i.ToString() + "_cuotaingreso>"
|
|
respuestaXml += "<esc" + i.ToString() + "_endeudamiento>" + valores("esc" + i.ToString() + "_endeudamiento").ToString() + "</esc" + i.ToString() + "_endeudamiento>"
|
|
respuestaXml += "<esc" + i.ToString() + "_tipocambio_esp>" + valores("esc" + i.ToString() + "_tipocambio_esp").ToString() + "</esc" + i.ToString() + "_tipocambio_esp>"
|
|
respuestaXml += "<esc" + i.ToString() + "_ingresosnetos>" + valores("esc" + i.ToString() + "_ingresosnetos").ToString() + "</esc" + i.ToString() + "_ingresosnetos>"
|
|
respuestaXml += "<esc" + i.ToString() + "_tasa>" + (Double.Parse(valores("esc" + i.ToString() + "_tasa")) / 100).ToString() + "</esc" + i.ToString() + "_tasa>"
|
|
respuestaXml += "<esc" + i.ToString() + "_crecimiento_tasa>" + (valores("tasa_minimo") / 100).ToString() + "</esc" + i.ToString() + "_crecimiento_tasa>"
|
|
respuestaXml += "</Escenario_" + i.ToString() + ">"
|
|
Next
|
|
respuestaXml += "</Respuesta>"
|
|
Catch ex As Exception
|
|
respuestaXml = "<Respuesta><Error>" + ex.Message + "</Error></Respuesta>"
|
|
End Try
|
|
Return respuestaXml
|
|
End Function
|
|
|
|
Public Shared Function ObtieneParametrosSensibilizacion(ByVal proceso As String, _
|
|
ByVal tipo_tasa As String, _
|
|
ByVal moneda As String) As Hashtable
|
|
Dim parametros As Hashtable = Nothing
|
|
Dim NombreFuenteDatos As String = String.Empty
|
|
|
|
Dim strSQL As String = String.Empty
|
|
Dim strXML As String = String.Empty
|
|
|
|
Dim arrParametrosNombres(4),
|
|
arrParametrosValores(4) As String
|
|
|
|
Dim xmlResp As XmlDocument = Nothing
|
|
Dim xmlRoot As XmlNode = Nothing
|
|
|
|
Try
|
|
|
|
parametros = New Hashtable()
|
|
|
|
If proceso = Enumerador.ProcesoUltimus.PrestamoPrendario.ToString() Then
|
|
|
|
NombreFuenteDatos = Enumerador.FuenteDatosUltimus.BPMPRENDARIO.ToString()
|
|
strSQL = "usp_cp_sensibilizacion"
|
|
arrParametrosNombres(0) = ""
|
|
arrParametrosValores(0) = ""
|
|
arrParametrosNombres(1) = "@i_opcion"
|
|
arrParametrosValores(1) = "1"
|
|
arrParametrosNombres(2) = "@i_co_tipo_tasa"
|
|
arrParametrosValores(2) = tipo_tasa
|
|
arrParametrosNombres(3) = "@i_co_moneda"
|
|
arrParametrosValores(3) = moneda
|
|
arrParametrosNombres(4) = "@i_proceso"
|
|
arrParametrosValores(4) = proceso
|
|
|
|
strXML = outConector.EjecutarComandoSQLArreglo(proceso, NombreFuenteDatos, strSQL, arrParametrosNombres, arrParametrosValores, 0)
|
|
|
|
|
|
If (strXML <> "<NewDataSet />") Then
|
|
xmlResp = New XmlDocument
|
|
xmlResp.LoadXml(strXML)
|
|
xmlRoot = xmlResp.SelectSingleNode("//NewDataSet/Table")
|
|
parametros = New Hashtable
|
|
parametros.Add("tasa_minimo", _
|
|
Double.Parse(xmlRoot.SelectSingleNode("it_minimo").InnerText))
|
|
parametros.Add("tasa_promedio", _
|
|
Double.Parse(xmlRoot.SelectSingleNode("it_promedio").InnerText))
|
|
parametros.Add("tasa_maximo", _
|
|
Double.Parse(xmlRoot.SelectSingleNode("it_maximo").InnerText))
|
|
|
|
parametros.Add("porc_devesp", 1)
|
|
|
|
parametros.Add("inc_devesp1", _
|
|
Double.Parse(xmlRoot.SelectSingleNode("de_inc_devesp1").InnerText))
|
|
parametros.Add("inc_devesp2", _
|
|
Double.Parse(xmlRoot.SelectSingleNode("de_inc_devesp2").InnerText))
|
|
parametros.Add("inc_devesp3", _
|
|
Double.Parse(xmlRoot.SelectSingleNode("de_inc_devesp3").InnerText))
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
parametros = New Hashtable
|
|
parametros.Add("Error", ex.Message)
|
|
End Try
|
|
|
|
Return parametros
|
|
|
|
End Function
|
|
|
|
|
|
Public Shared Sub CalculoSensibilizacionOperaciones(ByVal Incidente As Integer,
|
|
ByVal Solicitud As Integer,
|
|
ByVal Proceso As String,
|
|
ByVal Identificacion As String,
|
|
ByVal IngresosNetosColones As Double,
|
|
ByVal IngresosNetosDolares As Double,
|
|
ByVal TipoCambio As Double,
|
|
ByVal CuotaPrestamo As Double,
|
|
ByVal TasaInteres As Double,
|
|
ByVal TipoTasa As String,
|
|
ByVal CoMoneda As Integer,
|
|
ByVal PlazoPrestamo As String,
|
|
ByVal MontoPrestamo As Double,
|
|
ByVal Seguro As String,
|
|
ByVal IdCliente As Integer)
|
|
|
|
|
|
Dim strSQL As String = String.Empty
|
|
Dim strXML As String = String.Empty
|
|
Dim NombreSP As String = String.Empty
|
|
Dim sProceso As String = String.Empty
|
|
Dim NombreFuenteDatos As String = String.Empty
|
|
|
|
Dim xmlResp As XmlDocument = Nothing
|
|
Dim xmlRoot As XmlNode = Nothing
|
|
|
|
Dim arrParametrosNombres(17),
|
|
arrParametrosValores(17) As String
|
|
|
|
Try
|
|
|
|
If Proceso = Enumerador.ProcesoUltimus.PrestamoPrendario.ToString() Then
|
|
|
|
strSQL = "usp_wf_sensibilizacion_deudas"
|
|
NombreFuenteDatos = Enumerador.FuenteDatosUltimus.BPMDATA.ToString()
|
|
|
|
arrParametrosNombres(1) = "@i_opcion" : arrParametrosValores(1) = "1"
|
|
arrParametrosNombres(2) = "@i_incidente" : arrParametrosValores(2) = Incidente
|
|
arrParametrosNombres(3) = "@i_idsolicitud" : arrParametrosValores(3) = Solicitud
|
|
arrParametrosNombres(4) = "@i_identificacion" : arrParametrosValores(4) = Identificacion
|
|
arrParametrosNombres(5) = "@i_co_tipoparticipante" : arrParametrosValores(5) = "1"
|
|
arrParametrosNombres(6) = "@i_proceso" : arrParametrosValores(6) = Proceso
|
|
arrParametrosNombres(7) = "@i_ingreso_neto_col" : arrParametrosValores(7) = IngresosNetosColones
|
|
arrParametrosNombres(8) = "@i_ingreso_neto_dol" : arrParametrosValores(8) = IngresosNetosDolares
|
|
arrParametrosNombres(9) = "@i_tipo_cambio" : arrParametrosValores(9) = TipoCambio
|
|
arrParametrosNombres(10) = "@i_cuota" : arrParametrosValores(10) = CuotaPrestamo
|
|
arrParametrosNombres(11) = "@i_tasa" : arrParametrosValores(11) = TasaInteres
|
|
arrParametrosNombres(12) = "@i_tipo_tasa" : arrParametrosValores(12) = TipoTasa
|
|
arrParametrosNombres(13) = "@i_co_moneda" : arrParametrosValores(13) = CoMoneda
|
|
arrParametrosNombres(14) = "@i_plazo_meses" : arrParametrosValores(14) = PlazoPrestamo
|
|
arrParametrosNombres(15) = "@i_monto" : arrParametrosValores(15) = MontoPrestamo
|
|
arrParametrosNombres(16) = "@i_idcliente" : arrParametrosValores(16) = IdCliente
|
|
arrParametrosNombres(17) = "@i_seguros" : arrParametrosValores(17) = Seguro
|
|
|
|
strXML = outConector.EjecutarComandoSQLArreglo(Proceso, NombreFuenteDatos, strSQL, arrParametrosNombres, arrParametrosValores, 0)
|
|
|
|
If (strXML <> "<NewDataSet />") Then
|
|
xmlResp = New XmlDocument
|
|
xmlResp.LoadXml(strXML)
|
|
|
|
xmlRoot = xmlResp.SelectSingleNode("//NewDataSet/Table")
|
|
|
|
Dim RespCode = xmlRoot.SelectSingleNode("res_code").InnerText
|
|
If RespCode <> "0" Then
|
|
Dim RespMessage = xmlRoot.SelectSingleNode("res_message").InnerText
|
|
Dim RespErrProcedure = xmlRoot.SelectSingleNode("res_err_procedure").InnerText
|
|
Dim RespErrLine = xmlRoot.SelectSingleNode("res_err_line").InnerText
|
|
|
|
Throw New Exception(String.Format("Ha ocurrido un problema al intentar realizar el cálculo de sensibilización por operación.\nCode:{0}\nMessage:{1}\nStored Procedure:{2}\nLine{3}", RespCode, RespMessage, RespErrProcedure, RespErrLine))
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
Throw ex
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Public Shared Sub CargaEndeudamientoDTICalculado(ByVal Incidente As Integer,
|
|
ByVal Solicitud As Integer,
|
|
ByVal Proceso As String,
|
|
ByVal Identificacion As String,
|
|
ByVal IdCliente As Integer,
|
|
ByRef valores As Hashtable)
|
|
Dim strSQL As String = String.Empty
|
|
Dim strXML As String = String.Empty
|
|
Dim NombreSP As String = String.Empty
|
|
Dim sProceso As String = String.Empty
|
|
Dim NombreFuenteDatos As String = String.Empty
|
|
|
|
Dim xmlResp As XmlDocument = Nothing
|
|
Dim xmlRoot As XmlNode = Nothing
|
|
|
|
Dim arrParametrosNombres(6),
|
|
arrParametrosValores(6) As String
|
|
|
|
Try
|
|
|
|
If Proceso = Enumerador.ProcesoUltimus.PrestamoPrendario.ToString() Then
|
|
|
|
strSQL = "usp_wf_sensibilizacion_deudas"
|
|
NombreFuenteDatos = Enumerador.FuenteDatosUltimus.BPMDATA.ToString()
|
|
|
|
arrParametrosNombres(1) = "@i_opcion" : arrParametrosValores(1) = "3"
|
|
arrParametrosNombres(2) = "@i_incidente" : arrParametrosValores(2) = Incidente
|
|
arrParametrosNombres(3) = "@i_idsolicitud" : arrParametrosValores(3) = Solicitud
|
|
arrParametrosNombres(4) = "@i_identificacion" : arrParametrosValores(4) = Identificacion
|
|
arrParametrosNombres(5) = "@i_proceso" : arrParametrosValores(5) = Proceso
|
|
arrParametrosNombres(6) = "@i_idcliente" : arrParametrosValores(6) = IdCliente
|
|
|
|
strXML = outConector.EjecutarComandoSQLArreglo(Proceso, NombreFuenteDatos, strSQL, arrParametrosNombres, arrParametrosValores, 0)
|
|
|
|
If (strXML <> "<NewDataSet />") Then
|
|
xmlResp = New XmlDocument
|
|
xmlResp.LoadXml(strXML)
|
|
xmlRoot = xmlResp.SelectSingleNode("//NewDataSet/Table")
|
|
|
|
valores("esc0_endeudamiento") = xmlRoot.SelectSingleNode("sr_endeuda_esc_normal").InnerText
|
|
valores("esc1_endeudamiento") = xmlRoot.SelectSingleNode("sr_endeuda_esc_leve").InnerText
|
|
valores("esc2_endeudamiento") = xmlRoot.SelectSingleNode("sr_endeuda_esc_moderado").InnerText
|
|
valores("esc3_endeudamiento") = xmlRoot.SelectSingleNode("sr_endeuda_esc_severo").InnerText
|
|
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
Throw ex
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "Privados"
|
|
|
|
Private Shared Sub PmtEscenarios(ByVal escenario As Integer, _
|
|
ByVal PlazoPrestamo As String, _
|
|
ByVal MontoPrestamo As String, _
|
|
ByVal Seguro As String, _
|
|
ByVal TotalCompromiso As String, _
|
|
ByVal TipoCambio As String, _
|
|
ByVal CuotaPrestamo As String, _
|
|
ByVal Proceso As String, _
|
|
ByRef valores As Hashtable)
|
|
|
|
Dim PmtEscenario As Double = 0
|
|
Dim dblCuotaAnterior As Double = 0
|
|
Dim dbTasaAnterior As Double = 0
|
|
Dim dbTasaActual As Double = 0
|
|
|
|
Try
|
|
'******************************************************************************************
|
|
'Se elimina la forma anterior para el calculo de la cuota
|
|
'******************************************************************************************
|
|
PmtEscenario = (-1) * Microsoft.VisualBasic.Financial.Pmt((valores("esc" + escenario.ToString() + "_tasa") / 12), Double.Parse(PlazoPrestamo), Double.Parse(MontoPrestamo), 0, 0)
|
|
|
|
|
|
''******************************************************************************************
|
|
''Utiliza la cuota del escenario anterior o la cuota del prestamo (para el primer escenario)
|
|
''******************************************************************************************
|
|
|
|
'Dim sCuotaAnterior As String = IIf(valores("esc" + (escenario - 1).ToString() + "_cuota") Is Nothing, CuotaPrestamo, valores("esc" + (escenario - 1).ToString() + "_cuota"))
|
|
'Double.TryParse(sCuotaAnterior, dblCuotaAnterior)
|
|
|
|
''******************************************************************************************
|
|
''Utiliza la tasa del escenario anterior o la tasa del prestamo (para el primer escenario)
|
|
''******************************************************************************************
|
|
'Dim sTasaAnterior As String = IIf(valores("esc" + (escenario - 1).ToString() + "_tasa") Is Nothing, valores("TasaPrestamo"), valores("esc" + (escenario - 1).ToString() + "_tasa"))
|
|
'Double.TryParse(sTasaAnterior, dbTasaAnterior)
|
|
|
|
''******************************************************************************************
|
|
''Utiliza la tasa del escenario actual o la tasa del prestamo
|
|
''******************************************************************************************
|
|
'Dim sTasaActual As String = IIf(valores("esc" + escenario.ToString() + "_tasa") Is Nothing, valores("TasaPrestamo"), valores("esc" + escenario.ToString() + "_tasa"))
|
|
'Double.TryParse(sTasaActual, dbTasaActual)
|
|
|
|
|
|
'PmtEscenario = PmtCalculoCuotaEscenario(dblCuotaAnterior, dbTasaAnterior, dbTasaActual)
|
|
|
|
If Proceso = Enumerador.ProcesoUltimus.PrestamoPrendario.ToString() Or
|
|
Proceso = "CREDITO PERSONAL" Then
|
|
|
|
valores.Add("esc" + escenario.ToString() + "_cuota", PmtEscenario + Double.Parse(Seguro))
|
|
|
|
ElseIf Proceso.Equals("TARJETA_CREDITO") Then
|
|
valores.Add("esc" + escenario.ToString() + "_cuota", CuotaPrestamo)
|
|
|
|
End If
|
|
|
|
'valores.Add("esc" + escenario.ToString() + "_cuota", PmtEscenario + Double.Parse(Seguro))
|
|
valores.Add("esc" + escenario.ToString() + "_cuotaingreso", (valores("esc" + escenario.ToString() + "_cuota") / valores("esc" + escenario.ToString() + "_ingresosnetos")))
|
|
valores.Add("esc" + escenario.ToString() + "_endeudamiento", (((valores("esc" + escenario.ToString() + "_cuota") + Double.Parse(TotalCompromiso)) / valores("esc" + escenario.ToString() + "_ingresosnetos"))))
|
|
valores.Add("esc" + escenario.ToString() + "_tipocambio_esp", (Double.Parse(TipoCambio) * (1 + ((valores("porc_devesp") / 100) * valores("inc_devesp" + escenario.ToString())))))
|
|
|
|
Catch ex As Exception
|
|
|
|
Throw New Exception("Ha ocurrido un error en el calculo de los escenarios de sensibilización.Por favor contacte al administrador del sistema.")
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
Private Shared Function PmtCalculoCuotaEscenario(ByVal dblCuotaAnterior As Double, ByVal dblTasaAnterior As Double, ByVal dblTasaActual As Double) As Double
|
|
|
|
Dim dblCuotaEscenario As Double = 0
|
|
Try
|
|
dblCuotaEscenario = (dblCuotaAnterior * IIf(dblTasaActual > 1, dblTasaActual / 100, dblTasaActual)) / IIf(dblTasaAnterior > 1, dblTasaAnterior / 100, dblTasaAnterior)
|
|
Catch
|
|
dblCuotaEscenario = 0
|
|
End Try
|
|
|
|
Return dblCuotaEscenario
|
|
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
End Class
|