DepositosAPlazoCE.vb 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. Public Class DepositosAPlazoCE
  2. Private _DocId As Integer
  3. Private _CodigoInversion As String
  4. Private _MontoDeInversion As Double
  5. Private _FechaOperacion As Date
  6. Private _FechaVencimiento As Date
  7. Private _Tasa As Double
  8. Private _Plazo As Double
  9. Private _AnioBase As Integer
  10. Private _Periodicidad As String
  11. Private _RendimientoBruto As Double
  12. Private _RendimientoNeto As Double
  13. Private _IngresoBruto As Double
  14. Private _Impuestos As Double
  15. Private _IngresoNeto As Double
  16. Private _dtIntereses As DataTable
  17. Dim Operaciones As New Operaciones
  18. Public Property dtIntereses As DataTable
  19. Get
  20. Return _dtIntereses
  21. End Get
  22. Set(value As DataTable)
  23. _dtIntereses = value
  24. CalcularSumaIngresoBruto()
  25. CalcularSumaISR()
  26. CalcularIngresoNeto()
  27. End Set
  28. End Property
  29. Public Property CodigoInversion As String
  30. Get
  31. Return _CodigoInversion
  32. End Get
  33. Set(value As String)
  34. _CodigoInversion = value
  35. End Set
  36. End Property
  37. Public Property MontoDeInversion As Double
  38. Get
  39. Return _MontoDeInversion
  40. End Get
  41. Set(value As Double)
  42. _MontoDeInversion = value
  43. CalcularRendimientoBruto()
  44. CalcularRendimientoNeto()
  45. End Set
  46. End Property
  47. Public Property FechaOperacion As Date
  48. Get
  49. Return _FechaOperacion
  50. End Get
  51. Set(value As Date)
  52. _FechaOperacion = value
  53. End Set
  54. End Property
  55. Public Property FechaVencimiento As Date
  56. Get
  57. Return _FechaVencimiento
  58. End Get
  59. Set(value As Date)
  60. _FechaVencimiento = value
  61. End Set
  62. End Property
  63. Public Property Tasa As Double
  64. Get
  65. Return _Tasa
  66. End Get
  67. Set(value As Double)
  68. _Tasa = value
  69. End Set
  70. End Property
  71. Public Property Plazo As Double
  72. Get
  73. Return _Plazo
  74. End Get
  75. Set(value As Double)
  76. _Plazo = value
  77. CalcularRendimientoBruto()
  78. CalcularRendimientoNeto()
  79. End Set
  80. End Property
  81. Public Property Periodicidad As String
  82. Get
  83. Return _Periodicidad
  84. End Get
  85. Set(value As String)
  86. _Periodicidad = value
  87. End Set
  88. End Property
  89. Public ReadOnly Property RendimientoBruto As Double
  90. Get
  91. Return _RendimientoBruto
  92. End Get
  93. End Property
  94. Public ReadOnly Property RendimientoNeto As Double
  95. Get
  96. Return _RendimientoNeto
  97. End Get
  98. End Property
  99. Public Sub New()
  100. _MontoDeInversion = 0.00
  101. _FechaOperacion = Date.Now.Date
  102. _FechaVencimiento = Date.Now.Date
  103. _Tasa = 0.00
  104. _Plazo = 0
  105. _Periodicidad = "M"
  106. PreparaTablaIntereses()
  107. End Sub
  108. Private Sub PreparaTablaIntereses()
  109. _dtIntereses = New DataTable
  110. Dim column As DataColumn
  111. column = New DataColumn()
  112. column.DataType = GetType(String)
  113. column.ColumnName = "CodInv"
  114. column.Caption = "Codigo Inversion"
  115. column.ReadOnly = True
  116. _dtIntereses.Columns.Add(column)
  117. column = New DataColumn()
  118. column.DataType = GetType(Integer)
  119. column.ColumnName = "Correlativo"
  120. column.Caption = "Correlativo"
  121. column.ReadOnly = True
  122. _dtIntereses.Columns.Add(column)
  123. column = New DataColumn()
  124. column.DataType = GetType(Integer)
  125. column.ColumnName = "Plazo"
  126. column.Caption = "Plazo"
  127. _dtIntereses.Columns.Add(column)
  128. column = New DataColumn()
  129. column.DataType = GetType(Date)
  130. column.ColumnName = "Fecha"
  131. column.Caption = "Fecha"
  132. _dtIntereses.Columns.Add(column)
  133. column = New DataColumn()
  134. column.DataType = GetType(Double)
  135. column.ColumnName = "IngrBruto"
  136. column.Caption = "Ingreso Bruto"
  137. _dtIntereses.Columns.Add(column)
  138. column = New DataColumn()
  139. column.DataType = GetType(Double)
  140. column.ColumnName = "PorcImp"
  141. column.Caption = "Porc. de Impuesto"
  142. _dtIntereses.Columns.Add(column)
  143. column = New DataColumn()
  144. column.DataType = GetType(Double)
  145. column.ColumnName = "MontoImp"
  146. column.Caption = "Impuesto"
  147. _dtIntereses.Columns.Add(column)
  148. column = New DataColumn()
  149. column.DataType = GetType(Double)
  150. column.ColumnName = "IngrNeto"
  151. column.Caption = "Ingreso Neto"
  152. _dtIntereses.Columns.Add(column)
  153. column = New DataColumn()
  154. column.DataType = GetType(String)
  155. column.ColumnName = "Estado"
  156. column.Caption = "Estado"
  157. _dtIntereses.Columns.Add(column)
  158. End Sub
  159. Private Sub CalcularSumaIngresoBruto()
  160. If Not Double.TryParse(_dtIntereses.Compute("SUM(IngrBruto)", "").ToString, _IngresoBruto) Then
  161. _IngresoBruto = 0
  162. End If
  163. CalcularRendimientoBruto()
  164. End Sub
  165. Private Sub CalcularSumaISR()
  166. If Not Double.TryParse(_dtIntereses.Compute("SUM(MontoImp)", "").ToString, _Impuestos) Then
  167. _Impuestos = 0
  168. End If
  169. End Sub
  170. Private Sub CalcularIngresoNeto()
  171. If Not Double.TryParse(_dtIntereses.Compute("SUM(IngrNeto)", "").ToString, _IngresoNeto) Then
  172. _IngresoNeto = 0
  173. End If
  174. CalcularRendimientoNeto()
  175. End Sub
  176. Private Sub CalcularRendimientoBruto()
  177. Dim valor As Double
  178. Dim vIngresoBruto As Double = _IngresoBruto
  179. Dim vMontoInversion As Double = _MontoDeInversion
  180. Dim vDiasDelAnio As Integer = Utilidades.CalcularDiasDelAnio(_FechaVencimiento)
  181. Dim vPlazo As Integer = _Plazo
  182. valor = (vIngresoBruto / vMontoInversion) * (vDiasDelAnio / vPlazo)
  183. _RendimientoBruto = valor
  184. End Sub
  185. Private Sub CalcularRendimientoNeto()
  186. Dim valor As Double
  187. Dim vIngresoNeto As Double = _IngresoNeto
  188. Dim vMontoInversion As Double = _MontoDeInversion
  189. Dim vDiasDelAnio As Integer = Utilidades.CalcularDiasDelAnio(_FechaVencimiento)
  190. Dim vPlazo As Integer = _Plazo
  191. valor = (vIngresoNeto / vMontoInversion) * (vDiasDelAnio / vPlazo)
  192. _RendimientoNeto = valor
  193. End Sub
  194. Function CalcularPlazo(ByVal ValorPlazo As String)
  195. Dim Dias As Integer = 0
  196. If (ValorPlazo = "M") Then
  197. Dias = 30
  198. ElseIf (ValorPlazo = "T") Then
  199. Dias = 90
  200. ElseIf (ValorPlazo = "S") Then
  201. Dias = 180
  202. ElseIf (ValorPlazo = "A") Then
  203. Dias = 365
  204. End If
  205. Return Dias
  206. End Function
  207. Function CalcularIteraciones(ByVal PlazoGlobal As Integer, ByVal Plazo As Integer)
  208. Dim Cantidad As Integer = 0
  209. If (Not String.IsNullOrEmpty(Plazo.ToString) And Not Plazo.ToString = "0") Then
  210. Cantidad = PlazoGlobal / Plazo
  211. End If
  212. Return Cantidad
  213. End Function
  214. Function CalcularFecha(ByVal Dias As Integer, ByVal Fecha As Date)
  215. Return Fecha.AddDays(Dias)
  216. End Function
  217. Function CalculosIngrBruto(ByVal FechaInicial As Date, FechaFinal As Date, ByVal MontoInv As Double, ByVal Tasa As Double, ByVal Plazo As Integer)
  218. Dim IngresoBruto = 0.0, IngresoBrutoOpc1 = 0.0, IngresoBrutoOpc2 = 0.0
  219. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  220. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  221. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  222. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  223. If (Not CambioDeFecha = 0) Then
  224. If CambioDeFecha = 1 Then
  225. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  226. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  227. IngresoBrutoOpc1 = (MontoInv * Tasa * DiasPrimeraFecha) / 366
  228. IngresoBrutoOpc2 = (MontoInv * Tasa * DiasSegundaFecha) / 365
  229. ElseIf CambioDeFecha = 2 Then
  230. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  231. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  232. IngresoBrutoOpc1 = (MontoInv * Tasa * DiasPrimeraFecha) / 365
  233. IngresoBrutoOpc2 = (MontoInv * Tasa * DiasSegundaFecha) / 366
  234. End If
  235. IngresoBruto = IngresoBrutoOpc1 + IngresoBrutoOpc2
  236. Else
  237. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  238. IngresoBruto = (MontoInv * Tasa * Plazo) / 365
  239. End If
  240. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  241. IngresoBruto = (MontoInv * Tasa * Plazo) / 366
  242. End If
  243. End If
  244. Return IngresoBruto
  245. End Function
  246. Function Renta(ByVal PorcentajeRent As Double, ByVal IngBruto As Double)
  247. Dim DescuentoRenta As Double
  248. DescuentoRenta = IngBruto * PorcentajeRent
  249. Return DescuentoRenta
  250. End Function
  251. Function CalculosIngNeto(ByVal IngBruto As Double, ByVal Renta As Double)
  252. Dim CalculoIngrNeto As Double
  253. CalculoIngrNeto = IngBruto - Renta
  254. Return CalculoIngrNeto
  255. End Function
  256. End Class