Ed.BudgetVisualizer.Logic/ParserLogic.cs
/// <summary>
/// Determines each transaction's category from a list of available categories.
/// </summary>
/// <param name="transactions">Transaction list.</param>
/// <param name="categories">Category list.</param>
Determines each transaction's category from a list of available categories.
Determines each transaction ' s category from a list of available categories .
public static void UpdateTransactionCategories(List<Transaction> transactions, List<Category> categories)
        {
            foreach (var transaction in transactions)
            {
                bool isSet = false;
                foreach (var category in categories)
                {
                    if ((!string.IsNullOrEmpty(category.OriginRegex) && Regex.IsMatch(transaction.Origin, category.OriginRegex))
                        || (!string.IsNullOrEmpty(category.DescriptionRegex) && Regex.IsMatch(transaction.Description, category.DescriptionRegex)))
                    {
                        transaction.Category = category.Name;
                        isSet = true;
                        break;
                    }
                }
                if (!isSet)
                {
                    transaction.Category = transaction.IsCredit ? "Other Income" : "Other Expense";
                }
            }
        }
public static void UpdateTransactionCategories ( List < Transaction > transactions , List < Category > categories ) { foreach ( var transaction in transactions ) { bool isSet = false ; foreach ( var category in categories ) { if ( ( ! string . IsNullOrEmpty ( category . OriginRegex ) && Regex . IsMatch ( transaction . Origin , category . OriginRegex ) ) || ( ! string . IsNullOrEmpty ( category . DescriptionRegex ) && Regex . IsMatch ( transaction . Description , category . DescriptionRegex ) ) ) { transaction . Category = category . Name ; isSet = true ; break ; } } if ( ! isSet ) { transaction . Category = transaction . IsCredit ? " " : " " ; } } }
Determines each transaction's category from a list of available categories.
Determines each transaction ' s category from a list of available categories .
transactions
List<Transaction>
None
categories
List<Category>
None