예제 #1
0
        static void Main(string[] args)
        {
            AnnualAggregate    agg      = new AnnualAggregate();
            IndividualSettings settings = IndividualSettings.Deserialize("sample.json");

            /*
             * IndividualSettings output = new IndividualSettings();
             * output.PerPaycheckSettings = new List<PerPaycheckSettings>();
             * output.PerPaycheckSettings.Add(new PerPaycheckSettings() { Month = 3, Day = 15, StockAwards = 300 });
             * output.PerPaycheckSettings.Add(new PerPaycheckSettings() { Month = 9, Day = 15, Bonus = 80000 });
             * Console.WriteLine(output.Serialize());
             */

            List <int> days = new List <int>()
            {
                15, 30
            };

            for (int month = 1; month <= 12; month++)
            {
                foreach (int day in days)
                {
                    Paycheck p = new Paycheck(month, day, settings, agg);
                    agg.UpdateFromPaycheck(p);

                    WriteToConsole(string.Format("Paycheck ({0}/{1})", month, day), p);
                    Console.WriteLine();
                    WriteToConsole("Current Aggregate", agg);
                    Console.WriteLine();
                    Console.WriteLine();
                }
            }
        }
예제 #2
0
            public static double ESPP(double earnings, IndividualSettings settings, AnnualAggregate aggregate)
            {
                double target  = earnings * (settings.ESPPWithholdingRate / 100);
                double allowed = Constants.Threshold.ESPPConstributions - aggregate.ESPP;

                return(Math.Min(target, allowed));
            }
예제 #3
0
        public Paycheck(int month, int day, IndividualSettings settings, AnnualAggregate aggregate)
        {
            // Set the date for this paycheck
            this.PaycheckMonth = month;
            this.PaycheckDay   = day;

            // Gross pay inputs
            this.Wages = Calculate.Paycheck.Salary(this.PaycheckMonth, settings);
            this.Bonus = Calculate.Paycheck.Bonus(this.PaycheckMonth, this.PaycheckDay, settings);
            double grossPay = this.Wages + this.Bonus;

            // Pre-Tax withholdings and additional taxable stuff -> HSA before PreTax!
            this.PreTax401k      = Calculate.Paycheck.PreTax401k(grossPay, settings, aggregate);
            this.HSA             = Calculate.Paycheck.HSA(grossPay, this.PreTax401k, settings, aggregate);
            this.StockAwards     = Calculate.Paycheck.StockAwards(this.PaycheckMonth, this.PaycheckDay, settings);
            this.TaxableEarnings = grossPay - this.PreTax401k + settings.StayFitTaxable + this.StockAwards + settings.DisabilityInsuranceTaxable - this.HSA;

            // Taxes
            this.Federal        = Calculate.Taxes.Federal(this.TaxableEarnings, this.Bonus, settings);
            this.SocialSecurity = Calculate.Taxes.SocialSecurity(this.TaxableEarnings, this.PreTax401k, aggregate);
            this.Medicare       = Calculate.Taxes.Medicare(this.TaxableEarnings, this.PreTax401k, settings.ImputedLifeInsurance, aggregate);

            // After tax withholdings
            double earnings = this.TaxableEarnings - this.Federal - this.SocialSecurity - this.Medicare;

            this.AfterTax401k = Calculate.Paycheck.AfterTax401k(earnings, settings, aggregate);
            earnings         -= this.AfterTax401k;
            this.ESPP         = Calculate.Paycheck.ESPP(earnings, settings, aggregate);
        }
예제 #4
0
            public static double SocialSecurity(double taxableEarnings, double preTax401k, AnnualAggregate aggregate)
            {
                double cap       = Constants.Threshold.SocialSecurityCap * (Constants.TaxRate.SocialSecurity / 100);
                double remaining = cap - aggregate.SocialSecurity;
                double expected  = (taxableEarnings + preTax401k) * (Constants.TaxRate.SocialSecurity / 100);

                return(Math.Min(expected, remaining));
            }
예제 #5
0
            public static double AfterTax401k(double earnings, IndividualSettings settings, AnnualAggregate aggregate)
            {
                double target  = earnings * (settings.AfterTax401kWithholdingRate / 100);
                double allowed = Constants.Threshold.AfterTax401kConstributions - aggregate.AfterTax401k;

                return(Math.Min(target, allowed));
            }
예제 #6
0
            public static double HSA(double grossPay, double preTax401k, IndividualSettings settings, AnnualAggregate aggregate)
            {
                double hsaTarget = settings.HSALumpSum - aggregate.HSA;

                return(Math.Min(hsaTarget, grossPay - preTax401k));
            }
예제 #7
0
            public static double PreTax401k(double grossPay, IndividualSettings settings, AnnualAggregate aggregate)
            {
                double target  = grossPay * (settings.PreTax401kWithholdingRate / 100);
                double allowed = Constants.Threshold.PreTax401kContributions - aggregate.PreTax401k;

                return(Math.Min(target, allowed));
            }
예제 #8
0
            public static double Medicare(double taxableEarnings, double preTax401k, double imputedLifeInsurance, AnnualAggregate aggregate)
            {
                double medicareEarnings = taxableEarnings + preTax401k + imputedLifeInsurance;

                if (aggregate.TaxableEarnings > Constants.Threshold.MedicareRateChange)
                {
                    return(taxableEarnings * (Constants.TaxRate.MedicareAboveThreshold / 100));
                }
                else if (aggregate.TaxableEarnings + medicareEarnings < Constants.Threshold.MedicareRateChange)
                {
                    return(medicareEarnings * (Constants.TaxRate.MedicareBelowThreshold / 100));
                }
                else
                {
                    double below = Constants.Threshold.MedicareRateChange - aggregate.TaxableEarnings;
                    double above = medicareEarnings - below;
                    return((below * (Constants.TaxRate.MedicareBelowThreshold / 100)) + (above * (Constants.TaxRate.MedicareAboveThreshold / 100)));
                }
            }