Пример #1
0
 private bool IsIncome(ExpenseMessage message)
 {
     return(message.Body.Contains("Получен кредитен превод-IB") ||
            message.Body.Contains("Вноска по сметка") ||
            message.Body.Contains("Възстановени средства") ||
            message.Body.Contains("Получен превод"));
 }
        public Transaction Parse(ExpenseMessage expenseMessages)
        {
            if (!IsReiffeisenMessage(expenseMessages))
            {
                return(null);
            }
            var         lines = expenseMessages.Body;
            Transaction t     = null;

            if (IsPurchaseMessage(expenseMessages))
            {
                t = new Transaction();
                var rx      = new Regex(@"(?<operation>(POKUPKA|TEGLENE NA ATM)) (za| ){0,1} (?<amount>[\d\.]+) BGN.+? pri (?<details>.+?) na (?<date>[\d\.]+?) ", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                var matches = rx.Matches(lines);
                var op      = matches[0].Groups["operation"].Value.Trim();
                t.Amount  = decimal.Parse(matches[0].Groups["amount"].Value.Trim());
                t.Details = op + " " + matches[0].Groups["details"].Value.Trim();
                t.Date    = DateTime.ParseExact(matches[0].Groups["date"].Value.Trim(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
                t.Type    = TransactionType.Expense;
                t.Source  = "reifeizen_mail";
            }

            return(t);
        }
Пример #3
0
 private bool IsSuccessOperationMessage(ExpenseMessage message)
 {
     return(!message.Body.Contains("Неуспешна картова транзакция"));
 }
Пример #4
0
 private bool IsAllianzMessage(ExpenseMessage message)
 {
     return(message.Subject.Contains("Движение по сметка: "));
 }
Пример #5
0
        public Transaction Parse(ExpenseMessage message)
        {
            if (!IsAllianzMessage(message))
            {
                return(null);
            }
            if (!IsSuccessOperationMessage(message))
            {
                return(null);
            }
            Transaction result = new Transaction();
            var         tId    = message.Subject.Split('#')[1].TrimEnd(')');

            result.TransactionId = tId;
            var    title         = string.Empty;
            var    accountNumber = string.Empty;
            string reason        = string.Empty;
            string actor         = string.Empty;

            using (var html = new StringReader(message.Body))
            {
                var line = html.ReadLine();
                while (line != null)
                {
                    if (line.Contains("<title>"))
                    {
                        title = ExtractInnerText(line);
                    }
                    if (line.Contains(">Сметка<"))
                    {
                        accountNumber = ExtractInnerText(html.ReadLine());
                    }
                    if (line.Contains(">Дата<"))
                    {
                        result.Date = this.GetDate(html);
                    }
                    if (line.Contains(">Основание<"))
                    {
                        reason = this.GetReason(html);
                    }
                    if (line.Contains(">Контрагент<"))
                    {
                        actor = this.GetSource(html);
                    }
                    if (line.Contains(">Сума<"))
                    {
                        result.Amount = this.GetAmount(html);
                    }
                    line = html.ReadLine();
                }
            }

            result.Type = IsIncome(message) ? TransactionType.Income : TransactionType.Expense;
            SetDetails(result, title, accountNumber, reason, actor);
            result.Source = "allianz_mail";
            if (message.Body.RemoveRepeatingSpaces().Contains("Такса Нар.превод"))
            {
                result.Details = "Такса Нар.превод";
            }
            return(result);
        }
 private bool IsReiffeisenMessage(ExpenseMessage expenseMessages)
 {
     return(expenseMessages.Subject.Contains("Notification from RBBBG") ||
            expenseMessages.Subject.Contains("Notification CC RBB"));
 }
 private bool IsPurchaseMessage(ExpenseMessage expenseMessages)
 {
     return(expenseMessages.Body.Contains("Bihme iskali da Vi uvedomim za POKUPKA"));
 }