أعد كتابة الدالة التالية مع تحسينها مع الحفاظ على اسمها الأصلي وأسماء المتغيرات        // Class67
public static List<view_customers_balance> smethod_15(int int_0)
{
	List<view_customers_balance> result = new List<view_customers_balance>();
	try
	{
		int?[] array = new int?[]
		{
			new int?(MainAccountsIDs.CUSTOMERS),
			new int?(MainAccountsIDs.VENDOR),
			new int?(MainAccountsIDs.MixPeople)
		};
		CurrencyInfo.currencyShortcut();
		mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
		ParameterExpression parameterExpression;
		List<Class57> list = (from u in mrsalesdbEntities.view_customers_balance
		where u.pepole_ID == int_0
		select u into s
		group s by new
		{
			s.pepole_ID,
			s.Currency_ID,
			s.Currency_Index,
			s.Factor
		}).Select(Expression.Lambda(Expression.MemberInit(Expression.New(typeof(Class57)), new MemberBinding[]
		{
			Expression.Bind(methodof(Class57.set_pepole_ID(int)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType7<int, int?, int?, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType7<int, int?, int?, decimal?>.get_pepole_ID()))),
			Expression.Bind(methodof(Class57.set_Currency_ID(int?)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType7<int, int?, int?, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType7<int, int?, int?, decimal?>.get_Currency_ID()))),
			Expression.Bind(methodof(Class57.set_Currency_Index(int?)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType7<int, int?, int?, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType7<int, int?, int?, decimal?>.get_Currency_Index()))),
			Expression.Bind(methodof(Class57.set_credit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.credit
			})),
			Expression.Bind(methodof(Class57.set_debit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.debit
			})),
			Expression.Bind(methodof(Class57.set_balance(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.balance
			}))
		}), new ParameterExpression[]
		{
			parameterExpression
		})).ToList<Class57>();
		list.Count<Class57>();
		foreach (Class57 @class in list)
		{
			int id = AddationalCurrencies.usedCurrencies.Where(new Func<ad_additional_currencies, bool>(Class67.<>c.<>c_0.method_2)).FirstOrDefault<ad_additional_currencies>().id;
			int currID = (@class.Currency_ID == null) ? id : @class.Currency_ID.Value;
			if (@class.Currency_ID != null)
			{
				int value = @class.Currency_Index.Value;
			}
			@class.credit = new decimal?(@class.credit.Value.GetDecimalParts(false, currID));
			@class.debit = new decimal?(@class.debit.Value.GetDecimalParts(false, currID));
			@class.balance = new decimal?(@class.balance.Value.GetDecimalParts(false, currID));
		}
		result = list.Select(new Func<Class57, view_customers_balance>(Class67.<>c.<>c_0.method_3)).ToList<view_customers_balance>();
	}
	catch (Exception ex)
	{
		MessageBox.Show(ex.Message.ToString());
	}
	return result;
}