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); }
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); }
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 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); }
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 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 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); }
public void SalariedUnionMemberDuesTest() { var empId = 1; var name = "Bogdan"; var address = "Home"; var salary = 1000.0; AddSalariedEmployee t = new AddSalariedEmployee(empId, name, address, salary); t.Execute(); var memberId = 7734; var dues = 9.42; ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, dues); cmt.Execute(); var payDate = new DateTime(2001, 11, 30); PaydayTransaction pt = new PaydayTransaction(payDate); pt.Execute(); PayCheck pc = pt.GetPayCheck(empId); Assert.IsNotNull(pc); Assert.AreEqual(payDate, pc.PayDate); Assert.AreEqual(salary, pc.GrossPay, .001); Assert.AreEqual(5 * dues, pc.Deductions, .001); Assert.AreEqual(salary - (5 * dues), pc.NetPay, .001); }
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("未到支付日期"); } }
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 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); }
public void PaySingleHourlyEmployeeTwoTimeCards() { int empId = 3; string name = "Marek"; string address = "Home"; double hourlyRate = 15.25; int hours1 = 2; int hours2 = 5; AddHourlyEmployee t = new AddHourlyEmployee(empId, name, address, hourlyRate); t.Execute(); DateTime payDate = new DateTime(2001, 11, 9); // piątek TimeCardTransaction tc1 = new TimeCardTransaction(payDate, hours1, empId); tc1.Execute(); TimeCardTransaction tc2 = new TimeCardTransaction(payDate.AddDays(-1), hours2, empId); tc2.Execute(); PaydayTransaction pt = new PaydayTransaction(payDate); pt.Execute(); var pc = pt.GetPayCheck(empId); ValidatePayCheck(pt, empId, payDate, (7) * hourlyRate); }
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); }
public void PaySingleCommissionedEmployeeTwoSalesReceipts() { int empId = 328; 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); }
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); }
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); }
public void PaySingleCommissionedEmployeeWithSalesReceiptsSpanningTwoPayPeriods() { int empId = 2; AddCommissionedEmployee t = new AddCommissionedEmployee( empId, "Bob", "Home", 1000.00, 10.00, database); t.Execute(); DateTime payDate = new DateTime(2001, 11, 16); // Friday DateTime dateInPreviousPayPeriod = new DateTime(2001, 11, 2); SalesReceiptTransaction srt = new SalesReceiptTransaction( payDate, 100.00, empId, database); srt.Execute(); SalesReceiptTransaction srt2 = new SalesReceiptTransaction( dateInPreviousPayPeriod, 200.00, empId, database); srt2.Execute(); PaydayTransaction pt = new PaydayTransaction(payDate, database); pt.Execute(); ValidatePaycheck(pt, empId, payDate, 1010.00); }
public void PaySingleSalariedEmployee() { int empId = SetupSalariedEmployee(); var payDate = new DateTime(2001, 11, 30); var pt = new PaydayTransaction(payDate); pt.Execute(); ValidateNoDeductionPaycheck(empId, payDate, 2300.0); }
public void PayingSingleHourlyEmployeeNoTimeCards() { int empId = SetupHourlyEmployee(); var payDate = new DateTime(2001, 11, 9); // Friday var pt = new PaydayTransaction(payDate); pt.Execute(); ValidateNoDeductionPaycheck(empId, payDate, 0.0); }
public void TestPayingSingleHourlyEmployeeNoTimeCards() { const int empId = 19; var t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25); t.Execute(); var payDate = new DateTime(2020, 11, 6); var pt = new PaydayTransaction(payDate); pt.Execute(); ValidateHourlyPaycheck(pt, empId, payDate, 0.0); }
public void PayingSingleHourlyEmployeeWithouTTimeCards() { int employeeId = AddHourlyEmployee(); DateTime payDate = new DateTime(2019, 4, 26); PaydayTransaction pt = new PaydayTransaction(payDate); pt.Execute(); PayCheck pc = pt.GetPayCheck(employeeId); ValidateHourlyPayCheck(payDate, pc, 0.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); }
public void PayingSingleCommissionedEmployeeNoReceipts() { int empId = 2; AddCommissionedEmployee t = new AddCommissionedEmployee( empId, "Bill", "Home", 1500, 10, database); t.Execute(); DateTime payDate = new DateTime(2001, 11, 16); // Payday PaydayTransaction pt = new PaydayTransaction(payDate, database); pt.Execute(); ValidatePaycheck(pt, empId, payDate, 1500.0); }
public void PayingSingleHourlyEmployeeNoTimeCards() { int empId = 2; AddHourlyEmployee t = new AddHourlyEmployee( empId, "Bill", "Home", 15.25, database); t.Execute(); DateTime payDate = new DateTime(2001, 11, 9); // Friday PaydayTransaction pt = new PaydayTransaction(payDate, database); pt.Execute(); ValidatePaycheck(pt, empId, payDate, 0.0); }
public void PayingCommisionEmployeeNoSalesRecipt() { int empId = 4; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2); t.Execute(); DateTime payDate = new DateTime(2001, 11, 2); PaydayTransaction pt = new PaydayTransaction(payDate); pt.Execute(); ValidateCommisionPaycheck(pt, empId, payDate, 2500 / 2); }
public void PayingSingleCommissionedEmployeeWithoutSaleReciept() { int employeeId = AddCommissionedEmployee(); DateTime payDate = new DateTime(2019, 4, 19); PaydayTransaction pt = new PaydayTransaction(payDate); pt.Execute(); PayCheck pc = pt.GetPayCheck(employeeId); ValidateHourlyPayCheck(payDate, pc, 800.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); }
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); }
public void PayingSingleHourlyEmployeeNoTimeCards() { int empId = 2; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Билл", "Домашний", 15.25); t.Execute(); DateTime payDate = new DateTime(2001, 11, 9); PaydayTransaction pt = new PaydayTransaction(payDate); pt.Execute(); ValidateHourlyPaycheck(pt, empId, payDate, 0.0); }
public void TestPaySingleCommissionEmployeeWithNoSalesReceipt() { int empId = 4; AddCommissionEmployee t = new AddCommissionEmployee(empId, "Kubing", "Home", 2000.0, 3.0, database); t.Execute(); DateTime payDate = new DateTime(2001, 11, 16); PaydayTransaction pt = new PaydayTransaction(payDate, database); pt.Execute(); ValidateCommissionedPaycheck(pt, empId, payDate, 2000.0); }