public CostsModel CalculateProjectCosts(ResourceSeriesSetModel resourceSeriesSet) { if (resourceSeriesSet == null) { throw new ArgumentNullException(nameof(resourceSeriesSet)); } var costs = new CostsModel(); if (resourceSeriesSet.Combined.Any()) { costs.DirectCost = resourceSeriesSet.Combined .Where(x => x.InterActivityAllocationType == InterActivityAllocationType.Direct) .Sum(x => x.Values.Sum(y => y * x.UnitCost)); costs.IndirectCost = resourceSeriesSet.Combined .Where(x => x.InterActivityAllocationType == InterActivityAllocationType.Indirect) .Sum(x => x.Values.Sum(y => y * x.UnitCost)); costs.OtherCost = resourceSeriesSet.Combined .Where(x => x.InterActivityAllocationType == InterActivityAllocationType.None) .Sum(x => x.Values.Sum(y => y * x.UnitCost)); } costs.TotalCost = costs.DirectCost + costs.IndirectCost + costs.OtherCost; return(costs); }
public static Costs Map(this CostsModel costsModel) { var costs = new Costs { ShopID = costsModel.ShopID, CategoryID = costsModel.CategoryID, AmountOfCost = costsModel.AmountOfCost, DateOfCost = costsModel.DateOfCost, AdditionalInformation = costsModel.AdditionalInformation }; return(costs); }
public void CalculateCosts() { lock (m_Lock) { ClearCosts(); if (HasCompilationErrors) { return; } CostsModel costs = ResourceSeriesSet != null?m_ProjectService.CalculateProjectCosts(ResourceSeriesSet) : new CostsModel(); DirectCost = costs.DirectCost; IndirectCost = costs.IndirectCost; OtherCost = costs.OtherCost; TotalCost = costs.TotalCost; } }