Пример #1
0
        public void TestSalesReceiptTransaction()
        {
            int empId = 4;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2);

            t.Execute();

            SalesReceiptTransaction srt = new SalesReceiptTransaction(new DateTime(2005, 7, 31), 20, empId);

            srt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);
            CommissionedClassification hc = pc as CommissionedClassification;

            SalesReceipt sr = hc.GetSalesReceipt(new DateTime(2005, 7, 31));

            Assert.IsNotNull(sr);
            Assert.AreEqual(20, sr.Amount);
        }
        public void TestSalesReceiptTransaction()
        {
            int empId = 5;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 1000.00, 15);

            t.Execute();

            SalesReceiptTransaction tct = new SalesReceiptTransaction(new DateTime(2005, 7, 31), 200.0, empId);

            tct.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is ComissinedClassification);

            ComissinedClassification hc = pc as ComissinedClassification;
            SalesReceipt             tc = hc.GetSalesReceipt(new DateTime(2005, 7, 31));

            Assert.IsNotNull(tc);
            Assert.AreEqual(200.0, tc.Amount);
        }
        public void TestAddSalesReceiptTransaction()
        {
            #region Arrange
            int employeeId            = 5;
            AddCommissionedEmployee t = new AddCommissionedEmployee(employeeId, "user", "home", 1000, 97.5);
            t.Execute();

            DateTime workingDate        = new DateTime(2019, 4, 21);
            SalesReceiptTransaction srt = new SalesReceiptTransaction(
                employeeId, workingDate, 200
                );
            #endregion

            #region Action
            srt.Execute();
            #endregion

            #region Assert
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            e.Classification.Should().BeOfType <CommissionedClassification>();
            CommissionedClassification cc = e.Classification as CommissionedClassification;

            SalesReceipt sr = cc.GetSalesReceipt(workingDate);
            sr.Should().NotBeNull();
            sr.Amount.Should().Be(200);
            #endregion
        }
Пример #4
0
        public void TestSalesReceiptTransaction()
        {
            int      empId            = 6;
            DateTime saleDate         = new DateTime(2017, 09, 07);
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Commissioned", "Sertãozinho", 1000, 10, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);

            SalesReceiptTransaction srt = new SalesReceiptTransaction(empId, saleDate, 100.00, database);

            srt.Execute();

            CommissionedClassification cc = pc as CommissionedClassification;
            SalesReceipt sr = cc.GetSalesReceipt(saleDate);

            Assert.IsNotNull(sr);
            Assert.AreEqual(100.00, sr.SaleAmount, .001);
        }
Пример #5
0
        public void TestSalesReceiptTransaction()
        {
            int empId = 5;
            AddCommissionedEmployee t =
                new AddCommissionedEmployee(
                    empId, "Bill", "Home", 2000, 15.25, database);

            t.Execute();
            SalesReceiptTransaction tct =
                new SalesReceiptTransaction(
                    new DateTime(2005, 7, 31), 250.00, empId, database);

            tct.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionClassification);
            CommissionClassification cc = pc as CommissionClassification;

            SalesReceipt sr = cc.GetSalesReceipt(new DateTime(2005, 7, 31));

            Assert.IsNotNull(sr);
            Assert.AreEqual(250.00, sr.SaleAmount, .001);
        }
Пример #6
0
        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);
        }
Пример #7
0
        public void LoadCommissionedClassificationOneSalesReceipt()
        {
            employee.Schedule       = new BiweeklySchedule();
            employee.Method         = new DirectDepositMethod("1st Bank", "0123456");
            employee.Classification = new CommissionedClassification(500.00, 80.30);
            database.AddEmployee(employee);

            var saleDay = new DateTime(2001, 11, 16);
            SalesReceiptTransaction srt = new SalesReceiptTransaction(saleDay, 3, 123, database);

            srt.Execute();

            Employee loadedEmployee = database.GetEmployee(123);
            PaymentClassification classification = loadedEmployee.Classification;

            Assert.IsTrue(classification is CommissionedClassification);

            CommissionedClassification commissionedClassification = classification as CommissionedClassification;

            Assert.AreEqual(500.00, commissionedClassification.Salary, .01);
            Assert.AreEqual(80.30, commissionedClassification.CommissionRate, .01);

            var salesReceipts = commissionedClassification.SalesReceipts;

            Assert.AreEqual(1, salesReceipts.Count);

            var sr = salesReceipts[saleDay] as SalesReceipt;

            Assert.IsNotNull(sr);
            Assert.AreEqual(3, sr.Amount);
        }
Пример #8
0
        public void SalesReceiptTransaction()
        {
            int empId = 5;
            AddCommissionedEmployee t = new AddCommissionedEmployee(
                empId, "Bob", "Home", 1000.00, 10, database);

            t.Execute();

            SalesReceiptTransaction srt = new SalesReceiptTransaction(
                new DateTime(2005, 7, 31), 100.0, empId, database);

            srt.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);
            CommissionedClassification cc = pc as CommissionedClassification;

            SalesReceipt sr = cc.GetSalesReceipt(new DateTime(2005, 7, 31));

            Assert.IsNotNull(sr);
            Assert.AreEqual(100, sr.Amount);
        }
Пример #9
0
        public void TestSalesReceiptTransaction()
        {
            int empId = 6;
            AddCommissionEmployee t = new AddCommissionEmployee(empId, "Kubing", "Home", 2000, 3.0, database);

            t.Execute();

            var saleDay = new DateTime(2017, 3, 19);
            SalesReceiptTransaction srt = new SalesReceiptTransaction(saleDay, 4, empId, database);

            srt.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);

            CommissionedClassification hc = pc as CommissionedClassification;
            var salesReceipts             = database.GetSalesReceipts(empId).ToList();
            var sr = salesReceipts.FirstOrDefault(x => x.Date == saleDay);

            Assert.IsNotNull(sr);
            Assert.AreEqual(4, sr.Amount);
        }
Пример #10
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);
        }
Пример #11
0
        public void TestSalesReceiptTransaction()
        {
            int empId = 2;
            var addTx = new AddCommissionedEmployee(empId, "Bill", "Home", 1000M, 3.2M);

            addTx.Execute();

            var salesReceiptTX = new SalesReceiptTransaction(1000M, new Date(10, 31, 2001), empId);

            salesReceiptTX.Execute();

            var employee = Database.GetEmployee(empId);

            Assert.IsNotNull(employee);

            PaymentClassification classification = employee.GetClassification();
            var commissionedClassification       = (CommissionedClassification)classification;

            var receipts = commissionedClassification.GetSalesReceiptsForDate(new Date(10, 31, 2001));

            Assert.AreEqual(1, receipts.Count, "Receipt count for date is not 1");
            var firstReceipt = receipts.First();

            Assert.AreEqual(1000M, firstReceipt.Amount);
        }
        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);
        }
Пример #13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int                     id           = int.Parse(TextBox1.Text);
            int                     amount       = int.Parse(TextBox2.Text);
            DateTime                time         = DateTime.Now;
            PayrollDatabase         database     = new FunctionPayrollDatabase();
            SalesReceiptTransaction salesReceipt = new SalesReceiptTransaction(time, amount, id, database);

            salesReceipt.Execute();
        }
Пример #14
0
        public void PayingSingleCommissionEmployeeOneSalesCards()
        {
            int empid = 26;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empid, "Bob", "Home", 15000, 10);

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

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

            pt.Execute();
            ValidateCommissionPaycheck(pt, empid, payDate, 15100);
        }
Пример #15
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);
        }
Пример #16
0
        public void PayingCommisionEmployeeOnFiveFridaysMonth()
        {
            int empId = 4;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2);

            t.Execute();

            DateTime payDate           = new DateTime(2017, 3, 31);
            SalesReceiptTransaction st = new SalesReceiptTransaction(payDate, 2, empId);

            st.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            ValidateCommisionPaycheck(pt, empId, payDate, 3.2 * 2);
        }
Пример #17
0
        public void PayingCommisionEmployeeOneSalesRecipt()
        {
            int empId = 4;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2);

            t.Execute();

            DateTime payDate           = new DateTime(2001, 11, 2);
            SalesReceiptTransaction st = new SalesReceiptTransaction(payDate, 2, empId);

            st.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            ValidateCommisionPaycheck(pt, empId, payDate, (2500 / 2) + (3.2 * 2));
        }
Пример #18
0
        public void PaySingleCommissionedEmployeeOneReceipt()
        {
            int empId = 2;
            AddCommissionedEmployee t = new AddCommissionedEmployee(
                empId, "Bill", "Home", 1500, 10, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 16); // Payday

            SalesReceiptTransaction sr =
                new SalesReceiptTransaction(payDate, 5000.00, empId, database);

            sr.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 2000.00);
        }
Пример #19
0
        public void TestPaySingleCommissionEmployeeOneSalesReceipt()
        {
            int empId = 5;
            AddCommissionEmployee t = new AddCommissionEmployee(empId, "Kubing", "Home", 2000.0, 3.0, database);

            t.Execute();

            DateTime payDate = new DateTime(2001, 11, 16);

            SalesReceiptTransaction srt = new SalesReceiptTransaction(payDate, 3, empId, database);

            srt.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();

            ValidateCommissionedPaycheck(pt, empId, payDate, 2000.0 + 3 * 3.0);
        }
        public void GivenNotExistingEmployeeId_WhenExecuteAddSalesReceiptTransaction_ThenThrowInvalidOperationException()
        {
            #region Arrange
            int      employeeId         = 1000;
            DateTime workingDate        = new DateTime(2019, 4, 21);
            SalesReceiptTransaction srt = new SalesReceiptTransaction(
                employeeId, workingDate, 200
                );
            #endregion

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

            #region Assert
            ex.Should().BeOfType <InvalidOperationException>();
            ex.Message.Should().Contain("No such employee.");
            #endregion
        }
        public void PaySingleCommissionedEmployeeOnWrongDate()
        {
            int empId = 327;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 1000, 15);

            t.Execute();

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

            tct.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();

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

            Assert.IsNull(pc);
        }
Пример #22
0
        public void PaySingleCommissionedEmployeeOneSalesReceipt()
        {
            int empId = 5;
            AddCommissionedEmployee t = new AddCommissionedEmployee(
                empId, "Bob", "Home", 1000.00, 10.00, database);

            t.Execute();

            DateTime payDate = new DateTime(2001, 11, 9); // Friday

            SalesReceiptTransaction srt = new SalesReceiptTransaction(
                payDate, 100.00, empId, database);

            srt.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();

            ValidatePaycheck(pt, empId, payDate, 1010);
        }
Пример #23
0
        public void PayingCommisionEmployeeOnWrongDate()
        {
            int empId = 4;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2);

            t.Execute();

            DateTime payDate           = new DateTime(2001, 11, 8);
            SalesReceiptTransaction st = new SalesReceiptTransaction(payDate, 2, empId);

            st.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPaycheck(empId);

            Assert.IsNull(pc);
        }
Пример #24
0
        public void TestPaySingleCommissionEmployeeOnWrongDate()
        {
            int empId = 5;
            AddCommissionEmployee t = new AddCommissionEmployee(empId, "Kubing", "Home", 2000.0, 3.0, database);

            t.Execute();

            DateTime payDate = new DateTime(2001, 11, 15);

            SalesReceiptTransaction srt = new SalesReceiptTransaction(payDate, 3, empId, database);

            srt.Execute();

            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNull(pc);
        }
Пример #25
0
        public void SalesReceiptTransaction()
        {
            int          empId  = SetupCommissionedEmployee();
            var          date   = new DateTime(2020, 7, 27);
            const double amount = 490_000.0;

            var srt = new SalesReceiptTransaction(empId, date, amount);

            srt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            var          pc = Assert.IsType <CommissionedClassification>(e.Classification);
            SalesReceipt sr = pc.GetSalesReceipt(date);

            Assert.NotNull(sr);
            Assert.Equal(date, sr.Date);
            Assert.Equal(amount, sr.Amount);
        }
Пример #26
0
        public void SalesReceiptTransaction()
        {
            int empid = 7;
            AddCommissionedEmployee s = new AddCommissionedEmployee(empid, "Bill", "Home", 38, 25000);

            s.Execute();
            SalesReceiptTransaction crt = new SalesReceiptTransaction(new DateTime(2015, 10, 31), 15.15, empid);

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

            Assert.IsNotNull(e);
            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);
            CommissionedClassification cc = pc as CommissionedClassification;
            SalesReceipt sr = cc.GetSalary(new DateTime(2015, 10, 31));

            Assert.IsNotNull(sr);
            Assert.AreEqual(15.15, sr.Amount);
        }
Пример #27
0
        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 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);
        }
Пример #29
0
        public void PayingSingleCommissionEmployeeWithSalesCardsSpanningTwoPayPeriods()
        {
            int empid = 29;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empid, "Bill", "Home", 15000, 10);

            t.Execute();
            DateTime payDate = new DateTime(2015, 12, 4);
            DateTime dateInPreviousPayPeriod = new DateTime(2015, 11, 14);
            SalesReceiptTransaction tc       = new SalesReceiptTransaction(payDate, 1000, empid);

            tc.Execute();
            SalesReceiptTransaction tc1 = new SalesReceiptTransaction(payDate.AddDays(-1), 2000, empid);

            tc1.Execute();
            SalesReceiptTransaction tc2 = new SalesReceiptTransaction(dateInPreviousPayPeriod, 3000, empid);

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

            pt.Execute();
            ValidateCommissionPaycheck(pt, empid, payDate, 15300);
        }
Пример #30
0
        TestPaySingleCommissionedEmployeeWithReceiptsSpanningTwoPayPeriods()
        {
            int empId = 2;
            AddCommissionedEmployee t = new AddCommissionedEmployee(
                empId, "Bill", "Home", 1500, 10, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 16); // Payday

            SalesReceiptTransaction sr =
                new SalesReceiptTransaction(payDate, 5000.00, empId, database);

            sr.Execute();
            SalesReceiptTransaction sr2 = new SalesReceiptTransaction(
                payDate.AddDays(-15), 3500.00, empId, database);

            sr2.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 2000.00);
        }