Пример #1
0
    //static methods for calculations--------------------------------------------------------------------
    static TaxOutput CalculateTax()
    {
        TaxOutput taxOutput = new TaxOutput();

        double grossSalaryForCalculation = 0;

        //deduct childcare vouchers before starting tax calculation
        grossSalaryForCalculation = grossSalaryInput - childcareVoucherAmount;

        taxOutput.PersonalAllowance          = CalculatePersonalAllowance(grossSalaryForCalculation);
        taxOutput.TaxBasicRate               = CalculateBasicRateTax(grossSalaryForCalculation);
        taxOutput.TaxHigherRate              = CalculateHigherRateTax(grossSalaryForCalculation, taxOutput.PersonalAllowance);
        taxOutput.TaxAdditionalRate          = CalculateAdditionalRateTax(grossSalaryForCalculation);
        taxOutput.NationalInsurance          = CalculateNationalInsurance(grossSalaryForCalculation);
        taxOutput.TotalDeductions            = taxOutput.TaxBasicRate + taxOutput.TaxHigherRate + taxOutput.TaxAdditionalRate + taxOutput.NationalInsurance + childcareVoucherAmount + pensionAnnualAmount + studentLoanAnnualDeduction;
        taxOutput.NetSalary                  = grossSalaryInput - taxOutput.TotalDeductions;
        taxOutput.ChildcareVoucherAmount     = childcareVoucherAmount;
        taxOutput.PensionAnnualAmount        = pensionAnnualAmount;
        taxOutput.GrossSalaryInput           = grossSalaryInput;
        taxOutput.StudentLoanAnnualDeduction = studentLoanAnnualDeduction;

        //add contributions

        //if deductions exceed income
        if (taxOutput.NetSalary < 0)
        {
            taxOutput.NetSalary       = 0;
            taxOutput.TotalDeductions = grossSalaryInput;
            pensionAnnualAmount       = grossSalaryInput - taxOutput.TaxBasicRate - taxOutput.TaxHigherRate - taxOutput.TaxAdditionalRate - taxOutput.NationalInsurance - childcareVoucherAmount - studentLoanAnnualDeduction;
        }
        return(taxOutput);
    }
Пример #2
0
 void DrawTaxGraph(TaxOutput taxOutput)
 {
     ClientScript.RegisterStartupScript(this.GetType(), "anything", "drawTax('" + taxOutput.NetSalary + "','"
                                        + taxOutput.TaxBasicRate + "','"
                                        + taxOutput.TaxHigherRate + "','"
                                        + taxOutput.TaxAdditionalRate + "','"
                                        + taxOutput.NationalInsurance + "','"
                                        + pensionAnnualAmount + "','"
                                        + childcareVoucherAmount + "');", true);
 }
Пример #3
0
 void DrawContributionsGraph(TaxOutput taxOutput)
 {
     ClientScript.RegisterStartupScript(this.GetType(), "anything", "drawContributions('" + taxOutput.PensionsContribution + "','"
                                        + taxOutput.HealthContribution + "','"
                                        + taxOutput.EducationContribution + "','"
                                        + taxOutput.DefenceContribution + "','"
                                        + taxOutput.WelfareContribution + "','"
                                        + taxOutput.ProtectionContribution + "','"
                                        + taxOutput.TransportContribution + "','"
                                        + taxOutput.GeneralContribution + "','"
                                        + taxOutput.OtherContribution + "','"
                                        + taxOutput.InterestContribution + "');", true);
 }
Пример #4
0
    protected void btnCalculateTax_Click(object sender, EventArgs e)
    {
        //TaxOutput taxOutput = new TaxOutput();
        validInput = Double.TryParse(tbGrossSalary.Text, out grossSalaryInput);

        if (validInput)
        {
            TaxOutput taxOutput = CalculateTax();
            //output displayed with currency symbols and thousands separator
            lblChildcareVoucherAmount.Text = childcareVoucherAmount.ToString("C");
            lblStudentLoanAmount.Text      = studentLoanAnnualDeduction.ToString("C");
            lblpensionAnnualAmount.Text    = pensionAnnualAmount.ToString("C");
            lblPersonalAllowance.Text      = taxOutput.PersonalAllowance.ToString("C");
            lblBasicRateTax.Text           = taxOutput.TaxBasicRate.ToString("C");
            lblHigherRateTax.Text          = taxOutput.TaxHigherRate.ToString("C");
            lblAdditionalRateTax.Text      = taxOutput.TaxAdditionalRate.ToString("C");
            lblNationalInsurancePaid.Text  = taxOutput.NationalInsurance.ToString("C");
            lblTotalDeductions.Text        = taxOutput.TotalDeductions.ToString("C");
            lblNetSalary.Text = taxOutput.NetSalary.ToString("C");

            //if user says they are paying more pension than they get in salary
            if ((taxOutput.NetSalary == 0) && (pensionAnnualAmount > 0))
            {
                lblPensionError.Text = "Aren't your pension contributions a bit too high?";
            }
            double totalTaxAndNiPaid = taxOutput.TaxBasicRate + taxOutput.TaxHigherRate
                                       + taxOutput.TaxAdditionalRate + taxOutput.NationalInsurance;

            taxOutput.PensionsContribution   = totalTaxAndNiPaid * pensionsSpending;
            taxOutput.HealthContribution     = totalTaxAndNiPaid * healthSpending;
            taxOutput.EducationContribution  = totalTaxAndNiPaid * educationSpending;
            taxOutput.DefenceContribution    = totalTaxAndNiPaid * defenceSpending;
            taxOutput.WelfareContribution    = totalTaxAndNiPaid * welfareSpending;
            taxOutput.ProtectionContribution = totalTaxAndNiPaid * protectionSpending;
            taxOutput.TransportContribution  = totalTaxAndNiPaid * transportSpending;
            taxOutput.GeneralContribution    = totalTaxAndNiPaid * generalSpending;
            taxOutput.OtherContribution      = totalTaxAndNiPaid * otherSpending;
            taxOutput.InterestContribution   = totalTaxAndNiPaid * interestSpending;

            //DrawCharts(taxOutput);
            //DrawTaxGraph(taxOutput);
            //DrawContributionsGraph(taxOutput);
            DrawBothCharts(taxOutput);
        }
    }
Пример #5
0
    void DrawCharts(TaxOutput taxOutput)
    {
        hldataSource.Visible = true;

        double totalTaxAndNiPaid = taxOutput.TaxBasicRate + taxOutput.TaxHigherRate
                                   + taxOutput.TaxAdditionalRate + taxOutput.NationalInsurance;

        double pensionsContribution   = totalTaxAndNiPaid * pensionsSpending;
        double healthContribution     = totalTaxAndNiPaid * healthSpending;
        double educationContribution  = totalTaxAndNiPaid * educationSpending;
        double defenceContribution    = totalTaxAndNiPaid * defenceSpending;
        double welfareContribution    = totalTaxAndNiPaid * welfareSpending;
        double protectionContribution = totalTaxAndNiPaid * protectionSpending;
        double transportContribution  = totalTaxAndNiPaid * transportSpending;
        double generalContribution    = totalTaxAndNiPaid * generalSpending;
        double otherContribution      = totalTaxAndNiPaid * otherSpending;
        double interestContribution   = totalTaxAndNiPaid * interestSpending;

        ClientScript.RegisterStartupScript(GetType(), "draw", "drawContributions('" + taxOutput.PersonalAllowance + "','"
                                           + taxOutput.TaxBasicRate + "','"
                                           + taxOutput.TaxHigherRate + "','"
                                           + taxOutput.TaxAdditionalRate + "','"
                                           + taxOutput.NationalInsurance + "','"
                                           + taxOutput.NetSalary + "','"
                                           + childcareVoucherAmount + "','"
                                           + studentLoanAnnualDeduction + "','"
                                           + pensionAnnualAmount + "','"
                                           + grossSalaryInput + "','"
                                           + pensionsContribution + "','"
                                           + healthContribution + "','"
                                           + educationContribution + "','"
                                           + defenceContribution + "','"
                                           + welfareContribution + "','"
                                           + protectionContribution + "','"
                                           + transportContribution + "','"
                                           + generalContribution + "','"
                                           + otherContribution + "','"
                                           + interestContribution + "','"
                                           + totalTaxAndNiPaid + "');", true);
    }
Пример #6
0
    void DrawBothCharts(TaxOutput taxOutput)
    {
        hldataSource.Visible = true;

        ClientScript.RegisterStartupScript(this.GetType(), "anything", "draw('" + taxOutput.NetSalary + "','"
                                           + taxOutput.TaxBasicRate + "','"
                                           + taxOutput.TaxHigherRate + "','"
                                           + taxOutput.TaxAdditionalRate + "','"
                                           + taxOutput.NationalInsurance + "','"
                                           + taxOutput.PensionAnnualAmount + "','"
                                           + taxOutput.ChildcareVoucherAmount + "','"
                                           + taxOutput.StudentLoanAnnualDeduction + "','"
                                           + taxOutput.PensionsContribution + "','"
                                           + taxOutput.HealthContribution + "','"
                                           + taxOutput.EducationContribution + "','"
                                           + taxOutput.DefenceContribution + "','"
                                           + taxOutput.WelfareContribution + "','"
                                           + taxOutput.ProtectionContribution + "','"
                                           + taxOutput.TransportContribution + "','"
                                           + taxOutput.GeneralContribution + "','"
                                           + taxOutput.OtherContribution + "','"
                                           + taxOutput.InterestContribution
                                           + "');", true);
    }