/// <summary> /// Creates a set of test transactions, and a list containing those transactions /// </summary> public OfxFactory() { _ofxTransaction = new OfxTransaction { Amount = "+402.99", DatePosted = "20130307000000", FitId = "001", Name = "The Payee", Memo = "The Memo", RunningBalance = "200.29", TrnType = TrnTypeEnum.Credit }; _ofxTransaction2 = new OfxTransaction { Amount = "+146.77", DatePosted = "20130308000000", FitId = "001", //todo - test for duplicate FitIds Name = "The Payee2", Memo = "The Memo2", RunningBalance = "600.29", TrnType = TrnTypeEnum.Debit }; _ofxTransactions = new List<OfxTransaction> {_ofxTransaction, _ofxTransaction2}; }
/// <summary> /// Convert a Smile statement (both header and transactions) to Ofx format /// </summary> /// <param name="smileTransactions">List of Smile transactions</param> /// <param name="statementAsXml">the original Smile statement converted to xml, to allow the getting of header information</param> /// <param name="fitIdPrefix"></param> /// <returns></returns> public OfxStatement ConvertSmileStatementObjectToOfxStatementObject(IEnumerable<SmileStatementTransaction> smileTransactions, XDocument statementAsXml) { var transactionCount = 0; var ofxTransactions = new List<OfxTransaction>(); StatementHeader = new SmileStatementHeader(statementAsXml, _statementManagerDateTime); foreach (var txn in smileTransactions) { var ofxTransaction = new OfxTransaction { Amount = StringUtils.RemoveNonMoneyChars(txn.AmountAsDebit.Contains(".") ? "-" + txn.AmountAsDebit : "+" + txn.AmountAsCredit), DatePosted = DateTimeUtils.ConvertDateAddTrailingZeroes(txn.TransactionDate, "dd/MM/yyyy", "yyyyMMdd", 6), FitId = string.Format("{0}-{1}", StatementHeader.AccountPageNumber, ++transactionCount), Name = txn.TransactionDetail, Memo = txn.TransactionDetail, RunningBalance = string.Empty, TrnType = DebitOrCredit(txn.AmountAsCredit) }; ofxTransactions.Add(ofxTransaction); } OfxHeader = StatementHeader.ConvertSmileToOfxStatementHeader(); return new OfxStatement(ofxTransactions, OfxHeader); }