Operaciones.vb 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  1. Public Class Operaciones
  2. Private V_TipoOperacion As String
  3. Dim dia As Integer
  4. Dim dias31 As Integer
  5. Dim febreros As Integer
  6. Dim bisiesto As Integer
  7. Dim V_IngresoBruto As Double = 0.0
  8. Dim V_FechaInicial As Date
  9. Dim V_FechaCorte As Date
  10. Dim ElementosConsulta As New CargarElementosDAO
  11. Dim V_CodEmpr = ElementosConsulta.CodEmpr
  12. 'Dim V_CodIF = ElementosConsulta.CodIF
  13. Dim V_CodEmis = ElementosConsulta.CodEmis
  14. Dim V_CodECalRi = ElementosConsulta.CodECalRi
  15. Dim V_CodPais = ElementosConsulta.CodPais
  16. Dim V_ListaPlazo = ElementosConsulta.ListaPlazosFactor
  17. Dim V_ListaTiposMercados = ElementosConsulta.ListaTiposMercado
  18. Dim V_ListaPeriodos = ElementosConsulta.ListaPeriodos
  19. Dim V_ListaTipoTasa = ElementosConsulta.ListaTipoTasa
  20. Dim V_ListaTipoRenta = ElementosConsulta.ListaTipoRenta
  21. Dim V_ListaEstado = ElementosConsulta.ListaEstado
  22. Dim V_ListaCasasCorredoras = ElementosConsulta.ListaCasasCorredoras
  23. Public ReadOnly Property ListaCasasCorredoras
  24. Get
  25. Return V_ListaCasasCorredoras
  26. End Get
  27. End Property
  28. Public ReadOnly Property ListaEstado
  29. Get
  30. Return V_ListaEstado
  31. End Get
  32. End Property
  33. Public ReadOnly Property ListaTipoRenta
  34. Get
  35. Return V_ListaTipoRenta
  36. End Get
  37. End Property
  38. Public ReadOnly Property ListaTipoTasa
  39. Get
  40. Return V_ListaTipoTasa
  41. End Get
  42. End Property
  43. Public ReadOnly Property ListaPeriodos
  44. Get
  45. Return V_ListaPeriodos
  46. End Get
  47. End Property
  48. Public ReadOnly Property CodPais
  49. Get
  50. Return V_CodPais
  51. End Get
  52. End Property
  53. Public ReadOnly Property CodEmpr
  54. Get
  55. Return V_CodEmpr
  56. End Get
  57. End Property
  58. Public ReadOnly Property ListaTiposMercados
  59. Get
  60. Return V_ListaTiposMercados
  61. End Get
  62. End Property
  63. Public ReadOnly Property ListaPlazo
  64. Get
  65. Return V_ListaPlazo
  66. End Get
  67. End Property
  68. Public ReadOnly Property CodEmis
  69. Get
  70. Return V_CodEmis
  71. End Get
  72. End Property
  73. Public ReadOnly Property CodECalRi
  74. Get
  75. Return V_CodECalRi
  76. End Get
  77. End Property
  78. Public Property TipoOperacion() As String
  79. Get
  80. Return V_TipoOperacion
  81. End Get
  82. Set(value As String)
  83. V_TipoOperacion = value
  84. End Set
  85. End Property
  86. Public Function DiasVencimiento(ByVal fecha1 As DateTime, ByVal fecha2 As DateTime)
  87. Dim rango = DateDiff(DateInterval.Day, fecha2, fecha1)
  88. Return rango
  89. End Function
  90. Public Function DiasAcumulados(ByVal fecha1 As DateTime, ByVal fecha2 As DateTime, ByVal Base As Integer)
  91. Dim Total As Integer = 0
  92. fecha1 = Format(fecha1, "dd/MM/yyyy")
  93. fecha2 = Format(fecha2, "dd/MM/yyyy")
  94. If (Base = 0 Or Base = 2) Then
  95. Total = Base360(fecha1, fecha2)
  96. ElseIf (Base = 1 Or Base = 3) Then
  97. Total = Base365(fecha1, fecha2)
  98. Else
  99. Total = 0
  100. End If
  101. Return Total
  102. End Function
  103. Public Function Dias(ByVal fecha1 As DateTime, ByVal fecha2 As DateTime, ByVal Base As Integer)
  104. Dim Total As Integer = 0
  105. If (Base = 0 Or Base = 2) Then
  106. Total = Base360(fecha1, fecha2)
  107. ElseIf (Base = 1 Or Base = 3) Then
  108. Total = Base365(fecha1, fecha2)
  109. Else
  110. Total = 0
  111. End If
  112. Return Total
  113. End Function
  114. Public Function CantidadDiasAgregar(ByVal fecha1 As DateTime, ByVal fecha2 As DateTime)
  115. Dim Total As Integer = 0
  116. Total = Dias360(fecha1, fecha2)
  117. Total = 0
  118. Return Total
  119. End Function
  120. Public Function InteresAcumulado(ByVal ValorNominal As Double, ByVal Cupon As Double, ByVal DiasAcumulados As Double, ByVal BaseDias As Integer)
  121. Dim Proceso = ValorNominal * Cupon * DiasAcumulados / BaseDias
  122. Return Proceso
  123. End Function
  124. Public Function InteresAcumuladoPBUR(ByVal ValorNominal As Double, ByVal PorcCupon As Double, ByVal DiasAcumulados As Integer, ByVal IndexBase As Integer, ByVal FechaInicial As Date, FechaFinal As Date)
  125. Dim Proceso As Double = 0
  126. If (IndexBase = 0) Then
  127. Proceso = ValorNominal * PorcCupon * DiasAcumulados / 360
  128. ElseIf IndexBase = 1 Then
  129. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  130. Dim CambioDeFecha As Integer = CambioBase(FechaInicial, FechaFinal)
  131. Dim PrimeraFechaUltima = PrimeraFechaCambioBase(FechaInicial)
  132. Dim UltimaFechaPrimero = FinalFechaCambioBase(FechaFinal)
  133. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  134. If (Not CambioDeFecha = 0) Then
  135. If CambioDeFecha = 1 Then
  136. DiasPrimeraFecha = DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  137. DiasSegundaFecha = DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  138. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  139. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  140. ElseIf CambioDeFecha = 2 Then
  141. DiasPrimeraFecha = DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  142. DiasSegundaFecha = DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  143. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 365
  144. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 366
  145. End If
  146. Proceso = PrOpc1 + PrOpc2
  147. Else
  148. If (AñoBisiesto(FechaInicial) = 364) Then
  149. Proceso = ValorNominal * PorcCupon * DiasAcumulados / 365
  150. End If
  151. If (AñoBisiesto(FechaInicial) = 365) Then
  152. Proceso = ValorNominal * PorcCupon * DiasAcumulados / 366
  153. End If
  154. End If
  155. ElseIf IndexBase = 2 Then
  156. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  157. Dim CambioDeFecha As Integer = CambioBase(FechaInicial, FechaFinal)
  158. Dim PrimeraFechaUltima = PrimeraFechaCambioBase360(FechaInicial)
  159. Dim UltimaFechaPrimero = FinalFechaCambioBase360(FechaFinal)
  160. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  161. If (Not CambioDeFecha = 0) Then
  162. If CambioDeFecha = 1 Then
  163. DiasPrimeraFecha = DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  164. DiasSegundaFecha = DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  165. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  166. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  167. ElseIf CambioDeFecha = 2 Then
  168. DiasPrimeraFecha = DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  169. DiasSegundaFecha = DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  170. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 365
  171. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 366
  172. End If
  173. Proceso = PrOpc1 + PrOpc2
  174. Else
  175. If (AñoBisiesto(FechaInicial) = 364) Then
  176. Proceso = ValorNominal * PorcCupon * DiasAcumulados / 365
  177. End If
  178. If (AñoBisiesto(FechaInicial) = 365) Then
  179. Proceso = ValorNominal * PorcCupon * DiasAcumulados / 366
  180. End If
  181. End If
  182. ElseIf IndexBase = 3 Then
  183. Proceso = ValorNominal * PorcCupon * DiasAcumulados / 360
  184. End If
  185. Return Proceso
  186. End Function
  187. Public Function InteresAcumuladoPor(ByVal InteresAcumulado As Double, ByVal ValorNominal As Double)
  188. Dim Proceso = InteresAcumulado / ValorNominal * 360 * 180
  189. Return Proceso
  190. End Function
  191. Public Function PrecioSucio(ByVal PrecioCompra As Double, ByVal InteresAcumulado As Double)
  192. Dim Proceso = PrecioCompra * 0.01 + InteresAcumulado
  193. Return Proceso
  194. End Function
  195. Public Function ValorTrasado(ByVal PrecioCompra As Double, ByVal ValorNominal As Double)
  196. Dim Proceso = (PrecioCompra / 100) * ValorNominal
  197. Return Proceso
  198. End Function
  199. Public Function Comisiones(ByVal Comision As Double, ByVal ValorTrasado As Double)
  200. Dim Valor = CDec(Comision) * CDec(ValorTrasado)
  201. Return Valor
  202. End Function
  203. Public Function MontoPagar(ByVal ValorTrasado As Double, ByVal ComisionBolsa As Double, ByVal ComisionCasa As Double, ByVal InteresAcumulado As Double, ByVal CostoTransferencias As Double)
  204. Dim Valor = ValorTrasado + ComisionBolsa + ComisionCasa + InteresAcumulado + CostoTransferencias
  205. Return Valor
  206. End Function
  207. Public Function MontoRecibir(ByVal ValorTrasado As Double, ByVal ComisionBolsa As Double, ByVal ComisionCasa As Double, ByVal InteresAcumulado As Double)
  208. Dim Valor = ValorTrasado - ComisionBolsa - ComisionCasa + InteresAcumulado
  209. Return Valor
  210. End Function
  211. Public Function Base360(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  212. Dim Total As Integer = 0
  213. Dim dias = DateDiff(DateInterval.Day, Fecha1, Fecha2)
  214. Dim dia As Integer
  215. Dim dias31 As Integer
  216. Dim febreros As Integer
  217. Dim bisiesto As Integer
  218. While (Fecha1 < Fecha2)
  219. dia = dia + 1
  220. If (Fecha1.Day = 31) Then
  221. dias31 = dias31 + 1
  222. End If
  223. If (Fecha1.Month = 2 And Fecha1.Day = 28) Then
  224. febreros = febreros + 2
  225. End If
  226. If (Fecha1.Month = 2 And Fecha1.Day = 29) Then
  227. bisiesto = bisiesto + 1
  228. End If
  229. Fecha1 = Fecha1.AddDays(1)
  230. End While
  231. Total = dia - dias31 + febreros - bisiesto
  232. Return Total
  233. End Function
  234. Public Function Dias360(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  235. Dim Total As Integer = 0
  236. Dim dias = DateDiff(DateInterval.Day, Fecha1, Fecha2)
  237. Dim dia As Integer = 0
  238. Dim dias31 As Integer = 0
  239. Dim febreros As Integer = 0
  240. Dim bisiesto As Integer = 0
  241. Dim PasaFebrero As Integer = 0
  242. Dim PasaBisiesto As Integer = 0
  243. While (Fecha1 < Fecha2)
  244. dia = dia + 1
  245. If (Fecha1.Day = 31) Then
  246. dias31 = dias31 + 1
  247. End If
  248. If (Fecha1.Month = 2 And Fecha1.Day = 28) Then
  249. febreros = febreros + 2
  250. PasaFebrero += 1
  251. End If
  252. If (Fecha1.Month = 2 And Fecha1.Day = 29) Then
  253. bisiesto = bisiesto + 1
  254. PasaBisiesto += 1
  255. End If
  256. Fecha1 = Fecha1.AddDays(1)
  257. End While
  258. Total = dia + dias31 - febreros - bisiesto
  259. Return Total
  260. End Function
  261. Public Function FechaDias360(ByVal Fecha1 As Date, ByVal Day As Integer)
  262. Dim CorrelativoDias As Integer = 1
  263. Dim Dias As Integer = Day
  264. Dim Fecha As Date = Fecha1
  265. While CorrelativoDias <= Dias
  266. Dim Bisiesto As Integer = AñoBisiesto(Fecha)
  267. If Bisiesto = 365 Then
  268. If Fecha.Day = 31 Then
  269. Fecha = Fecha.AddDays(2)
  270. CorrelativoDias += 1
  271. ElseIf Fecha.Day = 29 And Fecha.Month = 2 Then
  272. Fecha = Fecha.AddDays(1)
  273. CorrelativoDias += 2
  274. Else
  275. Fecha = Fecha.AddDays(1)
  276. CorrelativoDias += 1
  277. End If
  278. Else
  279. If Fecha.Day = 31 Then
  280. Fecha = Fecha.AddDays(2)
  281. CorrelativoDias += 1
  282. ElseIf Fecha.Day = 28 And Fecha.Month = 2 Then
  283. Fecha = Fecha.AddDays(1)
  284. CorrelativoDias += 3
  285. Else
  286. Fecha = Fecha.AddDays(1)
  287. CorrelativoDias += 1
  288. End If
  289. End If
  290. End While
  291. Return Fecha
  292. End Function
  293. Public Function FechaDias3602829(ByVal Fecha1 As Date, ByVal Day As Integer,Byval DiaFijo As integer)
  294. Dim CorrelativoDias As Integer = 1
  295. Dim Dias As Integer = Day
  296. Dim Fecha As Date = Fecha1
  297. Dim Conteo As Integer = 0
  298. While CorrelativoDias <= Dias
  299. Conteo += 1
  300. Dim Bisiesto As Integer = AñoBisiesto(Fecha)
  301. If Bisiesto = 365 Then
  302. If Fecha.Day = 31 Then
  303. Fecha = Fecha.AddDays(2)
  304. CorrelativoDias += 1
  305. ElseIf Fecha.Day = 29 And Fecha.Month = 2 Then
  306. If DiaFijo = 30 Then
  307. If CorrelativoDias = Dias Then
  308. CorrelativoDias += 2
  309. Else
  310. Fecha = Fecha.AddDays(1)
  311. If Conteo = 1 Then
  312. CorrelativoDias += 1
  313. Else
  314. CorrelativoDias += 2
  315. End If
  316. End If
  317. Else
  318. Fecha = Fecha.AddDays(1)
  319. CorrelativoDias += 2
  320. End If
  321. Else
  322. Fecha = Fecha.AddDays(1)
  323. CorrelativoDias += 1
  324. End If
  325. Else
  326. If Fecha.Day = 31 Then
  327. Fecha = Fecha.AddDays(2)
  328. CorrelativoDias += 1
  329. ElseIf Fecha.Day = 28 And Fecha.Month = 2 Then
  330. If DiaFijo = 30 Then
  331. If (CorrelativoDias + 1) = Dias Then
  332. CorrelativoDias += 3
  333. Else
  334. Fecha = Fecha.AddDays(1)
  335. If Conteo = 1 Then
  336. CorrelativoDias += 1
  337. Else
  338. CorrelativoDias += 3
  339. End If
  340. End If
  341. ElseIf DiaFijo = 29 Then
  342. If CorrelativoDias = Dias Then
  343. CorrelativoDias += 3
  344. Else
  345. Fecha = Fecha.AddDays(1)
  346. If Conteo = 1 Then
  347. CorrelativoDias += 2
  348. Else
  349. CorrelativoDias += 3
  350. End If
  351. End If
  352. Else
  353. Fecha = Fecha.AddDays(1)
  354. CorrelativoDias += 3
  355. End If
  356. Else
  357. Fecha = Fecha.AddDays(1)
  358. CorrelativoDias += 1
  359. End If
  360. End If
  361. End While
  362. Return Fecha
  363. End Function
  364. Public Function Base365(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  365. Dim dias = DateDiff(DateInterval.Day, Fecha1, Fecha2)
  366. Return dias
  367. End Function
  368. Function AñoBisiesto(ByVal Fecha As Date)
  369. Dim Año As String = Fecha.Year
  370. Dim Dias As Integer = 0
  371. Dim FechaPrimero As Date = "01/01/" + Año
  372. Dim FechaFinal As Date = "31/12/" + Año
  373. Dias = DateDiff(DateInterval.Day, FechaPrimero, FechaFinal)
  374. Return Dias
  375. End Function
  376. Function CambioBase(ByVal FechaInicial As Date, ByVal FechaFinal As Date)
  377. Dim AñoInicial = FechaInicial.Year
  378. Dim AñoFinal = FechaFinal.Year
  379. Dim CambioDeBase As Integer = 0
  380. If (Not AñoInicial = AñoFinal) Then
  381. If (AñoBisiesto(FechaInicial) = 365) Then
  382. CambioDeBase = 1
  383. ElseIf (AñoBisiesto(FechaFinal) = 365) Then
  384. CambioDeBase = 2
  385. End If
  386. End If
  387. Return CambioDeBase
  388. End Function
  389. Function PrimeraFechaCambioBase(ByVal FechaInicial As Date)
  390. Dim AñoInicial As String = FechaInicial.Year
  391. Dim FechaPrimerCorte As Date = "31/12/" + AñoInicial
  392. Return FechaPrimerCorte
  393. End Function
  394. Function PrimeraFechaCambioBase360(ByVal FechaInicial As Date)
  395. Dim AñoInicial As String = FechaInicial.Year
  396. Dim FechaPrimerCorte As Date = "30/12/" + AñoInicial
  397. Return FechaPrimerCorte
  398. End Function
  399. Function FinalFechaCambioBase(ByVal FechaFinal As Date)
  400. Dim AñoFinal As String = FechaFinal.Year
  401. Dim FechaInicialSegundoCorte As Date = "01/01/" + AñoFinal
  402. Return FechaInicialSegundoCorte
  403. End Function
  404. Function FinalFechaCambioBase360(ByVal FechaFinal As Date)
  405. Dim AñoFinal As String = FechaFinal.Year
  406. Dim FechaInicialSegundoCorte As Date = "01/01/" + AñoFinal
  407. Return FechaInicialSegundoCorte
  408. End Function
  409. Function DiasDespuesCambioPrimeraFecha365(ByVal FechaIncial As Date, ByVal FechaFinal As Date, ByVal CambioDeFecha As Integer)
  410. Dim Dias As Integer
  411. If (CambioDeFecha = 1) Then
  412. Dias = DateDiff(DateInterval.Day, FechaIncial, FechaFinal) + 1
  413. Else
  414. Dias = DateDiff(DateInterval.Day, FechaIncial, FechaFinal)
  415. End If
  416. Return Dias
  417. End Function
  418. Function DiasDespuesCambioPrimeraFecha366(ByVal FechaIncial As Date, ByVal FechaFinal As Date, ByVal CambioDeFecha As Integer)
  419. Dim Dias As Integer
  420. If (CambioDeFecha = 2) Then
  421. Dias = DateDiff(DateInterval.Day, FechaIncial, FechaFinal) + 1
  422. Else
  423. Dias = DateDiff(DateInterval.Day, FechaIncial, FechaFinal)
  424. End If
  425. Return Dias
  426. End Function
  427. Function DiasDespuesCambioPrimeraFecha366Varios(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  428. Dim Dias As Integer = 0
  429. While (Fecha1 < Fecha2)
  430. If AñoBisiesto(Fecha1) = 365 Then
  431. Dias += 1
  432. End If
  433. Fecha1 = Fecha1.AddDays(1)
  434. End While
  435. Return Dias
  436. End Function
  437. Function DiasDespuesCambioPrimeraFecha365Varios(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  438. Dim Dias As Integer = 0
  439. While (Fecha1 < Fecha2)
  440. If AñoBisiesto(Fecha1) = 364 Then
  441. Dias += 1
  442. End If
  443. Fecha1 = Fecha1.AddDays(1)
  444. End While
  445. Return Dias
  446. End Function
  447. Function DiasDespuesCambioPrimeraFecha360Bi(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  448. Dim Dias As Integer = 0
  449. While (Fecha1 < Fecha2)
  450. If AñoBisiesto(Fecha1) = 365 Then
  451. If (Not Fecha1.Day = 31) Then
  452. If (Fecha1.Day = 29) Then
  453. Dias += 1
  454. End If
  455. Dias += 1
  456. End If
  457. End If
  458. Fecha1 = Fecha1.AddDays(1)
  459. End While
  460. Return Dias
  461. End Function
  462. Function DiasDespuesCambioPrimeraFecha360(ByVal Fecha1 As Date, ByVal Fecha2 As Date)
  463. Dim Dias As Integer = 0
  464. While (Fecha1 < Fecha2)
  465. If AñoBisiesto(Fecha1) = 364 Then
  466. If (Not Fecha1.Day = 31) Then
  467. If (Fecha1.Day = 28) Then
  468. Dias += 2
  469. End If
  470. Dias += 1
  471. End If
  472. End If
  473. Fecha1 = Fecha1.AddDays(1)
  474. End While
  475. Return Dias
  476. End Function
  477. Function DiasDespuesCambioPrimeraFecha360(ByVal FechaIncial As Date, ByVal FechaFinal As Date, ByVal CambioDeFecha As Integer)
  478. Dim Dias As Integer
  479. Dias = Base360(FechaInicial, FechaFinal)
  480. Return Dias
  481. End Function
  482. 'Public Sub ValidarEntrada(sender As Object, e As KeyPressEventArgs)
  483. ' If (Char.IsNumber(e.KeyChar)) Then
  484. ' e.Handled = False
  485. ' ElseIf Char.IsSeparator(e.KeyChar) Then
  486. ' e.Handled = True
  487. ' ElseIf Char.IsLetter(e.KeyChar) Then
  488. ' e.Handled = True
  489. ' ElseIf Char.IsSymbol(e.KeyChar) Then
  490. ' e.Handled = True
  491. ' ElseIf Char.IsWhiteSpace(e.KeyChar) Then
  492. ' e.Handled = True
  493. ' End If
  494. 'End Sub
  495. Public Sub ValidarEntrada(sender As Object, e As KeyPressEventArgs, ByVal NoAgregar As Boolean)
  496. If (Char.IsNumber(e.KeyChar)) Then
  497. e.Handled = False
  498. ElseIf Char.IsSeparator(e.KeyChar) Then
  499. e.Handled = True
  500. ElseIf Char.IsLetter(e.KeyChar) Then
  501. e.Handled = True
  502. ElseIf Char.IsPunctuation(e.KeyChar) Then
  503. If Not e.KeyChar = "." Then
  504. e.Handled = True
  505. End If
  506. ElseIf Char.IsSymbol(e.KeyChar) Then
  507. e.Handled = True
  508. ElseIf Char.IsWhiteSpace(e.KeyChar) Then
  509. e.Handled = True
  510. End If
  511. If NoAgregar Then
  512. e.Handled = True
  513. End If
  514. End Sub
  515. Function Meses(ByVal CantidadMeses As Integer, ByVal Fecha As Date, ByVal MesFijo As Date)
  516. Dim i As Integer = 0
  517. Dim DiaInicial As Integer = 0
  518. Dim Dia = MesFijo.Day
  519. DiaInicial = Dia
  520. Fecha = Fecha.AddMonths(CantidadMeses)
  521. Dim Mes = Fecha.Month
  522. Mes = Fecha.Month
  523. If (DiaInicial = 31) Then
  524. If ((Mes = 1 Or Mes = 3 Or Mes = 5 Or Mes = 7 Or Mes = 8 Or Mes = 10 Or Mes = 12)) Then
  525. Dim Año = Fecha.Year
  526. Fecha = CDate(("31/" + Mes.ToString + "/" + Año.ToString))
  527. ElseIf (Mes = 2) Then
  528. Dim Año = Fecha.Year
  529. If (AñoBisiesto(Fecha) = 364) Then
  530. Fecha = CDate(("28/" + Mes.ToString + "/" + Año.ToString))
  531. End If
  532. If (AñoBisiesto(Fecha) = 365) Then
  533. Fecha = CDate(("29/" + Mes.ToString + "/" + Año.ToString))
  534. End If
  535. Else
  536. Dim Año = Fecha.Year
  537. Fecha = CDate(("30/" + Mes.ToString + "/" + Año.ToString))
  538. End If
  539. ElseIf (DiaInicial = 30) Then
  540. If (Mes = 2) Then
  541. Dim Año = Fecha.Year
  542. Fecha = CDate(("28/" + Mes.ToString + "/" + Año.ToString))
  543. Else
  544. Dim Año = Fecha.Year
  545. Fecha = CDate(("30/" + Mes.ToString + "/" + Año.ToString))
  546. End If
  547. ElseIf (DiaInicial = 29) Then
  548. If (Mes = 2) Then
  549. Dim Año = Fecha.Year
  550. Fecha = CDate(("28/" + Mes.ToString + "/" + Año.ToString))
  551. Else
  552. Dim Año = Fecha.Year
  553. Fecha = CDate(("29/" + Mes.ToString + "/" + Año.ToString))
  554. End If
  555. End If
  556. Return Fecha
  557. End Function
  558. Function FechaFinMes(ByVal FechaPri As Date, ByVal Periodicidad As String, ByVal Base As Integer)
  559. Dim Dias As Integer = 0
  560. Dim Meses As Integer = 0
  561. If Periodicidad = "M" Then
  562. Meses = 1
  563. ElseIf Periodicidad = "T" Then
  564. Meses = 3
  565. ElseIf Periodicidad = "S" Then
  566. Meses = 6
  567. ElseIf Periodicidad = "A" Then
  568. Meses = 12
  569. End If
  570. If Base = 365 Then
  571. Dim FechaAnterior As Date = Format(FechaPri, "dd/MM/yyyy")
  572. Dim FechaCreada As Date = Format(FechaPri, "dd/MM/yyyy")
  573. Dim DiaAnterior As Integer = FechaAnterior.Day
  574. Dim MesAnterior As Integer = FechaAnterior.Month
  575. Dim DiaDiferenciaAnterior31 As Integer = 31 - DiaAnterior
  576. Dim FechaTemporal31 As Date = FechaAnterior.AddDays(DiaDiferenciaAnterior31)
  577. Dim DiaDiferenciaAnterior30 As Integer = 30 - DiaAnterior
  578. Dim FechaTemporal30 As Date = FechaAnterior.AddDays(DiaDiferenciaAnterior30)
  579. Dim DiaDiferenciaAnterior29 As Integer = 29 - DiaAnterior
  580. Dim FechaTemporal29 As Date = FechaAnterior.AddDays(DiaDiferenciaAnterior29)
  581. Dim DiaDiferenciaAnterior28 As Integer = 28 - DiaAnterior
  582. Dim FechaTemporal28 As Date = FechaAnterior.AddDays(DiaDiferenciaAnterior28)
  583. ''''''''
  584. If FechaTemporal31.Month = MesAnterior Then
  585. If Periodicidad = "M" Then
  586. If DiaDiferenciaAnterior31 > 0 Then
  587. FechaCreada = FechaTemporal31
  588. Else
  589. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior31, 0, Base)
  590. End If
  591. Else
  592. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior31, 0, Base)
  593. End If
  594. ElseIf FechaTemporal30.Month = MesAnterior Then
  595. If Periodicidad = "M" Then
  596. If DiaDiferenciaAnterior30 > 0 Then
  597. FechaCreada = FechaTemporal30
  598. Else
  599. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior30, 0, Base)
  600. End If
  601. Else
  602. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior30, 0, Base)
  603. End If
  604. ElseIf FechaTemporal29.Month = MesAnterior Then
  605. If Periodicidad = "M" Then
  606. If DiaDiferenciaAnterior29 > 0 Then
  607. FechaCreada = FechaTemporal29
  608. Else
  609. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior29, 0, Base)
  610. End If
  611. Else
  612. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior29, 0, Base)
  613. End If
  614. ElseIf FechaTemporal28.Month = MesAnterior Then
  615. If Periodicidad = "M" Then
  616. If DiaDiferenciaAnterior28 > 0 Then
  617. FechaCreada = FechaTemporal28
  618. Else
  619. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior28, 0, Base)
  620. End If
  621. Else
  622. FechaCreada = FechaMensual(FechaAnterior, Periodicidad, "FinMes", DiaDiferenciaAnterior28, 0, Base)
  623. End If
  624. End If
  625. Return FechaCreada
  626. ElseIf Base = 360 Then
  627. Dim FechaAnterior As Date = FechaPri
  628. Dim FechaCreada As Date = FechaPri
  629. Dim DiasAnterior As Integer = FechaAnterior.Day
  630. Dim DiasFaltantes As Integer = 30 - FechaAnterior.Day
  631. Dim FechaTemporalValidarDiasMes As Date = Date.Today.Date
  632. Dim CantidadDiasMes As Integer = 0
  633. Dim MesAnterior As Integer = FechaAnterior.Month
  634. If Periodicidad = "M" Then
  635. If DiasFaltantes > 0 Then
  636. FechaTemporalValidarDiasMes = Format(CDate("01/" + MesAnterior.ToString + "/" + FechaAnterior.Year.ToString), "dd/MM/yyyy")
  637. If FechaTemporalValidarDiasMes.AddDays(30).Month = MesAnterior Then
  638. 'Tiene 31 Dias
  639. CantidadDiasMes = 31
  640. ElseIf FechaTemporalValidarDiasMes.AddDays(29).Month = MesAnterior Then
  641. 'Tiene 30 Dias
  642. CantidadDiasMes = 30
  643. ElseIf FechaTemporalValidarDiasMes.AddDays(28).Month = MesAnterior Then
  644. 'Tiene 29 Dias
  645. CantidadDiasMes = 29
  646. ElseIf FechaTemporalValidarDiasMes.AddDays(27).Month = MesAnterior Then
  647. 'Tiene 28 Dias
  648. CantidadDiasMes = 28
  649. End If
  650. If CantidadDiasMes = 31 Or CantidadDiasMes = 30 Then
  651. FechaCreada = FechaCreada.AddDays(DiasFaltantes)
  652. ElseIf CantidadDiasMes = 29 Then
  653. If DiasFaltantes = 1 Then
  654. FechaCreada = FechaCreada.AddDays(30)
  655. Else
  656. FechaCreada = FechaCreada.AddDays(DiasFaltantes - 1)
  657. End If
  658. ElseIf CantidadDiasMes = 28 Then
  659. If DiasFaltantes = 2 Then
  660. FechaCreada = FechaCreada.AddDays(30)
  661. Else
  662. FechaCreada = FechaCreada.AddDays(DiasFaltantes - 2)
  663. End If
  664. End If
  665. Else
  666. FechaCreada = FechaCreada.AddMonths(Meses)
  667. End If
  668. Else
  669. Dim DiasCreada As Integer = 0
  670. Dim MesCreada As Integer = 0
  671. If DiasFaltantes > 0 Then
  672. FechaCreada = FechaAnterior.AddMonths(Meses - 1)
  673. DiasCreada = FechaCreada.Day
  674. DiasFaltantes = 30 - FechaCreada.Day
  675. MesCreada = FechaCreada.Month
  676. FechaTemporalValidarDiasMes = Format(CDate("01/" + MesCreada.ToString + "/" + FechaCreada.Year.ToString), "dd/MM/yyyy")
  677. If FechaTemporalValidarDiasMes.AddDays(30).Month = MesCreada Then
  678. 'Tiene 31 Dias
  679. CantidadDiasMes = 31
  680. ElseIf FechaTemporalValidarDiasMes.AddDays(29).Month = MesCreada Then
  681. 'Tiene 30 Dias
  682. CantidadDiasMes = 30
  683. ElseIf FechaTemporalValidarDiasMes.AddDays(28).Month = MesCreada Then
  684. 'Tiene 29 Dias
  685. CantidadDiasMes = 29
  686. ElseIf FechaTemporalValidarDiasMes.AddDays(27).Month = MesCreada Then
  687. 'Tiene 28 Dias
  688. CantidadDiasMes = 28
  689. End If
  690. If CantidadDiasMes = 31 Or CantidadDiasMes = 30 Then
  691. FechaCreada = FechaCreada.AddDays(DiasFaltantes)
  692. ElseIf CantidadDiasMes = 29 Then
  693. If DiasFaltantes = 1 Then
  694. FechaCreada = FechaCreada.AddDays(30)
  695. Else
  696. FechaCreada = FechaCreada.AddDays(DiasFaltantes - 1)
  697. End If
  698. ElseIf CantidadDiasMes = 28 Then
  699. If DiasFaltantes = 2 Then
  700. FechaCreada = FechaCreada.AddDays(30)
  701. Else
  702. FechaCreada = FechaCreada.AddDays(DiasFaltantes - 2)
  703. End If
  704. End If
  705. Else
  706. FechaCreada = FechaAnterior.AddMonths(Meses)
  707. End If
  708. End If
  709. Return FechaCreada
  710. End If
  711. End Function
  712. Function FechaMensual(ByRef Fecha As Date, ByRef Periodicidad As String, ByVal TipoCalculo As String, ByVal DiasSobrantes As Integer, ByVal DiaFijo As Integer, ByVal Base As Integer)
  713. Dim Meses As Integer = 0
  714. If Periodicidad = "M" Then
  715. Meses = 1
  716. ElseIf Periodicidad = "T" Then
  717. Meses = 3
  718. ElseIf Periodicidad = "S" Then
  719. Meses = 6
  720. ElseIf Periodicidad = "A" Then
  721. Meses = 12
  722. End If
  723. If Base = 365 Then
  724. 'TipoCalculo: FinMes,Mensual'
  725. Dim FechaAnterior As Date = Format(Fecha, "dd/MM/yyyy")
  726. Dim FechaCreada As Date = Format(Fecha, "dd/MM/yyyy")
  727. If DiasSobrantes > 0 Then
  728. FechaCreada = FechaCreada.AddMonths(Meses - 1)
  729. Else
  730. FechaCreada = FechaCreada.AddMonths(Meses)
  731. End If
  732. Dim DiaCreada As Integer = FechaCreada.Day
  733. Dim MesCreada As Integer = FechaCreada.Month
  734. Dim DiaDiferenciaAnterior31 As Integer = 31 - DiaCreada
  735. Dim FechaTemporal31 As Date = FechaCreada.AddDays(DiaDiferenciaAnterior31)
  736. Dim DiaDiferenciaAnterior30 As Integer = 30 - DiaCreada
  737. Dim FechaTemporal30 As Date = FechaCreada.AddDays(DiaDiferenciaAnterior30)
  738. Dim DiaDiferenciaAnterior29 As Integer = 29 - DiaCreada
  739. Dim FechaTemporal29 As Date = FechaCreada.AddDays(DiaDiferenciaAnterior29)
  740. Dim DiaDiferenciaAnterior28 As Integer = 28 - DiaCreada
  741. Dim FechaTemporal28 As Date = FechaCreada.AddDays(DiaDiferenciaAnterior28)
  742. If TipoCalculo = "FinMes" Then
  743. If FechaTemporal31.Month = MesCreada Then
  744. If DiaDiferenciaAnterior31 > 0 Then
  745. FechaCreada = FechaTemporal31
  746. End If
  747. ElseIf FechaTemporal30.Month = MesCreada Then
  748. If DiaDiferenciaAnterior30 > 0 Then
  749. FechaCreada = FechaTemporal30
  750. End If
  751. ElseIf FechaTemporal29.Month = MesCreada Then
  752. If DiaDiferenciaAnterior29 > 0 Then
  753. FechaCreada = FechaTemporal29
  754. End If
  755. ElseIf FechaTemporal28.Month = MesCreada Then
  756. If DiaDiferenciaAnterior28 > 0 Then
  757. FechaCreada = FechaTemporal28
  758. End If
  759. End If
  760. Return FechaCreada
  761. ElseIf TipoCalculo = "Mensual" Then
  762. FechaAnterior = Fecha
  763. FechaCreada = Fecha.AddMonths(Meses)
  764. MesCreada = FechaCreada.Month
  765. DiaCreada = FechaCreada.Day
  766. DiaDiferenciaAnterior31 = 31 - DiaCreada
  767. FechaTemporal31 = FechaCreada.AddDays(DiaDiferenciaAnterior31)
  768. DiaDiferenciaAnterior30 = 30 - DiaCreada
  769. FechaTemporal30 = FechaCreada.AddDays(DiaDiferenciaAnterior30)
  770. DiaDiferenciaAnterior29 = 29 - DiaCreada
  771. FechaTemporal29 = FechaCreada.AddDays(DiaDiferenciaAnterior29)
  772. If DiaFijo = 31 Then
  773. If MesCreada = FechaTemporal31.Month Then
  774. FechaCreada = FechaTemporal31
  775. ElseIf MesCreada = FechaTemporal30.Month Then
  776. FechaCreada = FechaTemporal30
  777. ElseIf MesCreada = FechaTemporal29.Month Then
  778. FechaCreada = FechaTemporal29
  779. Else
  780. FechaCreada = FechaTemporal28
  781. End If
  782. ElseIf DiaFijo = 30 Then
  783. If MesCreada = FechaTemporal30.Month Then
  784. FechaCreada = FechaTemporal30
  785. ElseIf MesCreada = FechaTemporal29.Month Then
  786. FechaCreada = FechaTemporal29
  787. Else
  788. FechaCreada = FechaTemporal28
  789. End If
  790. ElseIf DiaFijo = 29 Then
  791. If MesCreada = FechaTemporal29.Month Then
  792. FechaCreada = FechaTemporal29
  793. Else
  794. FechaCreada = FechaTemporal28
  795. End If
  796. Else
  797. Dim DiaAgregar As Integer = DiaFijo - FechaCreada.Day
  798. FechaCreada = FechaCreada.AddDays(DiaAgregar)
  799. End If
  800. Return FechaCreada
  801. End If
  802. ElseIf Base = 360 Then
  803. Dim Dias As Integer = Meses * 30
  804. Dim FechaAnterior As Date = Fecha
  805. FechaAnterior = FechaDias3602829(FechaAnterior, Dias, DiaFijo)
  806. Return FechaAnterior
  807. End If
  808. End Function
  809. Function ConvertirDecimal(ByVal Dec As String)
  810. Dim value As Double = 0
  811. If Dec Is Nothing Then
  812. Dec = 0
  813. End If
  814. Dec = Dec.ToString.Trim("%")
  815. If (Decimal.TryParse(Dec, value)) Then Return value Else Return 0
  816. End Function
  817. Function ConvertirEntero(ByVal Int As String)
  818. Dim value As Integer = 0
  819. If Int Is Nothing Then
  820. Int = 0
  821. End If
  822. Int = Int.ToString.Trim("%")
  823. If (Integer.TryParse(Int, value)) Then Return value Else Return 0
  824. End Function
  825. Function ConvertirFecha(ByVal Fecha As String)
  826. Dim value As Date = Date.Today.Date
  827. If (Date.TryParse(Fecha, value)) Then Return value Else Return Date.Today.Date
  828. End Function
  829. Function ConvertirFechaBaseDatos(ByVal Fecha As String)
  830. Dim value As Date = Date.Today.Date
  831. If (Date.TryParse(Fecha, value)) Then Return value Else Return DBNull.Value
  832. End Function
  833. Sub TraspasarDatos(ByVal CodigoExiste As String, ByVal CodigoInstrumentoExiste As String,
  834. ByVal IsNueva As String, ByVal TipoTransaccionCompraVenta As String,
  835. ByVal FamiliaTitulo As String, ByVal Monto As Double,
  836. ByVal Precio As Double, ByVal RendimientoEsperado As Double,
  837. ByVal IngresosEsperados As Double)
  838. If IsNueva = "N" Then
  839. Dim General As New DAOGeneral
  840. Dim Tabla As String = String.Empty
  841. If CodigoInstrumentoExiste = "ACCI" Or CodigoInstrumentoExiste = "ACCNC" Or
  842. CodigoInstrumentoExiste = "ACCNP" Then
  843. Tabla = "ACC0"
  844. ElseIf CodigoInstrumentoExiste = "PPER" Then
  845. Tabla = "PPER0"
  846. ElseIf CodigoInstrumentoExiste = "DAP" Then
  847. Tabla = "DAP0"
  848. ElseIf CodigoInstrumentoExiste = "NEST" Then
  849. Tabla = "NETS0"
  850. ElseIf CodigoInstrumentoExiste = "FUTU" Then
  851. Tabla = "FUT0"
  852. ElseIf CodigoInstrumentoExiste = "OPC" Then
  853. Tabla = "OPC0"
  854. ElseIf CodigoInstrumentoExiste = "PEMP" Then
  855. Tabla = "PEMP0"
  856. ElseIf CodigoInstrumentoExiste = "LETE" Then
  857. Tabla = "LET0"
  858. ElseIf CodigoInstrumentoExiste = "CETE" Then
  859. Tabla = "CET0"
  860. ElseIf CodigoInstrumentoExiste = "PBUR" Then
  861. Tabla = "PBUR"
  862. ElseIf CodigoInstrumentoExiste = "VCN" Then
  863. Tabla = "VCN"
  864. ElseIf CodigoInstrumentoExiste = "BONO" Then
  865. Tabla = "BON0"
  866. ElseIf CodigoInstrumentoExiste = "CINV" Then
  867. Tabla = "CIN0"
  868. ElseIf CodigoInstrumentoExiste = "EURB" Then
  869. Tabla = "EURB0"
  870. ElseIf CodigoInstrumentoExiste = "TIT" Then
  871. Tabla = "TIT"
  872. ElseIf CodigoInstrumentoExiste = "FINV" Then
  873. Tabla = "FINV"
  874. ElseIf CodigoInstrumentoExiste = "REPO" Then
  875. Tabla = "REP0"
  876. ElseIf CodigoInstrumentoExiste = "REPOVENTA" Then
  877. Tabla = "REPOVENTA"
  878. End If
  879. Dim RetCodigoInversionExiste As Boolean = General.ExisteTitulo(CodigoExiste, Tabla)
  880. If Not RetCodigoInversionExiste Then
  881. Dim RetMonto As Double = 0
  882. Dim RetPrecio As Double = 0
  883. Dim RetRendimiento As Double = 0
  884. Dim RetIngresosEsp As Double = 0
  885. Dim RetUnidadesAcciones As Integer = 0
  886. Dim RetUnidadesContratosFuturos As Integer = 0
  887. Dim RetCantidadContratosFuturos As Integer = 0
  888. Dim RetCuotaParticipacionFINV As Integer = 0
  889. Dim RetValorParticipacionFINV As Integer = 0
  890. If FamiliaTitulo = "FamiliaAcciones" Then
  891. RetMonto = ConvertirDecimal(Monto.ToString)
  892. RetPrecio = ConvertirDecimal(Precio.ToString)
  893. RetRendimiento = 0
  894. RetIngresosEsp = 0
  895. RetUnidadesAcciones = ConvertirDecimal((RetMonto / RetPrecio).ToString)
  896. Variables.RetMonto = RetMonto
  897. Variables.RetPrecio = RetPrecio
  898. Variables.RetUnidadesAcciones = RetUnidadesAcciones
  899. ElseIf FamiliaTitulo = "FamiliaPrestamoPersonal" Then
  900. RetMonto = ConvertirDecimal(Monto.ToString)
  901. RetPrecio = 0
  902. RetRendimiento = ConvertirDecimal(RendimientoEsperado.ToString)
  903. RetIngresosEsp = 0
  904. Variables.RetMonto = RetMonto
  905. Variables.RetRendimiento = RetRendimiento
  906. ElseIf FamiliaTitulo = "FamiliaDAP" Then
  907. RetMonto = ConvertirDecimal(Monto.ToString)
  908. RetPrecio = 0
  909. RetRendimiento = ConvertirDecimal(RendimientoEsperado.ToString)
  910. RetIngresosEsp = 0
  911. Variables.RetMonto = RetMonto
  912. Variables.RetRendimiento = RetRendimiento
  913. ElseIf FamiliaTitulo = "FamiliaFuturos" Then
  914. RetMonto = ConvertirDecimal(Monto.ToString)
  915. RetPrecio = ConvertirDecimal(Precio.ToString)
  916. RetRendimiento = 0
  917. RetIngresosEsp = 0
  918. RetUnidadesContratosFuturos = 1
  919. RetCantidadContratosFuturos = ConvertirDecimal((RetMonto / (RetUnidadesContratosFuturos * RetPrecio)))
  920. Variables.RetMonto = RetMonto
  921. Variables.RetPrecio = RetPrecio
  922. Variables.RetUnidadesContratosFuturos = RetUnidadesContratosFuturos
  923. Variables.RetCantidadContratosFuturos = RetCantidadContratosFuturos
  924. ElseIf FamiliaTitulo = "FamiliaEmpresas" Then
  925. RetMonto = ConvertirDecimal(Monto.ToString)
  926. RetPrecio = 0
  927. RetRendimiento = ConvertirDecimal(RendimientoEsperado.ToString)
  928. RetIngresosEsp = 0
  929. Variables.RetMonto = RetMonto
  930. Variables.RetRendimiento = RetRendimiento
  931. ElseIf FamiliaTitulo = "FamiliaLetes" Then
  932. RetMonto = ConvertirDecimal(Monto.ToString)
  933. RetPrecio = 0
  934. RetRendimiento = ConvertirDecimal(RendimientoEsperado.ToString)
  935. RetIngresosEsp = 0
  936. Variables.RetMonto = RetMonto
  937. Variables.RetRendimiento = RetRendimiento
  938. ElseIf FamiliaTitulo = "FamiliaCINV" Then
  939. RetMonto = ConvertirDecimal(Monto.ToString)
  940. RetPrecio = ConvertirDecimal(Precio.ToString)
  941. RetRendimiento = ConvertirDecimal(RendimientoEsperado.ToString)
  942. RetIngresosEsp = 0
  943. Variables.RetMonto = RetMonto
  944. Variables.RetRendimiento = RetRendimiento
  945. Variables.RetPrecio = RetPrecio
  946. ElseIf FamiliaTitulo = "FamiliaFINV" Then
  947. RetMonto = ConvertirDecimal(Monto.ToString)
  948. RetPrecio = 0
  949. RetRendimiento = ConvertirDecimal(RendimientoEsperado.ToString)
  950. RetIngresosEsp = 0
  951. Variables.RetMonto = RetMonto
  952. Variables.RetRendimiento = RetRendimiento
  953. RetValorParticipacionFINV = 1
  954. RetCuotaParticipacionFINV = ConvertirDecimal(RetMonto / RetValorParticipacionFINV)
  955. Variables.RetValorParticipacionFINV = RetValorParticipacionFINV
  956. Variables.RetCuotaParticipacionFINV = RetCuotaParticipacionFINV
  957. ElseIf FamiliaTitulo = "FamiliaReporto" Then
  958. RetMonto = ConvertirDecimal(Monto.ToString)
  959. Variables.RetMonto = RetMonto
  960. End If
  961. Variables.TipoTransaccionCompraVenta = TipoTransaccionCompraVenta
  962. End If
  963. Else
  964. RetCodigoInversionExiste = True
  965. End If
  966. Variables.RetCodigoInversionExiste = RetCodigoInversionExiste
  967. End Sub
  968. End Class