private static decimal?RedistributeValuePerApartment(AssociationExpenses associationExpense, Apartments apartment) { decimal?result = null; // todo change this to be for index expense or add new if branch //if (associationExpense.SplitPerStairCase.HasValue && associationExpense.SplitPerStairCase.Value) //{ var redistributeSum = GetRedistributeValueForIndexExpenseForStairCase(associationExpense, apartment); var allApartmentsOnSamecounter = ApartmentExpensesManager.GetApartmentsOnSameCounter(associationExpense.Id, apartment.Id_StairCase).Count(); if (redistributeSum.HasValue && allApartmentsOnSamecounter != 0) { if (associationExpense.Id_ExpenseType == (int)ExpenseType.PerIndex && !AssociationExpensesManager.HasCounterOfExpense(apartment.Id, associationExpense.Id_Expense)) { } else { result = redistributeSum / allApartmentsOnSamecounter; } } //} //else //{ // var redistributeVal = CalculateRedistributeValue(associationExpense.Id); // int allApartmentsNr; // if (associationExpense.Id_ExpenseType == (int)ExpenseType.PerIndex) // { // IEnumerable<Apartments> apartments = AssociationExpensesManager.GetApartmentsNrThatShouldRedistributeTo(associationExpense.Id); // allApartmentsNr = apartments.Count(); // } // else // { // allApartmentsNr = associationExpense.Associations.Apartments.Count(); // } // if (redistributeVal != null && redistributeVal.HasValue && allApartmentsNr != 0) // { // if (associationExpense.Id_ExpenseType == (int)ExpenseType.PerIndex && !AssociationExpensesManager.HasCounterOfExpense(apartment.Id, associationExpense.Id_Expense)) // { // } // else // { // result = redistributeVal.Value / allApartmentsNr; // } // } //} return(result); }
private static decimal?RedistributeValuePerApartmentDependents(AssociationExpenses associationExpense, Apartments apartment) { decimal?result = null; //if (associationExpense.SplitPerStairCase.HasValue && associationExpense.SplitPerStairCase.Value) //{ var redistributeSum = GetRedistributeValueForIndexExpenseForStairCase(associationExpense, apartment); var allApartmentsDependents = ApartmentExpensesManager.GetApartmentsOnSameCounter(associationExpense.Id, apartment.Id_StairCase).Sum(t => t.Dependents); if (redistributeSum.HasValue && allApartmentsDependents != 0) { if (associationExpense.Id_ExpenseType == (int)ExpenseType.PerIndex && !AssociationExpensesManager.HasCounterOfExpense(apartment.Id, associationExpense.Id_Expense)) { } else { result = redistributeSum * apartment.Dependents / allApartmentsDependents; } } //} //else //{ // var allApartmentsDependentsu = AssociationExpensesManager.GetApartmentsNrThatShouldRedistributeTo(associationExpense.Id).Sum(e => e.Dependents); //if (allApartmentsDependents != 0) //{ // var redistributeVal = CalculateRedistributeValue(associationExpense.Id); // if (redistributeVal != null && redistributeVal.HasValue && allApartmentsDependents != 0) // { // if (associationExpense.Id_ExpenseType == (int)ExpenseType.PerIndex && !AssociationExpensesManager.HasCounterOfExpense(apartment.Id, associationExpense.Id_Expense)) // { // } // else // { // result = redistributeVal.Value * apartment.Dependents / allApartmentsDependents; // } // } //} //} return(result); }