| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728 |
-
- Public Class AccionesCE
- Private _CodigoInversion As String
- Private _TipoOperacion As String
- Private _AccionPreferente As String
- Private _OperacionEnBolsa As String
- Private _FactorDeDividendo As Double
- Private _IngresoBruto As Double
- Private _IngresoBrutoPendiente As Double
- Private _ISR As Double
- Private _ISRPendiente As Double
- Private _IngresoNeto As Double
- Dim Operaciones As New Operaciones
- Private _IngresoNetoPendiente As Double
- Private _dtImpuestosYComisiones As DataTable
- Private _dtDividendos As DataTable
- Private _TipoInstrumento As String = "ACC"
- Private _CodigoInstrumentoFinanciero As String
- Private _DescripcionTipoInstrumento As String
- Private _Registro As DataTable
- Private _ComisionCompraCasa As Double
- Private _ComisionCompraBolsa As Double
- Private _ComisionVentaCasa As Double
- Private _ComisionVentaBolsa As Double
- Private _IOF As Boolean
- Private _Renta As Boolean
- Private _Tipo As String
- Private _RetornoBruto As Double
- Private _GananciaDeCapitalTotalVentasus As Double = 0
- Private _RetornoAnualizadoBrutoVentasus As Double = 0
- Private _MontoNetoVentasus As Double = 0
- Private _PrecioSucioVentasus As Double = 0
- Private _ComisionPorcentajeCompraCasa As Double = 0
- Private _ComisionPorcentajeCompraBolsa As Double = 0
- Private _ComisionPorcentajeVentaCasa As Double = 0
- Private _ComisionPorcentajeVentaBolsa As Double = 0
- Private _MontoNetoComprasus As Double = 0
- 'COMPRA
- Private _CodigoCasaCompra As String
- Private _PrecioLimpioCompra As Double
- Private _FechaOperacionCompra As Date
- Private _FechaLiquidacionCompra As Date
- Private _DiasDeTenenciaCompra As Integer
- Private _GananciaDeCapitalTotalCompra As Double
- Private _GananciaDeCapitalUnitarioCompra As Double
- Private _RetornoAnualizadoBrutoCompra As Double
- Private _RetornoAnualizadoNetoCompra As Double
- Private _CantidadCompra As Integer
- Private _ValorTransadoCompra As Double
- Private _MontoNetoCompra As Double
- Private _PrecioSucioCompra As Double
- Private _SumaImpuestosYComisionesCompra As Double
- 'VENTA
- Private _CodigoCasaVenta As String
- Private _PrecioLimpioVenta As Double
- Private _FechaOperacionVenta As Date
- Private _FechaLiquidacionVenta As Date
- Private _DiasDeTenenciaVenta As Integer
- Private _GananciaDeCapitalTotalVenta As Double
- Private _GananciaDeCapitalUnitarioVenta As Double
- Private _RetornoAnualizadoBrutoVenta As Double
- Private _RetornoAnualizadoNetoVenta As Double
- Private _CantidadVenta As Integer
- Private _ValorTransadoVenta As Double
- Private _MontoNetoVenta As Double
- Private _PrecioSucioVenta As Double
- Private _SumaImpuestosYComisionesVenta As Double
- 'GENERAL
- Public Property CodigoInversion
- Get
- Return _CodigoInversion
- End Get
- Set(value)
- _CodigoInversion = value
- End Set
- End Property
- Public Property AccionPreferente As String
- Get
- Return _AccionPreferente
- End Get
- Set(value As String)
- _AccionPreferente = value
- End Set
- End Property
- Public Property OperacionEnBolsa As String
- Get
- Return _OperacionEnBolsa
- End Get
- Set(value As String)
- _OperacionEnBolsa = value
- End Set
- End Property
- Public Property FactorDeDividendo As Double
- Get
- Return _FactorDeDividendo
- End Get
- Set(value As Double)
- _FactorDeDividendo = value
- End Set
- End Property
- Public Property ImpuestosYComisiones As DataTable
- Get
- Return _dtImpuestosYComisiones
- End Get
- Set(value As DataTable)
- _dtImpuestosYComisiones = value
- CalcularSumaImpuestosyComisiones()
- End Set
- End Property
- 'COMPRA
- Public Property CodigoCasaCompra As String
- Get
- Return _CodigoCasaCompra
- End Get
- Set(value As String)
- _CodigoCasaCompra = value
- End Set
- End Property
- Public Property PrecioLimpioCompra As Double
- Get
- Return _PrecioLimpioCompra
- End Get
- Set(value As Double)
- _PrecioLimpioCompra = value
- CalculaValorTrasadoCompra()
- End Set
- End Property
- Public Property FechaOperacionCompra As Date
- Get
- Return _FechaOperacionCompra
- End Get
- Set(value As Date)
- _FechaOperacionCompra = value
- End Set
- End Property
- Public Property FechaVencimientoCompra As Date
- Get
- Return _FechaLiquidacionCompra
- End Get
- Set(value As Date)
- _FechaLiquidacionCompra = value
- CalcularDiasDeTenenciaVenta()
- End Set
- End Property
- Public Property DiasDeTenenciaCompra As Integer
- Get
- Return _DiasDeTenenciaCompra
- End Get
- Set(value As Integer)
- _DiasDeTenenciaCompra = value
- End Set
- End Property
- Public Property ComisionVentaBolsa As Double
- Get
- Return _ComisionVentaBolsa
- End Get
- Set(value As Double)
- _ComisionVentaBolsa = value
- End Set
- End Property
- Public Property ComisionPorcentajeVentaBolsa As Double
- Get
- Return _ComisionPorcentajeVentaBolsa
- End Get
- Set(value As Double)
- _ComisionPorcentajeVentaBolsa = value
- End Set
- End Property
- Public Property ComisionVentaCasa As Double
- Get
- Return _ComisionVentaCasa
- End Get
- Set(value As Double)
- _ComisionVentaCasa = value
- End Set
- End Property
- Public Property ComisionPorcentajeVentaCasa As Double
- Get
- Return _ComisionPorcentajeVentaCasa
- End Get
- Set(value As Double)
- _ComisionPorcentajeVentaCasa = value
- End Set
- End Property
- Public Property ComisionCompraBolsa As Double
- Get
- Return _ComisionCompraBolsa
- End Get
- Set(value As Double)
- _ComisionCompraBolsa = value
- End Set
- End Property
- Public Property ComisionPorcentajeCompraBolsa As Double
- Get
- Return _ComisionPorcentajeCompraBolsa
- End Get
- Set(value As Double)
- _ComisionPorcentajeCompraBolsa = value
- End Set
- End Property
- Public Property ComisionCompraCasa As Double
- Get
- Return _ComisionCompraCasa
- End Get
- Set(value As Double)
- _ComisionCompraCasa = value
- End Set
- End Property
- Public Property ComisionPorcentajeCompraCasa As Double
- Get
- Return _ComisionPorcentajeCompraCasa
- End Get
- Set(value As Double)
- _ComisionPorcentajeCompraCasa = value
- End Set
- End Property
- Public Property IOF As Boolean
- Get
- Return _IOF
- End Get
- Set(value As Boolean)
- _IOF = value
- End Set
- End Property
- Public Property Renta As Boolean
- Get
- Return _Renta
- End Get
- Set(value As Boolean)
- _Renta = value
- End Set
- End Property
- Public Property GananciaDeCapitalTotalCompra As Double
- Get
- Return _GananciaDeCapitalTotalCompra
- End Get
- Set(value As Double)
- _GananciaDeCapitalTotalCompra = value
- End Set
- End Property
- Public Property GananciaDeCapitalUnitarioCompra As Double
- Get
- Return _GananciaDeCapitalUnitarioCompra
- End Get
- Set(value As Double)
- _GananciaDeCapitalUnitarioCompra = value
- End Set
- End Property
- Public Property RetornoAnualizadoBrutoCompra As Double
- Get
- Return _RetornoAnualizadoBrutoCompra
- End Get
- Set(value As Double)
- _RetornoAnualizadoBrutoCompra = value
- End Set
- End Property
- Public Property RetornoAnualizadoNetoCompra As Double
- Get
- Return _RetornoAnualizadoNetoCompra
- End Get
- Set(value As Double)
- _RetornoAnualizadoNetoCompra = value
- End Set
- End Property
- Public Property CantidadCompra As Integer
- Get
- Return _CantidadCompra
- End Get
- Set(value As Integer)
- _CantidadCompra = value
- CalculaValorTrasadoCompra()
- CalcularPrecioSucioCompra()
- End Set
- End Property
- Public Property ValorTransadoCompra As Double
- Get
- Return _ValorTransadoCompra
- End Get
- Set(value As Double)
- _ValorTransadoCompra = value
- End Set
- End Property
- Public Property MontoNetoCompra As Double
- Get
- Return _MontoNetoCompra
- End Get
- Set(value As Double)
- _MontoNetoCompra = value
- CalcularMontoNetoCompra()
- End Set
- End Property
- Public Property MontoNetoComprasus As Double
- Get
- Return _MontoNetoComprasus
- End Get
- Set(value As Double)
- _MontoNetoComprasus = value
- End Set
- End Property
- Public Property PrecioSucioCompra As Double
- Get
- Return _PrecioSucioCompra
- End Get
- Set(value As Double)
- _PrecioSucioCompra = value
- End Set
- End Property
- Public Property SumaImpuestosYComisionesCompra As Double
- Get
- Return _SumaImpuestosYComisionesCompra
- End Get
- Set(value As Double)
- _SumaImpuestosYComisionesCompra = value
- CalcularMontoNetoCompra()
- End Set
- End Property
- 'VENTA
- Public Property CodigoCasaVenta As String
- Get
- Return _CodigoCasaVenta
- End Get
- Set(value As String)
- _CodigoCasaVenta = value
- End Set
- End Property
- Public Property PrecioLimpioVenta As Double
- Get
- Return _PrecioLimpioVenta
- End Get
- Set(value As Double)
- _PrecioLimpioVenta = value
- CalcularValorTransadoVenta()
- End Set
- End Property
- Public Property FechaOperacionVenta As Date
- Get
- Return _FechaOperacionVenta
- End Get
- Set(value As Date)
- _FechaOperacionVenta = value
- End Set
- End Property
- Public Property FechaVencimientoVenta As Date
- Get
- Return _FechaLiquidacionVenta
- End Get
- Set(value As Date)
- _FechaLiquidacionVenta = value
- CalcularDiasDeTenenciaVenta()
- End Set
- End Property
- Public Property DiasDeTenenciaVenta As Integer
- Get
- Return _DiasDeTenenciaVenta
- End Get
- Set(value As Integer)
- _DiasDeTenenciaVenta = value
- End Set
- End Property
- Public Property GananciaDeCapitalTotalVenta As Double
- Get
- Return _GananciaDeCapitalTotalVenta
- End Get
- Set(value As Double)
- _GananciaDeCapitalTotalVenta = value
- End Set
- End Property
- Public Property GananciaDeCapitalTotalVentasus As Double
- Get
- Return _GananciaDeCapitalTotalVentasus
- End Get
- Set(value As Double)
- _GananciaDeCapitalTotalVentasus = value
- End Set
- End Property
- Public Property GananciaDeCapitalUnitarioVenta As Double
- Get
- Return _GananciaDeCapitalUnitarioVenta
- End Get
- Set(value As Double)
- _GananciaDeCapitalUnitarioVenta = value
- End Set
- End Property
- Public Property RetornoAnualizadoBrutoVenta As Double
- Get
- CalcularRetornoAnualBrutoVenta()
- Return _RetornoAnualizadoBrutoVenta
- End Get
- Set(value As Double)
- _RetornoAnualizadoBrutoVenta = value
- End Set
- End Property
- Public Property RetornoAnualizadoBrutoVentasus As Double
- Get
- Return _RetornoAnualizadoBrutoVentasus
- End Get
- Set(value As Double)
- _RetornoAnualizadoBrutoVentasus = value
- End Set
- End Property
- Public Property RetornoAnualizadoNetoVenta As Double
- Get
- CalcularRetornoAnualNetoVenta()
- Return _RetornoAnualizadoNetoVenta
- End Get
- Set(value As Double)
- _RetornoAnualizadoNetoVenta = value
- End Set
- End Property
- Public Property CantidadVenta As Integer
- Get
- Return _CantidadVenta
- End Get
- Set(value As Integer)
- _CantidadVenta = value
- CalcularValorTransadoVenta()
- CalcularGananciaDeCapitalUnitarioVenta()
- CalcularPrecioSucioVenta()
- End Set
- End Property
- Public Property Tipo As String
- Get
- Return _Tipo
- End Get
- Set(value As String)
- _Tipo = value
- End Set
- End Property
- Public Property RetornoBruto As Double
- Get
- Return _RetornoBruto
- End Get
- Set(value As Double)
- _RetornoBruto = value
- End Set
- End Property
- Public Property ValorTransadoVenta As Double
- Get
- Return _ValorTransadoVenta
- End Get
- Set(value As Double)
- _ValorTransadoVenta = value
- End Set
- End Property
- Public Property MontoNetoVenta As Double
- Get
- Return _MontoNetoVenta
- End Get
- Set(value As Double)
- _MontoNetoVenta = value
- End Set
- End Property
- Public Property MontoNetoVentasus As Double
- Get
- Return _MontoNetoVentasus
- End Get
- Set(value As Double)
- _MontoNetoVentasus = value
- End Set
- End Property
- Public Property PrecioSucioVenta As Double
- Get
- Return _PrecioSucioVenta
- End Get
- Set(value As Double)
- _PrecioSucioVenta = value
- End Set
- End Property
- Public Property PrecioSucioVentasus As Double
- Get
- Return _PrecioSucioVentasus
- End Get
- Set(value As Double)
- _PrecioSucioVentasus = value
- End Set
- End Property
- Public Property SumaImpuestosYComisionesVenta As Double
- Get
- Return _SumaImpuestosYComisionesVenta
- End Get
- Set(value As Double)
- _SumaImpuestosYComisionesVenta = value
- CalcularMontoNetoVenta()
- End Set
- End Property
- Public Sub New()
- 'GENERAL
- _IngresoBruto = 0
- _IngresoBrutoPendiente = 0
- _ISR = 0
- _ISRPendiente = 0
- _IngresoNeto = 0
- _IngresoNetoPendiente = 0
- _dtImpuestosYComisiones = New DataTable
- _dtDividendos = New DataTable
- _Registro = New DataTable
- 'COMPRA
- _PrecioLimpioCompra = 0
- _FechaOperacionCompra = Date.Now.Date
- _FechaLiquidacionCompra = Date.Now.Date
- _CantidadCompra = 1
- _DiasDeTenenciaCompra = 0
- _GananciaDeCapitalTotalCompra = 0
- _GananciaDeCapitalUnitarioCompra = 0
- _RetornoAnualizadoBrutoCompra = 0
- _RetornoAnualizadoNetoCompra = 0
- _ValorTransadoCompra = 0
- _MontoNetoCompra = 0
- _PrecioSucioCompra = 0
- 'VENTA
- _PrecioLimpioVenta = 0
- _FechaOperacionVenta = Date.Now.Date
- _FechaLiquidacionVenta = Date.Now.Date
- _CantidadVenta = 1
- _DiasDeTenenciaVenta = 0
- _GananciaDeCapitalTotalVenta = 0
- _GananciaDeCapitalUnitarioVenta = 0
- _RetornoAnualizadoBrutoVenta = 0
- _RetornoAnualizadoNetoVenta = 0
- _CantidadVenta = 0
- _ValorTransadoVenta = 0
- _MontoNetoVenta = 0
- _PrecioSucioVenta = 0
- End Sub
- 'CALCULOS COMPRA
- Private Sub CalculaValorTrasadoCompra()
- _ValorTransadoCompra = _CantidadCompra * _PrecioLimpioCompra
- CalcularMontoNetoCompra()
- End Sub
- Private Sub CalcularMontoNetoCompra()
- _MontoNetoCompra = _ValorTransadoCompra + _SumaImpuestosYComisionesCompra
- CalcularPrecioSucioCompra()
- CalcularGananciaDeCapitalTotalVenta()
- CalcularRetornoAnualBrutoVenta()
- CalcularRetornoAnualNetoVenta()
- End Sub
- Private Sub CalcularPrecioSucioCompra()
- If (String.IsNullOrEmpty(_CantidadCompra.ToString) Or _CantidadCompra.ToString = "0") Then
- _PrecioSucioCompra = "0.0"
- Else
- _PrecioSucioCompra = _MontoNetoCompra / _CantidadCompra
- End If
- End Sub
- 'CALCULOS VENTA
- Private Sub CalcularDiasDeTenenciaVenta()
- Dim valor As Integer
- If _FechaLiquidacionVenta > Date.Today.Date Then
- valor = DateDiff(DateInterval.Day, _FechaLiquidacionCompra, Date.Today.Date)
- Else
- valor = DateDiff(DateInterval.Day, _FechaLiquidacionCompra, _FechaLiquidacionVenta)
- End If
- _DiasDeTenenciaVenta = valor
- CalcularRetornoAnualBrutoVenta()
- CalcularRetornoAnualNetoVenta()
- End Sub
- Private Sub CalcularValorTransadoVenta()
- _ValorTransadoVenta = _PrecioLimpioVenta * _CantidadVenta
- CalcularMontoNetoVenta()
- End Sub
- Private Sub CalcularMontoNetoVenta()
- _MontoNetoVenta = _ValorTransadoVenta - _SumaImpuestosYComisionesVenta
- CalcularGananciaDeCapitalTotalVenta()
- CalcularPrecioSucioVenta()
- End Sub
- Private Sub CalcularGananciaDeCapitalTotalVenta()
- _GananciaDeCapitalTotalVenta = _MontoNetoVenta - _MontoNetoCompra
- CalcularGananciaDeCapitalUnitarioVenta()
- CalcularRetornoAnualBrutoVenta()
- CalcularRetornoAnualNetoVenta()
- End Sub
- Private Sub CalcularGananciaDeCapitalUnitarioVenta()
- _GananciaDeCapitalUnitarioVenta = _GananciaDeCapitalTotalVenta / _CantidadVenta
- _GananciaDeCapitalUnitarioVenta = Format(_GananciaDeCapitalUnitarioVenta, "0.0000")
- End Sub
- Private Sub CalcularRetornoAnualBrutoVenta()
- If _DiasDeTenenciaVenta = 0 Or _MontoNetoCompra = 0 Then
- _RetornoAnualizadoBrutoVenta = 0
- Else
- _RetornoAnualizadoBrutoVenta = ((_GananciaDeCapitalTotalVenta + Variables.IngresoBruto) / _MontoNetoCompra) * 365 / _DiasDeTenenciaVenta
- End If
- End Sub
- Private Sub CalcularRetornoAnualNetoVenta()
- If _DiasDeTenenciaVenta = 0 Or _MontoNetoCompra Then
- _RetornoAnualizadoNetoVenta = 0
- Else
- _RetornoAnualizadoNetoVenta = ((_GananciaDeCapitalTotalVenta + Variables.IngresoNeto) / _MontoNetoCompra) * 365 / _DiasDeTenenciaVenta
- End If
- End Sub
- Private Sub CalcularPrecioSucioVenta()
- _PrecioSucioVenta = _MontoNetoVenta / _CantidadVenta
- End Sub
- Private Sub CalcularSumaImpuestosyComisiones()
- If Not Double.TryParse(_dtImpuestosYComisiones.Compute("SUM(MontoImp)", "TipoOper='C'").ToString, _SumaImpuestosYComisionesCompra) Then
- _SumaImpuestosYComisionesCompra = 0
- End If
- If Not Double.TryParse(_dtImpuestosYComisiones.Compute("SUM(MontoImp)", "TipoOper='V'").ToString, _SumaImpuestosYComisionesVenta) Then
- _SumaImpuestosYComisionesVenta = 0
- End If
- CalcularMontoNetoCompra()
- CalcularMontoNetoVenta()
- End Sub
- End Class
|