public void UnassignedSuperTest() { decimal income = PaySlip.GetGrossIncome(0.0m); decimal super = PaySlip.GetSuper(income, -8); Assert.Equal(0, super); }
public void SuperTest() { decimal income = PaySlip.GetGrossIncome(60050m); decimal super = PaySlip.GetSuper(income, 9); Assert.Equal(450, super); }
public void UnassignedDateTest() { DateTime newDate = new DateTime(); string date = PaySlip.GetPayPeriod(newDate, newDate); Assert.Equal("Invalid Date", date); }
public void GeneratePaySlipTest398() { Staff staff; Manager manager; Admin admin; Admin admin1; List <Staff> list; staff = new Staff((string)null, (float)0); staff.HoursWorked = 0; staff.CalculatePay(); manager = new Manager(""); ((Staff)manager).HoursWorked = 161; manager.CalculatePay(); admin = new Admin((string)null); ((Staff)admin).HoursWorked = 1; admin.CalculatePay(); admin1 = new Admin((string)null); ((Staff)admin1).HoursWorked = 0; admin1.CalculatePay(); Staff[] staffs = new Staff[4]; staffs[0] = staff; staffs[1] = (Staff)manager; staffs[2] = (Staff)admin; staffs[3] = (Staff)admin1; list = new List <Staff>((IEnumerable <Staff>)staffs); PaySlip s0 = new PaySlip(0, 0); this.GeneratePaySlipTest(s0, list); Assert.IsNotNull((object)s0); }
public async Task <ActionResult <PaySlip> > PostPaySlip(PaySlip paySlip) { _context.PaySlips.Add(paySlip); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPaySlip", new { id = paySlip.PaySlipId }, paySlip)); }
internal string ToStringTest([PexAssumeUnderTest] PaySlip target) { string result = target.ToString(); return(result); // TODO: add assertions to method PaySlipTest.ToStringTest(PaySlip) }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; PaySlip paySlip = await service.GetPaySlipAsync(selectedMonth); id = paySlip.Id; Organisation = paySlip.Organisation; FirstName = paySlip.FirstName; LastName = paySlip.LastName; MiddleName = paySlip.MiddleName; TabNumber = paySlip.TabNumber; Department = paySlip.Department; Position = paySlip.Position; if (Accrued.Count > 0) { Accrued.Clear(); } IsBusy = false; }
private static List <IPaySlip> GetPaySlips() { var paySlipOne = new PaySlip { EmployeeName = "Test One", PayPeriod = "1 March - 31 March", SuperAmount = 401, GrossIncome = 5001, IncomeTax = 901 }; var paySlipTwo = new PaySlip { EmployeeName = "Test Two", PayPeriod = "1 March - 31 March", SuperAmount = 402, GrossIncome = 5002, IncomeTax = 902 }; var paySlips = new List <IPaySlip> { paySlipOne, paySlipTwo }; return(paySlips); }
private void InsertPayslipDetails(Employee empData, DateTime date) { var obj = Session["LoginCredentials"] as Employee; var payslipDetails = (from emp in _databaseObj.Employees join slip in _databaseObj.Payslips on emp.EmpId equals slip.empRefID where slip.DateofSalaryCredit.Month == date.Month && slip.DateofSalaryCredit.Year == date.Year && emp.EmpId == obj.EmpId select new { emp.FirstName }).FirstOrDefault(); if (payslipDetails == null) { Random rnum = new Random(); int PFDeduction_rn = rnum.Next(300, 1000); PaySlip _payslipObj = new PaySlip() { BasicSalary = 15000, HouseRentAllowance = 6000, DateofSalaryCredit = date, Bonus = 13500, PFNumber = "HJ/0JK53" + rnum.Next(300) + "/GH023" + rnum.Next(500), PFDeduction = PFDeduction_rn, TravelAllowance = 2500, SpecialAllowance = 6000, TotalEarning = 41200 - PFDeduction_rn, empRefID = empData.EmpId }; _databaseObj.Payslips.Add(_payslipObj); _databaseObj.SaveChanges(); } }
public void WithFactory_GivenMonthAndYear_ReturnPaySlip() { var fakeUserInput = new FakeUserInput(); var rate = (float)1.2; var staff = new Staff("Joe", rate); var myStaff = new List <IStaff> { staff }; var fakeFileReader = new FakeFileReader(myStaff); var paySlip = new PaySlip(1, 2000); var fakeFactory = new FakeFactory(paySlip); //FactoryPaySlip.SetCustomerPaySlip(paySlip); PayRollProgram input = new PayRollProgram(fakeUserInput, fakeFileReader, new AlternateFactoryPaySlip(), new FactoryStaff()); Assert.That(staff.TotalPay, Is.EqualTo(0)); input.PayRoll(); Assert.That(staff.HoursWorked, Is.EqualTo(fakeUserInput.GetHoursWorked())); Assert.That(staff.TotalPay, Is.EqualTo(fakeUserInput.GetHoursWorked() * rate)); }
public async Task <IActionResult> PutPaySlip(int id, PaySlip paySlip) { if (id != paySlip.PaySlipId) { return(BadRequest()); } _context.Entry(paySlip).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaySlipExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Equals_ObjectIsNotEmployee_ReturnsFalse() { Employee e = new Employee("David", "Rudd", 60050, 0.09); PaySlip p = new PaySlip(new DateTime(DateTime.Today.Year, 3, 1), new DateTime(DateTime.Today.Year, 3, 31)); Assert.False(e.Equals(p)); }
internal PaySlip ConstructorTest(int payMonth, int payYear) { PaySlip target = new PaySlip(payMonth, payYear); return(target); // TODO: add assertions to method PaySlipTest.ConstructorTest(Int32, Int32) }
public void GeneratePayslip_NegativeSuper_ThrowsNegativeNumberException(uint annualIncome, double superRate, uint grossIncome, uint incomeTax, uint netIncome, uint super) { DateTime beginning = new DateTime(DateTime.Today.Year, 3, 1), end = new DateTime(DateTime.Today.Year, 3, 31); PaySlip p = new PaySlip(beginning, end, grossIncome, incomeTax, netIncome, super); Assert.Throws <NegativeNumberException>(() => this.Fixture.Generator.GeneratePayslip(new TaxCalculator(), p, annualIncome, superRate)); }
public void Equals_DifferentEndDate_ReturnsFalse(string endDate) { DateTime startDate = new DateTime(DateTime.Today.Year, 3, 1); PaySlip p1 = new PaySlip(startDate, new DateTime(DateTime.Today.Year, 3, 31), 5004, 922, 4082, 450); PaySlip p2 = new PaySlip(startDate, DateTime.ParseExact(endDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), 5004, 922, 4082, 450); Assert.False(p1.Equals(p2)); }
public void NetIncome() { decimal income = PaySlip.GetGrossIncome(60050m); decimal tax = PaySlip.GetIncomeTax(60050m); decimal net = PaySlip.GetNetIncome(income, tax); Assert.Equal(4082, net); }
public ActionResult DeleteConfirmed(int id) { PaySlip paySlip = db.PaySlips.Find(id); db.PaySlips.Remove(paySlip); db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { List <Staff> myStaff = new List <Staff>(); FileReader fr = new FileReader(); int month = 0; int year = 0; while (year == 0) { Console.WriteLine("\nPlease enter the year."); try { year = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { Console.WriteLine(e.Message + "Please try again."); } } while (month == 0) { Console.WriteLine("Please enter the month."); try { month = Convert.ToInt32(Console.ReadLine()); if (month < 1 || month > 12) { Console.WriteLine("Month must be between 1 and 12."); month = 0; } } catch (Exception e) { Console.WriteLine(e.Message + "Please try again month."); } } myStaff = fr.ReadFile(); for (int i = 0; i < myStaff.Count; i++) { try { Console.WriteLine("Enter hours worked for {0}", myStaff[i].NameOfStaff); myStaff[i].HoursWorked = Convert.ToInt32(Console.ReadLine()); myStaff[i].CalculatePay(); Console.WriteLine(myStaff[i].ToString()); } catch (Exception e) { Console.WriteLine(e.Message); i--; } } PaySlip ps = new PaySlip(month, year); ps.GeneratePaySlip(myStaff); ps.GenerateSummary(myStaff); Console.Read(); }
private Employee ParseEmployeeLine(string line) { string[] parameters = line.Split(','), dates; int super = 0; if (parameters.Length != 5) { throw new WrongParameterNumberException(); } // No data validation is done to the names : too many cases to consider uint annualIncome = 0; try { annualIncome = UInt32.Parse(parameters[2]); } catch (Exception) { throw new AnnualIncomeFormatException(); } try { string superStr = Regex.Match(parameters[3], "[0-9]*").Value; // discard the % symbol super = Int32.Parse(superStr); } catch (Exception) { throw new SuperFormatException(); } if (super < 0 || super > 50) { throw new SuperOutOfBoundsException(); } PaySlip p; try { dates = parameters[4].Split('-'); // separate the two dates p = new PaySlip(DateTime.Parse(dates[0] + " " + DateTime.Today.Year), DateTime.Parse(dates[1] + " " + DateTime.Today.Year)); } catch (Exception) { throw new DateIntervalFormatException(); } Employee e = new Employee(parameters[0], parameters[1], annualIncome, (double)super / 100, new List <PaySlip>() { p }); p.Employee = e; return(e); }
public ActionResult DisplayPaySlip(int Month, int Year) { if (Session["LoginCredentials"] != null) { var obj = Session["LoginCredentials"] as Employee; var payslipDetails = (from emp in _databaseObj.Employees join slip in _databaseObj.Payslips on emp.EmpId equals slip.empRefID where slip.DateofSalaryCredit.Month == Month && slip.DateofSalaryCredit.Year == Year && emp.EmpId == obj.EmpId select new { emp.FirstName, emp.LastName, emp.DOJ, slip.BasicSalary, slip.DateofSalaryCredit, slip.Bonus, slip.TotalEarning, slip.SpecialAllowance, slip.PFNumber, slip.PFDeduction, slip.HouseRentAllowance, slip.TravelAllowance }); PaySlip _payObj = new PaySlip(); _payObj.Employees = new Employee(); foreach (var temp in payslipDetails) { _payObj.Employees.FirstName = temp.FirstName; _payObj.Employees.LastName = temp.LastName; _payObj.Employees.DOJ = temp.DOJ; _payObj.BasicSalary = temp.BasicSalary; _payObj.SpecialAllowance = temp.SpecialAllowance; _payObj.TravelAllowance = temp.TravelAllowance; _payObj.HouseRentAllowance = temp.HouseRentAllowance; _payObj.PFDeduction = temp.PFDeduction; _payObj.PFNumber = temp.PFNumber; _payObj.TotalEarning = temp.TotalEarning; _payObj.DateofSalaryCredit = temp.DateofSalaryCredit; _payObj.Bonus = temp.Bonus; } FillDropDown(); if (_payObj.BasicSalary != 0) { return(View(_payObj)); } else { ViewBag.payslipMsg = "Pay SLip Not Generated Till Yet"; return(View(_payObj)); } } else { return(RedirectToAction("UserLogin")); } }
public void Equals_DifferentSuper_ReturnsFalse(uint super) { DateTime startDate = new DateTime(DateTime.Today.Year, 3, 1); DateTime endDate = new DateTime(DateTime.Today.Year, 3, 31); PaySlip p1 = new PaySlip(startDate, endDate, 5004, 922, 4082, 450); PaySlip p2 = new PaySlip(startDate, endDate, 5004, 922, 4082, super); Assert.False(p1.Equals(p2)); }
public void Equals_DifferentNetIncome_ReturnsFalse(uint netincome) { DateTime startDate = new DateTime(DateTime.Today.Year, 3, 1); DateTime endDate = new DateTime(DateTime.Today.Year, 3, 31); PaySlip p1 = new PaySlip(startDate, endDate, 5004, 922, 4082, 450); PaySlip p2 = new PaySlip(startDate, endDate, 5004, 922, netincome, 450); Assert.False(p1.Equals(p2)); }
public void GetPaye_GivenNoEmployeeAge_ThrowsException() { // Arrange var employee = new Employee(); var paySlip = new PaySlip(employee); // Assert Assert.Throws <System.ArgumentException>(() => paySlip.GetPaye()); }
public void GenerateSummaryTestThrowsNullReferenceException451() { List <Staff> list; Staff[] staffs = new Staff[1]; list = new List <Staff>((IEnumerable <Staff>)staffs); PaySlip s0 = new PaySlip(0, 0); this.GenerateSummaryTest(s0, list); }
/// <summary> /// Fake repo to return a random int. /// </summary> /// <param name="paySlip"></param> /// <returns>99</returns> public async Task <int> CreatePaySlipAsync(PaySlip paySlip) { var result = await Task.Run(() => { Random rnd = new Random(); return(rnd.Next(1, 100)); }); return(result); }
public void GenerateSummaryTest139() { List <Staff> list; Staff[] staffs = new Staff[0]; list = new List <Staff>((IEnumerable <Staff>)staffs); PaySlip s0 = new PaySlip(0, 0); this.GenerateSummaryTest(s0, list); Assert.IsNotNull((object)s0); }
public void GeneratePayslip_ValidInput_UpdatesPayslipAccordingly(uint annualIncome, double superRate, uint grossIncome, uint incomeTax, uint netIncome, uint super) { DateTime beginning = new DateTime(DateTime.Today.Year, 3, 1), end = new DateTime(DateTime.Today.Year, 3, 31); PaySlip p1 = new PaySlip(beginning, end, grossIncome, incomeTax, netIncome, super), p2 = new PaySlip(beginning, end); Assert.NotEqual(p1, p2); this.Fixture.Generator.GeneratePayslip(new TaxCalculator(), p2, annualIncome, superRate); Assert.Equal(p1, p2); }
static string CreateSlipFile(PaySlipModel paySlipModel, string fileName) { var filePath = Path.Combine(Program.TemporaryFileDirectory, fileName); var slip = new PaySlip { PaySlipInformation = paySlipModel }; slip.ExportToPdf(filePath); return(filePath); }
public IActionResult DeletePaySlip(long id) { PaySlip a = PaySlip_repo.Find(id); if (a == null) { return(NotFound()); } PaySlip_repo.Delete(a); return(Ok()); }
public ActionResult Edit([Bind(Include = "PaySlipId,OnDate,Month,Year,EmployeeId,CurrentSalaryId,BasicSalary,NoOfDaysPresent,TotalSale,SaleIncentive,WOWBillAmount,WOWBillIncentive,LastPcsAmount,LastPCsIncentive,OthersIncentive,GrossSalary,StandardDeductions,TDSDeductions,PFDeductions,AdvanceDeducations,OtherDeductions,Remarks")] PaySlip paySlip) { if (ModelState.IsValid) { db.Entry(paySlip).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CurrentSalaryId = new SelectList(db.CurrentSalaries, "CurrentSalaryId", "CurrentSalaryId", paySlip.CurrentSalaryId); ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", paySlip.EmployeeId); return(View(paySlip)); }
public void Initialise() { payslip = new PaySlip { Employee = new Employee { Name = new Name { FirstName = "David", LastName = "Rudd" }, AnnualSalary = 60050, SuperRate = 0.09f, PaymentPeriod = "01 March - 31 March" } }; payslip.Process(); }