internal static int GetInvoicesNr(AssociationExpenses associationExpense) { if (associationExpense.SplitPerStairCase.HasValue && associationExpense.SplitPerStairCase.Value) { return(AssociationCountersManager.GetAllByExpenseType(associationExpense.Id_Estate, associationExpense.Id_Expense).Count()); } else { return(1); } }
public static decimal?GetRedistributeValuePerIndex(AssociationExpenses associationExpense) { decimal?result = null; var invoice = associationExpense.Invoices.FirstOrDefault(i => i.Id_StairCase == null && i.Id_EstateExpense == associationExpense.Id); var assCountersForThisExpense = AssociationCountersManager.GetAllByExpenseType(associationExpense.Id_Estate, associationExpense.Id_Expense).ToList(); foreach (var counter in assCountersForThisExpense) { var pricePerUnit = UnitPricesManager.GetPrice(associationExpense.Id, counter.AssociationCountersStairCase.FirstOrDefault().Id_StairCase); decimal?sumOfIndexes = ApartmentExpensesManager.GetSumOfIndexesOnSameCounter(associationExpense.Id, counter.AssociationCountersStairCase.FirstOrDefault().Id_StairCase); if (sumOfIndexes.HasValue & invoice != null && pricePerUnit.HasValue) { var consummedIndices = InvoiceIndexesManager.GetByInvoiceAndCounterFirst(invoice, counter); if (consummedIndices != null && consummedIndices.IndexOld.HasValue && consummedIndices.IndexNew.HasValue) { result = ((consummedIndices.IndexNew.Value - consummedIndices.IndexOld.Value) - sumOfIndexes.Value) * pricePerUnit.Value; } } } return(result); }
public static void AddDefault(AssociationExpenses associationExpense) { if (associationExpense == null) { return; } if (associationExpense.SplitPerStairCase.HasValue && associationExpense.SplitPerStairCase.Value) { var assCounters = AssociationCountersManager.GetAllByExpenseType(associationExpense.Id_Estate, associationExpense.Id_Expense); foreach (var assCounter in assCounters) { var result = new Invoices { Id_EstateExpense = associationExpense.Id, Value = null, Id_StairCase = null, id_assCounter = assCounter.Id }; GetContext().Invoices.Add(result); } } else { var result = new Invoices { Id_EstateExpense = associationExpense.Id, Value = null, Id_StairCase = null }; GetContext().Invoices.Add(result); } GetContext().SaveChanges(); }