private void ProcessPayuEmails(QifEntry entry, IEnumerable <string> validEmailBodys) { foreach (var body in validEmailBodys.ToArray()) { string receiver = string.Empty; try { receiver = PayuParsers.SyncPaymentReceiver.Parse(body); } catch (ParseException) { } if (receiver == string.Empty) { try { receiver = PayuParsers.SyncPaymentStupidInfo.Parse(body); } catch (ParseException) { } } if (receiver != string.Empty) { entry.Description = string.Format("{0} - {1}", receiver, entry.Description); break; } } }
public void SetUp() { entry = new QifEntry { Description = "Name", }; var mockConfig = new Mock <IConfig>(); mockConfig.Setup(c => c.GetString("Account", "QifImport")).Returns("QifImport"); m_config = mockConfig.Object; }
public void SetUp() { entry1 = new QifEntry { Amount = 1000, Date = new BankDates { BookingDate = DateTime.Parse("2012-01-20"), OperationDate = DateTime.Parse("2012-01-19") }, Description = "A thing you bought in a shop", Payee = "myself", AccountName = DefaultAccount }; }
private void ProcessPayuTransaction(QifEntry entry, MessageCollection emails) { string payuId = PayuParsers.SyncIdParser.Parse(entry.Description.ToLower()); bool html; var validEmailBodys = from mail in emails let txt = mail.GetDecodedBody(out html) where txt.IndexOf(payuId) > 0 select txt; if (validEmailBodys.Count() > 0) { ProcessPayuEmails(entry, validEmailBodys); } }
public void TestQifEntryParserOK_1() { string entry1 = @"2012.01.10 PRZELEW W RAMACH BANKU NA RACH OBCY 0,20 0,50 2012.01.02 11 2222 3333 4444 5555 6666 7777 John Smith very important payment from Mr. John Smith"; QifEntry entry = AliorSyncPdfParsers.QifEntryParser.Parse(entry1); Assert.AreEqual(DateTime.Parse("2012.01.10"), entry.Date.BookingDate); Assert.AreEqual(DateTime.Parse("2012.01.02"), entry.Date.OperationDate); Assert.AreEqual(decimal.Parse("0.20", CultureInfo.InvariantCulture), entry.Amount); Assert.AreEqual("11 2222 3333 4444 5555 6666 7777", entry.Payee); Assert.AreEqual("PRZELEW W RAMACH BANKU NA RACH OBCY: John Smith very important payment" + " from Mr. John Smith", entry.Description); }
public void TestQifEntryParserOK_2() { string entry1 = @"2012.01.15 PRZELEW KRAJOWY ELIXIR PRZYCHODZACY Z INNEGO 100,00 0,0 2012.01.05 BANKU 11 2222 3333 4444 5555 6666 7777 Jan Kowalski very important payment from Mr. John Smith"; QifEntry entry = AliorSyncPdfParsers.QifEntryParser.Parse(entry1); Assert.AreEqual(DateTime.Parse("2012.01.15"), entry.Date.BookingDate); Assert.AreEqual(DateTime.Parse("2012.01.05"), entry.Date.OperationDate); Assert.AreEqual(decimal.Parse("100", CultureInfo.InvariantCulture), entry.Amount); Assert.AreEqual("11 2222 3333 4444 5555 6666 7777", entry.Payee); Assert.AreEqual("PRZELEW KRAJOWY ELIXIR PRZYCHODZACY Z INNEGO BANKU: Jan Kowalski " + "very important payment from Mr. John Smith", entry.Description); }
private IList <QifEntry> TryParseTransactions(List <XElement> boxesList, int startIndex, int count, out int i) { var result = new List <QifEntry>(); QifEntry current = null; i = startIndex; int found = 0; while (found < count) { var line = (string)boxesList [i].Elements("line").Aggregate(strAgg); // check if current line is a standard operation name if (!IsOpLine(line)) { throw new ApplicationException(string.Format("Wrong line: {0}", line)); } current = new QifEntry { Description = line }; decimal amount = decimal.Parse((string)boxesList [i + 1].Element("line")); //double balance = double.Parse ((string) boxesList [i + 2].Element ("line")); var nextLine = (string)boxesList [i + 3].Elements("line").Aggregate(strAgg); current.Amount = amount; result.Add(current); found++; if (IsOpLine(nextLine)) { i += 3; continue; } current.Description += " " + nextLine; i += 4; } if (count != result.Count) { throw new ApplicationException("Parsing error, wrong number of entries parsed"); } return(result); }
private void ProcessPayuAllegroEmails(QifEntry entry, IEnumerable <string> validEmailBodys) { foreach (var body in validEmailBodys.ToArray()) { string description = string.Empty; try { description = PayuParsers.QuickAndDirtyHtmlInfoParser.Parse(body); } catch (ParseException) { } if (description != string.Empty) { entry.Description = string.Format("Allegro: {0} - {1}", description, entry.Description); break; } } }
private void ProcessPayuAllegroTransaction(QifEntry entry, MessageCollection emails) { try { Tuple <string, string> ids = PayuParsers.SyncAndAllegroIdParser.Parse(entry.Description.ToLower()); bool html; var validEmailBodys = from mail in emails let txt = mail.GetDecodedBody(out html) where txt.IndexOf(ids.Item2) > 0 select txt; if (validEmailBodys.Count() > 0) { ProcessPayuAllegroEmails(entry, validEmailBodys); } } catch (ParseException) { } }
private bool IsPayuTransaction(QifEntry entry) { return(entry.Description.Contains(PAYU_MARK)); }
private bool IsPayuAllegroTransaction(QifEntry entry) { return(entry.Description.Contains(PAYU_ALLEGRO_MARK)); }