Public Class DepositosAPlazoCE Private _DocId As Integer Private _CodigoInversion As String Private _MontoDeInversion As Double Private _FechaOperacion As Date Private _FechaVencimiento As Date Private _Tasa As Double Private _Plazo As Double Private _AnioBase As Integer Private _Periodicidad As String Private _RendimientoBruto As Double Private _RendimientoNeto As Double Private _IngresoBruto As Double Private _Impuestos As Double Private _IngresoNeto As Double Private _dtIntereses As DataTable Dim Operaciones As New Operaciones Public Property dtIntereses As DataTable Get Return _dtIntereses End Get Set(value As DataTable) _dtIntereses = value CalcularSumaIngresoBruto() CalcularSumaISR() CalcularIngresoNeto() End Set End Property Public Property CodigoInversion As String Get Return _CodigoInversion End Get Set(value As String) _CodigoInversion = value End Set End Property Public Property MontoDeInversion As Double Get Return _MontoDeInversion End Get Set(value As Double) _MontoDeInversion = value CalcularRendimientoBruto() CalcularRendimientoNeto() End Set End Property Public Property FechaOperacion As Date Get Return _FechaOperacion End Get Set(value As Date) _FechaOperacion = value End Set End Property Public Property FechaVencimiento As Date Get Return _FechaVencimiento End Get Set(value As Date) _FechaVencimiento = value End Set End Property Public Property Tasa As Double Get Return _Tasa End Get Set(value As Double) _Tasa = value End Set End Property Public Property Plazo As Double Get Return _Plazo End Get Set(value As Double) _Plazo = value CalcularRendimientoBruto() CalcularRendimientoNeto() End Set End Property Public Property Periodicidad As String Get Return _Periodicidad End Get Set(value As String) _Periodicidad = value End Set End Property Public ReadOnly Property RendimientoBruto As Double Get Return _RendimientoBruto End Get End Property Public ReadOnly Property RendimientoNeto As Double Get Return _RendimientoNeto End Get End Property Public Sub New() _MontoDeInversion = 0.00 _FechaOperacion = Date.Now.Date _FechaVencimiento = Date.Now.Date _Tasa = 0.00 _Plazo = 0 _Periodicidad = "M" PreparaTablaIntereses() End Sub Private Sub PreparaTablaIntereses() _dtIntereses = New DataTable Dim column As DataColumn column = New DataColumn() column.DataType = GetType(String) column.ColumnName = "CodInv" column.Caption = "Codigo Inversion" column.ReadOnly = True _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Integer) column.ColumnName = "Correlativo" column.Caption = "Correlativo" column.ReadOnly = True _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Integer) column.ColumnName = "Plazo" column.Caption = "Plazo" _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Date) column.ColumnName = "Fecha" column.Caption = "Fecha" _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Double) column.ColumnName = "IngrBruto" column.Caption = "Ingreso Bruto" _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Double) column.ColumnName = "PorcImp" column.Caption = "Porc. de Impuesto" _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Double) column.ColumnName = "MontoImp" column.Caption = "Impuesto" _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(Double) column.ColumnName = "IngrNeto" column.Caption = "Ingreso Neto" _dtIntereses.Columns.Add(column) column = New DataColumn() column.DataType = GetType(String) column.ColumnName = "Estado" column.Caption = "Estado" _dtIntereses.Columns.Add(column) End Sub Private Sub CalcularSumaIngresoBruto() If Not Double.TryParse(_dtIntereses.Compute("SUM(IngrBruto)", "").ToString, _IngresoBruto) Then _IngresoBruto = 0 End If CalcularRendimientoBruto() End Sub Private Sub CalcularSumaISR() If Not Double.TryParse(_dtIntereses.Compute("SUM(MontoImp)", "").ToString, _Impuestos) Then _Impuestos = 0 End If End Sub Private Sub CalcularIngresoNeto() If Not Double.TryParse(_dtIntereses.Compute("SUM(IngrNeto)", "").ToString, _IngresoNeto) Then _IngresoNeto = 0 End If CalcularRendimientoNeto() End Sub Private Sub CalcularRendimientoBruto() Dim valor As Double Dim vIngresoBruto As Double = _IngresoBruto Dim vMontoInversion As Double = _MontoDeInversion Dim vDiasDelAnio As Integer = Utilidades.CalcularDiasDelAnio(_FechaVencimiento) Dim vPlazo As Integer = _Plazo valor = (vIngresoBruto / vMontoInversion) * (vDiasDelAnio / vPlazo) _RendimientoBruto = valor End Sub Private Sub CalcularRendimientoNeto() Dim valor As Double Dim vIngresoNeto As Double = _IngresoNeto Dim vMontoInversion As Double = _MontoDeInversion Dim vDiasDelAnio As Integer = Utilidades.CalcularDiasDelAnio(_FechaVencimiento) Dim vPlazo As Integer = _Plazo valor = (vIngresoNeto / vMontoInversion) * (vDiasDelAnio / vPlazo) _RendimientoNeto = valor End Sub Function CalcularPlazo(ByVal ValorPlazo As String) Dim Dias As Integer = 0 If (ValorPlazo = "M") Then Dias = 30 ElseIf (ValorPlazo = "T") Then Dias = 90 ElseIf (ValorPlazo = "S") Then Dias = 180 ElseIf (ValorPlazo = "A") Then Dias = 365 End If Return Dias End Function Function CalcularIteraciones(ByVal PlazoGlobal As Integer, ByVal Plazo As Integer) Dim Cantidad As Integer = 0 If (Not String.IsNullOrEmpty(Plazo.ToString) And Not Plazo.ToString = "0") Then Cantidad = PlazoGlobal / Plazo End If Return Cantidad End Function Function CalcularFecha(ByVal Dias As Integer, ByVal Fecha As Date) Return Fecha.AddDays(Dias) End Function Function CalculosIngrBruto(ByVal FechaInicial As Date, FechaFinal As Date, ByVal MontoInv As Double, ByVal Tasa As Double, ByVal Plazo As Integer) Dim IngresoBruto = 0.0, IngresoBrutoOpc1 = 0.0, IngresoBrutoOpc2 = 0.0 Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal) Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial) Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal) Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0 If (Not CambioDeFecha = 0) Then If CambioDeFecha = 1 Then DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha) DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha) IngresoBrutoOpc1 = (MontoInv * Tasa * DiasPrimeraFecha) / 366 IngresoBrutoOpc2 = (MontoInv * Tasa * DiasSegundaFecha) / 365 ElseIf CambioDeFecha = 2 Then DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha) DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha) IngresoBrutoOpc1 = (MontoInv * Tasa * DiasPrimeraFecha) / 365 IngresoBrutoOpc2 = (MontoInv * Tasa * DiasSegundaFecha) / 366 End If IngresoBruto = IngresoBrutoOpc1 + IngresoBrutoOpc2 Else If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then IngresoBruto = (MontoInv * Tasa * Plazo) / 365 End If If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then IngresoBruto = (MontoInv * Tasa * Plazo) / 366 End If End If Return IngresoBruto End Function Function Renta(ByVal PorcentajeRent As Double, ByVal IngBruto As Double) Dim DescuentoRenta As Double DescuentoRenta = IngBruto * PorcentajeRent Return DescuentoRenta End Function Function CalculosIngNeto(ByVal IngBruto As Double, ByVal Renta As Double) Dim CalculoIngrNeto As Double CalculoIngrNeto = IngBruto - Renta Return CalculoIngrNeto End Function End Class