public async Task ShowExpenseReportAsync(ExpenseReportViewModel expenseReportViewModel) { await DependencyService.Get <IViewService>().ExecuteBusyActionAsync( async() => { var serviceFactory = DependencyService.Get <IServiceFactory>(); //TODO: expenseReportViewModel.EmployeeId = App.EmployeeId; var editReportVM = new EditExpenseReportViewModel(serviceFactory) { ExpenseReport = expenseReportViewModel, }; AddChargesViewModel addChargesVM = new AddChargesViewModel(serviceFactory); await addChargesVM.LoadChargesAsync(); editReportVM.AddCharges = addChargesVM; ExpenseReportChargesViewModel associatedChargesVM = new ExpenseReportChargesViewModel(serviceFactory); await associatedChargesVM.LoadChargesAsync(expenseReportViewModel.ExpenseReportId); editReportVM.AssociatedCharges = associatedChargesVM; await Navigation?.PushAsync(new ExpenseReportDetailPage() { ViewModel = editReportVM }, true); }); }
public async Task <IActionResult> Update(Guid id, ExpenseReportViewModel expenseReportViewModel) { var expense = await _expenseReportRepository.GetCompleteExpenseReportById(id, UserId); if (expense == null) { return(BadRequest()); } var authResult = await _authorizationService.AuthorizeAsync(User, expense, ExpenseAuthorizationHandler.CAN_ACESS_EXPENSE); if (!authResult.Succeeded) { return(new ForbidResult()); } var expenseToUpdate = _mapper.Map <ExpenseReport>(expenseReportViewModel); var success = await _expenseReportService.Update(expenseToUpdate); if (!success) { return(BadRequest()); } return(NoContent()); }
public async Task <IActionResult> Expense(int?page) { IList <Expense> totalExpense = new List <Expense>(); List <Expense> expenseItems = context. Expenses .Include(item => item.ExpenseCategory) .ToList(); IList <ExpenseCategory> expenseCategories = context.ExpenseCategories.ToList(); foreach (var item in expenseItems) { totalExpense.Add(item); } ; ExpenseReportViewModel viewModel = new ExpenseReportViewModel { ExpenseCategories = expenseCategories, Expenses = expenseItems, TotalExpense = totalExpense }; return(View(viewModel)); ViewBag.Title = "Expenses in Category"; int pageSize = 3; }
public void ShowExpenseReport(ExpenseReportViewModel expenseReportViewModel) { EventHandler <EventArgs <ExpenseReportViewModel> > handler = this.ShowExpenseReportRequested; if (handler != null) { handler(this, new EventArgs <ExpenseReportViewModel>(expenseReportViewModel)); } }
public IActionResult Report() { ExpenseReportViewModel viewModel = new ExpenseReportViewModel(); viewModel.Attorneys = _attorneyRepo.Attorneys; viewModel.NewExpenseReport = new NewExpenseReport(); //viewModel.NewExpenseReport.InitialDate = DateTime.Now; //viewModel.NewExpenseReport.FinalDate = DateTime.Now.Date; return(View(viewModel)); }
public ExpenseReportViewModel GetExpenseReport(ReportRequestModel model) { var expenses = _expense.GetExpensesByDateRange(model).ToList(); var totalExpense = expenses.Sum(x => x.Amount); var viewModels = new ExpenseReportViewModel(expenses, totalExpense); return(viewModels); }
async void AddItem_Clicked(object sender, EventArgs e) { ExpenseReportViewModel reportVM = new ExpenseReportViewModel(DependencyService.Get <IServiceFactory>()) { Approver = "jhill", EmployeeId = App.EmployeeId, ExpenseReportId = null, }; await this.ShowExpenseReportAsync(reportVM); }
public void NewReport() { ExpenseReportViewModel reportVM = new ExpenseReportViewModel() { Approver = this.EmployeeViewModel.Manager, EmployeeId = this.EmployeeViewModel.EmployeeId, ExpenseReportId = 0, }; this.ShowExpenseReportAsync(reportVM); }
public ActionResult Update(int?expReportId) { if (expReportId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExpenseReportViewModel vm = new ExpenseReportViewModel(); vm.ExpenseReport = _reportService.GetByExpenseReportID(expReportId); vm.LineItems = _lineItemService.GetLineItems(expReportId); return(View(vm)); }
void ExpenseReportsView_ShowExpenseReport(object sender, EventArgs e) { if (sender == null) { return; } DevExpress.Mvvm.IDialogService service = ViewReportDialogService; ExpenseReportViewModel expenseReportViewModel = (ExpenseReportViewModel)sender; var editReportVM = new EditExpenseReportViewModel(); editReportVM.ExpenseReport = expenseReportViewModel; AddChargesViewModel addChargesVM = new AddChargesViewModel(); addChargesVM.LoadCharges(); editReportVM.AddCharges = addChargesVM; ExpenseReportChargesViewModel associatedChargesVM = new ExpenseReportChargesViewModel(); associatedChargesVM.LoadCharges(expenseReportViewModel.ExpenseReportId); editReportVM.AssociatedCharges = associatedChargesVM; List <UICommand> commands = new List <UICommand>(); if (DataContext is ApproveExpenseReportsViewModel) { ICommand approveCommand = new DelegateCommand <CancelEventArgs>(x => { //if(ApproveDialogService.ShowDialog(MessageBoxButton.OKCancel, "Confirm expense report", null) == MessageBoxResult.OK) { expenseReportViewModel.ApproveReportCommand.Execute(null); //} else { // x.Cancel = true; //} }); commands.Add(new UICommand(null, "Approve", approveCommand, true, false)); } if (editReportVM.CanSubmit) { commands.Add(new UICommand(null, "Submit", expenseReportViewModel.SubmitReportCommand, true, false)); } UICommand cancelCommand = new UICommand(null, "Close", null, false, true); commands.Add(cancelCommand); if (service.ShowDialog(commands, expenseReportViewModel.Purpose + " report", editReportVM) != cancelCommand) { expenseReportViewModel.ExpenseReportsViewModel.OnExpenseReportApproved(editReportVM); } }
public ActionResult Update(ExpenseReport expenseReport) { if (ModelState.IsValid) { _reportService.Update(expenseReport); return(RedirectToAction("ViewExpenseReport", "ExpenseReport", new { expReportId = expenseReport.ExpenseReportID })); } ExpenseReportViewModel vm = new ExpenseReportViewModel(); vm.ExpenseReport = _reportService.GetByExpenseReportID(expenseReport.ExpenseReportID); vm.LineItems = _lineItemService.GetLineItems(expenseReport.ExpenseReportID); return(View(vm)); }
public void ShowExpenseReport(ExpenseReportViewModel expenseReportViewModel) { var editReportVM = new EditExpenseReportViewModel(); editReportVM.ExpenseReport = expenseReportViewModel; AddChargesViewModel addChargesVM = new AddChargesViewModel(); addChargesVM.LoadCharges(); editReportVM.AddCharges = addChargesVM; ExpenseReportChargesViewModel associatedChargesVM = new ExpenseReportChargesViewModel(); associatedChargesVM.LoadCharges(expenseReportViewModel.ExpenseReportId); editReportVM.AssociatedCharges = associatedChargesVM; this.CurrentViewModel = editReportVM; }
public ActionResult ViewExpenseReport(int?expReportId) { if (expReportId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExpenseReportViewModel vm = new ExpenseReportViewModel(); vm.ExpenseReport = _reportService.GetByExpenseReportID(expReportId); vm.LineItems = _lineItemService.GetLineItems(expReportId); vm.LineItem = new LineItem(); vm.LineItem.ExpenseReportID = expReportId; var categories = _categoryService.GetCategories(); ViewBag.CategoryID = new SelectList(categories, "CategoryID", "CategoryName", null); return(View(vm)); }
public async void ShowExpenseReportAsync(ExpenseReportViewModel expenseReportViewModel) { await this.ViewService.ExecuteBusyActionAsync( async() => { var editReportVM = new EditExpenseReportViewModel(); editReportVM.ExpenseReport = expenseReportViewModel; AddChargesViewModel addChargesVM = new AddChargesViewModel(); await addChargesVM.LoadChargesAsync(); editReportVM.AddCharges = addChargesVM; ExpenseReportChargesViewModel associatedChargesVM = new ExpenseReportChargesViewModel(); await associatedChargesVM.LoadChargesAsync(expenseReportViewModel.ExpenseReportId); editReportVM.AssociatedCharges = associatedChargesVM; this.CurrentViewModel = editReportVM; }); }
public ActionResult CreateLineItem(LineItem lineItem) { if (ModelState.IsValid) { _lineItemService.Create(lineItem); return(RedirectToAction("ViewExpenseReport", "ExpenseReport", new { expReportId = lineItem.ExpenseReportID })); } ExpenseReportViewModel vm = new ExpenseReportViewModel(); vm.ExpenseReport = _reportService.GetByExpenseReportID(lineItem.ExpenseReportID); vm.LineItems = _lineItemService.GetLineItems(lineItem.ExpenseReportID); vm.LineItem = new LineItem(); vm.LineItem.ExpenseReportID = lineItem.ExpenseReportID; var categories = _categoryService.GetCategories(); ViewBag.CategoryID = new SelectList(categories, "CategoryID", "CategoryName", null); return(View("ViewExpenseReport", vm)); }
public async Task <IActionResult> Add(ExpenseReportViewModel expenseReportViewModel) { foreach (var expenseReportDetail in expenseReportViewModel.Details.Where(p => p.Image != null)) { var imageName = $"{Guid.NewGuid()}_{expenseReportDetail.Image}"; await _imageFileService.Upload(expenseReportDetail.ImageUpload, imageName); expenseReportDetail.Image = imageName; } var expense = _mapper.Map <ExpenseReport>(expenseReportViewModel); expense.UserId = UserId; var success = await _expenseReportService.Add(expense); if (!success) { return(ApiResponse(ModelState)); } return(NoContent()); }
public List <ExpenseReportViewModel> GetReport(string bonType, DateTime?dateFrom, DateTime?dateTo, int offset) { //IQueryable<InventoryWeavingMovement> Query = this.DbSetMovement; DateTime DateFrom = dateFrom == null ? new DateTime(1970, 1, 1) : (DateTime)dateFrom; DateTime DateTo = dateTo == null ? DateTime.Now : (DateTime)dateTo; var result = (from a in DbContext.InventoryWeavingDocuments join b in DbContext.InventoryWeavingMovements on a.Id equals b.InventoryWeavingDocumentId where a._IsDeleted == false && b._IsDeleted == false && a.BonType == (string.IsNullOrWhiteSpace(bonType) ? a.BonType : bonType) && a.Date.AddHours(offset).Date >= DateFrom.Date && a.Date.AddHours(offset).Date <= DateTo.Date orderby a.Date, a._CreatedUtc ascending select new ExpenseReportViewModel { Date = a.Date, Construction = b.Construction, BonNo = a.BonNo, Grade = b.Grade, Type = b.Type, MaterialName = b.MaterialName, WovenType = b.WovenType, Yarn1 = b.Yarn1, Yarn2 = b.Yarn2, YarnOrigin1 = b.YarnOrigin1, YarnOrigin2 = b.YarnOrigin2, YarnType1 = b.YarnType1, YarnType2 = b.YarnType2, Qty = b.Quantity, QtyPiece = b.QuantityPiece }); var data1 = result.GroupBy(s => new { s.Date, s.BonNo, s.Grade, s.Type, s.MaterialName, s.WovenType, s.Width, s.Yarn1, s.Yarn2, s.YarnOrigin1, s.YarnOrigin2, s.YarnType1, s.YarnType2 }).Select(s => new ExpenseReportViewModel() { Date = s.Key.Date, BonNo = s.FirstOrDefault().BonNo, Construction = s.FirstOrDefault().Construction, Grade = s.FirstOrDefault().Grade, Type = s.Key.Type, Qty = s.Sum(d => d.Qty), QtyPiece = s.Sum(d => d.QtyPiece), MaterialName = s.Key.MaterialName, WovenType = s.Key.WovenType, Width = s.Key.Width, Yarn1 = s.Key.Yarn1, Yarn2 = s.Key.Yarn2, YarnOrigin1 = s.Key.YarnOrigin1, YarnOrigin2 = s.Key.YarnOrigin2, YarnType1 = s.Key.YarnType1, YarnType2 = s.Key.YarnType2 }); var Data = data1.GroupBy(s => new { s.MaterialName, s.WovenType, s.Width, s.Yarn1, s.Yarn2, s.YarnOrigin1, s.YarnOrigin2, s.YarnType1, s.YarnType2, }).Select(s => new ExpenseReportViewModel() { Date = s.FirstOrDefault().Date, BonNo = s.FirstOrDefault().BonNo, Construction = s.FirstOrDefault().Construction, Grade = s.FirstOrDefault().Grade, Qty = s.FirstOrDefault(d => d.Type == "OUT") != null ? s.FirstOrDefault(d => d.Type == "IN").Qty - s.FirstOrDefault(d => d.Type == "OUT").Qty : s.FirstOrDefault(d => d.Type == "OUT") == null ? s.FirstOrDefault(d => d.Type == "IN").Qty : 0, QtyPiece = s.FirstOrDefault(d => d.Type == "OUT") != null ? s.FirstOrDefault(d => d.Type == "IN").QtyPiece - s.FirstOrDefault(d => d.Type == "OUT").QtyPiece : s.FirstOrDefault(d => d.Type == "OUT") == null ? s.FirstOrDefault(d => d.Type == "IN").QtyPiece : 0 }).Where(x => x.Qty > 0 && x.QtyPiece > 0).ToList(); List <ExpenseReportViewModel> reportViewModels = new List <ExpenseReportViewModel>(); int index = 1; foreach (var i in Data) { reportViewModels.Add(new ExpenseReportViewModel { Date = i.Date, BonNo = i.BonNo, Construction = i.Construction, Grade = i.Grade, Qty = i.Qty, QtyPiece = i.QtyPiece }); } var total = new ExpenseReportViewModel { //Date = , BonNo = "", Construction = "Total:", Grade = "", QtyPiece = Math.Round(Data.Sum(x => x.QtyPiece), 2), Qty = Math.Round(Data.Sum(x => x.Qty), 2) }; reportViewModels.Add(total); return(reportViewModels); //return Data.ToList(); }