private void initializeAllowance() { MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController(); Miscellaneous foodAllowanceBenefits = miscellaneousController.fetchMiscellaneousBenefitByNameAndEmployee(employee, "FoodAllowance"); Miscellaneous transpoAllowanceBenefits = miscellaneousController.fetchMiscellaneousBenefitByNameAndEmployee(employee, "TransportationAllowance"); foodAllowance.Text = foodAllowanceBenefits.amount.ToString("0.##"); transpoAllowance.Text = transpoAllowanceBenefits.amount.ToString("0.##"); }
private void addMiscButton_Click(object sender, EventArgs e) { MiscellaneousControllerInterface miscController = new MiscellaneousController(); if (miscName.Text != null && miscAmount.Text != null) { Miscellaneous misc = new Miscellaneous(); misc.name = miscName.Text; misc.description = miscDescription.Text; misc.type = miscType.Text == "Benefits" ? MiscType.Benefits : MiscType.Deductions; misc.amount = Convert.ToDecimal(miscAmount.Text); miscController.addMisc(misc); FormControllerInterface formController = new FormController(); formController.showAdminDashBoardForMisc(adminDashboard, this); } }
public MiscellaneousControllerTest() { var host = WebHost.CreateDefaultBuilder() .UseStartup <Startup>() .Build(); bool isTestMode = false; mockMiscellaneousDataRepository = new Moq.Mock <IMiscellaneous>(); mockMiscellaneousController = new MiscellaneousController(mockMiscellaneousDataRepository.Object); //var builder = new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory()) // .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); //// .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) //// .AddEnvironmentVariables(); //Configuration = builder.Build(); if (isTestMode) { ////iConnection = new Core.DAL.Fakes.MasterDataDALRepository<BaseModel>(); //masterDataRepository = new Fakes.MasterDataRepository(iHotelLibrary, iCurrencyConnectionLibrary, iMarketConnectionLibrary, // iOccupancyConnectionLibrary, iSupplierConnectionLibrary, iRoomTypeLibrary, // iLanguageLibrary, iHotelFacilityGroupLibrary, // iHotelFacilityTypeLibrary, iHotelFacilityLibrary, // iPaymentMethodLibrary, iRateTypeLibrary, iTaxTypeLibrary, iTaxApplicabilityLibrary); //masterDataController = new MasterDataController(masterDataRepository); } else { //// iCountryLibrary = new Core.DAL.Repositories.DapperConnection<Country>(); // iHotelLibrary = new Core.DAL.Repositories.DapperConnection<Hotel>(Configuration); // iHotelTypeLibary = new Core.DAL.Repositories.DapperConnection<HotelType>(Configuration); // masterDataRepository = new Repositories.MasterDataRepository(iHotelLibrary, iHotelTypeLibary, iDesignationLibrary, iCityLibrary, iCountryLibrary, iCurrencyConnectionLibrary, // iMarketConnectionLibrary, iOccupancyConnectionLibrary, iSupplierConnectionLibrary, iChannelManagerConnectionLibrary, // iHotelBrandLibrary, iHotelChainLibrary, iLanguageLibrary, // iPaymentMethodLibrary, iRateTypeLibrary, iTaxTypeLibrary, iTaxApplicabilityLibrary, iMealsConnectionLibrary, iCuisineTypeConnectionLibrary); // masterDataController = new MasterDataController(masterDataRepository); } }
private void createEmployeeButton_Click(object sender, EventArgs e) { EmployeeControllerInterface employeeController = new EmployeeController(); if (username.Text.Equals("")) { MessageBox.Show("Username cannot be empty."); return; } if (firstname.Text.Equals("")) { MessageBox.Show("Firstname cannot be empty."); return; } if (middlename.Text.Equals("")) { MessageBox.Show("Middlename cannot be empty."); return; } if (lastname.Text.Equals("")) { MessageBox.Show("Lastname cannot be empty."); return; } if (foodAllowance.Text.Equals("")) { MessageBox.Show("Food Allowance cannot be empty."); return; } if (transpoAllowance.Text.Equals("")) { MessageBox.Show("Transpo Allowance cannot be empty."); return; } if (createEmployeeButton.Text == "Create") { if (password.Text != confirmPassword.Text) { MessageBox.Show("Password did not matched"); password.Text = ""; confirmPassword.Text = ""; return; } Employee employee = new Employee(); employee.employeeId = Convert.ToInt64(employeeId.Text); employee.userAccount = new User(); employee.userAccount.username = username.Text; employee.userAccount.password = password.Text; if (checkUsernameIfExist(employee.userAccount)) { MessageBox.Show("Username is not available anymore, please create another username."); return; } Role role = new Role(); employee.userAccount.role = role; employee.userAccount.role.id = 2; employee.userAccount.role.type = "employee"; employee.userAccount.status = AccountStatus.Enable; employee.fullName = lastname.Text + ", " + firstname.Text + " " + middlename.Text; employee.birthDate = birthdayTimePicker.Text; employee.gender = genderComboBox.Text; PositionControllerInterface positionController = new PositionController(); employee.jobPosition = positionController.fetchPositionByName(positionComboBox.Text); employee.civilStatus = civilStatusComboBox.Text; try { employee.dependents = Convert.ToInt32(dependents.Text); } catch (FormatException ex) { MessageBox.Show("Dependents must be a number!"); return; } employee.address = address.Text; employee.contactNumber = contactNumber.Text; employee.tin = tin.Text; employee.sssId = sssId.Text; employee.philHealthId = philHealthId.Text; employee.pagIbigId = pagIbigId.Text; employee.dateEmployed = DateTime.Now.ToString(); decimal foodAllowanceAmount = 0.00M; decimal transpoAllowanceAmount = 0.00M; try { foodAllowanceAmount = Convert.ToDecimal(foodAllowance.Text); transpoAllowanceAmount = Convert.ToDecimal(transpoAllowance.Text); } catch (FormatException ex) { MessageBox.Show("Allowance amount must be a number!"); return; } if (employeeController.saveEmployee(employee).id > 0) { Miscellaneous foodAllowanceBenefits = new Miscellaneous(); foodAllowanceBenefits.name = "FoodAllowance"; foodAllowanceBenefits.description = "Food Allowance"; foodAllowanceBenefits.amount = foodAllowanceAmount; foodAllowanceBenefits.type = MiscType.Benefits; Miscellaneous transpoAllowanceBenefits = new Miscellaneous(); transpoAllowanceBenefits.name = "TransportationAllowance"; transpoAllowanceBenefits.description = "Transportation Allowance"; transpoAllowanceBenefits.amount = transpoAllowanceAmount; transpoAllowanceBenefits.type = MiscType.Benefits; MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController(); foodAllowanceBenefits = miscellaneousController.addMiscByEmployee(foodAllowanceBenefits, employee); transpoAllowanceBenefits = miscellaneousController.addMiscByEmployee(transpoAllowanceBenefits, employee); MessageBox.Show("Successfully added new employee."); FormControllerInterface formController = new FormController(); formController.showAdminDashBoard(adminDashboard, this); } else { MessageBox.Show("Please try again, or contact the administrator."); password.Text = ""; confirmPassword.Text = ""; } } else if (createEmployeeButton.Text == "Update") { employee.fullName = lastname.Text + ", " + firstname.Text + " " + middlename.Text; employee.birthDate = birthdayTimePicker.Text; employee.gender = genderComboBox.Text; PositionControllerInterface positionController = new PositionController(); employee.jobPosition = positionController.fetchPositionByName(positionComboBox.Text); employee.civilStatus = civilStatusComboBox.Text; try { employee.dependents = Convert.ToInt32(dependents.Text); } catch (FormatException ex) { MessageBox.Show("Dependents must be a number!"); return; } if (isAccountStatusInvalid()) { MessageBox.Show("Account status is not valid."); return; } employee.address = address.Text; employee.contactNumber = contactNumber.Text; employee.tin = tin.Text; employee.sssId = sssId.Text; employee.philHealthId = philHealthId.Text; employee.pagIbigId = pagIbigId.Text; employee.userAccount.status = accountStatusComboBox.Text.Equals("Disable") ? AccountStatus.Disable : AccountStatus.Enable; decimal foodAllowanceAmount = 0.00M; decimal transpoAllowanceAmount = 0.00M; try { foodAllowanceAmount = Convert.ToDecimal(foodAllowance.Text); transpoAllowanceAmount = Convert.ToDecimal(transpoAllowance.Text); } catch (FormatException ex) { MessageBox.Show("Allowance amount must be a number!"); return; } if (employeeController.updateEmployee(employee) != null) { UserControllerInterface userController = new UserController(); userController.updateUserAccountStatus(employee.userAccount); MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController(); Miscellaneous foodAllowanceBenefits = miscellaneousController.fetchMiscellaneousBenefitByNameAndEmployee(employee, "FoodAllowance"); foodAllowanceBenefits.amount = foodAllowanceAmount; Miscellaneous transpoAllowanceBenefits = miscellaneousController.fetchMiscellaneousBenefitByNameAndEmployee(employee, "TransportationAllowance"); transpoAllowanceBenefits.amount = transpoAllowanceAmount; foodAllowanceBenefits = miscellaneousController.updateMiscellaneousBenefitAmountById(foodAllowanceBenefits); foodAllowanceBenefits = miscellaneousController.updateMiscellaneousBenefitAmountById(transpoAllowanceBenefits); MessageBox.Show("Successfully updated employee."); FormControllerInterface formController = new FormController(); formController.showAdminDashBoard(adminDashboard, this); } else { MessageBox.Show("Please try again, or contact the administrator."); } } }
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.##"); }