Ejemplo n.º 1
0
        public void TestHourlyUnionMemberServiceCharge()
        {
            int empId = 12;
            var t     = new AddHourlyEmployee(empId, "Bill", "Home", 15.24m);

            t.Execute();

            int memberId = 1337;
            var cmt      = new ChangeMemberTransaction(empId, memberId, 9.42m);

            cmt.Execute();
            DateTime payDate             = new DateTime(2020, 03, 20);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, payDate, 19.42m);

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

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

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

            ValidatePaycheck(pt, empId, payDate, 8 * 15.24m, 9.42m + 19.42m);
        }
Ejemplo n.º 2
0
        public void TestServiceChargesSpanningMultiplePayPeriods()
        {
            int empId = 1;
            var t     = new AddHourlyEmployee(empId, "Bill", "Home", 15.23m);

            t.Execute();

            int memberId = 1234;
            var cmt      = new ChangeMemberTransaction(empId, memberId, 9.42m);

            cmt.Execute();

            var payDate   = new DateTime(2020, 03, 20);
            var earlyDate = new DateTime(2020, 03, 13);
            var lateDate  = new DateTime(2020, 03, 27);

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

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

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

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

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

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 8 * 15.23m, 9.42m + 19.42m);
        }
Ejemplo n.º 3
0
        public void TestChangeNoAffiliation()
        {
            int empId           = 8;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Lance", "Home", 13.37m);

            t.Execute();
            int memberId = 7742;
            ChangeAffiliationTransaction cat = new ChangeMemberTransaction(empId, memberId, 99.42m);

            cat.Execute();
            ChangeAffiliationTransaction cuat = new ChangeUnaffiliatedTransaction(empId);

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

            Assert.That(e, Is.Not.Null);
            Affiliation affiliation = e.Affiliation;

            Assert.That(affiliation, Is.Not.Null);
            Assert.That(affiliation is NoAffiliation);
            NoAffiliation na     = affiliation as NoAffiliation;
            Employee      member = PayrollDatabase.GetUnionMember(memberId);

            Assert.That(member, Is.Null);
        }
Ejemplo n.º 4
0
        public void TestAddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.75m);

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

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

            UnionAffiliation ua = new UnionAffiliation();

            e.Affiliation = ua;
            int memberId = 86;

            PayrollDatabase.AddUnionMember(memberId, empId);

            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, new DateTime(2020, 02, 02), 12.95m);

            sct.Execute();
            ServiceCharge sc = ua.GetServiceCharge(new DateTime(2020, 02, 02));

            Assert.That(sc, Is.Not.Null);
            Assert.That(sc.Amount, Is.EqualTo(12.95m));
        }
Ejemplo n.º 5
0
        public void TestPaySingleHourlyEmployeeNoTimeCards()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25m);

            t.Execute();
            DateTime          payDate = new DateTime(2020, 2, 7);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 0.0m);
        }
Ejemplo n.º 6
0
        public void TestChangeNameTransaction()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bob", "Home", 12.99m);

            t.Execute();
            ChangeEmployeeTransaction cnt = new ChangeNameTransaction(empId, "Bill");

            cnt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.That(e, Is.Not.Null);
            Assert.That(e.Name, Is.EqualTo("Bill"));
        }
Ejemplo n.º 7
0
        public void TestPaySingleHourlyEmployeeOvertimeOneTimeCard()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "home", 15.25m);

            t.Execute();
            DateTime payDate = new DateTime(2020, 2, 7);

            TimeCardTransaction tct = new TimeCardTransaction(payDate, 9.0, empId);

            tct.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, (8m + 1.5m) * 15.25m);
        }
Ejemplo n.º 8
0
        public void TestPaySingleHourlyEmployeeTwoTimeCards()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "home", 15.25m);

            t.Execute();
            DateTime payDate = new DateTime(2020, 2, 7);

            TimeCardTransaction tct = new TimeCardTransaction(payDate, 2.0, empId);

            tct.Execute();
            TimeCardTransaction tct2 = new TimeCardTransaction(payDate.AddDays(-5), 5.0, empId);

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

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 7m * 15.25m);
        }
Ejemplo n.º 9
0
        public void TestPaySingleHourlyEmployeeOnWrongDate()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "home", 15.25m);

            t.Execute();
            DateTime payDate = new DateTime(2020, 2, 6);

            TimeCardTransaction tct = new TimeCardTransaction(payDate, 2.0, empId);

            tct.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

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

            Assert.That(pc, Is.Null);
        }
Ejemplo n.º 10
0
        public void TestHourlyUnionMemberDues()
        {
            int empId = 1;
            var t     = new AddHourlyEmployee(empId, "Bob", "Home", 12.0m);

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

            cmt.Execute();

            DateTime payDate = new DateTime(2020, 01, 24);
            var      pt      = new PaydayTransaction(payDate);

            pt.Execute();

            //1 Friday
            var unionDues = 9.42m;

            ValidatePaycheck(pt, empId, payDate, 0m, unionDues);
        }
Ejemplo n.º 11
0
        public void TestPaySingleHourlyEmployeeWithTimeCardSpanningTwoPayPeriods()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "home", 15.25m);

            t.Execute();
            DateTime payDate = new DateTime(2020, 2, 7);
            DateTime dateInPreviousPeriod = payDate.AddDays(-7);

            TimeCardTransaction tct = new TimeCardTransaction(payDate, 2.0, empId);

            tct.Execute();
            TimeCardTransaction tct2 = new TimeCardTransaction(dateInPreviousPeriod, 10.0, empId);

            tct2.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 30.5m);
        }
Ejemplo n.º 12
0
        public void TestAddHourlyEmployee()
        {
            int empId = 2;
            AddEmployeeTransaction t = new AddHourlyEmployee(empId, "Bob", "Home", 12.75m);

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

            Assert.That(e.Name, Is.EqualTo("Bob"));

            PaymentClassification pc = e.Classification;

            Assert.That(pc is HourlyClassification, Is.True);
            HourlyClassification hc = pc as HourlyClassification;

            Assert.That(hc.HourlyRate, Is.EqualTo(12.75m));
            PaymentSchedule ps = e.Schedule;

            Assert.That(ps is WeeklySchedule, Is.True);

            PaymentMethod pm = e.Method;

            Assert.That(pm is HoldMethod, Is.True);
        }
Ejemplo n.º 13
0
        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));
        }