Beispiel #1
0
        public Payslip GeneratePaySlip(double anuualSalaray, double superRate)
        {
            TaxRates taxRates = GetTaxRates(anuualSalaray);
            Payslip  payslip  = new Payslip();

            payslip.grossMonthly = Math.Round((float)anuualSalaray / 12f, MidpointRounding.AwayFromZero);
            payslip.incomeTax    = Math.Round((taxRates.baseRate + ((anuualSalaray - taxRates.lower - 1) * taxRates.additional)) / 12, MidpointRounding.AwayFromZero);
            payslip.netMonthly   = payslip.grossMonthly - payslip.incomeTax;
            payslip.superRate    = Math.Round(payslip.grossMonthly * superRate / 100, MidpointRounding.AwayFromZero);

            return(payslip);
        }
Beispiel #2
0
 private TaxRates GetTaxRates(double annualSalary)
 {
     String sqlCommand = "select * from Tax where Lower <= " + annualSalary + " and Upper >= " + annualSalary;
     SQLiteCommand command = new SQLiteCommand(sqlCommand, m_connection);
     SQLiteDataReader reader = command.ExecuteReader();
     //assuming only one row is retrieved
     TaxRates taxRate = new TaxRates();
     try
     {
         reader.Read();
         taxRate.lower = Convert.ToInt32(reader["Lower"]);
         taxRate.upper = Convert.ToInt32(reader["Upper"]);
         taxRate.baseRate = Convert.ToInt32(reader["Base"]);
         taxRate.additional = Convert.ToSingle(reader["Additional"]);
     }
     catch(Exception ex)
     { 
       return taxRate; //will return empty tax rate in case of database error
     }
     return taxRate;
 }
Beispiel #3
0
        private TaxRates GetTaxRates(double annualSalary)
        {
            String           sqlCommand = "select * from Tax where Lower <= " + annualSalary + " and Upper >= " + annualSalary;
            SQLiteCommand    command    = new SQLiteCommand(sqlCommand, m_connection);
            SQLiteDataReader reader     = command.ExecuteReader();
            //assuming only one row is retrieved
            TaxRates taxRate = new TaxRates();

            try
            {
                reader.Read();
                taxRate.lower      = Convert.ToInt32(reader["Lower"]);
                taxRate.upper      = Convert.ToInt32(reader["Upper"]);
                taxRate.baseRate   = Convert.ToInt32(reader["Base"]);
                taxRate.additional = Convert.ToSingle(reader["Additional"]);
            }
            catch (Exception ex)
            {
                return(taxRate); //will return empty tax rate in case of database error
            }
            return(taxRate);
        }