Beispiel #1
0
        private static Transaction CreateTransaction(OcrTransaction ocrTransaction)
        {
            DateTime?       postedDate      = JLPParserV1.GetTransactionDate(ocrTransaction.PostedDate);
            DateTime?       transactionDate = JLPParserV1.GetTransactionDate(ocrTransaction.PostedDate);
            string          name            = ocrTransaction.Name;
            TransactionType txType          = JLPParserV1.GetTransactionType(ocrTransaction.Credit);
            decimal?        amount          = ocrTransaction.Amount.TryAsDecimal();

            if (txType == TransactionType.DEBIT)
            {
                amount = 0 - amount;
            }

            Transaction result = null;

            if (postedDate.HasValue && transactionDate.HasValue && String.IsNullOrWhiteSpace(name) == false && amount.HasValue)
            {
                result = new Transaction()
                {
                    TxType          = txType,
                    PostedDate      = postedDate.Value,
                    TransactionDate = transactionDate.Value,
                    Name            = name,
                    Note            = ocrTransaction.Note,
                    Amount          = amount.Value
                };
            }
            return(result);
        }
Beispiel #2
0
        private static OcrTransaction CreateOcrTransaction(DateTime statementDate, GroupCollection groups)
        {
            string postedDateStr      = groups[1].Value.Trim() + " " + statementDate.Year;
            string transactionDateStr = groups[2].Value.Trim() + " " + statementDate.Year;

            DateTime?postedDate      = JLPParserV1.GetTransactionDate(postedDateStr);
            DateTime?transactionDate = JLPParserV1.GetTransactionDate(transactionDateStr);

            if (postedDate.HasValue && transactionDate.HasValue)
            {
                if (postedDate.Value > statementDate)
                {
                    postedDate = postedDate.Value.AddYears(-1);
                }
                if (transactionDate.Value > statementDate)
                {
                    transactionDate = transactionDate.Value.AddYears(-1);
                }
            }
            postedDateStr      = (postedDate.HasValue) ? postedDate.Value.ToShortDateString() : postedDateStr;
            transactionDateStr = (transactionDate.HasValue) ? transactionDate.Value.ToShortDateString() : transactionDateStr;

            var result = new OcrTransaction()
            {
                PostedDate      = postedDateStr,
                TransactionDate = transactionDateStr,
                Name            = groups[3].Value.Trim(),
                Amount          = groups[4].Value.Trim(),
                Credit          = groups[5].Value.Trim(),
                Note            = groups[6].Value.Trim()
            };

            return(result);
        }