Пример #1
0
 public void PersonExit(int holdings, int m)
 {
     if (m < 11)                                                                                                       //ingen yderligere rente, hvis vi allerede er i december
     {
         _holdingsW += Convert.ToUInt32(holdings * Math.Pow((1 + PensionSystem.InterestRate(12)), 11 - m) - holdings); //en person dør og pensionsdepotet overgår til pensionskassen (med renter for resten af året)
     }
     //Implementer: Overførsel af opsparing til evt. ægtefælle
 }
Пример #2
0
        public int Update(int age, int[] contributionRate, int[] contributionLivsrente, int startRate = -1, int startLivrente = -1, int dead = -1)
        {
            if (udvalgt && age == 65)
            {
                Console.WriteLine("65 år");
            }

            int installment         = 0; //årets samlede pensionsudbetaling
            int installmentLivrente = 0;

            for (int m = 0; m < 12; m++)
            {
                _livrenteDepotPrimoBx = PensionSystem.PensionfundLivrente.UpdateHoldings(age, _livrenteDepotUltimoAx, _dx, m); //beregn ny beholdning (Bx)
                if (m == 0)
                {
                    w = _livrenteDepotPrimoBx;
                }

                if (udvalgt && m == 0 && age < 65)
                {
                    int expected = PensionSystem.PensionfundLivrente.InstallmentExpected(age, m, _livrenteDepotPrimoBx, contributionLivsrente[m]);
//          Console.WriteLine("Forventet pension: " + expected);
                }

                #region ratepension
                if (startRate == m && _ratesLeft < 1)
                {
                    _ratesLeft = 12 * 10;              //aktiver ratepensionsudbetaling sæt udbetaling til at vare 10 år
                }
                ContributionRate(contributionRate[m]); //indbetal til ratepension
                installment += InstallmentRate();      //udbetal ratepension
                #endregion ratepension

                _activeLivrente |= startLivrente == m;                                    //aktiver livrentepensionsudbetaling

                PensionSystem.PensionfundLivrente.Growth(w);                              //faktisk rente tilskrivning
                PensionSystem.PensionfundLivrente.Contribution(contributionLivsrente[m]); //orienter pensionsfund om indbetaling

                if (_activeLivrente /*&& installmentLivrente == 0*/ && _livrenteDepotPrimoBx > 0)
                {
                    installmentLivrente = PensionSystem.PensionfundLivrente.CalculateInstallment(age, m, _livrenteDepotPrimoBx); //beregn livsrentepension, hvis aktiv
                }
                PensionSystem.PensionfundLivrente.Installment(installmentLivrente);                                              //orienter pensionsfund om udbetaling

                w = Convert.ToInt32((1 + PensionSystem.InterestRate(12)) * w) + contributionLivsrente[m] - installmentLivrente;
                _livrenteDepotUltimoAx = Convert.ToInt32((1 + PensionSystem.InterestRateForecasted(12)) * _livrenteDepotPrimoBx) + contributionLivsrente[m] - installmentLivrente;

                installment += installmentLivrente;
                if (udvalgt && m == 0 && installmentLivrente > 0)
                {
                    Console.WriteLine("Udbetaling, m=" + m + ", " + installmentLivrente + " Kr.");
                }


                if (dead == m) //personen dør denne måned
                {
                    PensionSystem.PensionfundLivrente.PersonExit(w, m);
                    PensionSystem.PensionfundRate.PersonExit(_holdingsRate, m);
                    return(installment);
                }

                if (m == 11)
                {
                    _dx = PensionSystem.PensionfundLivrente.CalculateDx(age, m, _livrenteDepotUltimoAx); //beregnes efter Ax
                }
            }

            return(installment);
        }
Пример #3
0
 public void Growth(int bx)
 {
     _holdingsW += Convert.ToUInt32(bx * PensionSystem.InterestRate(12)); //forøg pensionsdebot med rente for persons personlige beholdning
 }
Пример #4
0
        public int Update(int age, int[] contributionRate, int[] contributionLivsrente, int[] contributionInvalide, int startRate = -1, int startLivrente = -1, int startInvalideAldersPension = -1, int invalid = -1, int dead = -1)
        {
            double tmp = 0;

            if (udvalgt && age == 65)
            {
                Console.WriteLine("65 år");
            }

            int installment = 0; //årets samlede pensionsudbetaling

            #region ratepension
            for (int m = 0; m < 12; m++)
            {
                if (startRate == m && _ratesLeft < 1)
                {
                    _ratesLeft = 12 * 10;              //aktiver ratepensionsudbetaling sæt udbetaling til at vare 10 år
                }
                ContributionRate(contributionRate[m]); //indbetal til ratepension
                installment += InstallmentRate();      //udbetal ratepension

                if (udvalgt && m == 0 && installment > 0)
                {
                    Console.WriteLine("Ratepension, udbetalt (m=" + m + "): " + installment);
                }

                if (dead == m) //personen dør denne måned
                {
                    PensionSystem.PensionfundRate.PersonExit(_holdingsRate, m);
                    break;
                }

//        _dx = _livrenteDepotUltimoAx;
            }
            #endregion ratepension

            #region simpel livrente
            int installmentLivrente = 0;
            for (int m = 0; m < 12; m++)
            {
                _livrenteDepotPrimoBx = PensionSystem.PensionfundLivrente.UpdateHoldings(age, _livrenteDepotUltimoAx, _dx, m); //beregn ny beholdning (Bx)
                if (m == 0)
                {
                    w = _livrenteDepotPrimoBx;
                }

                if (udvalgt && m == 0 && age < 65)
                {
                    int expected = PensionSystem.PensionfundLivrente.InstallmentExpected(age, m, _livrenteDepotPrimoBx, contributionLivsrente[m]);
//          Console.WriteLine("Forventet pension: " + expected);
                }

                _activeLivrente |= startLivrente == m;                                    //aktiver livrentepensionsudbetaling

                PensionSystem.PensionfundLivrente.Growth(w);                              //faktisk rente tilskrivning
                PensionSystem.PensionfundLivrente.Contribution(contributionLivsrente[m]); //orienter pensionsfund om indbetaling

                if (_activeLivrente /*&& installmentLivrente == 0*/ && _livrenteDepotPrimoBx > 0)
                {
                    installmentLivrente = PensionSystem.PensionfundLivrente.CalculateInstallment(age, m, _livrenteDepotPrimoBx); //beregn livsrentepension, hvis aktiv
                }
                PensionSystem.PensionfundLivrente.Installment(installmentLivrente);                                              //orienter pensionsfund om udbetaling

                w = Convert.ToInt32((1 + PensionSystem.InterestRate(12)) * w) + contributionLivsrente[m] - installmentLivrente;
                _livrenteDepotUltimoAx = Convert.ToInt32((1 + PensionSystem.InterestRateForecasted(12)) * _livrenteDepotPrimoBx) + contributionLivsrente[m] - installmentLivrente;

                installment += installmentLivrente;
//        if (udvalgt && installmentLivrente > 0)
//          Console.WriteLine("Udbetaling livrente, m=" + m + ", " + installmentLivrente + " Kr.");

                if (dead == m) //personen dør denne måned
                {
                    PensionSystem.PensionfundLivrente.PersonExit(w, m);
                    break;
                }

                if (m == 11)
                {
                    _dx = PensionSystem.PensionfundLivrente.CalculateDx(age, m, _livrenteDepotUltimoAx); //beregnes efter Ax
                }
            }
            #endregion simpel livrente

            #region simpel livrente med invalidepension
            int installmentInvalide = 0;
            for (int m = 0; m < 12; m++)
            {
                #region selve invalidepensionen
                if (_invalid)
                {
                    invalid = -1;         //kan kun blive invalid een gang
                }
                _invalid |= invalid == m; //aktiver invalidepension

                if (_invalid && age >= PensionSystem._pensionAge)
                {
                    _invalid = false; //når du når pensionsalderen behandles du ikke længere som invalid, men som pensionist
                    _activeInvalideAlders = true;
                }

                if (_invalid)
                {
                    _ddf = PensionSystem.PensionfundInvalide.CalculateDdf(age, m, _adf, _expectedPension, invalid == m); //indvalidebeholdning primo før bonus
                    _bdf = PensionSystem.PensionfundInvalide.CalculateBdf(m, _ddf);                                      //indvalidebeholdning, justeret m. bonus
                    int fd = Math.Min(99999989, PensionSystem.PensionfundInvalide.CalculateFd(age, m, _bdf));            //udbetaling
                    _adf = PensionSystem.PensionfundInvalide.CalculateAdf(_bdf, fd);                                     //indvalidebeholdning ultimo

                    if (m == 0)
                    {
                        _wdf = _bdf;
                    }
                    PensionSystem.PensionfundInvalide.Growth(_wdf);    //rentetilskrivning
                    PensionSystem.PensionfundInvalide.Installment(fd); //orienter pensionsfund om udbetaling
                    _wdf = Convert.ToInt32((1 + PensionSystem.InterestRate(12)) * _wdf - fd);
                }
                #endregion selve invalidepensionen

                #region opsparingssikring
                int fdi = 0;
                if (_invalid)
                {
                    _ddi = PensionSystem.PensionfundInvalide.CalculateDdi(age, m, _latestContribution, _adi, invalid == m); //indvalidebeholdning primo før bonus
                    _bdi = PensionSystem.PensionfundInvalide.CalculateBdi(m, _ddi);                                         //indvalidebeholdning, justeret m. bonus
                    fdi  = PensionSystem.PensionfundInvalide.CalculateFdi(age, m, _bdi);                                    //"udbetaling"
                    _adi = PensionSystem.PensionfundInvalide.CalculateAdi(_bdi, fdi);                                       //indvalidebeholdning ultimo

                    if (m == 0)
                    {
                        _wdi = _bdi;
                    }
                    PensionSystem.PensionfundInvalide.Growth(_wdi); //rentetilskrivning
//          PensionSystem.PensionfundInvalide.Installment(fdi); //orienter pensionsfund om "udbetaling"

                    _wdi = Convert.ToInt32((1 + PensionSystem.InterestRate(12)) * _wdi - fdi);
                }
                #endregion opsparingssikring

                #region alderspension og pensionsindbetaling
                _activeInvalideAlders |= startInvalideAldersPension == m;                                  //aktiver alderspension
                _invalideDepotPrimoBx  = PensionSystem.PensionfundInvalide.UpdateHoldings(_dxInvalide, m); //beregn ny beholdning (Bx)

                int expected = 0;
                if (age < 65)
                {
                    if (_invalid)
                    {
                        expected = PensionSystem.PensionfundInvalide.InstallmentExpected(age, m, _invalideDepotPrimoBx, fdi);
                    }
                    else
                    {
                        expected = PensionSystem.PensionfundInvalide.InstallmentExpected(age, m, _invalideDepotPrimoBx, contributionInvalide[m]);
                    }
                }
                if (udvalgt && m == 0 && age < 65)
                {
                    Console.WriteLine("Forventet invalide pension: " + expected + " (" + m + ")");
//          Console.WriteLine("Invalide alderspension, beholdning primo (Bx): " + _invalideDepotPrimoBx + " (" + m + ")");
                }

                if (m == 0)
                {
                    wi = _invalideDepotPrimoBx;
                }
                PensionSystem.PensionfundInvalide.Growth(wi); //faktisk rente tilskrivning

                if (_invalid)
                {
                    ;//PensionSystem.PensionfundInvalide.Contribution(fdi); //orienter pensionsfund om indbetaling
                }
                else
                {
                    PensionSystem.PensionfundInvalide.Contribution(contributionInvalide[m]); //orienter pensionsfund om indbetaling
                }
                if (contributionInvalide[m] > 0)
                {
                    _latestContribution = contributionInvalide[m]; //anvendes til bestemmelse af opsparingssikring ved invaliditet
                }
                if (_activeInvalideAlders && _invalideDepotPrimoBx > 0)
                {
                    installmentInvalide = PensionSystem.PensionfundInvalide.CalculateInstallment(age, m, _invalideDepotPrimoBx); //beregn livsrentepension, hvis aktiv
                }
                PensionSystem.PensionfundInvalide.Installment(installmentInvalide);                                              //orienter pensionsfund om udbetaling

                if (_invalid)
                {
                    wi = Convert.ToInt32((1 + PensionSystem.InterestRate(12)) * wi) + fdi;
                }
                else
                {
                    wi = Convert.ToInt32((1 + PensionSystem.InterestRate(12)) * wi) + contributionInvalide[m] - installmentInvalide;
                }

                double pidf, pidi;
                if (_invalid || (contributionInvalide[m] <= 0 && _timeSinceLastInvalideContribution++ > 3) || _activeInvalideAlders) //hvis der ikke er indbetalt til invalidepension i 3 måneder, stoppes dækning og præmier
                {
                    pidf = 0;
                    pidi = 0;
                }
                else
                {
                    _timeSinceLastInvalideContribution = 0;
                    pidf = PensionSystem.PensionfundInvalide.CalculatePidf(age, m, _invalideDepotPrimoBx, contributionInvalide[m]); //pidf skal dække pensionsudbetaling for invalide
                    pidi = PensionSystem.PensionfundInvalide.CalculatePidi(age, m, contributionInvalide[m]);                        //pidi skal dække pensionsindbetaling for invalide
                    tmp += pidi;
                }

                if (_invalid)
                {
                    _invalideDepotUltimoAx = Convert.ToInt32((1 + PensionSystem.InterestRateForecasted(12)) * _invalideDepotPrimoBx + fdi);
                }
                else
                {
                    _invalideDepotUltimoAx = Convert.ToInt32((1 + PensionSystem.InterestRateForecasted(12)) * _invalideDepotPrimoBx + contributionInvalide[m] - installmentInvalide - pidf - pidi);
                }

                installment += installmentInvalide;
                #endregion alderspension og pensionsindbetaling

                if (udvalgt /*&& m == 0*/ && installmentInvalide > 0)
                {
                    Console.WriteLine("Udbetaling invalide, m=" + m + ", " + installmentInvalide + " Kr.");
                }

                _expectedPension = expected;                                  //anvendes ved invalidering

                if (dead == m)                                                //personen dør denne måned
                {
                    PensionSystem.PensionfundInvalide.PersonExit(age, m, wi); //pensionsbeholdning slettes fra pensionskasse.
                    break;
                }

                _dxInvalide = PensionSystem.PensionfundInvalide.CalculateDx(age, m, _invalideDepotUltimoAx, _activeInvalideAlders);

                if (m == 11)
                {
                    PensionSystem.PensionfundInvalide.RegisterDx(_dxInvalide);
                    PensionSystem.PensionfundInvalide.RegisterDx(_ddf);
                    PensionSystem.PensionfundInvalide.RegisterDx(_ddi);
                }
            }
            #endregion simpel livrente med invalidepension

            return(installment);
        }