Beispiel #1
0
        private decimal CalculatePayForTimeCard(TimeCard tc)
        {
            decimal overtimeHours = CalculateOvertimeHours(tc);
            decimal regularHours  = CalculateRegularHours(tc, overtimeHours);

            return((regularHours + 1.5m * overtimeHours) * HourlyRate);
        }
        public void TestTimeCardTransaction()
        {
            int empId           = 5;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25m);

            t.Execute();

            TimeCardTransaction tct = new TimeCardTransaction(new DateTime(2020, 02, 02), 8.0, empId);

            tct.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.That(e, Is.Not.Null);

            PaymentClassification pc = e.Classification;

            Assert.That(pc is HourlyClassification, Is.True);
            HourlyClassification hc = pc as HourlyClassification;
            TimeCard             tc = hc.GetTimeCard(new DateTime(2020, 02, 02));

            Assert.That(tc, Is.Not.Null);
            Assert.That(tc.Hours, Is.EqualTo(8.0));
        }
Beispiel #3
0
 private decimal CalculateRegularHours(TimeCard tc, decimal overtime)
 {
     return(Convert.ToDecimal(tc.Hours) - overtime);
 }
Beispiel #4
0
 private decimal CalculateOvertimeHours(TimeCard tc)
 {
     return(Convert.ToDecimal(Math.Max(0, tc.Hours - 8)));
 }
Beispiel #5
0
 public void AddTimeCard(TimeCard timeCard)
 {
     timeCards[timeCard.Date] = timeCard;
 }