private decimal CalculateAnnualGrossPay(Payroll employeePayroll)
        {
            if (employeePayroll == null)
                return 0;

            return employeePayroll.GrossMonthlySalary*employeePayroll.NumberOfChecks;
        }
        public PayrollDetails CalculatePayrollDetails(Payroll employeePayroll, IEnumerable<Dependents> employeeDependents, string name)
        {
            var grossAnnualPay = CalculateAnnualGrossPay(employeePayroll);

            var dependentsDeductions = CalculateAnnualDependentDeductions(employeeDependents.Count());

            var annualDeductions = CalculateAnnualDeductions(dependentsDeductions);

            var annualSavings = CalculateAnnualSavings(annualDeductions, employeeDependents, name);

            return CreatePayrollDetail(grossAnnualPay, dependentsDeductions, annualSavings);
        }
        public List<Payroll> GetPayrolls()
        {
            var dal = new EmployeeDAL();
            var employees = dal.GetAllEmployees();

            var payrolls = new List<Payroll>();

            foreach (var employee in employees)
            {
                var payroll = new Payroll {Employee = employee, Pay = 100000.0};
                payrolls.Add(payroll);
            }
            return payrolls;
        }
        public ActionResult Save(Payroll payroll)
        {
            if (!ModelState.IsValid)
            {
                using (var db = new nominaDBContext())
                {
                    var viewModel = new PayrollViewModel()
                    {
                        employeeList = db.Employee.Include(e => e.Payroll).Where(e => e.Payroll.Count() == 0 && e.Active).ToList(),
                        Payroll      = payroll
                    };
                    return(View("Edit", viewModel));
                }
            }


            using (var db = new nominaDBContext())
            {
                var employeeInDb   = db.Employee.Find(payroll.EmployeeId);
                var afp            = Convert.ToDouble(employeeInDb.GrossSalary) * 0.0287;
                var ars            = Convert.ToDouble(employeeInDb.GrossSalary) * 0.0304;
                var taxableSalary  = employeeInDb.GrossSalary - Convert.ToDecimal((afp + ars));
                var isr            = calculateISR(Convert.ToDouble(taxableSalary));
                var retentionTotal = afp + ars + isr;

                var newPayroll = new Payroll()
                {
                    EmployeeId     = payroll.EmployeeId,
                    GrossSalary    = employeeInDb.GrossSalary,
                    RetentionAfp   = afp,
                    RetentionArs   = ars,
                    TaxableSalary  = taxableSalary,
                    RetentionIsr   = isr,
                    RetentionTotal = retentionTotal,
                    NetIncome      = employeeInDb.GrossSalary - Convert.ToDecimal(retentionTotal)
                };

                db.Payroll.Add(newPayroll);

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #5
0
 private void MultSaveBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to adjust the current rates multipliers?",
                                  "Rates Multipliers", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try {
             Payroll.SetRates(MultDTPKR.Value, double.Parse(RatesL2.Value.ToString("N2")),
                              double.Parse(RatesL3.Value.ToString("N2")), double.Parse(RatesL4.Value.ToString("N2")),
                              double.Parse(RatesL5.Value.ToString("N2")),
                              double.Parse(RatesL6.Value.ToString("N2")), double.Parse(RatesL7.Value.ToString("N2")),
                              double.Parse(RatesL8.Value.ToString("N2")), double.Parse(RatesL9.Value.ToString("N2")));
             MultEditMode(false);
             LoadRatesMult();
         }
         catch (Exception ex) {
             ShowErrorBox("Rates Multipliers", ex.Message);
         }
     }
 }
Beispiel #6
0
        public void EmployeeWithTwoDependentsAndNoDiscount()
        {
            //setup
            var employee = new Employee("Deanna", "Troi");

            employee.AddDependent(new Dependent("Daughter1", "Troi", "child"));
            employee.AddDependent(new Dependent("Son1", "Troi", "child"));

            var samplePayroll = new Payroll()
            {
                Benefit = defaultBenefit, Employee = employee
            };

            // execute
            var benefitCost = calculator.ComputeBenefitCostPerYear(samplePayroll);

            //assert
            Assert.AreEqual(employeeBenefitCost + (dependentBenefitCost * 2), benefitCost);
        }
 private void btnGeneratePayroll_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Driver driver = (Driver)cboRouteDriver.SelectedItem;
         Payroll payroll = new Payroll(driver, Convert.ToInt32(txtDistance.Text));
         payroll.DeparturePoint = txtDeparturePoint.Text;
         payroll.DestinationPont = txtDestination.Text;
         payroll.Driver = driver;
         payroll.DriverName = payroll.Driver.ToString();
         payroll.Distance = Convert.ToInt32(txtDistance.Text);
         txtTotalPay.Text = payroll.TotalPay.ToString();
         
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #8
0
        public bool Payroll(int employeeId)
        {
            var employeeDetails = db.EmployeeDetails.FirstOrDefault(e => e.Id == employeeId);

            int basicsalary = (int)employeeDetails.Salary;

            int ConveyanceAllowance = 0, MedicalAllowance = 0, HouseRentAllowance = 0, NetSalary = 0, TotalAllowances;

            if (basicsalary >= 40000)
            {
                ConveyanceAllowance = basicsalary * 20 / 100;
                MedicalAllowance    = basicsalary * 30 / 100;
                HouseRentAllowance  = basicsalary * 40 / 100;
            }
            else if (basicsalary >= 35000)
            {
                ConveyanceAllowance = basicsalary * 15 / 100;
                MedicalAllowance    = basicsalary * 25 / 100;
                HouseRentAllowance  = basicsalary * 30 / 100;
            }
            else if (basicsalary >= 30000)
            {
                ConveyanceAllowance = basicsalary * 10 / 100;
                MedicalAllowance    = basicsalary * 20 / 100;
                HouseRentAllowance  = basicsalary * 25 / 100;
            }
            else
            {
                ConveyanceAllowance = 0;
                MedicalAllowance    = 0;
                HouseRentAllowance  = 0;
            }
            TotalAllowances = ConveyanceAllowance + MedicalAllowance + HouseRentAllowance;
            NetSalary       = basicsalary + TotalAllowances;
            Payroll p = new Payroll();

            p.EmployeeId  = employeeId;
            p.BasicSalary = basicsalary;
            p.Allowances  = TotalAllowances;
            db.Payrolls.Add(p);
            db.SaveChanges();
            return(true);
        }
 public bool EditPayroll(int PayrollID, int WorkDay, int Bonus, int Penalty, int Total, string Currency, string Desc)
 {
     try
     {
         Payroll payroll = context.Payrolls.FirstOrDefault(p => p.PayrollID == PayrollID);
         payroll.WorkDay  = WorkDay;
         payroll.Bonus    = Bonus;
         payroll.Penalty  = Penalty;
         payroll.Total    = Total;
         payroll.Currency = Currency;
         payroll.Desc     = Desc;
         context.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw new Exception("Error Edit Payroll: " + e.Message);
     }
 }
Beispiel #10
0
        protected override void DeletePayrollAction()
        {
            if (!ControlsMng.IsCurrentItemValid(Payrolls_DGW))
            {
                return;
            }

            Payroll item = ControlsMng.GetCurrentItem(Payrolls_DGW) as Payroll;

            if (item.OidPago != 0)
            {
                PgMng.ShowInfoException(Resources.Messages.NOMINA_CON_PAGO);
                return;
            }

            _entity.Nominas.Remove(_entity, item);

            Payrolls_BS.DataSource = _entity.Nominas;
        }
Beispiel #11
0
        /// <summary>
        /// les donnee concernant une salaire
        /// </summary>
        public PayrollCard (Payroll payroll)
        {
            PayrollGuid=payroll.PayrollGuid;
            Designation=payroll.Designation;
            IsPaid = payroll.IsPaid;
            TotalSalary = 0;

            Employment employ;
            using (var db = new WinxoContext()) employ=db.Employments.Find(payroll.EmploymentGuid);

            var payrollStart = employ.SalaryRecurrence == InstallmentRecurrence.Once ? employ.StartDate.GetValueOrDefault() 
                               : payroll.PaycheckDate.GetValueOrDefault().AddMonths(-((int)employ.SalaryRecurrence));

            switch (employ.PayType)
            {
                
                //case PayType.HoursWorked:
                //    TotalSalary=(payroll.HoursWorked.TotalMinutes*(employ.HourlyPay/60));
                //    RenumerationsCards.Add(new DataCard {
                //        Info1="Heures Travaillées",
                //        Info2=payroll.HoursWorked.TotalHoursMins(),
                //        Info3=TotalSalary.ToString("0.##", CultureInfo.CurrentCulture)+" dhs"
                //    });
                //    break;
            }

            foreach (var salary in PayrollManager.StaticGetSalaries(employ.EmploymentGuid, payrollStart, payroll.PaycheckDate)) {
                RenumerationsCards.Add(new ViewCard(salary));
                TotalSalary+= salary.Remuneration;
            }

            if (payroll.PaycheckDate > DateTime.Today)
                TotalSalaryString="Estimation: "+TotalSalary.ToString("0.##", CultureInfo.CurrentCulture)+" dhs";
            else
                TotalSalaryString="Total: "+TotalSalary.ToString("0.##", CultureInfo.CurrentCulture)+" dhs";         

            if (!payroll.IsPaid) return;
            TotalSalary = payroll.FinalPaycheck;
            TotalSalaryString ="Paid: "+TotalSalary.ToString("0.##", CultureInfo.CurrentCulture)+" dhs";
            NumeroReference="Ref: "+payroll.NumeroReference;
            Observations = "Finance User ("+payroll.DatePaid.GetValueOrDefault().ToShortDateString()+")";    //+" par "+payroll.PaymentMethode.GetEnumDescription();
            YesNoColor ="Blue";
        }
Beispiel #12
0
        protected override void EditEmployeeAction()
        {
            if (!ControlsMng.IsCurrentItemValid(Payrolls_DGW))
            {
                return;
            }

            Payroll item = ControlsMng.GetCurrentItem(Payrolls_DGW) as Payroll;

            EmployeeEditForm form = new EmployeeEditForm(item.OidEmpleado, this);

            form.ShowDialog();

            if (form.ActionResult == DialogResult.OK)
            {
                _employees.GetItem(item.OidEmpleado).CopyFrom(form.Entity);
                CalculatePayrollAction();
            }
        }
        public override void ChangeStateAction(EEstadoItem estado)
        {
            switch (estado)
            {
            case EEstadoItem.Unlock:
                _entity = Payroll.ChangeEstado(ActiveOID, moleQule.Base.EEstado.Abierto);
                break;

            case EEstadoItem.Contabilizado:
                _entity = Payroll.ChangeEstado(ActiveOID, moleQule.Base.EEstado.Contabilizado);
                break;

            case EEstadoItem.Emitido:
                _entity = Payroll.ChangeEstado(ActiveOID, moleQule.Base.EEstado.Emitido);
                break;
            }

            _action_result = DialogResult.OK;
        }
Beispiel #14
0
        public void PayrollCostTocompany_CalculatePayrollCostTocompany_ReturnPayrollCostTocompany()
        {
            var payroll = new Payroll();

            List <HrEmployee> Employees = new List <HrEmployee>();
            var Employee1 = new HrEmployee();

            Employee1.Salary = 500000;
            Employees.Add(Employee1);

            var Employee2 = new HrEmployee();

            Employee2.Salary = 250000;
            Employees.Add(Employee2);

            var result = (int)payroll.PayrollCostTocompany(Employees);

            Assert.AreEqual(result, 750000);
        }
        public ActionResult Create(Payroll payroll, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null && file.ContentLength > 0)
                {
                    string name = Path.GetFileName(file.FileName);
                    string path = "~/Images/" + name;

                    file.SaveAs(Server.MapPath(path));
                    db.Payrolls.Add(new Payroll
                    {
                        PayrollID   = payroll.PayrollID,
                        Amount      = payroll.Amount,
                        PaymentType = payroll.PaymentType,
                        PaymentDate = payroll.PaymentDate,
                        EmployeeId  = payroll.EmployeeId,
                        ImagePath   = path
                    });
                    db.SaveChanges();
                }
                else
                {
                    db.Payrolls.Add(new Payroll
                    {
                        PayrollID   = payroll.PayrollID,
                        Amount      = payroll.Amount,
                        PaymentType = payroll.PaymentType,
                        PaymentDate = payroll.PaymentDate,
                        EmployeeId  = payroll.EmployeeId
                    });
                    db.SaveChanges();
                }



                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeID", "FullName", payroll.EmployeeId);
            return(View(payroll));
        }
Beispiel #16
0
        public void EmployeeWithDependentDiscount()
        {
            //setup
            var employee = new Employee("Commander", "Worf");

            employee.AddDependent(new Dependent("Alexander", "Worf", "child"));

            var samplePayroll = new Payroll()
            {
                Benefit = defaultBenefit, Employee = employee
            };

            // execute
            var benefitCost = calculator.ComputeBenefitCostPerYear(samplePayroll);

            //assert
            var expectedcost = employeeBenefitCost + dependentBenefitCost - (dependentBenefitCost * discount);

            Assert.AreEqual(expectedcost, benefitCost);
        }
Beispiel #17
0
        protected override void SetGridFormat()
        {
            foreach (DataGridViewRow row in Payrolls_DGW.Rows)
            {
                if (row.IsNewRow)
                {
                    return;
                }

                Payroll item = (Payroll)row.DataBoundItem;

                if (item.OidPago != 0)
                {
                    row.Cells[ImporteNomina.Index].ReadOnly        = true;
                    row.Cells[ImporteNomina.Index].Style.BackColor = Face.ControlTools.Instance.ReadOnlyStyle.BackColor;
                }

                Face.Common.ControlTools.Instance.SetRowColor(row, item.EEstado);
            }
        }
        public bool UpdatePayroll(int id, Payroll data)
        {
            var res = _context.Payroll.FirstOrDefault(x => x.id == id);

            if (res == null)
            {
                return(false);
            }

            res.accrualId       = data.accrualId;
            res.employeeId      = data.employeeId;
            res.typeAccrualId   = data.typeAccrualId;
            res.amount          = data.amount;
            res.periodDateStart = data.periodDateStart;
            res.periodDateEnd   = data.periodDateEnd;
            res.cause           = data.cause;
            res.deleted         = data.deleted;
            _context.SaveChanges();
            return(true);
        }
Beispiel #19
0
        private void ButtonAddPay_Click(object sender, EventArgs e)
        {
            Payroll    pay    = GetPaymentMembers();
            PayrollBLL payBLL = new FulltimePayrollBLL();
            // check salary match with the work type
            bool checkResult = payBLL.CheckWorkType(pay);

            if (checkResult)
            {
                int id = ctr.addPayment(pay);
                MessageBox.Show("Add success!\n ",
                                "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                resetPayroll();
            }
            else
            {
                MessageBox.Show("Salary is not match with the work type!\n ",
                                "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #20
0
        public ActionResult PayrollView(string bname)
        {
            Payroll pObj = new Payroll();

            using (SqlConnection con = new SqlConnection("Data Source=RAHUL\\SQLEXPRESS01;Initial Catalog=Commercial;Integrated Security=True"))
            {
                string sqlQuery = "select * from BUSINESS where business_name='" + bname + "'";
                con.Open();
                SqlCommand    sqlCmd = new SqlCommand(sqlQuery, con);
                SqlDataReader sdr    = sqlCmd.ExecuteReader();
                if (sdr.Read())
                {
                    pObj.business_id     = Convert.ToInt32(sdr["business_id"]);
                    pObj.annual_revenue  = Convert.ToInt32(sdr["annual_revenue"]);
                    pObj.no_of_employees = Convert.ToInt32(sdr["number_of_employees"]);
                }
                con.Close();
            }
            return(View(pObj));
        }
Beispiel #21
0
        internal void updatePayment(Payroll pay)
        {
            PayrollBLL  payrollBLL;
            EmployeeDAL empDAL = new EmployeeDAL();
            Employee    emp    = empDAL.getItem(pay.EmployeeID);

            if (emp.WorkType == "Full time")
            {
                payrollBLL      = new FulltimePayrollBLL();
                pay.TotalSalary = payrollBLL.CalcSalary(pay);
                pay.Tax         = payrollBLL.CalcTax(pay.TotalSalary);
            }
            else
            {
                payrollBLL      = new ParttimePayrollBLL();
                pay.TotalSalary = payrollBLL.CalcSalary(pay);
                pay.Tax         = payrollBLL.CalcTax(pay.TotalSalary);
            }
            payDAL.updateItem(pay);
        }
        private void ConfigurePayrollViewModel(PayrollViewModel model)
        {
            var     date    = DateTime.Now.Date;
            Payroll payroll = new Payroll()
            {
                WorkerId           = model.WorkerId,
                Worker             = model.Worker,
                PositionId         = model.PositionId,
                Position           = model.Position,
                VacationBonus      = model.VacationBonus,
                CountofAbsentDays  = model.CountofAbsentDays,
                Bonus              = model.Bonus,
                ShopBonus          = model.ShopBonus,
                TotalSalary        = model.TotalSalary,
                DateOfPaidSalaries = date
            };

            _dbContext.Payrolls.Add(payroll);
            _dbContext.SaveChanges();
        }
Beispiel #23
0
        private void ButtonUpdatePay_Click(object sender, EventArgs e)
        {
            Payroll pay = GetPaymentMembers();

            pay.SalaryID = int.Parse(textBoxPayID.Text);
            PayrollBLL payBLL      = new FulltimePayrollBLL();
            bool       checkResult = payBLL.CheckWorkType(pay);

            if (checkResult)
            {
                ctr.updatePayment(pay);
                MessageBox.Show("Update success!\n ",
                                "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                resetPayroll();
            }
            else
            {
                MessageBox.Show("Salary is not match with the work type!\n ",
                                "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #24
0
        public async Task <ActionResult <Payroll> > Delete([FromBody] Payroll _payroll)
        {
            Payroll _payrollq = new Payroll();

            try
            {
                _payrollq = _context.Payroll
                            .Where(x => x.IdPlanilla == (Int64)_payroll.IdPlanilla)
                            .FirstOrDefault();

                _context.Payroll.Remove(_payrollq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_payrollq)));
        }
Beispiel #25
0
        public void Cancel(Payroll payroll)
        {
            using (var context = new CERPContext())
            {
                var wagePayment = context.WagePayments.SingleOrDefault(w => w.WagePaymentID == payroll.PayrollID);
                if (wagePayment == null)
                {
                    throw new Exception("Payroll not found");
                }

                // TODO: Check the Payroll has not already been confirmed
                var wagePaymentStatus = new WagePaymentStatusHistory
                {
                    WagePayment           = wagePayment,
                    WagePaymentStatusCode = "CNCL",
                    StatusChangedDate     = DateTime.Now
                };
                context.WagePaymentStatusHistory.Add(wagePaymentStatus);
                context.SaveChanges();
            }
        }
Beispiel #26
0
        private void miCalculerPayroll_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MdiChild mdiChild = new MdiChild();

                Payroll pay = sess_emp.GetPayroll();
                mdiChild.Content =
                    new FenRapport(this.MainMdiContainer, pay);
                mdiChild.Title      = "Rapport d'Employés";
                mdiChild.Height     = 650;
                mdiChild.Width      = 900;
                mdiChild.Background = MyGradientBrush.getBackgroundBrush();

                this.MainMdiContainer.Children.Add(mdiChild);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public ActionResult Edit(Int32 id)
        {
            PayrollDetailsViewModel lPayroll = new PayrollDetailsViewModel();

            lPayroll.EmployeePayrolls = new List <EmployeePayrollViewModel>();

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                Payroll lFindPayroll = db.Payroll.Find(id);
                if (lFindPayroll != null)
                {
                    List <PayrollDetails> lFindDetails = lFindPayroll.Details.ToList();
                    lFindDetails.ForEach(x =>
                    {
                        EmployeePayrollViewModel lEmployeeDetails = new EmployeePayrollViewModel();
                        lEmployeeDetails.EmployeeId    = x.EmployeeId;
                        lEmployeeDetails.Name          = $"{x.Employee.LastName}, {x.Employee.FirstName}";
                        lEmployeeDetails.PayRateType   = x.Employee.RateType.ToString();
                        lEmployeeDetails.PayRate       = x.Employee.Rate;
                        lEmployeeDetails.StandardHours = x.HoursStandardWorked;
                        lEmployeeDetails.OvertimeHours = x.HoursOvertimeWorked;
                        lEmployeeDetails.Deductions    = x.Deductions;

                        if (x.Employee.RateType == PayRateType.Hourly)
                        {
                            lEmployeeDetails.GrossPay = ((x.HoursStandardWorked * x.Employee.Rate) + (1.5M * x.Employee.Rate * x.HoursOvertimeWorked)) - x.Deductions;
                        }
                        else
                        {
                            lEmployeeDetails.GrossPay = ((x.Employee.Rate / 2080) * 40) - x.Deductions;
                        }

                        lEmployeeDetails.NetPay = lEmployeeDetails.GrossPay - lEmployeeDetails.Deductions;
                        lPayroll.EmployeePayrolls.Add(lEmployeeDetails);
                    });
                }
            }

            return(View("EditPayroll", lPayroll));
        }
Beispiel #28
0
        /// <summary>
        /// 新增工资页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AddPay()
        {
            Model.EmployeeInfo em = (Model.EmployeeInfo)Session["Employeer"];

            //查询所有员工
            EmployeeDal         edal   = new EmployeeDal();
            List <EmployeeInfo> emlist = edal.GetAllEmployeerElse(em.ID);

            ViewBag.allem = emlist;

            EmployeeDal dal = new EmployeeDal();

            if (Request["BasicWage"] != null)
            {
                int?id = Convert.ToInt32(Request["EmployeeId"]);
                //查询工资是否已经添加
                Payroll isexists = dal.GetPayByid(id);
                if (isexists != null)
                {
                    return(Content("1"));
                }
                else
                {
                    Payroll pay = new Payroll();
                    pay.BasicWage = Convert.ToInt32(Request["BasicWage"]);
                    pay.CommunicationAllowance = Convert.ToInt32(Request["CommunicationAllowance"]);
                    pay.EmployeeId             = id;
                    pay.LunchAllowance         = Convert.ToInt32(Request["LunchAllowance"]);
                    pay.MeritPay         = Convert.ToInt32(Request["MeritPay"]);
                    pay.TrafficAllowance = Convert.ToInt32(Request["TrafficAllowance"]);
                    bool isadd = dal.AddPay(pay);
                    if (isadd)
                    {
                        return(Content("0"));
                    }
                }
            }

            return(View());
        }
Beispiel #29
0
        /// <summary>
        /// Saves the payroll.
        /// </summary>
        /// <param name="payrollInfo">The payroll information.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">payrollInfo</exception>
        public async Task <int> SavePayroll(IPayrollView payrollInfo)
        {
            if (payrollInfo == null)
            {
                throw new ArgumentNullException(nameof(payrollInfo));
            }

            string result = string.Empty;

            var newRecord = new Payroll
            {
                BasicSalary      = payrollInfo.BasicSalary,
                EmployeeId       = payrollInfo.EmployeeId,
                CompanyId        = payrollInfo.CompanyId,
                NetSalary        = payrollInfo.NetSalary,
                IsActive         = true,
                DateCreated      = DateTime.UtcNow,
                PayrollHistoryId = payrollInfo.PayrollHistoryId
            };

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.Payrolls.Add(newRecord);
                    await dbContext.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                result = string.Format("Save payroll info - {0}, {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }


            int payrollId = newRecord.PayrollId;

            return(payrollId);
        }
        public ActionResult Calculate(BonusPoolCalculatorModel model)
        {
            int        selectedEmployeeId = model.SelectedEmployeeId;
            int        totalBonusPool     = model.BonusPoolAmount;
            HrEmployee hrEmployee         = (HrEmployee)db.HrEmployees.FirstOrDefault(item => item.ID == selectedEmployeeId);

            Payroll payroll = new Payroll();

            payroll.AllEmployees       = getEmployees();
            payroll.TotalCostToCompany = payroll.PayrollCostTocompany(payroll.AllEmployees);

            BonusPool bonusPool = new BonusPool();

            bonusPool.BonusPoolAmount = totalBonusPool;

            BonusPoolCalculatorResultModel result = new BonusPoolCalculatorResultModel();
            Allocation allocation = new Allocation();

            result.hrEmployee          = hrEmployee;
            result.bonusPoolAllocation = allocation.BonusAllocationCalculation(hrEmployee, payroll, bonusPool);
            return(View(result));
        }
        public ActionResult CalculatePayroll([Bind(Include = "FirstName,LastName, Month, AnnualSalary, Super")] PayrollModel payroll)
        {
            if (ModelState.IsValid)
            {
                IPayroll        payrollHelper  = new Payroll(payroll.AnnualSalary);
                ISuperAnnuation superAnnuation = new SuperAnnuation(payroll.AnnualSalary, payroll.Super);

                var payrollModel = new PayrollModel
                {
                    FullName    = payroll.FirstName + ' ' + payroll.LastName,
                    Month       = payroll.Month,
                    Payperiod   = payrollHelper.GetPayPeriod(payroll.Month),
                    GrossIncome = payrollHelper.CalculateGrossIncome(),
                    NetIncome   = payrollHelper.CalcualteNetIncome(),
                    IncomeTax   = payrollHelper.CaclulateIncomeTax(),
                    SuperFund   = superAnnuation.CalculateSuperAnnuation()
                };

                return(View("Index", payrollModel));
            }
            return(View("Index"));
        }
Beispiel #32
0
        public List <Payroll> GetAllPayrollListEmployee(string eid)
        {
            List <Payroll> payrollList = new List <Payroll>();

            string     query = "select employeeId,SalaryAmount,BonusAmount,departmentId from payroll where employeeID='" + eid + "'";
            SqlCommand cmd   = da.GetCommand(query);

            cmd.Connection.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Payroll p = new Payroll();
                p.employeeId   = reader.GetString(0);
                p.SalaryAmount = reader.GetInt32(1);
                p.bonusAmount  = reader.GetInt32(2);
                p.departmentId = reader.GetString(3);

                payrollList.Add(p);
            }
            return(payrollList);
        }
Beispiel #33
0
        private Payroll ClosePayroll(Employee employee, List <LiquidationDocument> liquidation)
        {
            liquidation.OfType <Absency>().ToList().ForEach(absency => absency.Amount = -employee.DailySalary());
            liquidation.Add(new Salary {
                Amount = employee.Salary, Employee = employee, EmployeeId = employee.Id
            });

            var payroll = new Payroll()
            {
                Employee        = employee,
                EmployeeId      = employee.Id,
                PreviousBalance = employee.Balance,
                Liquidation     = liquidation,
                Balance         = employee.Balance + liquidation.Select(x => x.Amount).DefaultIfEmpty(0).Sum()
            };

            employee.Accept(payroll);

            _payrollRepository.Add(payroll);

            return(payroll);
        }
Beispiel #34
0
        public async Task <string> UpdatePayroll(int id, Payroll payroll)
        {
            try
            {
                var res = await _context.Payrolls.FirstOrDefaultAsync(m => m.PayrollId == id);

                res.Month            = payroll.Month;
                res.Year             = payroll.Year;
                res.TotalPresent     = payroll.TotalPresent;
                res.TotalAbsent      = payroll.TotalAbsent;
                res.LeaveDays        = payroll.LeaveDays;
                res.Deduction        = payroll.Deduction;
                res.LeaveStatus      = payroll.LeaveStatus;
                res.FestivalAdvance  = payroll.FestivalAdvance;
                res.HousingLoan      = payroll.HousingLoan;
                res.VehicleLoan      = payroll.VehicleLoan;
                res.OtherLoan        = payroll.OtherLoan;
                res.LossOfPay        = payroll.LossOfPay;
                res.Tds              = payroll.Tds;
                res.ProfessionalFees = payroll.ProfessionalFees;
                res.OtherDeductions  = payroll.OtherDeductions;
                res.TotalEarnings    = payroll.TotalEarnings;
                res.OtherPay         = payroll.OtherPay;
                res.BasicSalary      = payroll.BasicSalary;
                res.SalaryPerDay     = payroll.SalaryPerDay;
                res.Pay              = payroll.Pay;
                res.Earnings         = payroll.Earnings;
                res.Deductions       = payroll.Deductions;
                res.NetPay           = payroll.NetPay;
                _context.Update(res);
                await _context.SaveChangesAsync();

                return("Updated Record");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void cloudDesktopButton4_Click(object sender, EventArgs e)
 {
     Payroll obj = new Payroll();
     obj.Show();
 }