public ActionResult Index(DateTime?from, DateTime?to) { var userId = User.Identity.GetUserId(); var expendituresDto = _expenditureService.GetUserExpendituresFromRange(userId, from, to); var allCategories = _categoryService.GetCategories(userId); var expendituresViewModel = new ExpendituresViewModel { ExpendituresDto = expendituresDto, AvailableCategories = allCategories }; return(View(expendituresViewModel)); }
public ActionResult IssuedExpenditures(DateTime?fromDate, DateTime?toDate) { var nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone(); nfi.NumberGroupSeparator = " "; var queryToDate = toDate ?? DateTime.Now.Date; var queryFromDate = fromDate ?? queryToDate.AddDays(-30); var expenditureList = (from expenditure in _db.Expenditures .Include(e => e.DeskGroup).Include(e => e.Type).Include(e => e.Object) .Where(e => e.PaymentTypeId == PaymentTypes.Cash) join eo in _db.ExpenditureOperations on expenditure.ExpenditureId equals eo.ExpenditureId into operations from operation in operations.OrderByDescending(o => o.OperationDateTime).Take(1) orderby operation.OperationDateTime descending where operation.OperationDateTime >= queryFromDate && operation.OperationDateTime < queryToDate.AddDays(1) select new { expenditure, operation }).ToList(); var model = new ExpendituresViewModel { FromDate = queryFromDate.ToString("d"), ToDate = queryToDate.ToString("d"), Items = (from e in expenditureList select new ExpenditureViewItem { ExpenditureId = e.expenditure.ExpenditureId, Amount = e.expenditure.Amount.ToString("#,0.00", nfi), Name = e.expenditure.Name, DeskGroup = e.expenditure.DeskGroup != null ? e.expenditure.DeskGroup.Name : "", Type = e.expenditure.Type != null ? e.expenditure.Type.Description : "", Object = e.expenditure.Object != null ? e.expenditure.Object.Description : "", IssuedDateTime = e.operation.OperationDateTime, Status = e.operation.OperationTypeId }).ToList() }; return(PartialView(model)); }
public ActionResult Index(ExpendituresViewModel viewModel) { return(RedirectToAction("Index", new { to = viewModel.ExpendituresDto.To, from = viewModel.ExpendituresDto.From })); }
public static bool IsComplete(this ProjectCreateSection projectCreateSection, Project project) { if (project == null) { return(false); } var currentFirmaSession = HttpRequestStorage.FirmaSession; switch (projectCreateSection.ToEnum) { case ProjectCreateSectionEnum.Basics: return(!new BasicsViewModel(project).GetValidationResults().Any()); case ProjectCreateSectionEnum.CustomAttributes: return(project.AreProjectCustomAttributesValid(currentFirmaSession)); case ProjectCreateSectionEnum.LocationSimple: var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults(); return(!locationSimpleValidationResults.Any()); case ProjectCreateSectionEnum.Organizations: return(!new OrganizationsViewModel(project, currentFirmaSession).GetValidationResults().ToList().Any()); case ProjectCreateSectionEnum.Contacts: return(!new ContactsViewModel(project, currentFirmaSession).GetValidationResults().ToList().Any()); case ProjectCreateSectionEnum.LocationDetailed: return(true); case ProjectCreateSectionEnum.ExpectedAccomplishments: return(true); case ProjectCreateSectionEnum.ReportedAccomplishments: if (!MultiTenantHelpers.TrackAccomplishments()) { return(true); } var pmValidationResults = new PerformanceMeasuresViewModel( project.PerformanceMeasureActuals.Select(x => new PerformanceMeasureActualSimple(x)).ToList(), project.PerformanceMeasureActualYearsExemptionExplanation, project.GetPerformanceMeasuresExemptReportingYears().Select(x => new ProjectExemptReportingYearSimple(x)).ToList(), project) { ProjectID = project.ProjectID }.GetValidationResults(); return(!pmValidationResults.Any()); case ProjectCreateSectionEnum.Budget: // todo: more complicated than that. return(ProjectCreateSection.Basics.IsComplete(project)); case ProjectCreateSectionEnum.ReportedExpenditures: if (MultiTenantHelpers.GetTenantAttributeFromCache().BudgetType == BudgetType.AnnualBudgetByCostType) { var expectedYears = project.CalculateCalendarYearRangeForExpendituresWithoutAccountingForExistingYears(); var missingYears = expectedYears.GetMissingYears(project.ProjectFundingSourceExpenditures.Select(x => x.CalendarYear)).ToList(); // for expenditures by cost type, we are just validating that either they have any expenditures for the required year range or they have no expenditures but have an explanation return((project.ProjectFundingSourceExpenditures.Any() && !missingYears.Any() && string.IsNullOrWhiteSpace(project.ExpendituresNote)) || (!project.ProjectFundingSourceExpenditures.Any() && !string.IsNullOrWhiteSpace(project.ExpendituresNote))); } else { var projectFundingSourceExpenditures = project.ProjectFundingSourceExpenditures.ToList(); var calendarYearRangeForExpenditures = projectFundingSourceExpenditures.CalculateCalendarYearRangeForExpenditures(project); var projectFundingSourceExpenditureBulks = ProjectFundingSourceExpenditureBulk.MakeFromList(projectFundingSourceExpenditures, calendarYearRangeForExpenditures); var validationResults = new ExpendituresViewModel(projectFundingSourceExpenditureBulks, project) { ProjectID = project.ProjectID } .GetValidationResults(); return(!validationResults.Any()); } case ProjectCreateSectionEnum.Classifications: var projectClassificationSimples = ProjectCreateController.GetProjectClassificationSimples(project); var classificationValidationResults = new EditProposalClassificationsViewModel(projectClassificationSimples, project).GetValidationResults(); return(!classificationValidationResults.Any()); case ProjectCreateSectionEnum.Assessment: return(!new EditAssessmentViewModel(project.ProjectAssessmentQuestions.Select(x => new ProjectAssessmentQuestionSimple(x)).ToList()).GetValidationResults().Any()); case ProjectCreateSectionEnum.Photos: return(ProjectCreateSection.Basics.IsComplete(project)); case ProjectCreateSectionEnum.AttachmentsAndNotes: return(ProjectCreateSection.Basics.IsComplete(project)); case ProjectCreateSectionEnum.BulkSetSpatialInformation: return(ProjectCreateSection.Basics.IsComplete(project)); case ProjectCreateSectionEnum.PartnerFinder: return(true); case ProjectCreateSectionEnum.ExternalLinks: return(ProjectCreateSection.Basics.IsComplete(project)); default: throw new ArgumentOutOfRangeException($"IsComplete(): Unhandled ProjectCreateSection Enum: {projectCreateSection.ToEnum}"); } }