public IFormattedClassification Format(IPostingClassification classification)
 {
     return(new FormattedClassification {
         Sign = classification.IsMonthClassification ? "" : classification.Credit ? "+" : "-",
         Classification = classification.Classification,
         CombinedClassification = (classification.IsMonthClassification ? "" : classification.Credit ? "(+) " : "(-) ") + classification.Classification
     });
 }
Exemplo n.º 2
0
        private static bool DoesPostingMatchYearAndMonth(IPosting posting, IPostingClassification classification)
        {
            if (classification.Month == 0 && classification.Year == 0)
            {
                return(true);
            }

            return(classification.Month == posting.Date.Month && classification.Year == posting.Date.Year);
        }
Exemplo n.º 3
0
        private bool IsPostingRelevantHere(IPosting posting, IEnumerable <IPostingClassification> postingClassifications, DateTime minDate, double minAmount, out IPostingClassification classification)
        {
            classification = null;
            if (Math.Abs(posting.Amount) < minAmount)
            {
                return(false);
            }
            if (posting.Date < minDate)
            {
                return(false);
            }

            var classifications = postingClassifications.Where(c => PostingClassificationMatcher.DoesPostingMatchClassification(posting, c)).ToList();

            if (classifications.Count != 1)
            {
                return(false);
            }

            classification = classifications[0];
            return(true);
        }
Exemplo n.º 4
0
 public bool DoesPostingMatchClassification(IPosting posting, IPostingClassification classification)
 {
     return(DoesPostingMatchDebitCredit(posting, classification) && DoesPostingMatchClue(posting, classification) && DoesPostingMatchYearAndMonth(posting, classification));
 }
Exemplo n.º 5
0
 private static bool DoesPostingMatchClue(IPosting posting, IPostingClassification classification)
 {
     return(string.IsNullOrEmpty(classification.Clue) || posting.Remark.Contains(classification.Clue, StringComparison.OrdinalIgnoreCase));
 }
Exemplo n.º 6
0
 private static bool DoesPostingMatchDebitCredit(IPosting posting, IPostingClassification classification)
 {
     return(classification.IsMonthClassification || classification.Credit == posting.Amount > 0 || !classification.Credit == posting.Amount < 0);
 }