Esempio n. 1
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationBudgetLineItem(GrantAllocation grantAllocation, CostType costType, decimal grantAllocationBudgetLineItemAmount) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationBudgetLineItemID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     this.GrantAllocation   = grantAllocation;
     grantAllocation.GrantAllocationBudgetLineItems.Add(this);
     this.CostTypeID = costType.CostTypeID;
     this.GrantAllocationBudgetLineItemAmount = grantAllocationBudgetLineItemAmount;
 }
Esempio n. 2
0
        public static BudgetVsActualLineItem GetTotalBudgetVsActualLineItem(this GrantAllocation grantAllocation)
        {
            var budget = grantAllocation.GrantAllocationBudgetLineItems.Select(bli => bli.GrantAllocationBudgetLineItemAmount).Sum();
            var expendituresFromDatamart = grantAllocation.GrantAllocationExpenditures.Select(gae => gae.ExpenditureAmount).Sum();
            var invoicedToDate           = grantAllocation.GrantAllocationAwards.Sum(grantAllocationAward => grantAllocationAward.GetTotalInvoicedToDate());

            var budgetVsActualLineItem = new BudgetVsActualLineItem(budget, expendituresFromDatamart, invoicedToDate);

            return(budgetVsActualLineItem);
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationProgramIndexProjectCode(GrantAllocation grantAllocation, ProgramIndex programIndex) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationProgramIndexProjectCodeID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     this.GrantAllocation   = grantAllocation;
     grantAllocation.GrantAllocationProgramIndexProjectCodes.Add(this);
     this.ProgramIndexID = programIndex.ProgramIndexID;
     this.ProgramIndex   = programIndex;
     programIndex.GrantAllocationProgramIndexProjectCodes.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationProgramManager(GrantAllocation grantAllocation, Person person) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationProgramManagerID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     this.GrantAllocation   = grantAllocation;
     grantAllocation.GrantAllocationProgramManagers.Add(this);
     this.PersonID = person.PersonID;
     this.Person   = person;
     person.GrantAllocationProgramManagers.Add(this);
 }
Esempio n. 5
0
        public static string GetAssociatedProgramIndexProjectCodePairsCommaDelimited(this GrantAllocation grantAllocation)
        {
            List <string> programIndexProjectCodePairs = new List <string>();

            foreach (var pair in grantAllocation.GrantAllocationProgramIndexProjectCodes)
            {
                programIndexProjectCodePairs.Add(pair.ProgramIndexProjectCodeDisplayString);
            }

            return(string.Join(", ", programIndexProjectCodePairs));
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectGrantAllocationRequest(Project project, GrantAllocation grantAllocation) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectGrantAllocationRequestID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectID = project.ProjectID;
     this.Project   = project;
     project.ProjectGrantAllocationRequests.Add(this);
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     this.GrantAllocation   = grantAllocation;
     grantAllocation.ProjectGrantAllocationRequests.Add(this);
 }
Esempio n. 7
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public AgreementGrantAllocation(Agreement agreement, GrantAllocation grantAllocation) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.AgreementGrantAllocationID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.AgreementID = agreement.AgreementID;
     this.Agreement   = agreement;
     agreement.AgreementGrantAllocations.Add(this);
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     this.GrantAllocation   = grantAllocation;
     grantAllocation.AgreementGrantAllocations.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationChangeLog(GrantAllocation grantAllocation, Person changePerson, DateTime changeDate) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationChangeLogID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID          = grantAllocation.GrantAllocationID;
     this.GrantAllocation            = grantAllocation;
     grantAllocation.GrantAllocationChangeLogs.Add(this);
     this.ChangePersonID = changePerson.PersonID;
     this.ChangePerson   = changePerson;
     changePerson.GrantAllocationChangeLogsWhereYouAreTheChangePerson.Add(this);
     this.ChangeDate = changeDate;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationFileResource(GrantAllocation grantAllocation, FileResource fileResource, string displayName) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationFileResourceID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID             = grantAllocation.GrantAllocationID;
     this.GrantAllocation = grantAllocation;
     grantAllocation.GrantAllocationFileResources.Add(this);
     this.FileResourceID = fileResource.FileResourceID;
     this.FileResource   = fileResource;
     fileResource.GrantAllocationFileResources.Add(this);
     this.DisplayName = displayName;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectGrantAllocationRequest(Project project, GrantAllocation grantAllocation, DateTime createDate, bool importedFromTabularData) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectGrantAllocationRequestID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectID = project.ProjectID;
     this.Project   = project;
     project.ProjectGrantAllocationRequests.Add(this);
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     this.GrantAllocation   = grantAllocation;
     grantAllocation.ProjectGrantAllocationRequests.Add(this);
     this.CreateDate = createDate;
     this.ImportedFromTabularData = importedFromTabularData;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationExpenditure(GrantAllocation grantAllocation, int biennium, int fiscalMonth, int calendarYear, int calendarMonth, decimal expenditureAmount) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationExpenditureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID            = grantAllocation.GrantAllocationID;
     this.GrantAllocation = grantAllocation;
     grantAllocation.GrantAllocationExpenditures.Add(this);
     this.Biennium          = biennium;
     this.FiscalMonth       = fiscalMonth;
     this.CalendarYear      = calendarYear;
     this.CalendarMonth     = calendarMonth;
     this.ExpenditureAmount = expenditureAmount;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GrantAllocationAward(GrantAllocation grantAllocation, FocusArea focusArea, string grantAllocationAwardName, DateTime grantAllocationAwardExpirationDate, int grantAllocationAwardCalendarStartYear) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GrantAllocationAwardID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GrantAllocationID      = grantAllocation.GrantAllocationID;
     this.GrantAllocation        = grantAllocation;
     grantAllocation.GrantAllocationAwards.Add(this);
     this.FocusAreaID = focusArea.FocusAreaID;
     this.FocusArea   = focusArea;
     focusArea.GrantAllocationAwards.Add(this);
     this.GrantAllocationAwardName              = grantAllocationAwardName;
     this.GrantAllocationAwardExpirationDate    = grantAllocationAwardExpirationDate;
     this.GrantAllocationAwardCalendarStartYear = grantAllocationAwardCalendarStartYear;
 }
        public GrantAllocationBudgetLineItemForGrid(GrantAllocation grantAllocation)
        {
            GrantModification = grantAllocation.GrantModification;
            GrantAllocation   = grantAllocation;

            //There are DB constraints that force one and only one Budget Line Item for each Cost Type for each Allocation, therefore the .First call should never crash.
            PersonnelAmount     = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Personnel.CostTypeID).GrantAllocationBudgetLineItemAmount;
            BenefitsAmount      = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Benefits.CostTypeID).GrantAllocationBudgetLineItemAmount;
            TravelAmount        = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Travel.CostTypeID).GrantAllocationBudgetLineItemAmount;
            SuppliesAmount      = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Supplies.CostTypeID).GrantAllocationBudgetLineItemAmount;
            ContractualAmount   = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Contractual.CostTypeID).GrantAllocationBudgetLineItemAmount;
            IndirectCostsAmount = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.IndirectCosts.CostTypeID).GrantAllocationBudgetLineItemAmount;
            OtherAmount         = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Other.CostTypeID).GrantAllocationBudgetLineItemAmount;
            EquipmentAmount     = grantAllocation.GrantAllocationBudgetLineItems.First(bli => bli.CostTypeID == CostType.Equipment.CostTypeID).GrantAllocationBudgetLineItemAmount;

            TotalAmount = grantAllocation.GrantAllocationBudgetLineItems.Where(bli => bli.CostTypeID != CostType.Other.CostTypeID && bli.CostTypeID != CostType.Equipment.CostTypeID).Sum(bli => bli.GrantAllocationBudgetLineItemAmount);
        }
        private static string GetGrantYearPrefixIfPresent(GrantAllocation ga)
        {
            const string yearMatchPattern = @"^(?<year>[1-9][0-9][0-9][0-9])-";

            var             grantYearRegex = new Regex(yearMatchPattern);
            MatchCollection matches        = grantYearRegex.Matches(ga.GrantModification.Grant.GrantNumber);

            if (matches.Count > 0)
            {
                var firstMatch = matches[0];
                // Grant year prefix
                return(firstMatch.Groups["year"].Value);
            }

            // No grant year prefix
            return(null);
        }
Esempio n. 15
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectGrantAllocationRequestUpdate CreateNewBlank(ProjectUpdateBatch projectUpdateBatch, GrantAllocation grantAllocation)
 {
     return(new ProjectGrantAllocationRequestUpdate(projectUpdateBatch, grantAllocation, default(DateTime), default(bool)));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectGrantAllocationRequest CreateNewBlank(Project project, GrantAllocation grantAllocation)
 {
     return(new ProjectGrantAllocationRequest(project, grantAllocation, default(DateTime), default(bool)));
 }
 public static void DeleteGrantAllocation(this IQueryable <GrantAllocation> grantAllocations, GrantAllocation grantAllocationToDelete)
 {
     DeleteGrantAllocation(grantAllocations, new List <GrantAllocation> {
         grantAllocationToDelete
     });
 }
Esempio n. 18
0
        public static List <BudgetVsActualLineItem> GetAllBudgetVsActualLineItemsByCostType(this GrantAllocation grantAllocation)
        {
            var budgetVsActualsLineItemList = new List <BudgetVsActualLineItem>();

            foreach (var costType in CostType.GetLineItemCostTypes())
            {
                var budget = grantAllocation.GrantAllocationBudgetLineItems.Where(bli => bli.CostTypeID == costType.CostTypeID).Select(bli => bli.GrantAllocationBudgetLineItemAmount).Sum();

                var expendituresFromDatamart = grantAllocation.GrantAllocationExpenditures
                                               .Where(gae => gae.CostTypeID == costType.CostTypeID).Select(gae => gae.ExpenditureAmount).Sum();

                var invoicedToDate = grantAllocation.GrantAllocationAwards.Sum(grantAllocationAward => grantAllocationAward.GetInvoicedToDateByCostType(costType));


                var budgetVsActualLineItem = new BudgetVsActualLineItem(costType, budget, expendituresFromDatamart, invoicedToDate);
                budgetVsActualsLineItemList.Add(budgetVsActualLineItem);
            }

            return(budgetVsActualsLineItemList);
        }
Esempio n. 19
0
 public static string GetNewNoteUrl(this GrantAllocation grantAllocation)
 {
     return(NewNoteUrlTemplate.ParameterReplace(grantAllocation.GrantAllocationID));
 }
Esempio n. 20
0
        public static List <GrantAllocationBudgetLineItem> CreateAllGrantAllocationBudgetLineItemsByCostType(this GrantAllocation grantAllocation)
        {
            var grantAllocationBudgetLineItems = new List <GrantAllocationBudgetLineItem>();
            var shouldSaveChanges = false;

            foreach (var costType in CostType.GetLineItemCostTypes())
            {
                var lineItemByCostType = grantAllocation.GrantAllocationBudgetLineItems.SingleOrDefault(bli => bli.CostTypeID == costType.CostTypeID);
                if (lineItemByCostType == null)
                {
                    var tempLineItem = new GrantAllocationBudgetLineItem(grantAllocation.GrantAllocationID, costType.CostTypeID, 0);
                    lineItemByCostType = HttpRequestStorage.DatabaseEntities.GrantAllocationBudgetLineItems.Add(tempLineItem);

                    shouldSaveChanges = true;
                }
                grantAllocationBudgetLineItems.Add(lineItemByCostType);
            }

            if (shouldSaveChanges)
            {
                HttpRequestStorage.DatabaseEntities.SaveChanges();
            }

            return(grantAllocationBudgetLineItems);
        }