Ejemplo n.º 1
0
        public void Execute()
        {
            Employee e = PayrollDatabase.GetEmployee(empId);

            if (e != null)
            {
                Change(e);
            }
            else
            {
                throw new InvalidOperationException("No such employee.");
            }
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            Employee e = PayrollDatabase.GetEmployee(empId);

            if (e == null)
            {
                return;
            }

            if (e.Classification is CommissionedClassification cc)
            {
                cc.AddSalesReceipt(new SalesReceipt(date, amount));
            }
            else
            {
                throw new InvalidOperationException("Tried to add sales receipt to non-commissioned employee");
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public void Execute()
        {
            Employee e = PayrollDatabase.GetEmployee(empId);

            if (e != null)
            {
                if (e.Classification is HourlyClassification hc)
                {
                    hc.AddTimeCard(new TimeCard(date, hours));
                }
                else
                {
                    throw new InvalidOperationException("Tried to add time card to non-hourly employee");
                }
            }
            else
            {
                throw new InvalidOperationException("No such employee.");
            }
        }
Ejemplo n.º 5
0
        public void TestAddSalariedEmployee()
        {
            int empId             = 1;
            AddSalariedEmployee t =
                new AddSalariedEmployee(empId, "Bob", "Home", 1000.00, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.AreEqual("Bob", e.Name);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is SalariedClassification);
            SalariedClassification sc = pc as SalariedClassification;

            Assert.AreEqual(1000.00, sc.Salary, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is MonthlySchedule);

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Ejemplo n.º 6
0
        public void AddServiceCharge()
        {
            var empId = 2;
            var t     = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            var e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            var af = new UnionAffiliation();

            e.Affiliation = af;
            var memberId = 86; // Maxwell Smart

            database.AddUnionMember(memberId, e);
            var sct =
                new ServiceChargeTransaction(
                    memberId, new DateTime(2005, 8, 8), 12.95, database);

            sct.Execute();
            var sc =
                af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, .001);
        }