Ejemplo n.º 1
0
        public ActionResult Paycheck(int paycheckID)
        {
            Paycheck paycheck = dbWorkMate.Paychecks.Find(paycheckID);

            if (paycheck == null)
            {
                return(HttpNotFound());
            }
            else if (paycheck.UserID != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }
            else
            {
                paycheck.PaycheckDetails = dbWorkMate.PaycheckDetails
                                           .Include(p => p.Paycheck)
                                           .Include(p => p.Paycheck.Job)
                                           .Include(p => p.Paycheck.PayDate)
                                           .Include(p => p.Schedule)
                                           .Where(e => e.PaycheckID == paycheck.ID)
                                           .ToList();

                PaycheckViewModel paycheckVM = new PaycheckViewModel()
                {
                    Paycheck = paycheck
                };

                return(View(paycheckVM));
            }
        }
        public async Task <Paycheck> GetPaycheckAsync(Employer employer, string documentId, int cchid)
        {
            if (String.IsNullOrWhiteSpace(documentId))
            {
                throw new InvalidOperationException("Invalid documentId.");
            }

            if (employer == null || string.IsNullOrWhiteSpace(employer.ConnectionString))
            {
                throw new InvalidOperationException("Invalid employer context.");
            }

            _repository.Initialize(employer.ConnectionString);

            var result = await _repository.GetPaycheckAsync(documentId, cchid);

            Paycheck paycheck = null;

            if (result != null)
            {
                paycheck = new Paycheck(result);
            }

            return(paycheck);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutPaycheck(int id, Paycheck paycheck)
        {
            if (id != paycheck.Id)
            {
                return(BadRequest());
            }

            _context.Entry(paycheck).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaycheckExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public bool IsInPayPeriod(DateTime theDate, Paycheck paycheck)
        {
            DateTime payPeriodEndDate   = paycheck.PayPeriodEndDate;
            DateTime payPeriodStartDate = paycheck.PayPeriodEndDate;

            return((theDate >= payPeriodStartDate) && (theDate <= payPeriodEndDate));
        }
        public ActionResult Edit([Bind(Include = "Id,ModeOfPaycheck,paycheck_date,payroll_id,payment_type,check_number,direct_deposit_number,payment_amount")] PaycheckModeModel paycheck)
        {
            // set old paycheck
            paycheck.SetPayroll(paycheck.payroll_id);
            Paycheck oldPaycheck = PaycheckModeModel.ToBase(paycheck);

            // assign fields to new paycheck
            var newPaycheck = dbBusiness.Paychecks.Find(oldPaycheck.Id);

            newPaycheck.paycheck_date         = oldPaycheck.paycheck_date;
            newPaycheck.payroll_id            = oldPaycheck.payroll_id;
            newPaycheck.payment_type          = oldPaycheck.payment_type;
            newPaycheck.check_number          = oldPaycheck.check_number;
            newPaycheck.direct_deposit_number = oldPaycheck.direct_deposit_number;
            newPaycheck.payment_amount        = oldPaycheck.payment_amount;

            dbBusiness.Entry(newPaycheck).State = EntityState.Modified;
            var result = dbBusiness.SaveChanges();

            if (result > 0)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.ActionTitle = "Edit ";
            return(View(paycheck));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <Paycheck> > PostPaycheck(Paycheck paycheck)
        {
            _context.Paychecks.Add(paycheck);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPaycheck", new { id = paycheck.Id }, paycheck));
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public Paycheck Get(string employeeName)
        {
            var employee = employeeRepository.Get(employeeName);

            if (employee == null)
            {
                throw new ArgumentException();
            }

            var paycheck = new Paycheck
            {
                BasePay = EmployeeConstants.EmployeeBasePay
            };

            double benefitsCost = CalculateBenefitsCost(employee.Name, true);

            foreach (var dependent in employee.Dependents)
            {
                benefitsCost += CalculateBenefitsCost(dependent.Name, false);
            }

            paycheck.AdjustedPay = CalculateAdjustedPay(benefitsCost);

            return(paycheck);
        }
Ejemplo n.º 9
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("未到支付日期");
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }
        public async Task <IActionResult> DeletePaycheck(Paycheck model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _itemGenerator.DeletePaycheckAndPushToDbAsync(model);

                    await _userEditor.SubtractCurrentMoney(model.Amount);

                    await _userEditor.SubtractBudgetedForNeeds(model.Amount * .5m);

                    await _userEditor.SubtractBudgetedForWants(model.Amount * .3m);

                    await _userEditor.SubtractBudgetedForSavings(model.Amount * .2m);

                    await _userEditor.SubtractFromAllTimeEarned(model.Amount);

                    return(RedirectToAction("Index", "Dashboard"));
                }
                catch
                {
                    return(BadRequest());
                }
            }
            return(BadRequest());
        }
Ejemplo n.º 13
0
        public async Task CreatePaycheck(Employee employee)
        {
            if (employee.LastPaycheckDate >= DateTime.Today)
            {
                return;
            }

            var grossAmount = employee.Salary / 26;

            var paycheck = new Paycheck()
            {
                Name        = $"{employee.FirstName} {employee.LastName}",
                EmployeeId  = employee.Id,
                GrossAmount = grossAmount,
                PayDate     = DateTime.Today
            };

            var deductions = await _deductionService.GetDeductions(employee.Id);

            await paycheck.AddDeductions(deductions);

            await _payrollRepository.CreatePaycheck(paycheck);

            employee.LastPaycheckDate = DateTime.Today;
            await _payrollRepository.UpdateEmployee(employee);
        }
Ejemplo n.º 14
0
        public Order ProccedPayment(Order order, string fullName, string carNumber)
        {
            if (string.IsNullOrEmpty(fullName) || string.IsNullOrEmpty(carNumber))
            {
                return(null);
            }

            if (order == null)
            {
                return(null);
            }

            if (order.Status != OrderStatus.New)
            {
                return(null);
            }

            // pretend to check payment
            var check = new Paycheck
            {
                Date       = DateTime.UtcNow,
                CardNumber = carNumber,
                FullName   = fullName,
                Amount     = order.TotalPrice
            };

            _paycheckRepository.Add(check);

            order.Paycheck    = check;
            order.Paycheck_Id = check.Id;
            order.Status      = OrderStatus.Paid;

            return(order);
        }
Ejemplo n.º 15
0
        public async Task PaycheckCreatedWithHsaDeductionShouldAddContribution()
        {
            var paycheck = new Paycheck
            {
                EmployeeId = 3,
                Deductions = new List <Deduction>
                {
                    new Deduction
                    {
                        Type   = "Hsa",
                        Amount = 40m
                    },
                    new Deduction
                    {
                        Type   = "401k",
                        Amount = 20m
                    }
                }
            };

            var hsaService = new Mock <IHsaService>();
            var service    = GetPayrollService(hsaService.Object);

            await service.PaycheckCreated(paycheck);

            hsaService.Verify(f => f.ContributionAdded(paycheck.EmployeeId, 40m));
        }
Ejemplo n.º 16
0
        public async Task DeletePaycheckAndPushToDbAsync(Paycheck model)
        {
            Paycheck paycheck = await _itemFetcherService.GetSpecificPaycheckAsync(model.Id);

            _db.Paychecks.Remove(paycheck);
            await _db.SaveChangesAsync();
        }
Ejemplo n.º 17
0
        private void ButtonOrder_Click(object a, RoutedEventArgs d)
        {
            ReloadPrices();
            DateTime st     = DatePickerStart.SelectedDate.Value;
            DateTime en     = DatePickerEnd.SelectedDate.Value;
            string   pplamt = TextBoxPplCount.Text;

            if (!Int32.TryParse(TextBoxPplCount.Text, out int count))
            {
                MessageBox.Show("Please, write a valid amount of people");
            }
            else
            if (st == null || en == null)
            {
                MessageBox.Show("Please, choose the dates of your tour");
            }
            else
            if (st < DateTime.Today || en < DateTime.Today || st.Equals(en))
            {
                MessageBox.Show("Start and end dates must be in future");
            }
            else
            {
                Paycheck p = new Paycheck();
                p.Voucher = new Voucher {
                    start_date = (DateTime)st, end_date = (DateTime)en, insurance_cost = defaultinsurance
                };
                p.ppl_count = count;
                p.payed     = false;

                Adapter.TemporaryPaycheck = p;

                this.NavigationService.Navigate(new AddClientPage());
            }
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            AnnualAggregate    agg      = new AnnualAggregate();
            IndividualSettings settings = IndividualSettings.Deserialize("sample.json");

            /*
             * IndividualSettings output = new IndividualSettings();
             * output.PerPaycheckSettings = new List<PerPaycheckSettings>();
             * output.PerPaycheckSettings.Add(new PerPaycheckSettings() { Month = 3, Day = 15, StockAwards = 300 });
             * output.PerPaycheckSettings.Add(new PerPaycheckSettings() { Month = 9, Day = 15, Bonus = 80000 });
             * Console.WriteLine(output.Serialize());
             */

            List <int> days = new List <int>()
            {
                15, 30
            };

            for (int month = 1; month <= 12; month++)
            {
                foreach (int day in days)
                {
                    Paycheck p = new Paycheck(month, day, settings, agg);
                    agg.UpdateFromPaycheck(p);

                    WriteToConsole(string.Format("Paycheck ({0}/{1})", month, day), p);
                    Console.WriteLine();
                    WriteToConsole("Current Aggregate", agg);
                    Console.WriteLine();
                    Console.WriteLine();
                }
            }
        }
Ejemplo n.º 19
0
        public void TestInitialize()
        {
            employee = new Employee
            {
                Id         = 123,
                FirstName  = "John",
                LastName   = "Galt",
                Department = "IT",
                Title      = "Software Developer",
                StartDate  = new DateTime(2019, 3, 5),
                Salary     = 50_000
            };

            paycheck1 = new Paycheck
            {
                Id         = 1,
                EmployeeId = employee.Id,
                IssueDate  = new DateTime(2019, 3, 17),
                Amount     = employee.BiWeeklyGrossPay
            };

            paycheck2 = new Paycheck
            {
                Id         = 2,
                EmployeeId = employee.Id,
                IssueDate  = new DateTime(2019, 4, 1),
                Amount     = employee.BiWeeklyGrossPay
            };
        }
Ejemplo n.º 20
0
        //private Paycheck _paycheck;
        public PaycheckPage(Paycheck paycheck)
        {
            InitializeComponent();
            BindingContext = paycheck;

            //Formatting digits from 1234 to 1,234
            TotalPayPreDeduction.Text  = double.Parse(paycheck.TotalPayPreDeduction.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            TotalPayPreDeduction1.Text = double.Parse(paycheck.TotalPayPreDeduction.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            MorningPay.Text            = double.Parse(paycheck.MorningPay.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            EveningPay.Text            = double.Parse(paycheck.EveningPay.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            Orlof.Text          = double.Parse(paycheck.Orlof.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            OrlofBanki.Text     = double.Parse(paycheck.OrlofBanki.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            OrlofBase.Text      = double.Parse(paycheck.OrlofBase.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            MorningPayRate.Text = double.Parse(paycheck.MorningPayRate.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            EveningPayRate.Text = double.Parse(paycheck.EveningPayRate.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            TotalPay.Text       = double.Parse(paycheck.TotalPay.ToString()).ToString("##,###", CultureInfo.CurrentCulture);

            TaxToPay.Text         = double.Parse(paycheck.TaxToPay.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            TaxTotal.Text         = double.Parse(paycheck.TaxTotal.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            TaxDiscount.Text      = double.Parse(paycheck.TaxDiscount.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            Lifeyrir.Text         = double.Parse(paycheck.Lifeyrir.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            SereignaLifeyrir.Text = double.Parse(paycheck.SereignaLifeyrir.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            StRv.Text             = double.Parse(paycheck.StRv.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            TotalDeduction.Text   = double.Parse(paycheck.TotalDeduction.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
            TotalDeduction1.Text  = double.Parse(paycheck.TotalDeduction.ToString()).ToString("##,###", CultureInfo.CurrentCulture);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        public async Task CreatePaycheck(Paycheck paycheck)
        {
            await _payrollContext.Paycheck.AddAsync(paycheck);

            await _payrollContext.SaveChangesAsync();

            await PaycheckCreated(paycheck);
        }
Ejemplo n.º 23
0
        private Paycheck BuildPaycheck(DeductionsRequest request)
        {
            var paycheck = new Paycheck();

            paycheck.Employee   = BuildEmployeeInfo(request);
            paycheck.Dependents = BuildDependentsInfo(request);
            return(paycheck);
        }
Ejemplo n.º 24
0
        public async Task <ActionResult> UpdatePaycheckAsync(int id, [FromBody] Paycheck paycheckRequest)
        {
            paycheckRequest.Id = id;
            paycheckRequest.SetBaseDate();
            await RepositoryServiceProvider.PaycheckService.UpdatePaycheckAsync(paycheckRequest);

            return(Ok());
        }
Ejemplo n.º 25
0
 public override double CalculatePay(Paycheck paycheck)
 {
     double totalPay = 0.0;
     foreach (TimeCard timeCard in timeCards.Values)
         if (timeCard.Date == paycheck.PayDate)
             totalPay += CalculatePayForTimeCard(timeCard);
     return totalPay;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Paycheck paycheck = dbBusiness.Paychecks.Find(id);

            dbBusiness.Paychecks.Remove(paycheck);
            dbBusiness.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 27
0
 public void DeletePaycheck(Paycheck paycheck)
 {
     if (paycheck == null)
     {
         throw new ArgumentException("paycheck is null.");
     }
     this.context.AddUpdateDeletePaycheck(null, null, paycheck);
 }
Ejemplo n.º 28
0
        internal static void UpdatePaycheckDate(DateTime newDate)
        {
            ApplicationDbContext _db      = new ApplicationDbContext();
            Paycheck             paycheck = _db.Paycheck.First <Paycheck>();

            paycheck.paycheckDate     = newDate;
            _db.Entry(paycheck).State = System.Data.Entity.EntityState.Modified;
            _db.SaveChanges();
        }
Ejemplo n.º 29
0
        public void PaycheckViewModel_CalculatesNetPay()
        {
            var paycheck = new Paycheck {
                Employee   = TestData.Paycheck.Employee,
                Dependents = TestData.Paycheck.Dependents
            };

            Assert.AreEqual(1942.31, paycheck.NetPay);
        }
        public Paycheck CalculatePayCheck(Employee employee)
        {
            Paycheck payCheck = new Paycheck();

            payCheck.GrossSalary = employee.HourlyRate * employee.HoursWorked;
            CalculateNetSalary(payCheck);

            return(payCheck);
        }
        public override double CalculateDeductions(Paycheck paycheck)
        {
            var fridaysInMonth = GetFridaysCountInPayPeriod(paycheck.StartDate, paycheck.EndDate);
            var totalDues      = Dues * fridaysInMonth;
            var charges        = serviceCharges.Where(sc => sc.Date.IsBetween(paycheck.StartDate, paycheck.EndDate))
                                 .Sum(sc => sc.Amount);

            return(totalDues + charges);
        }
Ejemplo n.º 32
0
 public void PayDay(Paycheck paycheck)
 {
     double grossPay = classification.CalculatePay(paycheck);
     double deductions = affilation.CalculateDeductions(paycheck);
     double netPay = grossPay - deductions;
     paycheck.GrossPay = grossPay;
     paycheck.Deductions = deductions;
     paycheck.NetPay = netPay;
     method.Pay(paycheck);
 }
Ejemplo n.º 33
0
 public void Execute()
 {
     ArrayList empIds = new ArrayList();
     empIds.AddRange(PayrollDatabase.GetAllEmployeeIds());
     foreach (int empId in empIds)
     {
         Employee employee = PayrollDatabase.GetEmployee(empId);
         if (employee.IsPayDate(payDate))
         {
             //DateTime startDate = employee.GetPayPeriodStartDate(payDate);
             //Paycheck pc = new Paycheck(startDate, payDate); //
             Paycheck pc = new Paycheck(payDate);
             paychecks[empId] = pc;
             employee.PayDay(pc);
         }
     }
 }
Ejemplo n.º 34
0
 public void Pay(Paycheck paycheck)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 35
0
 public void Pay(Paycheck paycheck)
 {
     paycheck.Setfield("Disposition","Hold");
 }
 public double CalculatePay(Paycheck paycheck)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 37
0
 public override double CalculatePay(Paycheck paycheck)
 {
     return salary;
 }
Ejemplo n.º 38
0
 public abstract double CalculatePay(Paycheck paycheck);
Ejemplo n.º 39
0
 public void DepositPaycheck(Paycheck paycheck, long intoAccountId)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 40
0
 public void Pay(Paycheck paycheck)
 {
 }
Ejemplo n.º 41
0
 public double CalculateDeductions(Paycheck paycheck)
 {
     return 0;
 }