public ActionResult Create(OpdExpenseVM opdExpense) { try { string buttonStatus = Request.Form["buttonName"]; if (ModelState.IsValid) { opdExpense.OpdType = FormType.HospitalExpense; opdExpense.Status = ClaimStatus.INPROGRESS; opdExpense.CreatedDate = DateTime.Now; opdExpense.EmployeeEmailAddress = GetEmailAddress(); OpdExpenseVM OpdExpense_Obj = _opdExpenseService.CreateOpdExpense(opdExpense); return(RedirectToAction("Edit", "HospitalExpense", new { id = Security.EncryptId(OpdExpense_Obj.ID) })); } return(RedirectToAction(UrlIndex, UrlOpdExpense)); } catch (Exception ex) { logger.Error("Hospital Expense : Create()" + ex.Message.ToString()); return(View(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } }
private string Validation(OpdExpenseVM oPDEXPENSE, string buttonStatus) { string message = ""; if (buttonStatus == "approved" || buttonStatus == "managerapproval") { if (oPDEXPENSE.TotalAmountApproved.ToString() == "") { message = Constants.MSG_APPROVAL_TOTALAMOUNTAPPROVED; } else if (oPDEXPENSE.HrComment == null) { message = Constants.MSG_APPROVAL_HRCOMMENTS; } else if (!ClaimAmountAndTotalAmount(oPDEXPENSE)) { message = Constants.MSG_GENERAL_TOTALCLAIMEDAMOUNT_TOTALAPPROVEDAMOUNT; } } else if (buttonStatus == "rejected") { if (oPDEXPENSE.HrComment == null) { message = Constants.MSG_APPROVAL_HRCOMMENTS; } } return(message); }
public ActionResult MANOPDExpense(OpdExpenseVM oPDEXPENSE) { try { string buttonStatus = Request.Form["buttonName"]; AuthenticateUser("MANOPDExpense"); string message = Validation(oPDEXPENSE, buttonStatus); if (message != string.Empty) { ModelState.AddModelError("", message); } if (buttonStatus == "approved") { oPDEXPENSE.Status = ClaimStatus.MANAPPROVED; } else if (buttonStatus == "rejected") { oPDEXPENSE.Status = ClaimStatus.MANREJECTED; } else { oPDEXPENSE.Status = ClaimStatus.MANINPROCESS; } if (ModelState.IsValid) { oPDEXPENSE.ModifiedDate = DateTime.Now; oPDEXPENSE.ManagementApprovalDate = DateTime.Now; oPDEXPENSE.ManagementEmailAddress = GetEmailAddress(); if (oPDEXPENSE.Status == ClaimStatus.MANAPPROVED) { oPDEXPENSE.HrApproval = true; oPDEXPENSE.FinanceApproval = true; oPDEXPENSE.ManagementApproval = true; } _opdExpenseService.UpdateOpdExpense(oPDEXPENSE); EmailSend(oPDEXPENSE); return(RedirectToAction(UrlIndex, UrlManApproval)); } var result2 = GeneralController.GetOPDExpense(Convert.ToInt32(oPDEXPENSE.ID), _opdExpenseService, _opdExpensePatientService, _opdExpenseImageService); ViewData["OPDEXPENSE_ID"] = oPDEXPENSE.ID; return(View(result2)); } catch (Exception ex) { logger.Error("MANAPPROVAL : MANOPDExpense([Bind])" + ex.Message.ToString()); return(View(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } }
public ActionResult HROPDExpense(OpdExpenseVM oPDEXPENSE) { try { string buttonStatus = Request.Form["buttonName"]; AuthenticateUser(); string remainingAmount = GeneralController.CalculateRemainingAmount(oPDEXPENSE.EmployeeEmailAddress, oPDEXPENSE.OpdType, oPDEXPENSE.HospitalizationType, oPDEXPENSE.MaternityType, _opdExpenseService, _setupExpenseAmountService, false); ViewBag.RemainingAmount = remainingAmount; string message = Validation(oPDEXPENSE, buttonStatus); if (message != string.Empty) { ModelState.AddModelError("", message); } if (ModelState.IsValid) { if (buttonStatus == "approved") { oPDEXPENSE.Status = ClaimStatus.HRAPPROVED; oPDEXPENSE.HrApproval = true; } else if (buttonStatus == "rejected") { oPDEXPENSE.Status = ClaimStatus.HRREJECTED; } else if (buttonStatus == "managerapproval") { oPDEXPENSE.Status = ClaimStatus.MANINPROCESS; } else { oPDEXPENSE.Status = ClaimStatus.HRINPROCESS; } oPDEXPENSE.ModifiedDate = DateTime.Now; oPDEXPENSE.HrApprovalDate = DateTime.Now; oPDEXPENSE.HrEmailAddress = GetEmailAddress(); _opdExpenseService.UpdateOpdExpense(oPDEXPENSE); EmailSend(oPDEXPENSE); return(RedirectToAction(UrlIndex, UrlHrApproval)); } var opdExpense = GeneralController.GetOPDExpense(Convert.ToInt32(oPDEXPENSE.ID), _opdExpenseService, _opdExpensePatientService, _opdExpenseImageService); ViewData["OPDEXPENSE_ID"] = oPDEXPENSE.ID; return(View(opdExpense)); } catch (Exception ex) { logger.Error("HRAPPROVAL : HROPDExpense([Bind])" + ex.Message.ToString()); return(View(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } }
private string Validation(OpdExpenseVM oPDEXPENSE, string buttonStatus) { string message = ""; if (buttonStatus == "managerapproval" || buttonStatus == "finalapproved") { if (oPDEXPENSE.TotalAmountApproved.ToString() == "") { message = Constants.MSG_APPROVAL_TOTALAMOUNTAPPROVED; } else if (oPDEXPENSE.FinanceComment == null) { message = Constants.MSG_APPROVAL_FINANCECOMMENTS; } else if (!ClaimAmountAndTotalAmount(oPDEXPENSE)) { message = Constants.MSG_GENERAL_TOTALCLAIMEDAMOUNT_TOTALAPPROVEDAMOUNT; } else if (buttonStatus == "finalapproved") { if (oPDEXPENSE.PayRollMonth == null) { message = Constants.MSG_GENERAL_ADD_PAYROLL_MONTH; } } } else if (buttonStatus == "rejected" || buttonStatus == "approved") { if (oPDEXPENSE.FinanceComment == null) { message = Constants.MSG_APPROVAL_FINANCECOMMENTS; } } return(message); }
public ActionResult Create(OpdExpenseVM OpdExpense) { try { if (ModelState.IsValid) { OpdExpense.Status = ClaimStatus.INPROGRESS; OpdExpense.CreatedDate = DateTime.Now; OpdExpense.EmployeeEmailAddress = GetEmailAddress(); OpdExpenseVM OpdExpense_Obj = _opdExpenseService.CreateOpdExpense(OpdExpense); ViewData["OPDEXPENSE_ID"] = OpdExpense_Obj.ID; ViewData["OPDTYPE"] = OpdExpense_Obj.OpdType; if (OpdExpense.OpdType == FormType.OPDExpense) { return(RedirectToAction("Edit", UrlOpdExpense, new { id = Security.EncryptId(OpdExpense_Obj.ID) })); } else if (OpdExpense.OpdType == FormType.EmployeeExpense) { return(RedirectToAction("Edit", UrlTravelExpense, new { id = Security.EncryptId(OpdExpense_Obj.ID) })); } } return(View(OpdExpense)); } catch (Exception ex) { logger.Error("OPD Expense : Create([Bind])" + ex.Message.ToString()); return(View(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } }
private bool ClaimAmountAndTotalAmount(OpdExpenseVM oPDEXPENSE) { bool result = false; if (oPDEXPENSE.TotalAmountApproved <= oPDEXPENSE.TotalAmountClaimed) { result = true; } return(result); }
public void EmailSend(OpdExpenseVM OpdExpense) { var patients = _opdExpensePatientService.GetOpdExpensesPatientAgainstOpdExpenseId(OpdExpense.ID); OpdExpense.OpdExpensePatients = patients; var images = _opdExpenseImageService.GetOpdExpensesImageAgainstOpdExpenseId(OpdExpense.ID); OpdExpense.OpdExpenseImages = images; var message = EmailUtils.GetMailMessage(OpdExpense); _emailService.SendEmail(message); }
private bool GetHOSExpenseAmount(OpdExpenseVM opdExpense, decimal?totalAmountClaimed) { bool result = false; var hospitalInformation = GeneralController.GetHospitalExpense(opdExpense.ID, _opdExpenseService, _opdExpensePatientService, _opdExpenseImageService); decimal?totalAmount = 0; foreach (var item in hospitalInformation.OpdExpenseImages) { totalAmount += item.ExpenseAmount; } if (totalAmount.Equals(totalAmountClaimed)) { result = true; } return(result); }
public ActionResult Edit(OpdExpenseVM opdExpense) { try { AuthenticateUser(); var hospitalInformation = GeneralController.GetHospitalExpense(opdExpense.ID, _opdExpenseService, _opdExpensePatientService, _opdExpenseImageService); ViewData["OPDEXPENSE_ID"] = opdExpense.ID; ViewData["OPDTYPE"] = opdExpense.OpdType; ViewBag.EmployeeDepartment = hospitalInformation.EmployeeDepartment; string buttonStatus = Request.Form["buttonName"]; CalculateRemainingAmount(hospitalInformation); if (buttonStatus == "submit") { opdExpense.Status = ClaimStatus.SUBMITTED; } else { opdExpense.Status = ClaimStatus.INPROGRESS; } if (opdExpense.Status == ClaimStatus.SUBMITTED) { if (hospitalInformation.OpdExpensePatients.Count > 0) { if (hospitalInformation.OpdExpenseImages.Count > 0) { if (GetHOSExpenseAmount(opdExpense, opdExpense.TotalAmountClaimed)) { decimal?remainingAmount = Convert.ToDecimal(ViewBag.RemainingAmount); if (opdExpense.TotalAmountClaimed <= remainingAmount) { if (ModelState.IsValid) { opdExpense.ModifiedDate = DateTime.Now; opdExpense.EmployeeEmailAddress = GetEmailAddress(); _opdExpenseService.UpdateOpdExpense(opdExpense); EmailSend(opdExpense); return(RedirectToAction(UrlIndex, UrlOpdExpense)); } } else { ModelState.AddModelError("", Constants.MSG_GENERAL_CLAIM_AMOUNT_REMAINING_AMOUNT); return(View(hospitalInformation)); } } else { ModelState.AddModelError("", Constants.MSG_GENERAL_OPD_EXPENSE_AMOUNT); return(View(hospitalInformation)); } } else { ModelState.AddModelError("", Constants.MSG_GENERAL_ADD_PATIENT_RECEIPTS); return(View(hospitalInformation)); } } else { ModelState.AddModelError("", Constants.MSG_GENERAL_ADD_PATIENT_INFORMATION); return(View(hospitalInformation)); } } else { if (ModelState.IsValid) { opdExpense.ModifiedDate = DateTime.Now; opdExpense.EmployeeEmailAddress = GetEmailAddress(); _opdExpenseService.UpdateOpdExpense(opdExpense); //EmailSend(opdExpense); return(RedirectToAction(UrlIndex, UrlOpdExpense)); } } return(View(hospitalInformation)); } catch (Exception ex) { logger.Error("Hospital Expense : Create()" + ex.Message.ToString()); return(View(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } }
public static MailMessage GetMailMessage(OpdExpenseVM expense) { string HrEmailSubject = "Opd Claim for HR approval"; string FinanceEmailSubject = "Opd claim for Finance approval"; string ManagementEmailSubject = "Opd claim for Management approval"; string FinanceRejectedSubject = "Opd claim rejected by finance"; string HrRejectedSubject = "Opd claim rejected by HR"; string EmployeeApprovedSubject = "opd claim approved"; string ManagementRejectedSubject = "Opd claim rejected by management"; string HrEmailKey = "HR:List"; string FinanceEmailKey = "FIN:List"; string ManagementEmailKey = "MAN:List"; OfficeManagerController managerController = new OfficeManagerController(); string RoleType = managerController.AuthenticateUserForEmail(); var message = new MailMessage(); message.Body = GetEmailBody(expense); message.IsBodyHtml = true; message.From = new MailAddress("*****@*****.**"); string toEmail = ""; if (expense.Status == ClaimStatus.SUBMITTED) { toEmail = ConfigUtil.GetConfigValue(HrEmailKey).Replace(",", "; "); message.Subject = HrEmailSubject; message.To.Add(new MailAddress(toEmail)); } else if (expense.Status == ClaimStatus.HRAPPROVED) { toEmail = ConfigUtil.GetConfigValue(FinanceEmailKey).Replace(",", "; "); message.Subject = FinanceEmailSubject; message.To.Add(new MailAddress(toEmail)); } else if (expense.Status == ClaimStatus.HRREJECTED) { toEmail = expense.EmployeeEmailAddress; message.Subject = HrRejectedSubject; message.To.Add(new MailAddress(toEmail)); } else if (expense.Status == ClaimStatus.FINAPPROVED) { toEmail = ConfigUtil.GetConfigValue(ManagementEmailKey).Replace(",", "; "); message.Subject = ManagementEmailSubject; message.To.Add(new MailAddress(toEmail)); } else if (expense.Status == ClaimStatus.FINREJECTED) { toEmail = ConfigUtil.GetConfigValue(HrEmailKey).Replace(",", "; "); message.Subject = FinanceRejectedSubject; message.To.Add(new MailAddress(toEmail)); } else if (expense.Status == ClaimStatus.MANAPPROVED) { toEmail = expense.EmployeeEmailAddress; message.Subject = EmployeeApprovedSubject; message.To.Add(new MailAddress(toEmail)); } else if (RoleType == "HR" && expense.Status == ClaimStatus.MANINPROCESS) { toEmail = ConfigUtil.GetConfigValue(ManagementEmailKey); message.Subject = ManagementEmailSubject; message.To.Add(new MailAddress(toEmail)); } else if (expense.Status == ClaimStatus.MANREJECTED) { toEmail = ConfigUtil.GetConfigValue(HrEmailKey); if (expense.FinanceApproval.HasValue && expense.FinanceApproval.Value) { toEmail = ConfigUtil.GetConfigValue(FinanceEmailKey); } message.Subject = ManagementRejectedSubject; message.To.Add(new MailAddress(toEmail)); } return(message); }
public OpdExpenseVM CreateOpdExpense(OpdExpenseVM opdExpenseVm) { var OpdExpense = _opdExpenseRepository.Add(Mapper.Map <OpdExpense>(opdExpenseVm), opdExpenseVm.EmployeeEmailAddress); return(Mapper.Map <OpdExpenseVM>(OpdExpense)); }
public ActionResult Edit(OpdExpenseVM OpdExpense) { try { string buttonStatus = Request.Form["buttonName"]; AuthenticateUser(); var opdInformation = GeneralController.GetTravelExpense(OpdExpense.ID, _opdExpenseService, _travelExpenseService); ViewData["OPDEXPENSE_ID"] = OpdExpense.ID; ViewData["OPDTYPE"] = OpdExpense.OpdType; ViewBag.EmployeeDepartment = opdInformation.EmployeeDepartment; if (buttonStatus == "submit") { OpdExpense.Status = ClaimStatus.FININPROCESS; } else { OpdExpense.Status = ClaimStatus.INPROGRESS; } if (OpdExpense.Status == ClaimStatus.FININPROCESS) { if (opdInformation.ListTravelExpense.Count > 0) { if (GetTravelExpenseAmount(OpdExpense.ID, OpdExpense.TotalAmountClaimed)) { if (ModelState.IsValid) { OpdExpense.ModifiedDate = DateTime.Now; OpdExpense.EmployeeEmailAddress = GetEmailAddress(); _opdExpenseService.UpdateOpdExpense(OpdExpense); return(RedirectToAction(UrlIndex, UrlOpdExpense)); } } else { ModelState.AddModelError("", Constants.MSG_GENERAL_TRAVEL_EXPENSE_AMOUNT); return(View(opdInformation)); } } else { ModelState.AddModelError("", Constants.MSG_GENERAL_ADD_TRAVEL_EXPENSE_RECEIPTS); return(View(opdInformation)); } } else { if (ModelState.IsValid) { OpdExpense.CreatedDate = DateTime.Now; OpdExpense.ModifiedDate = DateTime.Now; OpdExpense.EmployeeEmailAddress = GetEmailAddress(); _opdExpenseService.UpdateOpdExpense(OpdExpense); return(RedirectToAction(UrlIndex, UrlOpdExpense)); } } return(View(opdInformation)); } catch (Exception ex) { logger.Error("Travel Expense : Edit([Bind])" + ex.Message.ToString()); return(View(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } }
public void CalculateRemainingAmount(OpdExpenseVM opdInformation) { string remainingAmount = GeneralController.CalculateRemainingAmount(opdInformation.EmployeeEmailAddress, opdInformation.OpdType, string.Empty, string.Empty, _opdExpenseService, _setupExpenseAmountService, true); ViewBag.RemainingAmount = remainingAmount; }
public static HospitalExpenseVM GetHospitalExpense(int Id, IOpdExpenseService _opdExpenseService, IOpdExpensePatientService _opdExpensePatientService, IOpdExpenseImageService _opdExpenseImageService) { OpdExpenseVM opdExpense = _opdExpenseService.GetOpdExpensesAgainstId(Id); var hospitalInformation = new HospitalExpenseVM() { OpdExpensePatients = _opdExpensePatientService.GetOpdExpensesPatientAgainstOpdExpenseId(Id), OpdExpenseImages = _opdExpenseImageService.GetOpdExpensesImageAgainstOpdExpenseId(Id), ID = opdExpense.ID, ClaimantSufferedIllness = opdExpense.ClaimantSufferedIllness, ClaimantSufferedIllnessDetails = opdExpense.ClaimantSufferedIllnessDetails, ClaimantSufferedIllnessDate = opdExpense.ClaimantSufferedIllnessDate, DateIllnessNoticed = opdExpense.DateIllnessNoticed, DateRecovery = opdExpense.DateRecovery, Diagnosis = opdExpense.Diagnosis, DoctorName = opdExpense.DoctorName, DrugsPrescribedBool = opdExpense.DrugsPrescribedBool, DrugsPrescribedDescription = opdExpense.DrugsPrescribedDescription, EmployeeDepartment = opdExpense.EmployeeDepartment, EmployeeName = opdExpense.EmployeeName, EmployeeEmailAddress = opdExpense.EmployeeEmailAddress, HospitalName = opdExpense.HospitalName, FinanceApproval = opdExpense.FinanceApproval, FinanceComment = opdExpense.FinanceComment, FinanceApprovalDate = opdExpense.FinanceApprovalDate, FinanceEmailAddress = opdExpense.FinanceEmailAddress, FinanceName = opdExpense.FinanceName, HrApproval = opdExpense.HrApproval, HrComment = opdExpense.HrComment, HrName = opdExpense.HrName, HrApprovalDate = opdExpense.HrApprovalDate, HrEmailAddress = opdExpense.HrEmailAddress, ManagementApproval = opdExpense.ManagementApproval, ManagementComment = opdExpense.ManagementComment, ManagementName = opdExpense.ManagementName, ManagementApprovalDate = opdExpense.ManagementApprovalDate, ManagementEmailAddress = opdExpense.ManagementEmailAddress, PeriodConfinementDateFrom = opdExpense.PeriodConfinementDateFrom, PeriodConfinementDateTo = opdExpense.PeriodConfinementDateTo, Status = opdExpense.Status, OpdType = opdExpense.OpdType, TotalAmountClaimed = opdExpense.TotalAmountClaimed, TotalAmountApproved = opdExpense.TotalAmountApproved, ClaimYear = opdExpense.ClaimYear, ClaimMonth = opdExpense.ClaimMonth, CreatedDate = opdExpense.CreatedDate, ModifiedDate = opdExpense.ModifiedDate, PhysicalDocumentReceived = opdExpense.PhysicalDocumentReceived, PayRollMonth = opdExpense.PayRollMonth, ExpenseNumber = opdExpense.ExpenseNumber, OpdEncrypted = opdExpense.OpdEncrypted, HospitalizationType = opdExpense.HospitalizationType, MaternityType = opdExpense.MaternityType }; return(hospitalInformation); }
public void UpdateOpdExpense(OpdExpenseVM opdExpenseVm) { OpdExpense obj = Mapper.Map <OpdExpense>(opdExpenseVm); _opdExpenseRepository.Update(obj, opdExpenseVm.EmployeeEmailAddress); }
public static string GetEmailBody(OpdExpenseVM opdExpense) { string fileContent = File.ReadAllText(HttpContext.Current.Server.MapPath("~/EmailPages/ClaimForm.html")); fileContent = fileContent.Replace("__EmployeeName", opdExpense.EmployeeName) .Replace("__Month", opdExpense.ClaimMonth) .Replace("__Year", opdExpense.ClaimYear) .Replace("__Status", opdExpense.Status) .Replace("__Amount", opdExpense.TotalAmountClaimed.ToString()); var PatientRows = ""; var patientRowTeplate = @"<tr> <td align='center'>__sr</td> <td align='center'>__Name</td> <td align='center'>__Age</td> <td align='center'>__Relationship</td> </tr>"; int sr = 1; foreach (var patient in opdExpense.OpdExpensePatients) { PatientRows += patientRowTeplate.Replace("__sr", sr.ToString()) .Replace("__Name", patient.Name) .Replace("__Age", patient.Age.ToString()) .Replace("__Relationship", patient.RelationshipEmployee); sr++; } fileContent = fileContent.Replace("__PatientRows", PatientRows); string commentsTemplate = "<h2>__department</h2><strong>__FromName</strong><p>__comments</p>"; if (!string.IsNullOrEmpty(opdExpense.HrComment)) { fileContent = fileContent.Replace("__CommentsHeading", "<h3>Comments</h3>"); fileContent = fileContent.Replace("__HRComments", commentsTemplate.Replace("__department", "HR") .Replace("__FromName", opdExpense.HrName) .Replace("__comments", opdExpense.HrComment) ); } else { fileContent = fileContent.Replace("__HRComments", ""); } if (!string.IsNullOrEmpty(opdExpense.FinanceComment)) { fileContent = fileContent.Replace("__CommentsHeading", "<h3>Comments</h3>"); fileContent = fileContent.Replace("__FinanceComments", commentsTemplate.Replace("__department", "Finance") .Replace("__FromName", opdExpense.FinanceName) .Replace("__comments", opdExpense.FinanceComment) ); } else { fileContent = fileContent.Replace("__FinanceComments", ""); } if (!string.IsNullOrEmpty(opdExpense.ManagementComment)) { fileContent = fileContent.Replace("__CommentsHeading", "<h3>Comments</h3>"); fileContent = fileContent.Replace("__ManagerComments", commentsTemplate.Replace("__department", "Management") .Replace("__FromName", opdExpense.ManagementName) .Replace("__comments", opdExpense.ManagementComment) ); } else { fileContent = fileContent.Replace("__ManagerComments", ""); } fileContent = fileContent.Replace("__CommentsHeading", ""); return(fileContent); }