private void CalcIncomeTax(EmployeeInfo employeeInfo, Payslip payslip)
 {
     payslip.IncomeTax = this.taxRuleService.CalculateTaxRule(employeeInfo.AnnualSalary);
 }
        public void CalculatePayslip_ShouldReturnPayslip()
        {
            // Arrange
            EmployeeInfo employeeInfo = new EmployeeInfo
            {
                FirstName = "David",
                LastName = "Rudd",
                AnnualSalary = 60050,
                SuperRate = 0.09M,
                PaymentStartDate = "01 March – 31 March",
            };

            // Act
            Payslip actual = this.employeeIncomeService.CalculatePayslip(employeeInfo);

            // Assert
            Payslip expected = new Payslip
            {
                Name = "David Rudd",
                PayPeriod = "01 March – 31 March",
                GrossIncome = 5004,
                IncomeTax = 922,
                NetIncome = 4082,
                Super = 450
            };

            actual.ShouldBeEquivalentTo(expected);
        }
        public Payslip CalculatePayslip(EmployeeInfo employeeInfo)
        {
            this.CheckSuperRate(employeeInfo);
            this.CheckAnnualSalary(employeeInfo);

            Payslip payslip = new Payslip();

            this.CalcName(employeeInfo, payslip);
            this.CalcPayPeriod(employeeInfo, payslip);
            this.CalcGrossIncome(employeeInfo, payslip);
            this.CalcIncomeTax(employeeInfo, payslip);
            this.CalcNetIncome(payslip);
            this.CalcSuper(employeeInfo, payslip);

            return payslip;
        }
 private void btnCalculate_Click(object sender, EventArgs e)
 {
     try
     {
         decimal pay;
         if (!decimal.TryParse(txtTaxablePay.Text, out pay))
         {
             MessageBox.Show("Enter a valid taxable pay");
             return;
         }
         PayslipMaker pm    = new PayslipMaker(pay, connection);
         Payslip      pslip = pm.CreateAnonymousPayslip();
         dataGridViewTaxCalculator.DataSource = pslip.TaxBracketList;
         lblGrossTax.Text = pslip.GrossTax.ToString("C2");
     }
     catch (Exception ex)
     {
         Utils.ShowError(ex);
     }
 }
Esempio n. 5
0
        public static void AddPayslip(Payslip payslip)
        {
            EMSEntities datacontext = new EMSEntities();

            try
            {
                datacontext.Payslips.Add(payslip);
                datacontext.SaveChanges();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                throw exception;
            }
            finally
            {
                datacontext.Dispose();
            }
        }
        public async Task <ActionResult> GetPayslip([FromBody] Employee emp)
        {
            if (ModelState.IsValid)
            {
                Payslip payslip = null;

                payslip = await _webApiCallerService.WebApiCallerPost <Employee, Payslip>("api/Payslip", emp);

                if (payslip == null)
                {
                    return(View("Index"));
                }

                return(View(payslip));
            }
            else
            {
                //ViewBag.ErrorMessage = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors).Select(v => v.ErrorMessage));
                return(View("CreatePayslip"));
            }
        }
        public IEnumerable <Payslip> Read(string filePath)
        {
            var lines    = System.IO.File.ReadAllLines(filePath);
            var payslips = new List <Payslip>();

            foreach (var line in lines)
            {
                var cells   = line.Split(',');
                var payslip = new Payslip
                {
                    Name        = cells[0],
                    PayPeriod   = cells[1],
                    GrossIncome = Decimal.Parse(cells[2]),
                    IncomeTax   = Decimal.Parse(cells[3]),
                    NetIncome   = Decimal.Parse(cells[4]),
                    Super       = Decimal.Parse(cells[5])
                };
                payslips.Add(payslip);
            }
            return(payslips);
        }
Esempio n. 8
0
        public MakePayslipPDF(Payslip PayslipModel, Document doc, string Conn)
        {
            if (PayslipModel == null)
            {
                throw new ArgumentNullException("PayslipViewModel is null");
            }
            _ViewModel = PayslipModel;


            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            de  = new DataEntry(connection);
            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            document = doc;
        }
        public List <Payslip> GetPayslips()
        {
            try
            {
                var payslips = new List <Payslip>();

                foreach (var employee in employees)
                {
                    var payslip = new Payslip()
                    {
                        EmployeeDetails = employee
                    };

                    payslips.Add(payslip);
                }

                return(payslips);
            }
            catch (Exception)
            {
                //log exception details
                return(null);
            }
        }
Esempio n. 10
0
        private Payslip calculateThePaySlip()
        {
            Payslip payslip = new Payslip();

            //set the user details, say header of the payslip
            payslip.stringFirstName     = this.stringFirstName;
            payslip.stringLastName      = this.stringLastName;
            payslip.stringPayslipPeriod = this.dateTimePickerPaysleepPeriod.Value.ToString("MMM yyyy");

            // set the calculated values
            // this is mm yyyy
            // we should get the number of days after the start date of employment
            // here we assume the employee has been working the full month
            // and we don't check the employment start date
            Calculator calculator = new Calculator(stringPayslipPeriod, uintAnnualSalary, uintSuperRate);

            payslip.decimalGrossIncome = calculator.getGrossIncome();
            payslip.decimalIncomeTax   = calculator.getIncomeTax();
            payslip.decimalNetIncome   = calculator.getNetIncome();
            payslip.decimalSuper       = calculator.getSuper();

            // ready for display
            return(payslip);
        }
Esempio n. 11
0
 public async Task <Payslip> UpdateAsync(Payslip item)
 {
     return(await Payslips.UpdateAsync(item));
 }
Esempio n. 12
0
 public void OutputPayslip(Payslip payslip)
 {
     Payslip = payslip;
 }
Esempio n. 13
0
 public VikePayslipViewModel(Payslip payslip)
 {
     _Payslip = payslip;
 }
        public void GeneratesPayslipWithCorrectData(Employee employee, PayPeriod payPeriod, Payslip expected)
        {
            var taxCalculator           = new TaxCalculator(SetUpTestTaxTable());
            var monthlyPayslipGenerator = new MonthlyPayslipGenerator(taxCalculator);
            var actual = monthlyPayslipGenerator.Generate(employee, payPeriod);

            Assert.Equal(expected.GrossIncome, actual.GrossIncome);
        }
 private void CalcPayPeriod(EmployeeInfo employeeInfo, Payslip payslip)
 {
     payslip.PayPeriod = employeeInfo.PaymentStartDate;
 }
 private void CalcNetIncome(Payslip payslip)
 {
     payslip.NetIncome = payslip.GrossIncome - payslip.IncomeTax;
 }
Esempio n. 17
0
        private void initializeForm(Payslip payslip)
        {
            RequestControllerInterface       requestController       = new RequestController();
            MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController();
            SalaryControllerInterface        salaryController        = new SalaryController();
            AttendanceControllerInterface    attendanceController    = new AttendanceController();

            employeeFullName.Text = payslip.employee.fullName;
            dateEmployed.Text     = payslip.employee.dateEmployed;
            employeeNumber.Text   = payslip.employee.employeeId.ToString();
            position.Text         = payslip.employee.jobPosition.name;
            startDatePeriod.Text  = payslip.startDatePeriod.ToString();
            endDatePeriod.Text    = payslip.endDatePeriod.ToString();
            datePayable.Text      = payslip.dateCreated.ToString();
            positionName.Text     = payslip.employee.jobPosition.name;
            dailyRate.Text        = payslip.employee.jobPosition.salary.ToString("0.##");
            hourlyRate.Text       = calculateHourlyRate(payslip.employee.jobPosition.salary).ToString("0.##");
            TimeSpan timeSpent = fetchTotalHoursSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, attendanceController);

            hoursSpent.Text = Math.Round(timeSpent.TotalHours, 2).ToString();
            decimal totalBasePayAmount = calculateTotalBasePay(timeSpent, payslip.employee.jobPosition.salary);

            totalBasePay.Text = totalBasePayAmount.ToString("0.##");
            decimal foodAllowanceAmount      = fetchFoodAllowance(payslip, miscellaneousController);
            decimal totalFoodAllowanceAmount = calculateTotalSpecificAllowance(foodAllowanceAmount, timeSpent);

            foodAllowance.Text = totalFoodAllowanceAmount.ToString("0.##");
            decimal transpoAllowanceAmount      = fetchTranspoAllowance(payslip, miscellaneousController);
            decimal totalTranspoAllowanceAmount = calculateTotalSpecificAllowance(transpoAllowanceAmount, timeSpent);            transportation.Text = totalTranspoAllowanceAmount.ToString("0.##");
            decimal thirteenMonth = 0.00M;

            overtimeHours.Text = Math.Round(fetchTotalHoursOvertimeSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController).TotalHours, 2).ToString();
            decimal totalOvertimeAmount = calculateDailyBasedSalaryWithOvertimeRequests(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            overtimeAmount.Text = totalOvertimeAmount.ToString("0.##");

            List <Request> leaveRequests     = requestController.fetchLeaveRequest(payslip.employee, payslip.startDatePeriod, payslip.endDatePeriod);
            decimal        totalLeaveRequest = salaryController.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, payslip.employee.jobPosition.salary);

            if (hasLeaveRequests(totalLeaveRequest))
            {
                showLeaveFields();
                daysOfLeave.Text   = leaveRequests.Count.ToString();
                totalLeavePay.Text = totalLeaveRequest.ToString("0.##");
            }
            decimal cashAdvanceDeci = calculateTotalCashAdvanceAmount(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            cashAdvanceAmount.Text = cashAdvanceDeci.ToString("0.##");
            tax.Text                   = payslip.taxDeduction.ToString("0.##");
            sss.Text                   = payslip.sssDeduction.ToString("0.##");
            pagIbig.Text               = payslip.pagIbigDeduction.ToString("0.##");
            philHealth.Text            = payslip.philHealthDeduction.ToString("0.##");
            thirteenthMonthPay.Visible = false;
            if (payslip.thirteenMonthPay > 0.00M)
            {
                thirteenthMonthPay.Visible = true;
                thirteenthMonthPay.Text    = payslip.thirteenMonthPay.ToString("0.##") + " day/s";
            }

            earnings.Text          = totalBasePayAmount.ToString("0.##");
            benefits.Text          = (totalFoodAllowanceAmount + totalTranspoAllowanceAmount).ToString("0.##");
            extrasTotalAmount.Text = (totalOvertimeAmount + thirteenMonth + totalLeaveRequest).ToString("0.##");
            deductions.Text        = ((decimal.Round(payslip.taxDeduction, 2) + decimal.Round(payslip.sssDeduction, 2) + decimal.Round(payslip.pagIbigDeduction, 2) + decimal.Round(payslip.philHealthDeduction, 2) + decimal.Round(cashAdvanceDeci, 2)) * -1).ToString("0.##");
            decimal totalSalary = Convert.ToDecimal(earnings.Text) + Convert.ToDecimal(benefits.Text) + Convert.ToDecimal(deductions.Text);

            netPay.Text = totalSalary.ToString("0.##");
        }
Esempio n. 18
0
        public void Generate(Teacher teacher, Payslip payslip, PayrollRecord payrollRecord, string filename)
        {
            var months = new string[] { "Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
                                        "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" };

            var template = PdfReader.Open("fiche_paie.pdf");

            var page = template.Pages[0];

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // Create a font
            XFont titleFont  = new XFont("Calibri", 20, XFontStyle.Bold);
            XFont normalFont = new XFont("Calibri", 12);

            // Draw the text
            //gfx.DrawString("FICHE DE PAIE", titleFont, XBrushes.Black,
            //  new XRect(0, 0, page.Width, page.Height),
            //  XStringFormats.TopCenter);

            // Draw teacher info box
            //var teacherInfoRect = new XRect(50, 50, 150, 100);
            //XPen pen = new XPen(XColors.Black, 1);
            //gfx.DrawRectangle(pen, teacherInfoRect);



            // Draw Teacher info
            gfx.DrawString(teacher.Id.ToString(), normalFont, XBrushes.Black,
                           new XPoint(130, 114), XStringFormats.TopLeft);

            gfx.DrawString(teacher.CIN, normalFont, XBrushes.Black,
                           new XPoint(130, 129), XStringFormats.TopLeft);

            gfx.DrawString(teacher.FullName, normalFont, XBrushes.Black,
                           new XPoint(130, 144), XStringFormats.TopLeft);

            gfx.DrawString(teacher.Grade.ToString(), normalFont, XBrushes.Black,
                           new XPoint(130, 158), XStringFormats.TopLeft);

            gfx.DrawString(teacher.Status.ToString(), normalFont, XBrushes.Black,
                           new XPoint(130, 172), XStringFormats.TopLeft);

            gfx.DrawString(teacher.Speciality, normalFont, XBrushes.Black,
                           new XPoint(130, 188), XStringFormats.TopLeft);

            // Draw Payment info

            gfx.DrawString(months[payslip.Payment.PaymentDate.Month - 1] + " " + payslip.Payment.PaymentDate.Year, normalFont, XBrushes.Black,
                           new XPoint(382, 114), XStringFormats.TopLeft);

            gfx.DrawString(payslip.Payment.PaymentDate.ToString(), normalFont, XBrushes.Black,
                           new XPoint(382, 129), XStringFormats.TopLeft);

            gfx.DrawString(payslip.Payment.PaymentType.ToString(), normalFont, XBrushes.Black,
                           new XPoint(382, 144), XStringFormats.TopLeft);

            gfx.DrawString(payslip.Payment.Bank ?? "", normalFont, XBrushes.Black,
                           new XPoint(382, 158), XStringFormats.TopLeft);

            if (payslip.Payment.PaymentType == PaymentType.BankTransfer)
            {
                gfx.DrawString(payslip.Payment.Reference, normalFont, XBrushes.Black,
                               new XPoint(382, 172), XStringFormats.TopLeft);
            }
            else if (payslip.Payment.PaymentType == PaymentType.Check)
            {
                gfx.DrawString(payslip.Payment.Reference, normalFont, XBrushes.Black,
                               new XPoint(382, 188), XStringFormats.TopLeft);
            }

            // Draw payroll info
            gfx.DrawString(payrollRecord.HoursCount.ToString(), normalFont, XBrushes.Black,
                           new XPoint(36, 238), XStringFormats.TopLeft);

            gfx.DrawString(formatMoney(payrollRecord.Rate), normalFont, XBrushes.Black,
                           new XPoint(135, 238), XStringFormats.TopLeft);;

            gfx.DrawString(formatMoney(payrollRecord.GrossPay), normalFont, XBrushes.Black,
                           new XPoint(245, 238), XStringFormats.TopLeft);

            gfx.DrawString("15%", normalFont, XBrushes.Black,
                           new XPoint(350, 238), XStringFormats.TopLeft);

            gfx.DrawString(formatMoney(payrollRecord.Net), normalFont, XBrushes.Black,
                           new XPoint(447, 238), XStringFormats.TopLeft);

            // Draw total

            gfx.DrawString(formatMoney(payrollRecord.Net), normalFont, XBrushes.Black,
                           new XPoint(447, 636), XStringFormats.TopLeft);


            // Save the document...
            // const string filename = "HelloWorld.pdf";


            template.Save(filename);
            Process.Start(new ProcessStartInfo(/*Directory.GetCurrentDirectory() + "\\" +*/ filename)
            {
                UseShellExecute = true
            });

            // ...and start a viewer.
            //Process.Start(filename);
        }
Esempio n. 19
0
 public Task <Payslip> CreateAsync(Payslip item)
 {
     return(Payslips.CreateAsync(item));
 }
Esempio n. 20
0
        public Payslip createPayslip(DateTime startDatePeriod, DateTime endDatePeriod, Employee employee)
        {
            // attendanceLogSheet
            Payslip payslip = new Payslip();

            payslip.employee        = employee;
            payslip.startDatePeriod = startDatePeriod;
            payslip.endDatePeriod   = endDatePeriod;
            List <Attendance> attendances   = attendanceService.fetchEmployeeAttendance(startDatePeriod, endDatePeriod, employee);
            decimal           monthlySalary = decimal.Multiply(employee.jobPosition.salary, AVERAGE_WORKING_DAY_PER_MONTH);

            decimal dailyBasedSalary = 0.00M;

            dailyBasedSalary = employee.jobPosition.salary;
            decimal periodSalary = decimal.Round(salaryService.calculatePeriodSalary(attendances, dailyBasedSalary), 2);

            AttendanceControllerInterface attendanceController = new AttendanceController();
            TimeSpan timeSpent = fetchTotalHoursSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, attendanceController);

            periodSalary    = calculateTotalBasePay(timeSpent, payslip.employee.jobPosition.salary);
            payslip.basePay = periodSalary;

            decimal totalAllowanceAmount = 0.00M;
            MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController();
            decimal foodAllowanceAmount      = fetchFoodAllowance(payslip, miscellaneousController);
            decimal totalFoodAllowanceAmount = calculateTotalSpecificAllowance(foodAllowanceAmount, timeSpent);

            totalAllowanceAmount += totalFoodAllowanceAmount;

            decimal transpoAllowanceAmount      = fetchTranspoAllowance(payslip, miscellaneousController);
            decimal totalTranspoAllowanceAmount = calculateTotalSpecificAllowance(transpoAllowanceAmount, timeSpent);

            totalAllowanceAmount += totalTranspoAllowanceAmount;

            List <Request> overtimeRequests = requestService.fetchOvertimeRequests(employee, startDatePeriod, endDatePeriod);

            payslip.requests = overtimeRequests;

            List <Request> leaveRequests = requestService.fetchLeaveRequest(employee, startDatePeriod, endDatePeriod);

            payslip.requests.AddRange(leaveRequests);

            decimal totalLeaveAmount = decimal.Round(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary), 2);

            List <Miscellaneous> benefits = miscellaneousService.fetchMiscellaneousByBenefitType(employee);

            payslip.miscellaneous = benefits;

            RequestControllerInterface requestController = new RequestController();
            SalaryControllerInterface  salaryController  = new SalaryController();
            decimal totalOvertimeAmount = calculateDailyBasedSalaryWithOvertimeRequests(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            totalAllowanceAmount += totalOvertimeAmount;

            payslip.totalBenefits = totalAllowanceAmount + totalLeaveAmount;

            decimal cashAdvanceAmount = calculateTotalCashAdvanceAmount(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            payslip.sssDeduction = decimal.Divide(salaryService.fetchSssDeductionsWithPeriodSalary(monthlySalary), 2);
            payslip.sssDeduction = decimal.Round(payslip.sssDeduction, 2);

            payslip.pagIbigDeduction = decimal.Divide(salaryService.fetchPagIbigDeductionWithPeriodSalary(monthlySalary), 2);
            payslip.pagIbigDeduction = decimal.Round(payslip.pagIbigDeduction, 2);

            payslip.philHealthDeduction = decimal.Divide(salaryService.fetchPhilHealthDeductionWithPeriodSalary(monthlySalary), 2);
            payslip.philHealthDeduction = decimal.Round(payslip.philHealthDeduction, 2);

            Miscellaneous thirteenMonth = miscellaneousService.calculateThirteenMonth(employee, endDatePeriod);

            payslip.taxDeduction = decimal.Divide(salaryService.calculatePeriodSalaryTax(employee, monthlySalary), 2);

            decimal totalDeductions = (decimal.Round(payslip.taxDeduction, 2) + decimal.Round(payslip.sssDeduction, 2) + decimal.Round(payslip.pagIbigDeduction, 2) + decimal.Round(payslip.philHealthDeduction, 2) + decimal.Round(cashAdvanceAmount, 2));

            payslip.totalDeduction = totalDeductions;

            decimal totalSalary = payslip.basePay + payslip.totalBenefits - totalDeductions;

            payslip.netPay = totalSalary;

            return(payrollService.createPayslip(employee, payslip));

            /*
             * List<Request> overtimeRequests = requestService.fetchOvertimeRequests(employee, startDatePeriod, endDatePeriod);
             * payslip.requests = overtimeRequests;
             *
             * periodSalary += decimal.Round(salaryService.calculateDailyBasedSalaryWithOvertimeRequests(overtimeRequests, dailyBasedSalary), 2);
             * Console.WriteLine("periodSalaryWithOvertime---->>" + periodSalary);
             *
             * List<Request> leaveRequests = requestService.fetchLeaveRequest(employee, startDatePeriod, endDatePeriod);
             * payslip.requests.AddRange(leaveRequests);
             *
             * periodSalary += decimal.Round(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary), 2);
             * Console.WriteLine("periodSalaryWithLeave---->>" + periodSalary);
             *
             * List<Miscellaneous> benefits = miscellaneousService.fetchMiscellaneousByBenefitType(employee);
             * payslip.miscellaneous = benefits;
             *
             * periodSalary += decimal.Round(salaryService.fetchTotalAmountOfBenefits(benefits, attendances, leaveRequests), 2);
             * Console.WriteLine("periodSalaryWIthBenefits---->>" + periodSalary);
             *
             * //List<Miscellaneous> bonuses = miscellaneousService.fetchBonusMiscellaneousByDescriptionAsDate(employee, startDatePeriod, endDatePeriod);
             * //payslip.miscellaneous.AddRange(bonuses);
             *
             * //periodSalary += salaryService.fetchTotalBonus(bonuses);
             * //Console.WriteLine("periodSalaryWIthBonus---->>" + periodSalary);
             *
             * List<Request> cashAdvanceList = requestService.fetchAllApprovedCashAdvanceRequests(startDatePeriod, endDatePeriod, employee);
             * periodSalary -= decimal.Round(salaryService.fetchTotalCashAdvanceAmount(cashAdvanceList), 2);
             * Console.WriteLine("periodSalaryWIthCashAdvance---->>" + periodSalary);
             *
             * //List<Miscellaneous> deductions = miscellaneousService.fetchMiscellaneousByDeductionType(employee);
             *
             * //periodSalary -= decimal.Round(salaryService.fetchTotalDeductions(deductions), 2);
             *
             * payslip.sssDeduction = decimal.Divide(salaryService.fetchSssDeductionsWithPeriodSalary(monthlySalary), 2);
             * payslip.sssDeduction = decimal.Round(payslip.sssDeduction, 2);
             *
             * payslip.pagIbigDeduction = decimal.Divide(salaryService.fetchPagIbigDeductionWithPeriodSalary(monthlySalary), 2);
             * payslip.pagIbigDeduction = decimal.Round(payslip.pagIbigDeduction, 2);
             *
             * payslip.philHealthDeduction = decimal.Divide(salaryService.fetchPhilHealthDeductionWithPeriodSalary(monthlySalary), 2);
             * payslip.philHealthDeduction = decimal.Round(payslip.philHealthDeduction, 2);
             *
             * periodSalary -= payslip.sssDeduction;
             * periodSalary -= payslip.pagIbigDeduction;
             * periodSalary -= payslip.philHealthDeduction;
             * Console.WriteLine("periodSalaryWIthDeductions---->>" + periodSalary);
             *
             * payslip.taxDeduction = decimal.Divide(salaryService.calculatePeriodSalaryTax(employee, monthlySalary), 2);
             * periodSalary -= payslip.taxDeduction;
             *
             * payslip.netPay = decimal.Round(periodSalary, 2);
             * Console.WriteLine("periodSalaryWithholdingTax---->>" + periodSalary);
             */
        }
Esempio n. 21
0
        public Payslip addThirteenMonthPayToPayslip(Employee employee, Payslip payslip)
        {
            Miscellaneous thirteenMonthPay = miscellaneousService.fetchEmployeeMiscellaneousBenefitByEmployeeId(employee, "ThirteenMonthAllowance");

            return(payrollService.updatePayslipThirteenMonthPay(payslip, thirteenMonthPay));
        }
Esempio n. 22
0
 private decimal fetchTranspoAllowance(Payslip payslip, MiscellaneousControllerInterface miscellaneousController)
 {
     return(miscellaneousController.fetchMiscellaneousBenefitByNameAndEmployee(payslip.employee, "TransportationAllowance").amount);
     //return miscellaneousController.fetchTranspoAllowance().amount;
 }
        public void CalculatePayslip_ShouldReturnPayslip_WhenAnnualSalaryIsIntMaxAndSuperRateIs50()
        {
            // Arrange
            EmployeeInfo employeeInfo = new EmployeeInfo
            {
                FirstName = "David",
                LastName = "Rudd",
                AnnualSalary = int.MaxValue,
                SuperRate = 0.5M,
                PaymentStartDate = "01 March – 31 March",
            };

            // Act
            Payslip actual = this.employeeIncomeService.CalculatePayslip(employeeInfo);

            // Assert
            Payslip expected = new Payslip
            {
                Name = "David Rudd",
                PayPeriod = "01 March – 31 March",
                GrossIncome = 178956970,
                IncomeTax = 80528432,
                NetIncome = 98428538,
                Super = 89478485
            };

            actual.ShouldBeEquivalentTo(expected);
        }
Esempio n. 24
0
        public HttpResponseMessage CreateNewEmployee(EmployeeModel employee_details)
        {
            HttpResponseMessage Response = null;

            try
            {
                if (employee_details != null && employee_details.role_id != 0 /*&& employee_details.ctc != 0*/ && employee_details.id != 0 && employee_details.reporting_to != 0 && employee_details.designation_id != 0)
                {
                    Employee        existingInstance = EmployeeRepo.GetEmployeeById(employee_details.id);
                    List <Employee> employeeByMailid = EmployeeRepo.GetEmployeeByMailId(employee_details.email);
                    if (existingInstance != null)
                    {
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Employee ID already exists", "Employee ID already exists"));
                        return(Response);
                    }
                    if (employeeByMailid.Count != 0)
                    {
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Mail ID already exists", "Mail ID already exists"));
                        return(Response);
                    }

                    Employee employee = new Employee();
                    employee.id                       = employee_details.id;
                    employee.first_name               = employee_details.first_name;
                    employee.last_name                = employee_details.last_name;
                    employee.email                    = employee_details.email;
                    employee.date_of_birth            = employee_details.date_of_birth;
                    employee.date_of_joining          = employee_details.date_of_joining;
                    employee.contact_no               = employee_details.contact_no;
                    employee.reporting_to             = employee_details.reporting_to;
                    employee.year_of_experience       = Decimal.Parse(employee_details.Year_of_experience);
                    employee.gender                   = employee_details.gender;
                    employee.pan_no                   = employee_details.pan_no;
                    employee.bank_account_no          = employee_details.bank_account_no;
                    employee.emergency_contact_no     = employee_details.emergency_contact_no;
                    employee.emergency_contact_person = employee_details.emergency_contact_person;
                    employee.PF_no                    = employee_details.PF_no;
                    employee.medical_insurance_no     = employee_details.medical_insurance_no;
                    employee.blood_group              = employee_details.blood_group;
                    employee.designation              = employee_details.designation_id;
                    employee.created_on               = DateTime.Now;

                    bool isEmail = Regex.IsMatch(employee.email,
                                                 @"^([0-9a-zA-Z]" +            //Start with a digit or alphabetical
                                                 @"([\+\-_\.][0-9a-zA-Z]+)*" + // No continuous or ending +-_. chars in email
                                                 @")+" +
                                                 @"@(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]*\.)+[a-zA-Z0-9]{2,17})$"
                                                 , RegexOptions.IgnoreCase);
                    if (isEmail != true)
                    {
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Enter valid MailId", "Enter valid MailId"));
                    }
                    else if ((employee.date_of_birth.Year > (DateTime.Now.Year - 21)))
                    {
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Employee age is below 21 years", "Employee age is below 21 years"));
                    }
                    else
                    {
                        User user = new User();
                        user.user_name = employee.email;
                        string Temp_password = PasswordGenerator.GeneratePassword();
                        //Debug.WriteLine(Temp_password);
                        user.password = EncryptPassword.CalculateHash(Temp_password);
                        //Debug.WriteLine(user.password);
                        user.is_active = 1;
                        EmployeeRepo.CreateNewUser(user);
                        employee.user_id = user.id;
                        EmployeeRepo.CreateNewEmployee(employee);
                        User_role user_role = new User_role();
                        user_role.user_id = user.id;
                        user_role.role_id = employee_details.role_id;
                        EmployeeRepo.AssignEmployeeRole(user_role);
                        if (employee.gender.ToLower() == "male")
                        {
                            EmployeeRepo.InsertLeaveBalance(employee, Constants.MALE_LEAVE_TYPES);
                        }
                        else
                        {
                            EmployeeRepo.InsertLeaveBalance(employee, Constants.FEMALE_LEAVE_TYPES);
                        }

                        Salary_Structure salary = new Salary_Structure();
                        salary           = SalaryCalculation.CalculateSalaryStructure(employee_details.ctc);
                        salary.emp_id    = employee_details.id;
                        salary.is_active = 1;
                        salary.from_date = DateTime.Now;
                        salary.to_date   = null;
                        SalaryRepo.CreateSalaryStructure(salary);

                        Payslip payslip = new Payslip();
                        payslip = SalaryCalculation.FirstMonthSalary(employee_details.date_of_joining, salary);
                        if (payslip != null)
                        {
                            PayslipRepo.AddPayslip(payslip);
                        }
                        else
                        {
                            Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_401", "Error in salary structure generation or payslip generation", "Error in salary structure generation or payslip generation"));
                            return(Response);
                        }
                        string username = employee.first_name + " " + employee.last_name;
                        MailHandler.PasswordMailingFunction(username, employee.email, Temp_password);
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Employee added Successfully", "Employee added Successfully"));
                    }
                }
                else
                {
                    Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Invalid Input - check the fileds", "Invalid Input - check the fileds"));
                }
            }
            catch (DbEntityValidationException DBexception)
            {
                Debug.WriteLine(DBexception.Message);
                Debug.WriteLine(DBexception.GetBaseException());
                Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing or Type mismatch", DBexception.Message));
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message));
            }
            return(Response);
        }
 private void CalcGrossIncome(EmployeeInfo employeeInfo, Payslip payslip)
 {
     payslip.GrossIncome = this.roundService.Round(employeeInfo.AnnualSalary / CountOfMonth);
 }
Esempio n. 26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Generating payslips...");
            List <Staff> staffs;
            int          month = 0;
            int          year  = 0;

            while (year == 0)
            {
                Console.Write("\nPlease enter the year; ");
                try
                {
                    year = Convert.ToInt32(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.Write("\nPlease enter a valid year; ");
                }
            }

            while (month == 0)
            {
                Console.Write("\nPlease enter the month; ");
                try
                {
                    month = Convert.ToInt32(Console.ReadLine());
                    if (month < 1 || month > 12)
                    {
                        Console.Write("\nPlease enter a month between 1 & 12; ");
                        month = 0;
                    }
                }
                catch (FormatException)
                {
                    Console.Write("\nPlease enter a valid month; ");
                }
            }

            staffs = FileReader.ReadFile();
            for (int i = 0; i < staffs.Count; i++)
            {
                var staff = staffs[i];
                try
                {
                    Console.Write($"Enter hours worked for {staff.NameOfStaff}; ");
                    int hoursWorked = Convert.ToInt32(Console.ReadLine());
                    staff.HoursWorked = hoursWorked;
                    staff.CalculatePay();
                    Console.WriteLine(staff);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error occurred");
                    Console.WriteLine(e);
                    i--;
                }
            }
            Payslip ps = new Payslip(month, year);

            ps.GeneratePaySlip(staffs);
            ps.GenerateSummary(staffs);
            Console.WriteLine("DONE!");
        }
Esempio n. 27
0
 static void displayEmployeePaySlip(Employee employee, Payslip payslip)
 {
     Console.WriteLine("== Payslip of " + employee.name + " (" + employee.status + ") ==");
     Console.WriteLine("gross : " + payslip.gross);
     Console.WriteLine("contributions : " + payslip.contributions);
     Console.WriteLine("bonus : " + payslip.bonus);
     Console.WriteLine("---------------");
     Console.WriteLine("salary : " + payslip.salary);
 }
 private void CalcName(EmployeeInfo employeeInfo, Payslip payslip)
 {
     payslip.Name = string.Format("{0} {1}", employeeInfo.FirstName, employeeInfo.LastName);
 }
Esempio n. 29
0
        static void Main(string[] args)
        {
            List <Staff> listOfStaffObjects = new List <Staff>();
            int          month = 0; int year = 0;

            while (year == 0)
            {
                try
                {
                    Console.Write("Please enter the year: ");
                    year = Convert.ToInt32(Console.ReadLine());

                    while (month == 0)
                    {
                        try
                        {
                            Console.Write("Please enter the month: ");
                            month = Convert.ToInt32(Console.ReadLine());

                            if (month < 1 || month > 12)
                            {
                                Console.WriteLine("Invalid month entered.");
                                month = 0;
                            }
                            else
                            {
                                FileReaderManager fileReaderManager = new FileReaderManager();
                                listOfStaffObjects = fileReaderManager.ReadFile();
                                for (int i = 0; i < listOfStaffObjects.Count; i++)
                                {
                                    try
                                    {
                                        Console.WriteLine("Enter the hours work for " + listOfStaffObjects[i].NameOfStaff + ": ");
                                        listOfStaffObjects[i].HoursWorked = Convert.ToInt32(Console.ReadLine());

                                        listOfStaffObjects[i].CalculatePay();
                                        Console.WriteLine(listOfStaffObjects[i].ToString());

                                        Payslip ps = new Payslip(year, month);
                                        ps.GeneratePaySlip(listOfStaffObjects);
                                        ps.GenerateSummary(listOfStaffObjects);
                                        Console.Read();
                                    }
                                    catch (Exception ex)
                                    {
                                        i--;
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                }
                catch (FormatException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
 private void CalcSuper(EmployeeInfo employeeInfo, Payslip payslip)
 {
     payslip.Super = this.roundService.Round((double)(payslip.GrossIncome * employeeInfo.SuperRate));
 }
Esempio n. 31
0
 public void DeletePayslip(Payslip payslip)
 {
     _dbContext.Remove(payslip);
     _dbContext.SaveChanges();
 }
Esempio n. 32
0
 public GeneratePayslip()
 {
     payCheck = new Payslip();
 }
Esempio n. 33
0
 public Payslip Create(Payslip item)
 {
     return(Payslips.Create(item));
 }
Esempio n. 34
0
 public Payslip Update(Payslip item)
 {
     return(Payslips.Update(item));
 }
Esempio n. 35
-1
        public static void UpdatePayslip(Payslip payslip)
        {
            EMSEntities datacontext = new EMSEntities();

            try
            {
                datacontext.Entry(payslip).State = EntityState.Modified;
                datacontext.SaveChanges();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                throw exception;
            }
            finally
            {
                datacontext.Dispose();
            }
        }
Esempio n. 36
-1
 public static void DisplayPayslip(Payslip payslip)
 {
     DisplayEmployeeInfo(payslip.Employee);
     DisplayPayPeriod(payslip.PayPeriod);
     DisplayTaxInformation(payslip.TaxInformation);
 }