예제 #1
0
        public void SalariedUnionMemberDues()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(
                empId, "Bob", "Home", 1000.00, database);

            t.Execute();
            int memberId = 7734;
            ChangeMemberTransaction cmt =
                new ChangeMemberTransaction(empId, memberId, 9.42, database);

            cmt.Execute();
            DateTime          payDate = new DateTime(2001, 11, 30);
            PaydayTransaction pt      = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayDate);
            Assert.AreEqual(1000.0, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(47.1, pc.Deductions, .001);
            Assert.AreEqual(1000.0 - 47.1, pc.NetPay, .001);
        }
예제 #2
0
        public void HourlyUnionMemberServiceCharge()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.24, database);

            t.Execute();
            int memberId = 7734;
            ChangeMemberTransaction cmt =
                new ChangeMemberTransaction(empId, memberId, 9.42, database);

            cmt.Execute();
            DateTime payDate             = new DateTime(2001, 11, 9);
            ServiceChargeTransaction sct =
                new ServiceChargeTransaction(memberId, payDate, 19.42, database);

            sct.Execute();
            TimeCardTransaction tct =
                new TimeCardTransaction(payDate, 8.0, empId, database);

            tct.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 + 19.42, pc.Deductions, .001);
            Assert.AreEqual((8 * 15.24) - (9.42 + 19.42), pc.NetPay, .001);
        }
예제 #3
0
        protected static bool IsInPayPeriod(DateTime theDate, Paycheck paycheck)
        {
            DateTime payPeriodEndDate   = paycheck.PayPeriodEndDate;
            DateTime payPeriodStartDate = paycheck.PayPeriodStartDate;

            return(DateUtil.IsInPayPeriod(theDate, payPeriodStartDate, payPeriodEndDate));
        }
예제 #4
0
        public double CalculateDeduction(Paycheck paycheck)
        {
            int fridays = NumberOfFridaysInPayPeriod(paycheck.PayPeriodStartDate,
                                                     paycheck.PayPeriodEndDate);
            double totalDues = Dues * fridays;

            double serviceCharge = ServiceChargeForPeriod(paycheck.PayPeriodStartDate,
                                                          paycheck.PayPeriodEndDate);

            return(totalDues + serviceCharge);
        }
예제 #5
0
        public void Payday(Paycheck paycheck)
        {
            double grossPay   = Classification.CalculatePay(paycheck);
            double deductions = Affiliation.CalculateDeduction(paycheck);
            double netPay     = grossPay - deductions;

            paycheck.GrossPay   = grossPay;
            paycheck.Deductions = deductions;
            paycheck.NetPay     = netPay;
            Method.Pay(paycheck);
        }
예제 #6
0
        public void Payday(Paycheck paycheck)
        {
            double grossPay   = classification.CalculatePay(paycheck);
            double deductions = affiliation.CalculateDeductions(paycheck);
            double netPay     = grossPay - deductions;

            paycheck.GrossPay   = grossPay;
            paycheck.Deductions = deductions;
            paycheck.NetPay     = netPay;
            method.Pay(paycheck);
            lastPaycheck = paycheck;
        }
예제 #7
0
        private void ValidatePaycheck(PaydayTransaction pt,
                                      int empid, DateTime payDate, double pay)
        {
            Paycheck pc = pt.GetPaycheck(empid);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayDate);
            Assert.AreEqual(pay, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(0.0, pc.Deductions, .001);
            Assert.AreEqual(pay, pc.NetPay, .001);
        }
예제 #8
0
 public override void Execute()
 {
     foreach (Employee employee in database.GetAllEmployees())
     {
         if (employee.IsPayDate(payDate))
         {
             DateTime startDate = employee.GetPayPeriodStartDate(payDate);
             Paycheck pc        = new Paycheck(startDate, payDate);
             paychecks[employee.Id] = pc;
             employee.Payday(pc);
         }
     }
 }
예제 #9
0
        public double CalculatePay(Paycheck pc)
        {
            double pay = 0;

            foreach (TimeCard card in timeCards.Values)
            {
                if (DateUtil.IsInPayPeriod(card.Date, pc.PayPeriodStartDate, pc.PayPeriodEndDate))
                {
                    pay += CalculatePayForTimeCard(card);
                }
            }

            return(pay);
        }
예제 #10
0
        public double CalculatePay(Paycheck pc)
        {
            double pay = salary;

            foreach (SalesReceipt sr in salesReceipts.Values)
            {
                if (DateUtil.IsInPayPeriod(sr.Date, pc.PayPeriodStartDate, pc.PayPeriodEndDate))
                {
                    pay += sr.Amount * (commission / 100);
                }
            }

            return(pay);
        }
        public override double CalculatePay(Paycheck paycheck)
        {
            double salesTotal = 0;

            foreach (SalesReceipt receipt in salesReceipts.Values)
            {
                if (DateUtil.IsInPayPeriod(receipt.Date,
                                           paycheck.PayPeriodStartDate,
                                           paycheck.PayPeriodEndDate))
                {
                    salesTotal += receipt.SaleAmount;
                }
            }
            return(baseRate + (salesTotal * commissionRate * 0.01));
        }
예제 #12
0
        public override double CalculatePay(Paycheck paycheck)
        {
            double totalPay = 0.0;

            foreach (TimeCard timeCard in timeCards.Values)
            {
                if (DateUtil.IsInPayPeriod(timeCard.Date,
                                           paycheck.PayPeriodStartDate,
                                           paycheck.PayPeriodEndDate))
                {
                    totalPay += CalculatePayForTimeCard(timeCard);
                }
            }
            return(totalPay);
        }
예제 #13
0
        public void PaySingleSalariedEmployeeOnWrongDate()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(
                empId, "Bob", "Home", 1000.00, database);

            t.Execute();
            DateTime          payDate = new DateTime(2001, 11, 29);
            PaydayTransaction pt      = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNull(pc);
        }
예제 #14
0
        public double CalculateDeductions(Paycheck paycheck)
        {
            double charges = 0;

            foreach (ServiceCharge sc in serviceCharges.Values)
            {
                if (DateUtil.IsInPayPeriod(sc.Time, paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate))
                {
                    charges += sc.Amount;
                }
            }

            int fridays = NumberOfFridaysInPayPeriod(paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate);

            return(dues * fridays + charges);
        }
예제 #15
0
        public override void Execute()
        {
            ArrayList empIds = database.GetAllEmployeeIds();

            foreach (int empId in empIds)
            {
                Employee employee = database.GetEmployee(empId);
                if (employee.IsPayDate(payDate))
                {
                    DateTime startDate =
                        employee.GetPayPeriodStartDate(payDate);
                    Paycheck pc = new Paycheck(startDate, payDate);
                    paychecks[empId] = pc;
                    employee.Payday(pc);
                }
            }
        }
예제 #16
0
        public void ServiceChargesSpanningMultiplePayPeriods()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.24, database);

            t.Execute();
            int memberId = 7734;
            ChangeMemberTransaction cmt =
                new ChangeMemberTransaction(empId, memberId, 9.42, database);

            cmt.Execute();
            DateTime payDate   = new DateTime(2001, 11, 9);
            DateTime earlyDate =
                new DateTime(2001, 11, 2);                 // previous Friday
            DateTime lateDate =
                new DateTime(2001, 11, 16);                // next Friday
            ServiceChargeTransaction sct =
                new ServiceChargeTransaction(memberId, payDate, 19.42, database);

            sct.Execute();
            ServiceChargeTransaction sctEarly =
                new ServiceChargeTransaction(memberId, earlyDate, 100.00, database);

            sctEarly.Execute();
            ServiceChargeTransaction sctLate =
                new ServiceChargeTransaction(memberId, lateDate, 200.00, database);

            sctLate.Execute();
            TimeCardTransaction tct =
                new TimeCardTransaction(payDate, 8.0, empId, database);

            tct.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 + 19.42, pc.Deductions, .001);
            Assert.AreEqual((8 * 15.24) - (9.42 + 19.42), pc.NetPay, .001);
        }
예제 #17
0
        public void Execute()
        {
            var empIds = PayrollDatabase.GetAllEmployeeIds();

            foreach (int empId in empIds)
            {
                Employee employee = PayrollDatabase.GetEmployee(empId);
                if (!employee.IsPayDate(payDate))
                {
                    continue;
                }

                DateTime startDate = employee.GetPayPeriodStartDate(payDate);
                Paycheck pc        = new Paycheck(startDate, payDate);
                Paychecks[empId] = pc;
                employee.Payday(pc);
            }
        }
예제 #18
0
        public void PaySingleSalariedEmployee()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(
                empId, "Bob", "Home", 1000.00, database);

            t.Execute();
            DateTime          payDate = new DateTime(2001, 11, 30);
            PaydayTransaction pt      = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayDate);
            Assert.AreEqual(1000.00, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(0.0, pc.Deductions, .001);
            Assert.AreEqual(1000.00, pc.NetPay, .001);
        }
예제 #19
0
        public double CalculateDeductions(Paycheck paycheck)
        {
            double totalDues = 0;

            int fridays = NumberOfFridaysInPayPeriod(
                paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate);

            totalDues = dues * fridays;

            foreach (ServiceCharge charge in charges.Values)
            {
                if (DateUtil.IsInPayPeriod(charge.Time,
                                           paycheck.PayPeriodStartDate,
                                           paycheck.PayPeriodEndDate))
                {
                    totalDues += charge.Amount;
                }
            }

            return(totalDues);
        }
예제 #20
0
        public void PaySingleCommissionedEmployeeOnWrongDate()
        {
            int empId = 2;
            AddCommissionedEmployee t = new AddCommissionedEmployee(
                empId, "Bill", "Home", 1500, 10, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);             // wrong friday

            SalesReceiptTransaction sr =
                new SalesReceiptTransaction(payDate, 5000.00, empId, database);

            sr.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNull(pc);
        }
예제 #21
0
        public void PaySingleHourlyEmployeeOnWrongDate()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 8);             // Thursday

            TimeCardTransaction tc =
                new TimeCardTransaction(payDate, 9.0, empId, database);

            tc.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNull(pc);
        }
예제 #22
0
 public abstract double CalculatePay(Paycheck paycheck);
 public void Pay(Paycheck paycheck)
 {
     paycheck.SetField("Disposition", "Mail");
 }
예제 #24
0
 public override double CalculatePay(Paycheck paycheck)
 {
     return(salary);
 }
예제 #25
0
 public override double CalculatePay(Paycheck paycheck) =>
 salesReceipts.Values
 .Where(r => IsInPayPeriod(r.Date, paycheck))
 .Sum(r => r.Amount)
 * CommissionRate
 + Salary;
예제 #26
0
 public void Pay(Paycheck pc)
 {
     Console.WriteLine("Holding paycheck");
 }
 public void Pay(Paycheck paycheck)
 {
     paycheck.SetField("Disposition", "Mail");
 }
예제 #28
0
 public void Pay(Paycheck pc)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #29
0
 public double CalculateDeductions(Paycheck paycheck)
 {
     return(0);
 }
예제 #30
0
 public bool IsPayDate(DateTime payDate, Paycheck lastPaycheck)
 {
     return(IsLastDayOfMonth(payDate));
 }
예제 #31
0
 public bool IsPayDate(DateTime date, Paycheck lastPaycheck)
 {
     return(date.DayOfWeek == DayOfWeek.Friday);
 }