示例#1
0
        private Category getSuggestedCategoryForTransaction(ViewTransaction transaction)
        {
            var rules = BankApplicationState.UserConfig.Rules;

            foreach (var rule in rules)
            {
                if (rule.IsRuleTriggeredByTransaction(transaction))
                {
                    return(rule.TargetCategory);
                }
            }
            return(null);
        }
示例#2
0
        private ViewTransaction generateNewElementFromRange(List <ViewTransaction> transactions)
        {
            var first = new ViewTransaction(transactions[0].transaction);

            if (transactions.Count < 2)
            {
                return(first);
            }

            for (int i = 1; i < transactions.Count; ++i)
            {
                var item = transactions[i];
                first.Amount += item.Amount;
            }
            first.Date = String.Format("{0} items", transactions.Count);
            return(first);
        }
示例#3
0
 public void setSuggestedCategory(ViewTransaction transaction)
 {
     if (transaction.Amount > 0)
     {
         var c = BankApplicationState.UserConfig.Categories.Find(a => a.Setting == Category.CategorySetting.Income);
         transaction.WantedCategory = c;
         return;
     }
     else
     {
         Category c = getSuggestedCategoryForTransaction(transaction);
         if (c == null)
         {
             c = BankApplicationState.UserConfig.Categories[7]; //övrigt
         }
         transaction.WantedCategory = c;
     }
 }