public JsonResult ProcessInvoice(int invoiceId) { try { var vatRate = Convert.ToDecimal(ConfigurationManager.AppSettings["VatRate"]); var invoicedTimeSheets = timesheetService.GetTimeSheetsByInvoiceId(invoiceId); ViewBag.InvoiceType = invoicedTimeSheets.First().TimesheetTypeId; var isRetainer = (ViewBag.InvoiceType == 2); this.timesheetService.ProcessInvoice(invoiceId, (int)TimesheetStatus.Processed, (int)InvoiceStatus.Processed, vatRate, isRetainer); var json = new { success = true, data = "" }; return(this.Json(json)); } catch (Exception ex) { var json = new { success = false, data = ex.Message }; return(this.Json(json)); } }
public ActionResult ViewInvoiceReport(int id) { var invoice = this.timesheetService.GetInvoice(id); var associate = this.associateService.GetAssociate <AssociateModel>(invoice.AssociateId); if (associate.UmbrellaCompanyId > 0) { associate.UmbrellaCompanyName = this.associateService.GetUmbrellaCompanyName(associate.UmbrellaCompanyId); } string companyName = this.timesheetService.GetCompanyName(id); if (companyName == null) { companyName = associate.RegisteredCompanyName; if (associate.BusinessTypeId.GetValueOrDefault() == (int)MR_DAL.Enumerations.BusinessType.Umbrella) { companyName = associate.UmbrellaCompanyName; } } //var companyName = associate.RegisteredCompanyName; //if (associate.BusinessTypeId.GetValueOrDefault() == (int)MR_DAL.Enumerations.BusinessType.Umbrella) //{ // companyName = associate.UmbrellaCompanyName; //} ViewBag.InvoiceId = id; ViewBag.ReportNo = invoice.InvoiceId.ToString("00000"); ViewBag.Name = associate.FirstName + " " + associate.LastName; ViewBag.BusinessTypeId = associate.BusinessTypeId; ViewBag.Company = companyName; ViewBag.Code = invoice.AssociateId.ToString("00000"); ViewBag.AssociateId = invoice.AssociateId; ViewBag.HasFile = invoice.HasFile; ViewBag.ShowProcessButton = (invoice.Status == "Invoiced"); ViewBag.StartDate = invoice.StartDate; ViewBag.EndDate = invoice.EndDate; ViewBag.OptOutSelfBilling = associate.OptOutSelfBilling; try { IEnumerable <TimeSheetsGridViewModel> invoicedTimeSheets = timesheetService.GetTimeSheetsByInvoiceId(id); ViewBag.InvoiceType = invoicedTimeSheets.First().TimesheetTypeId; if (ViewBag.InvoiceType == 2) { var retainerEntries = this.timesheetService.GetInvoicesReportRetainerData(id); ViewBag.AssociateRate = retainerEntries.First().AssociateRate; } this.SetUploader(id); return(PartialView("_InvoiceReport")); } catch (Exception) { throw new Exception("Invoice Report doesn't contain any timesheets"); } }