Esempio 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);
        }
Esempio n. 2
0
        public decimal CalculateDeductions(Paycheck paycheck)
        {
            decimal result = CalculateBaseDues(paycheck);

            result += CalculateServiceChargeAmount(paycheck);

            return(result);
        }
Esempio n. 3
0
        private void ValidatePaycheck(PaydayTransaction pt, int empId, DateTime payDate, decimal pay, decimal deductions = 0m)
        {
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.That(pc, Is.Not.Null);
            Assert.That(pc.PayPeriodEndDate, Is.EqualTo(payDate));
            Assert.That(pc.GrossPay, Is.EqualTo(pay));
            Assert.That(pc.Deductions, Is.EqualTo(deductions));
            Assert.That(pc.NetPay, Is.EqualTo(pay - deductions));
        }
Esempio n. 4
0
        public void Payday(Paycheck paycheck)
        {
            decimal grossPay   = Classification.CalculatePay(paycheck);
            decimal deductions = Affiliation.CalculateDeductions(paycheck);
            decimal netPay     = grossPay - deductions;

            paycheck.GrossPay   = grossPay;
            paycheck.Deductions = deductions;
            paycheck.NetPay     = netPay;
            Method.Pay(paycheck);
        }
Esempio n. 5
0
        private decimal CalculateServiceChargeAmount(Paycheck paycheck)
        {
            var result = 0m;

            foreach (ServiceCharge charge in servicecharges.Values)
            {
                if (charge.Date.IsInPayPeriod(paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate))
                {
                    result += charge.Amount;
                }
            }
            return(result);
        }
        public decimal CalculatePay(Paycheck paycheck)
        {
            var result = Salary;

            foreach (SalesReceipt sr in salesReceipts.Values)
            {
                if (sr.Date.IsInPayPeriod(paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate))
                {
                    result += CommissionRate * sr.Amount;
                }
            }
            return(result);
        }
Esempio n. 7
0
        public decimal CalculatePay(Paycheck paycheck)
        {
            decimal result = 0m;

            foreach (TimeCard tc in timeCards.Values)
            {
                if (tc.Date.IsInPayPeriod(paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate))
                {
                    result += CalculatePayForTimeCard(tc);
                }
            }

            return(result);
        }
Esempio n. 8
0
        public void TestPaySingleSalariedEmployeeOnWrongDate()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00m);

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

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

            Assert.That(pc, Is.Null);
        }
Esempio n. 9
0
        public void Execute()
        {
            var empIds = PayrollDatabase.GetEmployeeIds();

            foreach (int empId in empIds)
            {
                var e = PayrollDatabase.GetEmployee(empId);
                if (e.IsPayDay(payDate))
                {
                    var      startDate = e.GetPayPeriodStartDate(payDate);
                    Paycheck pc        = new Paycheck(startDate, payDate);
                    paychecks[empId] = pc;
                    e.Payday(pc);
                }
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        private decimal CalculateBaseDues(Paycheck paycheck)
        {
            int fridays = NumberOfFridaysInPayPeriod(paycheck.PayPeriodStartDate, paycheck.PayPeriodEndDate);

            return(fridays * dues);
        }