foreach (var cc in costCentres)
{
var f = new Models.JobFinancials()
{
CostCentre = cc.Title,
CostCentreCode = cc.ID,
IsBudget = false,
Cost = CalculateCostDpnLink2DS041116(purchaseOrders.Where(jc => jc.CostCentre == cc.ID).ToList(), job.CurrencyId),
Sale = (decimal)((decimal)jsales.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueUK) * (currencyExchange ?? 1))
};
f.Cost += (decimal)(job.CurrencyId == DefaultFromCurrency ? jcts.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueUK)
: (job.CurrencyId == EURCurrency ? (jcts.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueEUR))
: (jcts.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueUS))) ?? (double?)0);
f.Cost += (decimal)(job.CurrencyId == DefaultFromCurrency ? others.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueUK)
: (job.CurrencyId == EURCurrency ? (others.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueEUR))
: (others.Where(jc => jc.CostCentre == cc.ID).Sum(jc => jc.ValueUS))) ?? (double?)0);
f.Sale += jCommitedSales.Where(x => x.CostCentre == cc.ID).Sum(x => x.Value);
var childCostCentres = DB.CostCentres.Where(x => x.ParentID == cc.ID);