public User(String name, TaxStatus status, bool employed) { this.name = name; this.taxStatus = status; this.employed = employed; this.projects = new List <Project>(); this.expenses = new List <Expense>(); this.netIncome = getGrossIncome(); this.predictedTax = GetPredictedTax(); }
private TaxStatus SelectedTaxStatus() { TaxStatus taxStatus = TaxStatus.Tax18; switch (cmbTax.Text) { case "Tax18": taxStatus = TaxStatus.Tax18; break; case "Tax2": taxStatus = TaxStatus.Tax2; break; } return(taxStatus); }
public static double CalcTaxes(double yearlyIncome, TaxStatus taxType, FilingStatus status, double principle) { if (TaxStatus.roth == taxType)//no taxes taken out { return(0); } else if (TaxStatus.qualified == taxType)//taxed on all withdrawals { double x = Convert.ToDouble(IncomeTaxCalculator.TotalIncomeTaxFor(status, (decimal)yearlyIncome, 0)); return(Convert.ToDouble(IncomeTaxCalculator.TotalIncomeTaxFor(status, (decimal)yearlyIncome, 0))); } else//taxed on only gains, not taxed on principle { if (yearlyIncome < principle) { return(0); } double y = Convert.ToDouble(IncomeTaxCalculator.TotalIncomeTaxFor(status, (decimal)(yearlyIncome - principle), 0)); return(Convert.ToDouble(IncomeTaxCalculator.TotalIncomeTaxFor(status, (decimal)(yearlyIncome - principle), 0))); } }
public LineItem(string itemName, Int16 qty, decimal each, TaxStatus taxable, string revenueGroup, string extraDetails, List <string> discountGroups) { this.itemName = itemName; this.quantity = qty; this.priceEach = each; this.taxable = taxable; this.revenueGroup = revenueGroup; this.extraDetails = extraDetails; if (discountGroups != null) { this.discountGroups = discountGroups; } else { this.discountGroups = new List <string>(); } }
public override int GetHashCode() { unchecked { var hashCode = Attributes != null?Attributes.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (CatalogVisibility != null ? CatalogVisibility.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Categories != null ? Categories.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExternalUrl != null ? ExternalUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Featured.GetHashCode(); hashCode = (hashCode * 397) ^ Id; hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0); hashCode = (hashCode * 397) ^ InStock.GetHashCode(); hashCode = (hashCode * 397) ^ ManageStock.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OnSale.GetHashCode(); hashCode = (hashCode * 397) ^ ParentId; hashCode = (hashCode * 397) ^ (Permalink != null ? Permalink.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PriceHtml != null ? PriceHtml.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Purchasable.GetHashCode(); hashCode = (hashCode * 397) ^ (RegularPrice != null ? RegularPrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RelatedIds != null ? RelatedIds.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SalePrice != null ? SalePrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ShortDescription != null ? ShortDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Slug != null ? Slug.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (StockQuantity != null ? StockQuantity.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TaxClass != null ? TaxClass.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TaxStatus != null ? TaxStatus.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TotalSales; hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Virtual.GetHashCode(); return(hashCode); } }
private static async Task InsertData(IServiceProvider serviceProvider) { //var owners = new ProductOwner[] //{ // new ProductOwner { Name = "Themesoft Inc", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new ProductOwner { Name = "Amor Sai Inc", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new ProductOwner { Name = "My Productowner Inc", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, //}; //await AddOrUpdateAsync(serviceProvider, a => a.ProductOwnerId, owners); var taxStatuses = new TaxStatus[] { new TaxStatus { TaxStatusCode = "1099", Description = "1099", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new TaxStatus { TaxStatusCode = "W2", Description = "W2", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new TaxStatus { TaxStatusCode = "C2C", Description = "C2C", CreatedUser = "******", CreatedDate = DateTime.UtcNow } }; await AddOrUpdateAsync(serviceProvider, a => a.TaxStatusCode, taxStatuses); var employmentTypes = new EmploymentType[] { new EmploymentType { EmploymentTypeCode = "1", Description = "Placement", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new EmploymentType { EmploymentTypeCode = "2", Description = "Passthrough", CreatedUser = "******", CreatedDate = DateTime.UtcNow } }; await AddOrUpdateAsync(serviceProvider, a => a.EmploymentTypeCode, employmentTypes); var VisaStatuses = new VisaType[] { new VisaType { VisaTypeCode = "1", Description = "US Citizen", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new VisaType { VisaTypeCode = "2", Description = "H1-B", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new VisaType { VisaTypeCode = "3", Description = "GC", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new VisaType { VisaTypeCode = "4", Description = "OPT EAD", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new VisaType { VisaTypeCode = "5", Description = "H4 EAD", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new VisaType { VisaTypeCode = "6", Description = "GC EAD", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, new VisaType { VisaTypeCode = "7", Description = "TN", CreatedUser = "******", CreatedDate = DateTime.UtcNow }, }; await AddOrUpdateAsync(serviceProvider, a => a.VisaTypeCode, VisaStatuses); //var endClient = new EndClient[] //{ // new EndClient { CompanyName="Walmart", TaxId="17-2466710", AddressLine1 ="Walmart Line 1", AddressLine2="Walmart Line 2", City= "Wal City", State ="NY", Zip ="12310", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new EndClient { CompanyName="Berkshire Hathaway", TaxId="17-2466711", AddressLine1 ="Berkshire Hathaway Line 1", AddressLine2="Berkshire Hathaway Line 2", City= "Berk City", State ="NY", Zip ="12315", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new EndClient { CompanyName="Apple", TaxId="17-2466712", AddressLine1 ="Apple Line 1", AddressLine2="Apple Line 2", City= "Wal City", State ="NY", Zip ="12316", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, //}; //await AddOrUpdateAsync(serviceProvider, a => a.EndClientId, endClient); //var client = new Client[] //{ // new Client { CompanyName="Exxon Mobil", TaxId="17-2466713", AddressLine1 ="Exxon Mobil Line 1", AddressLine2="Exxon Mobil Line 2", City= "Wal City", State ="NY", Zip ="12317", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new Client { CompanyName="UnitedHealth Group", TaxId="17-2466714", AddressLine1 ="UnitedHealth Group Line 1", AddressLine2="UnitedHealth Group Line 2", City= "Wal City", State ="NY", Zip ="12318", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new Client { CompanyName="CVS Health", TaxId="17-2466715", AddressLine1 ="CVS Health Line 1", AddressLine2="CVS Health Line 2", City= "Wal City", State ="NY", Zip ="12319", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new Client { CompanyName="General Motors", TaxId="17-2466716", AddressLine1 ="General Motors Line 1", AddressLine2="General Motors Line 2", City= "Wal City", State ="NY", Zip ="12312", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, //}; //await AddOrUpdateAsync(serviceProvider, a => a.ClientId, client); //var vendor = new Vendor[] //{ // new Vendor { CompanyName="Deloitte Consulting", TaxId="17-2466710", AddressLine1 ="Deloitte Consulting Line 1", AddressLine2="Deloitte Consulting Line 2", City= "D City", State ="NY", Zip ="12310", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new Vendor { CompanyName="Accenture", TaxId="17-2466711", AddressLine1 ="Accenture Line 1", AddressLine2="Accenture Line 2", City= "A City", State ="NY", Zip ="12315", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new Vendor { CompanyName="Mahindra", TaxId="17-2466712", AddressLine1 ="Mahindra Line 1", AddressLine2="Mahindra Line 2", City= "M City", State ="NY", Zip ="12316", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, // new Vendor { CompanyName="IBM Global", TaxId="17-2466714", AddressLine1 ="IBM Global Line 1", AddressLine2="IBM Global Line 2", City= "I City", State ="NY", Zip ="12318", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow }, //}; //await AddOrUpdateAsync(serviceProvider, a => a.VendorId, vendor); //var candidate = new Candidate[] //{ // new Candidate {FirstName= "John", LastName= "Lenon", MI= "", Gender= "M", SSN= "123231224", Email= "*****@*****.**", Phone= "1234567111", Phone2= "", AddressLine1 ="John Line 1", AddressLine2="John Line 2", City= "J City", State ="NY", Zip ="12310", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, // new Candidate {FirstName= "Jerry", LastName= "Lewls", MI= "", Gender= "M", SSN= "123231212", Email= "*****@*****.**", Phone= "1244467890", Phone2= "", AddressLine1 ="Jerry Line 1", AddressLine2="Jerry Line 2", City= "je City", State ="NY", Zip ="12310", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, // new Candidate {FirstName= "Shawn", LastName= "Grandy", MI= "", Gender= "M", SSN= "123231120", Email= "*****@*****.**", Phone= "1234561290", Phone2= "", AddressLine1 ="Grandy Line 1", AddressLine2="Grandy Line 2", City= "g City", State ="NY", Zip ="12310", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, // new Candidate {FirstName= "Chelsey", LastName= "Charbeneau", MI= "", Gender= "F", SSN= "121131226", Email= "*****@*****.**", Phone= "1114445544", Phone2= "", AddressLine1 ="chelsey Line 1", AddressLine2="chelsey Line 2", City= "c City", State ="NY", Zip ="12310", ProductOwnerId=4, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, //}; //await AddOrUpdateAsync(serviceProvider, a => a.CandidateId, candidate); //var enroll = new Enrollment[] //{ // new Enrollment {Internal= "I", HRUserId= 1, JobTitle= "Job Title 1", DurationYears= 1, DurationMonths= 0, BillRate= 75, PayRate= 71, StartDate= new DateTime(2017, 1, 1), EndDate= new DateTime(2018, 1, 1), VendorPO= "125jh6", CandidateId= 1005, EmploymentTypeCode= "1", TaxStatusCode= "C2C", ClientId= 4, EndClientId= 1, VendorId= 1, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, // new Enrollment {Internal= "I", HRUserId= 1, JobTitle= "Job Title 2", DurationYears= 1, DurationMonths= 6, BillRate= 80, PayRate= 75, StartDate= new DateTime(2017, 3, 1), EndDate= new DateTime(2019, 8, 1), VendorPO= "163454", CandidateId= 1006, EmploymentTypeCode= "1", TaxStatusCode= "C2C", ClientId= 1, EndClientId= 2, VendorId= 2, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, // new Enrollment {Internal= "I", HRUserId= 1, JobTitle= "Job Title 1", DurationYears= 2, DurationMonths= 0, BillRate= 60, PayRate= 45, StartDate= new DateTime(2016, 1, 1), EndDate= new DateTime(2018, 1, 1), VendorPO= "k23452", CandidateId= 1007, EmploymentTypeCode= "1", TaxStatusCode= "1099", ClientId= 2, EndClientId= 3, VendorId= 3, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, // new Enrollment {Internal= "I", HRUserId= 1, JobTitle= "Job Title 3", DurationYears= 0, DurationMonths= 6, BillRate= 55, PayRate= 50, StartDate= new DateTime(2017, 3, 1), EndDate= new DateTime(2017, 9, 1), VendorPO= "er3457", CandidateId= 1008, EmploymentTypeCode= "1", TaxStatusCode= "C2C", ClientId= 3, EndClientId= 2, VendorId= 3, CreatedUser = "******", CreatedDate = DateTime.UtcNow}, //}; //await AddOrUpdateAsync(serviceProvider, a => a.EnrollmentId, enroll); }
private void WriteSummary(IReportWriter writer, IList <ChartDataValue> data, TaxStatus taxStatus, string prefix, Predicate <Account> filter, bool subtotal) { bool wroteSectionHeader = false; string caption = prefix + "Investments"; decimal totalSectionMarketValue = 0; decimal totalSectionGainValue = 0; int rowCount = 0; IList <SecurityGroup> groups = null; if (this.selectedGroup != null) { groups = calc.RegroupBySecurity(this.selectedGroup); } else { groups = calc.GetHoldingsBySecurityType(filter); } // compute summary foreach (var securityGroup in groups) { decimal marketValue = 0; decimal gainLoss = 0; SecurityType st = securityGroup.Type; int count = 0; foreach (SecurityPurchase i in securityGroup.Purchases) { if (i.UnitsRemaining > 0) { marketValue += i.MarketValue; gainLoss += i.GainLoss; count++; } } if (taxStatus == TaxStatus.TaxFree) { gainLoss = 0; } if (count > 0) { if (!wroteSectionHeader) { WriteHeaderRow(writer, caption, "Market Value", "Taxable Gains"); wroteSectionHeader = true; } var color = GetRandomColor(); if (securityGroup.Security != null) { caption = securityGroup.Security.Name; } else { caption = prefix + Security.GetSecurityTypeCaption(st); } data.Add(new ChartDataValue() { Value = (double)RoundToNearestCent(marketValue), Label = caption, Color = color, UserData = securityGroup }); if (securityGroup.Security == null) { caption = " " + Security.GetSecurityTypeCaption(st); } WriteSummaryRow(writer, color, caption, marketValue.ToString("C"), gainLoss.ToString("C")); rowCount++; } totalSectionMarketValue += marketValue; totalSectionGainValue += gainLoss; } if (wroteSectionHeader && subtotal && rowCount > 1) { WriteSummaryRow(writer, Colors.Transparent, " SubTotal", totalSectionMarketValue.ToString("C"), totalSectionGainValue.ToString("C")); } totalMarketValue += totalSectionMarketValue; totalGainLoss += totalSectionGainValue; }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double amountWithFees = amount; if (Riders.Contains(Models.Riders.DeathBenefit)) { amountWithFees -= amountWithFees * .005; } double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { //double[] account = new double[deathAge-retireAge]; int count = 0; double temp = 0; temp = amountWithFees;//starting amount is lumpsum double principle = amountWithFees; double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3); //if rate is less than 1 if (rate < .01)//lower bound and upper boudn on interest rate for fixed indexed { rate = .01; } else if (rate > .06) { rate = .06; } if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge)//interest grows on initial investment { temp = temp * Math.Pow(1 + rate, 1); } else { withdrawalAmount += CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp -= CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp = temp * Math.Pow(1 + rate, 1); count++; } } //if (i < 500) //{ // trials.Add(account);//adds one trial to the list //} withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } //trials.Add(MedianAverageWithdrawal);//adds an array of the averages to the end of the lsit, will be taken out later and used return(MedianAverageWithdrawal); }
public double CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double amountWithFees = amount; if (Riders.Contains(Models.Riders.DeathBenefit))//death benefit rider { amountWithFees -= amountWithFees * .005; } double[] account = new double[deathAge - retireAge]; int count = 0; double temp = amountWithFees; double principle = amountWithFees; for (int j = age; j < deathAge; j++) { double rate = mean; if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge) { temp = temp * Math.Pow(1 + rate, 1); } if (j >= retireAge) { account[count] = CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); double Taxamount = TaxHelper.CalcTaxes(TaxHelper.CalcWithdrawalAmount(rate, temp, deathAge - retireAge), taxType, status, principle); temp -= CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp = temp * Math.Pow(1 + rate, 1); count++; } } double averageWithdrawal = 0; for (int i = 0; i < deathAge - retireAge; i++)//calculates average withdrawal during retirement { averageWithdrawal += account[i]; } averageWithdrawal = averageWithdrawal / (deathAge - retireAge); return(averageWithdrawal); }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) {//same as deferred variable except lumpsum instead of continuous payments double amountWithFees = amount; Boolean isGMWB; if (Riders.Contains(Models.Riders.GMWB))//Checks to see if GMWB is a rider { isGMWB = true; amountWithFees -= amountWithFees * .005; } else { isGMWB = false; } Boolean isGMAB; if (Riders.Contains(Models.Riders.GMAB))//checks to see if GMAB is a rider { isGMAB = true; amountWithFees -= amountWithFees * .005; } else { isGMAB = false; } if (Riders.Contains(Models.Riders.DeathBenefit)) { amountWithFees -= amountWithFees * .005; } double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { // double[] account = new double[deathAge-retireAge]; int count = 0; double temp = amountWithFees; double principle = amountWithFees; double minWithdrawal = 0; double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3); if (j == retireAge) { if (isGMAB && (principle > temp)) { temp = principle; } minWithdrawal = principle / (deathAge - retireAge);// CalcWithdrawal(mean, principle, deathAge - j + 1, taxType, status, principle); } if (j < retireAge) { temp = temp * Math.Pow(1 + rate, 1); } else { double withdrawal = CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); double taxes = TaxHelper.CalcTaxes(TaxHelper.CalcWithdrawalAmount(rate, temp, deathAge - retireAge + 1), taxType, status, principle); temp -= withdrawal; withdrawal = withdrawal - withdrawal * .03; if (isGMWB) { if (withdrawal < minWithdrawal) { withdrawal = minWithdrawal; } } withdrawalAmount += withdrawal; temp = temp * Math.Pow(1 + rate, 1); count++; } } withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } // trials.Add(MedianAverageWithdrawal);//adds an array of the averages to the end of the lsit, will be taken out later and used return(MedianAverageWithdrawal); }
public static double CalcTaxedWithdrawals(double rate, double presentValue, int yearsWithdrawing, TaxStatus taxType, FilingStatus status, double principle) { //Console.WriteLine(rate+ " rate "+presentValue+" PV "+CalcTaxes(CalcWithdrawalAmount(rate, presentValue, yearsWithdrawing), taxType, status, principle)); double withdrawal = CalcWithdrawalAmount(rate, presentValue, yearsWithdrawing); double taxes = CalcTaxes(withdrawal, taxType, status, principle); return(withdrawal - taxes); }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double withdrawalPercentageFee = 0; /*surrender fee:*/ //fee for withdrawing early if (age + 7 < retireAge) { withdrawalPercentageFee = 0.07; } else if (age + 6 < retireAge) { withdrawalPercentageFee = 0.06; } else if (age + 5 < retireAge) { withdrawalPercentageFee = 0.05; } else if (age + 4 < retireAge) { withdrawalPercentageFee = 0.04; } else if (age + 3 < retireAge) { withdrawalPercentageFee = 0.03; } else if (age + 2 < retireAge) { withdrawalPercentageFee = 0.02; } else if (age + 1 < retireAge) { withdrawalPercentageFee = 0.01; } /*surender fee:*/ double amountWithFees = amount; if (Riders.Contains(Models.Riders.DeathBenefit))//death benefit rider, only increases fee { amountWithFees -= amountWithFees * .005; } double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { // double[] account = new double[deathAge-retireAge]; int count = 0; //index of the array that withdrawal data is being input into double temp = 0; //current amount in the annuity double principle = 0; //untaxable part of account double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3);//random number from -3 to 3, 3 standard deviations is enough //if rate is less than 1 if (rate < .01)//fixed indexed has upper and lower bounds for rate { rate = .01; } else if (rate > .06) { rate = .06; } if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge)//depositing only , no withdrawing { temp = (temp + amountWithFees) * Math.Pow(1 + rate, 1); principle += amountWithFees; //adds to amount invested } if (j >= retireAge) //stop depositing and start withdrawing when retirement starts { double withdrawal = CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); //withdrawal amoutn with taxes and loan payment calc withdrawal = withdrawal - withdrawal * withdrawalPercentageFee; // subtract withdrawal early fee // account[count] = withdrawal; withdrawalAmount += withdrawal; temp -= withdrawal; temp = temp * Math.Pow(1 + rate, 1); //interest count++; //increment array counter } } withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } // trials.Add(MedianAverageWithdrawal);//adds an array of the averages to the end of the lsit, will be taken out later and used return(MedianAverageWithdrawal); }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, double lumpSum, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { double temp = lumpSum;//sets temp to equal lumpsum, if deferred this is 0 double returns = 0; double taxableAmount = 0; double principle = lumpSum; double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3);//random number between -3 and 3, then multiplied by std deviation if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge) { principle += amount; returns = (temp + amount) * Math.Pow(1 + rate, 1); //total returns taxableAmount = returns - temp; //interest made of of returns temp = returns; //-Convert.ToDouble(IncomeTaxCalculator.CapitalGainsTaxFor(status, (decimal)taxableAmount, (decimal)income));//capitol gains tax subtracted from interest made } else { withdrawalAmount += CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp -= CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp = temp * Math.Pow(1 + rate, 1); } } withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } return(MedianAverageWithdrawal); }
public abstract List <double[]> CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders);
public abstract double CalcWithdrawal(double rate, double presentValue, int yearsWithdrawing, TaxStatus taxType, FilingStatus status, double principle);
public double CalcWithdrawal(double rate, double presentValue, int yearsWithdrawing, TaxStatus taxType, FilingStatus status, double principle) { return(TaxHelper.CalcTaxedWithdrawals(rate, presentValue, yearsWithdrawing, taxType, status, principle)); }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double withdrawalPercentageFee = 0; /*surrender fee:*/ //fee for withdrawing early if (age + 7 < retireAge) { withdrawalPercentageFee = 0.07; } else if (age + 6 < retireAge) { withdrawalPercentageFee = 0.06; } else if (age + 5 < retireAge) { withdrawalPercentageFee = 0.05; } else if (age + 4 < retireAge) { withdrawalPercentageFee = 0.04; } else if (age + 3 < retireAge) { withdrawalPercentageFee = 0.03; } else if (age + 2 < retireAge) { withdrawalPercentageFee = 0.02; } else if (age + 1 < retireAge) { withdrawalPercentageFee = 0.01; } /*surender fee:*/ double amountWithFees = amount; Boolean isGMWB; if (Riders.Contains(Models.Riders.GMWB))//Checks to see if GMWB is a rider and charges fee { isGMWB = true; amountWithFees -= amountWithFees * .005; } else { isGMWB = false; } Boolean isGMAB; if (Riders.Contains(Models.Riders.GMAB))//checks to see if GMAb is a rider and charges fee { isGMAB = true; amountWithFees -= amountWithFees * .005; } else { isGMAB = false; } if (Riders.Contains(Models.Riders.DeathBenefit))//checks to see if death benefit is a rider and charges fee { amountWithFees -= amountWithFees * .005; } // List<double[]> trials = new List<double[]>(); double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { double principle = 0; //double[] account = new double[deathAge-retireAge]; int count = 0; double temp = 0; double minWithdrawal = 0;//minimum withdrawal. used if they have the GMWB rider double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3);//random number from -3 to 3 if (j == retireAge) { if (isGMAB && (principle > temp)) { temp = principle; } minWithdrawal = principle / (deathAge - retireAge); //minWithdrawal = CalcWithdrawal(mean, principle, deathAge - retireAge+1, taxType, status, principle);//minimum withdrawal used for GMWB rider // Console.WriteLine(minWithdrawal); } if (j < retireAge) { temp = (temp + amountWithFees) * Math.Pow(1 + rate, 1); principle += amountWithFees; } if (j >= retireAge) { double withdrawal = CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); withdrawal = withdrawal - withdrawal * withdrawalPercentageFee; temp -= withdrawal; withdrawal = withdrawal - withdrawal * .03; //3% fee for variable account if (isGMWB) //if they have the GMWb rider then they won't have a withdrawal less than principle { if (withdrawal < minWithdrawal) { withdrawal = minWithdrawal; } } // account[count] = withdrawal; withdrawalAmount += withdrawal; temp = temp * Math.Pow(1 + rate, 1); count++; } } //if (i < 500) //{ // trials.Add(account); //} withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } // trials.Add(MedianAverageWithdrawal);//adds an array of the averages to the end of the lsit, will be taken out later and used return(MedianAverageWithdrawal); }
public double CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double amountWithFees = amount; if (Riders.Contains(Models.Riders.DeathBenefit))//rider for Death benefit, doesn't actually do anything except add to the fees { amountWithFees -= amountWithFees * .005; } double withdrawalPercentageFee = 0; /*surrender fee:*/ //fee for withdrawaling funds too early if (age + 7 < retireAge) { withdrawalPercentageFee = 0.07; } else if (age + 6 < retireAge) { withdrawalPercentageFee = 0.06; } else if (age + 5 < retireAge) { withdrawalPercentageFee = 0.05; } else if (age + 4 < retireAge) { withdrawalPercentageFee = 0.04; } else if (age + 3 < retireAge) { withdrawalPercentageFee = 0.03; } else if (age + 2 < retireAge) { withdrawalPercentageFee = 0.02; } else if (age + 1 < retireAge) { withdrawalPercentageFee = 0.01; } /*surender fee:*/ double principle = 0; double[] account = new double[deathAge - retireAge]; double temp = 0; //the amount in the account at year "j" int count = 0; //counter for filling up array that is returned for (int j = age; j < deathAge; j++) { if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge)//when less than retire age, continue to deposit and no withdrawl { temp = (temp + amountWithFees) * Math.Pow(1 + mean, 1); principle += amountWithFees; } else//when greater than retire age, stop depositing and start withdrawing { double withdrawal = CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge));//withdrawal amoutn using payment calculator withdrawal = withdrawal - withdrawal * withdrawalPercentageFee;//withdrawal fee for doing it early account[count] = withdrawal; temp = temp - withdrawal; temp = temp * Math.Pow(1 + mean, 1);//interest count++; } } double averageWithdrawal = 0;//just create average withdrawal amount for fixed for (int i = 0; i < deathAge - retireAge; i++) { averageWithdrawal += account[i]; } averageWithdrawal = averageWithdrawal / (deathAge - retireAge); return(averageWithdrawal); }