Beispiel #1
0
        public void TestHourlyUnionMemberServiceCharge()
        {
            var empId = 1;
            var addTx = new AddHourlyEmployee(empId, "Bill", "Home", 15.24M);

            addTx.Execute();
            int memberId = 7734;
            var memberTx = new ChangeMemberTransaction(empId, memberId, 9.42M);

            memberTx.Execute();
            var payDate         = new Date(11, 9, 2001);
            var serviceChargeTx = new ServiceChargeTransaction(memberId, payDate, 19.42M);

            serviceChargeTx.Execute();
            var timecardTx = new TimeCardTransaction(payDate, 8, empId);

            timecardTx.Execute();
            var payDayTx = new PaydayTransaction(payDate);

            payDayTx.Execute();
            var paycheck = payDayTx.GetPaycheck(empId);

            Assert.IsNotNull(paycheck, "No paycheck available");
            Assert.AreEqual(payDate, paycheck.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24M, paycheck.GrossPay);
            Assert.AreEqual("Hold", paycheck.GetField("Disposition"));
            Assert.AreEqual(9.42M + 19.42M, paycheck.Deductions);
            Assert.AreEqual((8 * 15.24M) - (9.42M + 19.42M), paycheck.NetPay);
        }
Beispiel #2
0
        public void TestAddServiceCharge()
        {
            int empId    = 2;
            int memberId = 7734;
            var addTx    = new AddHourlyEmployee(empId, "Bill", "Home", 15.25M);

            addTx.Execute();

            var employee = Database.GetEmployee(empId);

            var unionAffiliation = new UnionAffiliation(memberId, 12.5M);

            employee.Affiliation = unionAffiliation;

            Database.AddUnionMember(memberId, employee);

            var serviceChargeTransaction = new ServiceChargeTransaction(memberId, new Date(11, 01, 2001), 12.95M);

            serviceChargeTransaction.Execute();

            var serviceCharge = unionAffiliation.GetServiceCharge(new Date(11, 01, 2001));

            Assert.IsNotNull(serviceCharge);
            Assert.AreEqual(12.95M, serviceCharge.Amount);
        }
Beispiel #3
0
        public void TestHourlyUnionMemberServiceCharge()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Kubing", "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.PayPeriodEnd);
            Assert.AreEqual(8 * 15.24, pc.GrossPay, 0.001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 + 19.42, pc.Deductions, 0.001);
            Assert.AreEqual((8 * 15.24) - (9.42 + 19.42), pc.NetPay, 0.001);
        }
        public void TestAddServiceCharge()
        {
            #region Arrange
            int employeeId          = 9;
            AddSalariedEmployee asd = new AddSalariedEmployee(employeeId, "user", "home", 1000.0);
            asd.Execute();
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            UnionAffiliation af = new UnionAffiliation();
            e.Affiliation = af;
            int memberId = 886;
            PayrollRepository.AddUnionMember(memberId, e);

            ServiceChargeTransaction sct = new ServiceChargeTransaction(
                memberId, new DateTime(2019, 10, 10), 10.0);
            #endregion

            #region Action
            sct.Execute();
            #endregion

            #region Assert
            ServiceCharge sc = af.GetServiceCharge(new DateTime(2019, 10, 10));
            sc.Should().NotBeNull();
            sc.Date.Should().Be(new DateTime(2019, 10, 10));
            sc.Amount.Should().Be(10.0);
            #endregion
        }
Beispiel #5
0
        public void AddServiceChargeTests()
        {
            int empId           = 2;
            var name            = "Bartosz";
            var hourlyRate      = 15.25;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

            t.Execute();
            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            var memberId        = 86;
            var dues            = 88.12;
            UnionAffiliation af = new UnionAffiliation(memberId, dues);

            e.Affiliation = af;
            var date   = new DateTime(2005, 8, 8);
            var charge = 12.95;

            PayrollDatabase.AddUnionMember(memberId, e);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, charge);

            sct.Execute();
            ServiceCharge sc = af.GetServiceCharge(date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(charge, sc.Amount, .001);
        }
Beispiel #6
0
        public void AddServiceCharge()
        {
            int empId = SetupHourlyEmployee();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            const int memberId = 86; // Maxwell Smart
            var       af       = new UnionAffiliation(memberId, 12.95);

            e.Affiliation = af;
            PayrollDatabase.AddUnionMember(memberId, e);

            var sct = new ServiceChargeTransaction(memberId,
                                                   new DateTime(2005, 8, 8),
                                                   12.95);

            sct.Execute();

            ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.NotNull(sc);
            Assert.Equal(12.95, sc.Amount);
        }
Beispiel #7
0
        public void AddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

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

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

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

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

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

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, .001);
        }
Beispiel #8
0
        public void HourlyUnionMemberServiceCharge()
        {
            int empid           = 31;
            AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bill", "Home", 15.24);

            t.Execute();
            int memberId = 7664;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empid, memberId, 9.42);

            cmt.Execute();
            DateTime payDate             = new DateTime(2015, 11, 27);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, payDate, 19.42);

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

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

            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);
        }
Beispiel #9
0
        public void HourlyUnionMemberServiceCharge()
        {
            int       empId    = SetupHourlyEmployee();
            const int memberId = 7734;
            var       cmt      = new ChangeMemberTransaction(empId, memberId, 9.42);

            cmt.Execute();

            var payDate = new DateTime(2001, 11, 9);
            var sct     = new ServiceChargeTransaction(memberId, payDate, 19.42);

            sct.Execute();

            var tct = new TimeCardTransaction(payDate, 8.0, empId);

            tct.Execute();

            var pt = new PaydayTransaction(payDate);

            pt.Execute();

            Paycheck pc = PaydayTransaction.GetPaycheck(empId);

            Assert.NotNull(pc);
            Assert.Equal(payDate, pc.PayPeriodEndDate);
            Assert.Equal(8 * 15.25, pc.GrossPay);
            Assert.Equal("Hold", pc.GetField("Disposition"));
            Assert.Equal(9.42 + 19.42, pc.Deductions);
            Assert.Equal((8 * 15.25) - (9.42 + 19.42), pc.NetPay);
        }
Beispiel #10
0
        public void ExecuteTest_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, 19.42, payDate, database);

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

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

            pt.Execute();

            ValidatePaycheck(pt, empId, payDate, 8 * 15.24, 9.42 + 19.42);
        }
Beispiel #11
0
        public void TestAddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Kubing", "Home", 15.25, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            int memberId = 86;

            database.AddUnionMember(memberId, e);

            UnionAffiliation ua = new UnionAffiliation(memberId, 99.52);

            e.Affiliation = ua;

            var date = new DateTime(2005, 8, 8);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database);

            sct.Execute();

            var           serviceCharges = database.GetServiceCharges(memberId);
            ServiceCharge sc             = serviceCharges.FirstOrDefault(x => x.Date == date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, 0.001);
        }
        public void UnionMemberWithTwoServiceCharge()
        {
            database.AddEmployee(employee);

            int memberId = 7783;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employee.EmpId, memberId, 99.42, database);

            cmt.Execute();

            var date = new DateTime(2005, 8, 8);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database);

            sct.Execute();

            var date2 = new DateTime(2005, 8, 15);
            ServiceChargeTransaction sct2 = new ServiceChargeTransaction(memberId, date2, 4.52, database);

            sct2.Execute();

            var serviceCharges = database.GetServiceCharges(memberId);

            Assert.AreEqual(2, serviceCharges.Count);

            ServiceCharge sc1 = serviceCharges[0];

            Assert.IsNotNull(sc1);
            Assert.AreEqual(12.95, sc1.Amount, 0.001);

            ServiceCharge sc2 = serviceCharges[1];

            Assert.IsNotNull(sc2);
            Assert.AreEqual(4.52, sc2.Amount, 0.001);
        }
Beispiel #13
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);
        }
        public void GivenNotExistingMemberId_WhenExecuteServiceCharge_ThenThrowInvalidOperaionException()
        {
            #region Arrange
            int memberId = 881;

            ServiceChargeTransaction sct = new ServiceChargeTransaction(
                memberId, new DateTime(2019, 10, 10), 10.0);
            #endregion

            #region Action
            Exception ex = Assert.Catch <Exception>(() => sct.Execute());
            #endregion

            #region Assert
            ex.Should().BeOfType <InvalidOperationException>();
            ex.Message.Should().Contain("No such union member.");
            #endregion
        }
        public void UnionMemberWithOneServiceCharge()
        {
            database.AddEmployee(employee);

            int memberId = 7783;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employee.EmpId, memberId, 99.42, database);

            cmt.Execute();

            var date = new DateTime(2005, 8, 8);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database);

            sct.Execute();

            var           serviceCharges = database.GetServiceCharges(memberId);
            ServiceCharge sc             = serviceCharges.FirstOrDefault(x => x.Date == date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, 0.001);
        }
Beispiel #16
0
        public void TestServiceChargesSpanningMultiplePayPeriods()
        {
            var empId = 1;
            var addTx = new AddHourlyEmployee(empId, "Bill", "Home", 15.24M);

            addTx.Execute();
            int memberId = 7734;
            var memberTx = new ChangeMemberTransaction(empId, memberId, 9.42M);

            memberTx.Execute();
            var earlyDate = new Date(11, 2, 2001);  //previous friday
            var payDate   = new Date(11, 9, 2001);
            var lateDate  = new Date(11, 16, 2001); //this friday

            var serviceChargeTx1 = new ServiceChargeTransaction(memberId, payDate, 19.42M);

            serviceChargeTx1.Execute();
            var serviceChargeTx2 = new ServiceChargeTransaction(memberId, earlyDate, 100M);

            serviceChargeTx2.Execute();
            var serviceChargeTx3 = new ServiceChargeTransaction(memberId, lateDate, 200M);

            serviceChargeTx3.Execute();

            var timecardTx = new TimeCardTransaction(payDate, 8, empId);

            timecardTx.Execute();

            var payDayTx = new PaydayTransaction(payDate);

            payDayTx.Execute();
            var paycheck = payDayTx.GetPaycheck(empId);

            Assert.IsNotNull(paycheck, "No paycheck available");
            Assert.AreEqual(payDate, paycheck.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24M, paycheck.GrossPay);
            Assert.AreEqual("Hold", paycheck.GetField("Disposition"));
            Assert.AreEqual(9.42M + 19.42M, paycheck.Deductions, "Deductions are incorrect");
            Assert.AreEqual((8 * 15.24M) - (9.42M + 19.42M), paycheck.NetPay);
        }
Beispiel #17
0
        public void ExecuteTest_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, 19.42, payDate, database);

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

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

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

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

            pt.Execute();

            ValidatePaycheck(pt, empId, payDate, 8 * 15.24, 9.42 + 19.42);
        }
Beispiel #18
0
        public void ServiceChargesSpanningMultiplePayPeriods()
        {
            int       empId    = SetupHourlyEmployee();
            const int memberId = 7734;
            var       cmt      = new ChangeMemberTransaction(empId, memberId, 9.42);

            cmt.Execute();

            var payDate   = new DateTime(2001, 11, 9);
            var earlyDate = new DateTime(2001, 11, 2);  // previous Friday
            var lateDate  = new DateTime(2001, 11, 16); // next Friday

            var sct = new ServiceChargeTransaction(memberId, payDate, 19.42);

            sct.Execute();
            var sctEarly = new ServiceChargeTransaction(memberId, earlyDate, 100.0);

            sctEarly.Execute();
            var sctLate = new ServiceChargeTransaction(memberId, lateDate, 200.0);

            sctLate.Execute();

            var tct = new TimeCardTransaction(payDate, 8.0, empId);

            tct.Execute();
            var pt = new PaydayTransaction(payDate);

            pt.Execute();

            Paycheck pc = PaydayTransaction.GetPaycheck(empId);

            Assert.NotNull(pc);
            Assert.Equal(payDate, pc.PayPeriodEndDate);
            Assert.Equal(8 * 15.25, pc.GrossPay);
            Assert.Equal("Hold", pc.GetField("Disposition"));
            Assert.Equal(9.42 + 19.42, pc.Deductions);
            Assert.Equal((8 * 15.25) - (9.42 + 19.42), pc.NetPay);
        }
Beispiel #19
0
        public void AddserviceCharge()
        {
            int empid           = 8;
            AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 23.41);

            t.Execute();
            Employee e = PayrollDatabase.GetEmployee_Static(empid);

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

            e.Affiliation = af;
            int memberId = 86;

            PayrollDatabase.AddUnionMember_Static(memberId, e);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, new DateTime(2015, 11, 8), 12.95);

            sct.Execute();
            ServiceCharge sc = af.GetServiceCharge(new DateTime(2015, 11, 8));

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Charge, .001);
        }
Beispiel #20
0
        public void ServiceChargesSpanningmultiplePayPeriods()
        {
            int empid           = 32;
            AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 15.24);

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

            cmt.Execute();
            DateTime payDate             = new DateTime(2015, 12, 11);
            DateTime earlyDate           = new DateTime(2015, 12, 4);
            DateTime lateDate            = new DateTime(2015, 12, 18);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, payDate, 19.42);

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

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

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

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

            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 ExecuteTest()
        {
            int    empId     = 15;
            int    memberId  = 86;
            double unionDues = 90.8;

            double   chargeAmount = 12;
            DateTime chargeDate   = new DateTime(2014, 6, 7);

            //增加并获取雇员
            AddCommissionedEmployee addComEmp = new AddCommissionedEmployee(empId, "Muma", "shanghai", 12.3, 1.56, database);

            addComEmp.Execute();
            Employee emp = database.GetEmployee(empId);

            Assert.IsNotNull(emp);

            //设置并保存公会会员
            Affiliation unionAffiliation = new UnionAffiliation(memberId, unionDues);

            emp.Affiliation = unionAffiliation;
            database.AddUnionMember(memberId, emp);

            //将会费信息添加到会员上
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, chargeAmount, chargeDate, database);

            sct.Execute();

            //检查会费
            UnionAffiliation ua = emp.Affiliation as UnionAffiliation;

            Assert.IsNotNull(ua);
            ServiceCharge sc = ua.GetServiceCharge(chargeDate);

            Assert.IsNotNull(sc);
            Assert.AreEqual(sc.Amount, chargeAmount, 0.001);
        }
 public void TestAddServiceCharge()
 {
     int empId = 7;
     AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
     t.Execute();
     Employee e = PayrollDatabase.GetEmployee(empId);
     Assert.IsNotNull(e);
     UnionAffiliation af = new UnionAffiliation();
     e.Affiliation = af;
     int memberId = 86;
     PayrollDatabase.AddUnionMember(86, e);
     ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, new DateTime(2015, 11, 8), 12.95);
     sct.Execute();
     ServiceCharge sc = af.GerServiceCharge(new DateTime(2015, 11, 8));
     Assert.IsNotNull(sc);
     Assert.AreEqual(12.95, sc.Charge, .001);
 }