FondosDeInversionCE.vb 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. Public Class FondosDeInversionCE
  2. Private _ValorNominal As Double
  3. Private _CuotasDeParticipacion As Double
  4. Private _ValorDeParticipacion As Double
  5. Private _PorcentajeComisionCasa As Double
  6. Private _ComisionCasa As Double
  7. Private _PorcentajeComisionBolsa As Double
  8. Private _ComisionBolsa As Double
  9. Private _ValorTransado As Double
  10. Private _FechaOperacion As Date
  11. Private _FechaLiquidacion As Date
  12. Private _FechaVencimiento As Date
  13. Private _RendimientoOfrecido As Double
  14. Private _Periodicidad As String
  15. Private _AnioBase As Integer
  16. Private _Plazo As Integer
  17. Private _Dividendo As Double
  18. Public FondoInversionDAO = New FondoInversionDAO
  19. Public Property ValorNominal As Double
  20. Get
  21. Return _ValorNominal
  22. End Get
  23. Set(value As Double)
  24. _ValorNominal = value
  25. CalcularValorTransado()
  26. End Set
  27. End Property
  28. Public Property CuotasDeParticipacion As Double
  29. Get
  30. Return _CuotasDeParticipacion
  31. End Get
  32. Set(value As Double)
  33. _CuotasDeParticipacion = value
  34. CalcularValorNominal()
  35. End Set
  36. End Property
  37. Public Property ValorDeParticipacion As Double
  38. Get
  39. Return _ValorDeParticipacion
  40. End Get
  41. Set(value As Double)
  42. _ValorDeParticipacion = value
  43. CalcularValorNominal()
  44. End Set
  45. End Property
  46. Public Property PorcentajeComisionCasa As Double
  47. Get
  48. Return _PorcentajeComisionCasa
  49. End Get
  50. Set(value As Double)
  51. _PorcentajeComisionCasa = value
  52. End Set
  53. End Property
  54. Public Property ComisionCasa As Double
  55. Get
  56. Return _ComisionCasa
  57. End Get
  58. Set(value As Double)
  59. _ComisionCasa = value
  60. CalcularValorTransado()
  61. End Set
  62. End Property
  63. Public Property PorcentajeComisionBolsa As Double
  64. Get
  65. Return _PorcentajeComisionBolsa
  66. End Get
  67. Set(value As Double)
  68. _PorcentajeComisionBolsa = value
  69. End Set
  70. End Property
  71. Public Property ComisionBolsa As Double
  72. Get
  73. Return _ComisionBolsa
  74. End Get
  75. Set(value As Double)
  76. _ComisionBolsa = value
  77. CalcularValorTransado()
  78. End Set
  79. End Property
  80. Public Property ValorTransado As Double
  81. Get
  82. Return _ValorTransado
  83. End Get
  84. Set(value As Double)
  85. _ValorTransado = value
  86. End Set
  87. End Property
  88. Public Property FechaOperacion As Date
  89. Get
  90. Return _FechaOperacion
  91. End Get
  92. Set(value As Date)
  93. _FechaOperacion = value
  94. End Set
  95. End Property
  96. Public Property FechaLiquidacion As Date
  97. Get
  98. Return _FechaLiquidacion
  99. End Get
  100. Set(value As Date)
  101. _FechaLiquidacion = value
  102. End Set
  103. End Property
  104. Public Property FechaVencimiento As Date
  105. Get
  106. Return _FechaVencimiento
  107. End Get
  108. Set(value As Date)
  109. _FechaVencimiento = value
  110. End Set
  111. End Property
  112. Public Property RendimientoOfrecido As Double
  113. Get
  114. Return _RendimientoOfrecido
  115. End Get
  116. Set(value As Double)
  117. _RendimientoOfrecido = value
  118. End Set
  119. End Property
  120. Public Property Periodicidad As String
  121. Get
  122. Return _Periodicidad
  123. End Get
  124. Set(value As String)
  125. _Periodicidad = value
  126. End Set
  127. End Property
  128. Public Property AnioBase As Integer
  129. Get
  130. Return _AnioBase
  131. End Get
  132. Set(value As Integer)
  133. _AnioBase = value
  134. End Set
  135. End Property
  136. Public Property Plazo As Integer
  137. Get
  138. Return _Plazo
  139. End Get
  140. Set(value As Integer)
  141. _Plazo = value
  142. End Set
  143. End Property
  144. Public Property Dividendo As Double
  145. Get
  146. Return _Dividendo
  147. End Get
  148. Set(value As Double)
  149. _Dividendo = value
  150. End Set
  151. End Property
  152. Sub New()
  153. ValorNominal = 0
  154. CuotasDeParticipacion = 0
  155. ValorDeParticipacion = 0
  156. PorcentajeComisionCasa = 0
  157. ComisionCasa = 0
  158. PorcentajeComisionBolsa = 0
  159. ComisionBolsa = 0
  160. ValorTransado = 0
  161. FechaOperacion = Date.Now.Date
  162. FechaLiquidacion = Date.Now.Date
  163. FechaVencimiento = Date.Now.Date
  164. RendimientoOfrecido = 0
  165. Periodicidad = ""
  166. AnioBase = 365
  167. Plazo = 0
  168. Dividendo = 0
  169. End Sub
  170. Public Sub CalcularValorNominal()
  171. Dim valor As Double
  172. Dim vCuotasParticipacion As Double = CuotasDeParticipacion
  173. Dim vValorDeParticipacion As Double = ValorDeParticipacion
  174. Try
  175. valor = vCuotasParticipacion * vValorDeParticipacion
  176. Catch ex As Exception
  177. valor = 0
  178. End Try
  179. ValorNominal = valor
  180. End Sub
  181. Public Sub CalcularComisionCasa()
  182. End Sub
  183. Public Sub CalcularComisionBolsa()
  184. End Sub
  185. Public Sub CalcularValorTransado()
  186. Dim valor As Double
  187. Dim vValorNominal As Double = ValorNominal
  188. Dim vComisionCasa As Double = ComisionCasa
  189. Dim vComisionBolsa As Double = ComisionBolsa
  190. Try
  191. valor = vValorNominal + vComisionCasa + vComisionBolsa
  192. Catch ex As Exception
  193. valor = 0
  194. End Try
  195. ValorTransado = valor
  196. End Sub
  197. Public Function TablaIngresos() As DataTable
  198. Dim dtIngresos As DataTable
  199. Dim vFilas As DataRow
  200. Dim vColumnas As DataColumn
  201. Dim vFechaInicial As Date
  202. Dim vSiguienteFecha As Date
  203. Dim vDias As Integer
  204. Dim vDividendo As Double = Dividendo
  205. Dim vIngreso As Double
  206. Dim vRendimiento As Double
  207. Dim vCuotasDeParticipacion As Double = CuotasDeParticipacion
  208. Dim vValorNominal As Double = ValorNominal
  209. Dim vAnioBase As Integer = AnioBase
  210. Dim vDiasDelMes As Integer
  211. Dim vEstaFecha As Date
  212. Dim vPrimerCalculo As Boolean = True
  213. dtIngresos = New DataTable
  214. vColumnas = New DataColumn
  215. vColumnas.DataType = GetType(Date)
  216. vColumnas.ColumnName = "Fecha"
  217. vColumnas.Caption = "Fecha de Corte"
  218. vColumnas.AllowDBNull = False
  219. dtIngresos.Columns.Add(vColumnas)
  220. vColumnas = New DataColumn
  221. vColumnas.DataType = GetType(Integer)
  222. vColumnas.ColumnName = "Dias"
  223. vColumnas.Caption = "Dias"
  224. vColumnas.AllowDBNull = False
  225. dtIngresos.Columns.Add(vColumnas)
  226. vColumnas = New DataColumn
  227. vColumnas.DataType = GetType(Double)
  228. vColumnas.ColumnName = "Dividendo"
  229. vColumnas.Caption = "Dividendo"
  230. vColumnas.AllowDBNull = False
  231. dtIngresos.Columns.Add(vColumnas)
  232. vColumnas = New DataColumn
  233. vColumnas.DataType = GetType(Double)
  234. vColumnas.ColumnName = "Ingreso"
  235. vColumnas.Caption = "Ingreso"
  236. vColumnas.AllowDBNull = False
  237. dtIngresos.Columns.Add(vColumnas)
  238. vColumnas = New DataColumn
  239. vColumnas.DataType = GetType(Double)
  240. vColumnas.ColumnName = "Rendimiento"
  241. vColumnas.Caption = "Rendimiento"
  242. vColumnas.AllowDBNull = False
  243. dtIngresos.Columns.Add(vColumnas)
  244. vFechaInicial = FechaOperacion
  245. vDiasDelMes = Date.DaysInMonth(vFechaInicial.Year, vFechaInicial.Month)
  246. vSiguienteFecha = New Date(vFechaInicial.Year, vFechaInicial.Month, vDiasDelMes)
  247. vDias = DateDiff(DateInterval.Day, vFechaInicial, vSiguienteFecha)
  248. While vSiguienteFecha.Date <= FechaVencimiento.Date
  249. If vPrimerCalculo Then
  250. vIngreso = ((vDividendo * vCuotasDeParticipacion) / 30) * vDias
  251. vPrimerCalculo = False
  252. Else
  253. vIngreso = vDividendo * vCuotasDeParticipacion
  254. End If
  255. vRendimiento = vIngreso / vValorNominal * vAnioBase / vDias
  256. vFilas = dtIngresos.NewRow
  257. vFilas("Fecha") = vSiguienteFecha
  258. vFilas("Dias") = vDias
  259. vFilas("Dividendo") = vDividendo
  260. vFilas("Ingreso") = vIngreso
  261. vFilas("Rendimiento") = vRendimiento
  262. dtIngresos.Rows.Add(vFilas)
  263. vEstaFecha = vSiguienteFecha
  264. vSiguienteFecha = vSiguienteFecha.AddDays(1)
  265. vDiasDelMes = Date.DaysInMonth(vSiguienteFecha.Year, vSiguienteFecha.Month)
  266. vSiguienteFecha = New Date(vSiguienteFecha.Year, vSiguienteFecha.Month, vDiasDelMes)
  267. vDias = DateDiff(DateInterval.Day, vEstaFecha, vSiguienteFecha)
  268. End While
  269. Return dtIngresos
  270. dtIngresos.Dispose()
  271. End Function
  272. Public Function CalculoValorNominal(ByVal CuotasParticipacion As Double, ByVal ValorParticipacion As Double)
  273. Dim Total = CuotasParticipacion * ValorParticipacion
  274. Return Total
  275. End Function
  276. Public Function CalculoFechaLiq(ByVal FechaOperaciones As Date, ByVal Dias As Integer)
  277. Dim fecha = FechaOperaciones.AddDays(Dias)
  278. Return fecha
  279. End Function
  280. Public Sub Modificar(ByVal Coleccion As Collection, ByVal Codigo As String)
  281. FondoInversionDAO.Modificar(Coleccion, Codigo)
  282. End Sub
  283. Public Sub Nuevo(ByVal Coleccion As Collection, ByVal Codigo As String)
  284. FondoInversionDAO.Nuevo(Coleccion, Codigo)
  285. End Sub
  286. Public Sub Eliminar(ByVal Codigo As String)
  287. FondoInversionDAO.Eliminar(Codigo)
  288. End Sub
  289. End Class