Пример #1
0
        public void TestSalariedUnionMemberDues()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Kubing", "Home", 1000.0, 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.PayPeriodEnd);
            Assert.AreEqual(1000.0, pc.GrossPay, 0.001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 * 5, pc.Deductions, 0.001);
            Assert.AreEqual(1000.0 - 9.42 * 5, pc.NetPay, 0.001);
        }
Пример #2
0
        public void TestPaySingleCommissionedEmployeeWithTwoSales()
        {
            int empId = 1;

            var addTx = new AddCommissionedEmployee(empId, "Bob", "Home", 1000, 0.2M);

            addTx.Execute();

            var saleTx1 = new SalesReceiptTransaction(100, new Date(11, 9, 2001), empId);

            saleTx1.Execute();

            var saleTx2 = new SalesReceiptTransaction(500, new Date(11, 9, 2001), empId);

            saleTx2.Execute();

            var payDate  = new Date(11, 16, 2001);
            var paydayTx = new PaydayTransaction(payDate);

            paydayTx.Execute();

            var paycheck = paydayTx.GetPaycheck(empId);

            ValidateCommisionedPaycheck(paydayTx, empId, payDate, 1120M);
        }
Пример #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DateTime          startdate = Convert.ToDateTime(TextBox1.Text);
            DateTime          enddate   = Convert.ToDateTime(TextBox2.Text);
            int               id        = int.Parse(TextBox3.Text);
            PayrollDatabase   database  = new FunctionPayrollDatabase();
            Employee          ee        = database.GetEmployee(id);
            Paycheck          st        = new Paycheck(startdate, enddate);
            double            pay       = ee.Classification.CalculatePay(st);
            PaydayTransaction pt        = new PaydayTransaction(enddate, database);

            pt.Execute();
            Paycheck pc   = pt.GetPaycheck(id);
            DateTime date = Convert.ToDateTime(TextBox4.Text);

            if (pc != null && date >= enddate)
            {
                string payMethod = TextBox5.Text;
                database.pay(id, pay, date, payMethod);
                MessageBox.Show("共付 " + pay + " 元", "通知");
            }
            else
            {
                MessageBox.Show("未到支付日期");
            }
        }
Пример #4
0
        public void TestPayCommissionedEmployeeTwoSalesReceipts()
        {
            const int empId = 30;
            var       t     = new AddCommissionedEmployee(empId, "Bob", "Home", 2500.00, 3.2);

            t.Execute();
            var payDate = new DateTime(2020, 7, 17);
            var srt     = new SalesReceiptTransaction(payDate, 100.0, empId);

            srt.Execute();
            var srt2 = new SalesReceiptTransaction(payDate.AddDays(-1), 200.0, empId);

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

            pt.Execute();

            var pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayDate);
            Assert.AreEqual((100.0 + 200) * 3.2, pc.GrossPay, 0.001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(0.0, pc.Deductions, 0.001);
            Assert.AreEqual((100.0 + 200) * 3.2, pc.NetPay, 0.001);
        }
Пример #5
0
        public void TestPayCommissionedEmployeeNoSalesReceipts()
        {
            const int empId = 28;
            var       t     = new AddCommissionedEmployee(empId, "Bob", "Home", 2500.00, 3.2);

            t.Execute();

            var payDate = new DateTime(2020, 7, 17);
            var pt      = new PaydayTransaction(payDate);

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

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayDate);
            Assert.AreEqual(0.0, pc.GrossPay, 0.001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(0.0, pc.Deductions, 0.001);
            Assert.AreEqual(0.0, pc.NetPay, 0.001);

            var payDate2 = new DateTime(2020, 7, 31);
            var pt2      = new PaydayTransaction(payDate2);

            pt2.Execute();

            var pc2 = pt2.GetPaycheck(empId);

            Assert.IsNotNull(pc2);
            Assert.AreEqual(payDate2, pc2.PayDate);
            Assert.AreEqual(2500.0, pc2.GrossPay, 0.001);
            Assert.AreEqual("Hold", pc2.GetField("Disposition"));
            Assert.AreEqual(0.0, pc2.Deductions, 0.001);
            Assert.AreEqual(2500.0, pc2.NetPay, 0.001);
        }
Пример #6
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);
        }
        public void TestPaySingleCommisionedEmployeeWithSalesReceiptsSpanningTwoPayPeriods()
        {
            // Arrange
            var employeeId    = 1;
            var commisionRate = 0.25;
            var salary        = 2400;

            new AddCommisionedEmployeeTransaction(employeeId, "Adam", "Address", salary, commisionRate).Execute();

            var date        = DateTime.Parse("2018-02-4");
            var salesAmount = 200;

            new SalesReceiptTransaction(employeeId, date, salesAmount).Execute();

            var lastPayPeriodDate = date - TimeSpan.FromDays(14);
            var salesAmount1      = 150;

            new SalesReceiptTransaction(employeeId, lastPayPeriodDate, salesAmount1).Execute();

            var fridayDate        = DateTime.Parse("2018-02-9");
            var paydayTransaction = new PaydayTransaction(fridayDate);

            // Act
            paydayTransaction.Execute();
            var paycheck    = paydayTransaction.GetPaycheck(employeeId);
            var expectedPay = salary + salesAmount * commisionRate;

            // Assert
            Assert.IsNotNull(paycheck);
            Assert.AreEqual(fridayDate, paycheck.EndDate);
            Assert.AreEqual(expectedPay, paycheck.GrossPay);
            Assert.AreEqual(PaymentMethodType.Hold, paycheck.Disposition);
            Assert.AreEqual(0, paycheck.Deductions);
            Assert.AreEqual(expectedPay, paycheck.NetPay);
        }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
0
        public void TestHourlyUnionMemberServiceCharge()
        {
            const int empId = 26;
            var       t     = new AddHourlyEmployee(empId, "Bill", "Home", 15.24);

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

            cmt.Execute();
            var payDate = new DateTime(2020, 11, 6);
            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();

            var pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEndDate);
            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 TestPaySalariedUnionMemberDues()
        {
            // Arrange
            var employeeId = 1;
            var salary     = 2400;

            new AddSalariedEmployeeTransaction(employeeId, "Adam", "Address", salary).Execute();

            var commisionRate = 9.25;
            var unionMemberId = 22;

            new ChangeEmployeeUnionAffiliationTransaction(employeeId, unionMemberId, commisionRate).Execute();

            var fridayDate        = new DateTime(2011, 1, 31);
            var paydayTransaction = new PaydayTransaction(fridayDate);

            // Act
            paydayTransaction.Execute();
            var paycheck           = paydayTransaction.GetPaycheck(employeeId);
            var expectedDeductions = 4 * commisionRate;

            // Assert
            Assert.IsNotNull(paycheck);
            Assert.AreEqual(fridayDate, paycheck.EndDate);
            Assert.AreEqual(salary, paycheck.GrossPay);
            Assert.AreEqual(PaymentMethodType.Hold, paycheck.Disposition);
            Assert.AreEqual(expectedDeductions, paycheck.Deductions);
            Assert.AreEqual(salary - expectedDeductions, paycheck.NetPay);
        }
        public void TestPaySingleHourlyEmployeeWithTwoTimeCards()
        {
            // Arrange
            var employeeId = 1;
            var hourlyRate = 15.25;

            new AddHourlyEmployeeTransaction(employeeId, "Adam", "Address", hourlyRate).Execute();

            var fridayDate = DateTime.Parse("2018-02-16");
            var hours1     = 5;
            var hours2     = 2;

            new TimeCardTransaction(employeeId, fridayDate, hours1).Execute();
            new TimeCardTransaction(employeeId, fridayDate.Subtract(TimeSpan.FromDays(2)), hours2).Execute();
            var paydayTransaction = new PaydayTransaction(fridayDate);

            // Act
            paydayTransaction.Execute();
            var paycheck    = paydayTransaction.GetPaycheck(employeeId);
            var expectedPay = (hours1 + hours2) * hourlyRate;

            // Assert
            Assert.IsNotNull(paycheck);
            Assert.AreEqual(fridayDate, paycheck.EndDate);
            Assert.AreEqual(expectedPay, paycheck.GrossPay);
            Assert.AreEqual(PaymentMethodType.Hold, paycheck.Disposition);
            Assert.AreEqual(0, paycheck.Deductions);
            Assert.AreEqual(expectedPay, paycheck.NetPay);
        }
        private void ValidateHourlyPaycheck(PaydayTransaction pt, int empid, DateTime payDate, double pay)
        {
            Paycheck pc = pt.GetPaycheck(empid, payDate);

            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);
        }
Пример #15
0
        private static void ValidateNoDeductionPaycheck(int empId, DateTime payDate, double pay)
        {
            Paycheck pc = PaydayTransaction.GetPaycheck(empId);

            Assert.NotNull(pc);
            Assert.Equal(payDate, pc.PayPeriodEndDate);
            Assert.Equal(pay, pc.GrossPay);
            Assert.Equal("Hold", pc.GetField("Disposition"));
            Assert.Equal(0.0, pc.Deductions);
            Assert.Equal(pay, pc.NetPay);
        }
Пример #16
0
        private void ValidateCommissionedPaycheck(PaydayTransaction pt, int empId, DateTime payDate, double pay)
        {
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEnd);
            Assert.AreEqual(pay, pc.GrossPay, 0.01);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(0.0, pc.Deductions, 0.01);
            Assert.AreEqual(pay, pc.NetPay, 0.01);
        }
Пример #17
0
        private void ValidateHourlyPaycheck(PaydayTransaction paydayTx, int empId, Date payDate, decimal pay)
        {
            var paycheck = paydayTx.GetPaycheck(empId);

            Assert.IsNotNull(paycheck);
            Assert.AreEqual(payDate, paycheck.PayPeriodEndDate);
            Assert.AreEqual(pay, paycheck.GrossPay);
            Assert.AreEqual("Hold", paycheck.GetField("Disposition"));
            Assert.AreEqual(0.0M, paycheck.Deductions);
            Assert.AreEqual(pay, paycheck.NetPay);
        }
        public void PaySingleCommissionedEmployeeMonthSalary()
        {
            int empId = 329;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 1000, 15);

            t.Execute();

            DateTime payDate            = new DateTime(2001, 11, 7); // Friday
            SalesReceiptTransaction tct = new SalesReceiptTransaction(payDate, 200.0, empId);

            tct.Execute();

            SalesReceiptTransaction tct2 = new SalesReceiptTransaction(payDate.AddDays(-1), 100.0, empId);

            tct.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();

            double commissionPay = ((200 * 15) / 100) + ((100 * 15) / 100);
            double salaryHalfPay = (1000 / 2);
            var    pay           = commissionPay + salaryHalfPay;

            ValidateHourlyPaycheck(pt, empId, payDate, pay);

            pt = new PaydayTransaction(payDate.AddDays(14));
            pt.Execute();

            ValidateHourlyPaycheck(pt, empId, payDate, 1000 / 2);


            Paycheck pc = pt.GetPaycheck(empId, payDate);
            var      totalMonthSalary = pc.GrossPay;

            pc = pt.GetPaycheck(empId, payDate);
            totalMonthSalary += pc.GrossPay;

            Assert.AreEqual(1000, totalMonthSalary);
        }
Пример #19
0
        public void PaySingleSalariedEmployeeOnWrongDate()
        {
            int empId   = SetupSalariedEmployee(SalariedEmployeeId + 10);
            var payDate = new DateTime(2001, 11, 29);

            var pt = new PaydayTransaction(payDate);

            pt.Execute();

            Paycheck pc = PaydayTransaction.GetPaycheck(empId);

            Assert.Null(pc);
        }
Пример #20
0
        public void PaySingleSalariedEmployeeOnWrongDate()
        {
            int empid             = 18;
            AddSalariedEmployee t = new AddSalariedEmployee(empid, "Bob", "Home", 1000.00);

            t.Execute();
            DateTime          payDate = new DateTime(2015, 12, 16);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

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

            Assert.IsNull(pc);
        }
Пример #21
0
        public async Task PyaSingleSalariedEmployeeOnWrongDate()
        {
            int empId             = 11;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000);
            await t.ExecuteAsync();

            DateTime          payDate = new DateTime(2001, 11, 29);
            PaydayTransaction pt      = new PaydayTransaction(payDate);
            await pt.ExecuteAsync();

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.Null(pc);
        }
Пример #22
0
        public void TestPaySingleSalariedEmployeeOnWrongDate()
        {
            const int empId = 18;
            var       t     = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00);

            t.Execute();
            var payDate = new DateTime(2020, 11, 29);
            var pt      = new PaydayTransaction(payDate);

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

            Assert.IsNull(pc);
        }
Пример #23
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);
        }
Пример #24
0
        public void PaySingleHourlyEmployeeOnWrongDate()
        {
            int empid           = 22;
            AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 15.25);

            t.Execute();
            DateTime            payDate = new DateTime(2015, 12, 3);
            TimeCardTransaction tc      = new TimeCardTransaction(payDate, 9.0, empid);

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

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

            Assert.IsNull(pc);
        }
Пример #25
0
        public void TestPaySingleCommissionedEmployeeWrongDate()
        {
            int empId = 1;

            var addTx = new AddCommissionedEmployee(empId, "Bob", "Home", 1000, 0.2M);

            addTx.Execute();

            var payDate  = new Date(11, 9, 2001);
            var paydayTx = new PaydayTransaction(payDate);

            paydayTx.Execute();

            var paycheck = paydayTx.GetPaycheck(empId);

            Assert.IsNull(paycheck, "paycheck expected null because it's not a paydate");
        }
        public void TestPayServiceChargesSpanningMultiplePayPeriods()
        {
            // Arrange
            var employeeId = 1;
            var hourlyRate = 24;

            new AddHourlyEmployeeTransaction(employeeId, "Adam", "Address", hourlyRate).Execute();

            var commisionRate = 9.25;
            var unionMemberId = 252;

            new ChangeEmployeeUnionAffiliationTransaction(employeeId, unionMemberId, commisionRate).Execute();

            var serviceChargeAmount = 11;
            var fridayDate          = new DateTime(2018, 02, 16);

            new ServiceChargeTransaction(unionMemberId, fridayDate, serviceChargeAmount).Execute();

            var earlierFridayDay     = fridayDate - TimeSpan.FromDays(7);
            var serviceChargeAmount1 = 100;

            new ServiceChargeTransaction(unionMemberId, earlierFridayDay, serviceChargeAmount1).Execute();

            var nextFridayDay        = fridayDate + TimeSpan.FromDays(7);
            var serviceChargeAmount2 = 100;

            new ServiceChargeTransaction(unionMemberId, nextFridayDay, serviceChargeAmount2).Execute();

            var hours = 8;

            new TimeCardTransaction(employeeId, fridayDate, hours).Execute();
            var paydayTransaction = new PaydayTransaction(fridayDate);

            // Act
            paydayTransaction.Execute();
            var paycheck    = paydayTransaction.GetPaycheck(employeeId);
            var expectedPay = hours * hourlyRate;

            // Assert
            Assert.IsNotNull(paycheck);
            Assert.AreEqual(fridayDate, paycheck.EndDate);
            Assert.AreEqual(expectedPay, paycheck.GrossPay);
            Assert.AreEqual(PaymentMethodType.Hold, paycheck.Disposition);
            Assert.AreEqual(commisionRate + serviceChargeAmount, paycheck.Deductions);
            Assert.AreEqual(expectedPay - commisionRate - serviceChargeAmount, paycheck.NetPay);
        }
Пример #27
0
        public void PaySingleCommissionEmployeeOnWrongDate()
        {
            int empid = 27;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empid, "Bill", "Home", 15000, 10);

            t.Execute();
            DateTime payDate           = new DateTime(2015, 12, 3);
            SalesReceiptTransaction tc = new SalesReceiptTransaction(payDate, 3, empid);

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

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

            Assert.IsNull(pc);
        }
Пример #28
0
        public void PayCommissionedEmployeeWithOneSaleWrongDate()
        {
            int empId   = SetupCommissionedEmployee();
            var payDate = new DateTime(2020, 7, 3); // First Friday

            var srt = new SalesReceiptTransaction(empId, payDate.AddDays(-1), 40_000);

            srt.Execute();

            var pt = new PaydayTransaction(payDate);

            pt.Execute();

            Paycheck paycheck = PaydayTransaction.GetPaycheck(empId);

            Assert.Null(paycheck);
        }
Пример #29
0
        public void PaySingleHourlyEmployeeOnWrongDate()
        {
            int empId   = SetupHourlyEmployee();
            var payDate = new DateTime(2001, 11, 8); // Thursday

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

            tc.Execute();

            var pt = new PaydayTransaction(payDate);

            pt.Execute();

            Paycheck pc = PaydayTransaction.GetPaycheck(empId);

            Assert.Null(pc);
        }
Пример #30
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);
        }