public IFormattedClassification Format(IPostingClassification classification) { return(new FormattedClassification { Sign = classification.IsMonthClassification ? "" : classification.Credit ? "+" : "-", Classification = classification.Classification, CombinedClassification = (classification.IsMonthClassification ? "" : classification.Credit ? "(+) " : "(-) ") + classification.Classification }); }
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); }
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); }
public bool DoesPostingMatchClassification(IPosting posting, IPostingClassification classification) { return(DoesPostingMatchDebitCredit(posting, classification) && DoesPostingMatchClue(posting, classification) && DoesPostingMatchYearAndMonth(posting, classification)); }
private static bool DoesPostingMatchClue(IPosting posting, IPostingClassification classification) { return(string.IsNullOrEmpty(classification.Clue) || posting.Remark.Contains(classification.Clue, StringComparison.OrdinalIgnoreCase)); }
private static bool DoesPostingMatchDebitCredit(IPosting posting, IPostingClassification classification) { return(classification.IsMonthClassification || classification.Credit == posting.Amount > 0 || !classification.Credit == posting.Amount < 0); }