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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }