示例#1
0
        //TODO: Add unit tests
        internal static decimal CalculatePayPacket(decimal annualNetIncome, PayFrequency payFrequency)
        {
            const decimal numberOfWeeksInYear  = 52.1786m;
            const decimal numberOfMonthsInYear = 12;

            decimal pay = 0;

            switch (payFrequency)
            {
            case PayFrequency.Weekly:
                pay = annualNetIncome / numberOfWeeksInYear;
                break;

            case PayFrequency.Fortnightly:
                pay = annualNetIncome * 2 / numberOfWeeksInYear;
                break;

            case PayFrequency.Monthly:
                pay = annualNetIncome / numberOfMonthsInYear;
                break;

            default:
                throw new ArgumentException($"PayFrequency '{payFrequency}' is not an supported.");
            }

            return(Round(pay));
        }
示例#2
0
        public static async Task <List <Employee> > GetEmployeesPaidToday(PayFrequency payFrequency)
        {
            Employee e = new Employee()
            {
                Company = new Company(), BusinessUnit = new BusinessUnit()
            };

            e.InsertDocument();

            //Get all employees from DB
            List <Employee> employees = e.GetAllEmployees();

            employees.Remove(e);
            e.Delete();

            List <Employee> employeesPaidToday = new List <Employee>();

            if (payFrequency == PayFrequency.Weekly)
            {
                //Filter employees that get paid weekly on this day
                employeesPaidToday = employees.Where(x => x.PayFrequency == PayFrequency.Weekly).ToList();
                employeesPaidToday = employeesPaidToday.Where(x => x.PayDate == (int)DateTime.Now.DayOfWeek).ToList();
            }
            else if (payFrequency == PayFrequency.Monthly)
            {
                //Filter employees that get paid monthly on this day
                employeesPaidToday = employees.Where(x => x.PayFrequency == PayFrequency.Monthly).ToList();
                employeesPaidToday = employeesPaidToday.Where(x => x.PayDate == DateTime.Now.Day).ToList();
            }

            //Filter lists on who is getting paid today
            return(employeesPaidToday);
        }
示例#3
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (BusinessEntityId == default(int) ? 0 : BusinessEntityId.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (PayFrequency == default(byte) ? 0 : PayFrequency.GetHashCode());
         hash = hash * 23 + (Rate == default(decimal) ? 0 : Rate.GetHashCode());
         hash = hash * 23 + (RateChangeDate == default(DateTime) ? 0 : RateChangeDate.GetHashCode());
         return(hash);
     }
 }
示例#4
0
        public SalaryDetails Calculate(decimal grossPackage, PayFrequency payFrequency)
        {
            var sd = serviceContainer.GetInstance <SalaryDetails>();

            sd.GrossPackage = grossPackage;
            // gross package = taxable income + 9.5 of taxable income
            sd.TaxableIncome  = Round(grossPackage * 100 / (100 + GetSuperannuationPercentage()));
            sd.Superannuation = Round(grossPackage - sd.TaxableIncome);

            var deductions = sd.GetDeductions();

            sd.NetIncome = Round(grossPackage - sd.Superannuation - deductions);

            sd.Payfrequency = payFrequency;
            sd.PayPacket    = CalculatePayPacket(sd.NetIncome, payFrequency);
            return(sd);
        }
示例#5
0
 public PayCalculator(PayFrequency payFrequency)
 {
     _payFrequentcy = payFrequency;
 }
示例#6
0
 public PayCalculatorWrong(PayFrequency payFrequency)
 {
     _payFrequency = payFrequency;
 }
 public PayCalculator(PayFrequency payFrequency)
 {
     _payFrequency = payFrequency;
 }