public Statement BuildStatement() { RawStatement rawStatement = BuildRaw(); Statement statement = new Statement { AccountNum = rawStatement.AccountNum }; foreach (var rawTrans in rawStatement.Transactions) { Transaction trans = new Transaction { Amount = rawTrans.Amount, Memo = rawTrans.Memo, Name = rawTrans.Name, PostedOn = rawTrans.PostedOn, RefNumber = rawTrans.RefNumber, TransactionId = rawTrans.TransactionId, Type = rawTrans.Type }; statement.Transactions.Add(trans); } statement.LedgerBalance = new LedgerBalance { Amount = rawStatement.LedgerBalance.Amount, AsOf = rawStatement.LedgerBalance.AsOf }; return(statement); }
public Statement BuildStatement() { RawStatement rawStatement = BuildRaw(); Statement statement = new Statement() { AccountNum = rawStatement.AccountNum }; foreach (var rawTrans in rawStatement.Transactions) { Transaction trans = new Transaction() { Amount = rawTrans.Amount, Memo = rawTrans.Memo, Name = rawTrans.Name, PostedOn = rawTrans.DatePosted, RefNumber = rawTrans.RefNumber, TransactionId = rawTrans.TransactionId, Type = rawTrans.Type }; statement.Transactions.Add(trans); } return(statement); }
private RawStatement BuildRaw() { RawStatement _statement = null; MemberInfo currentMember = null; RawTransaction _currentTransaction = null; foreach (var token in Parser.Parse(_fileText)) { if (token.IsElement) { var result = GetPropertyInfo(token.Content); if (result != null) { switch (result.Type) { case NodeType.StatementOpen: _statement = new RawStatement(); break; case NodeType.StatementClose: return(_statement); break; case NodeType.TransactionOpen: _currentTransaction = new RawTransaction(); break; case NodeType.TransactionClose: _statement.Transactions.Add(_currentTransaction); _currentTransaction = null; break; case NodeType.StatementProp: if (_statement == null) { _statement = new RawStatement(); } currentMember = result.Member; break; case NodeType.TransactionProp: currentMember = result.Member; break; case NodeType.LedgerBalanceOpen: _ledgerBalance = new RawLedgerBalance(); break; case NodeType.LedgerBalanceClose: _statement.LedgerBalance.Amount = _ledgerBalance.Amount; _statement.LedgerBalance.AsOf = _ledgerBalance.AsOf; break; case NodeType.LedgerBalanceProp: if (_ledgerBalance == null) { _ledgerBalance = new RawLedgerBalance(); } currentMember = result.Member; break; default: break; } } else { currentMember = null; } } else { if (currentMember != null && currentMember is PropertyInfo) { var property = (PropertyInfo)currentMember; switch (property.DeclaringType.Name) { case "RawStatement": property.SetValue(_statement, ConvertQfxType(token.Content, property.PropertyType)); break; case "RawTransaction": property.SetValue(_currentTransaction, ConvertQfxType(token.Content, property.PropertyType)); break; case "RawLedgerBalance": property.SetValue(_ledgerBalance, ConvertQfxType(token.Content, property.PropertyType)); break; default: break; } } } } return(_statement); }
private RawStatement BuildRaw() { RawStatement _statement = null; MemberInfo currentMember = null; RawTransaction _currentTransaction = null; foreach (var token in Parser.Parse(_fileText)) { if (token.IsElement) { var result = GetPropertyInfo(token.Content); if (result != null) { switch (result.Type) { case NodeType.StatementOpen: _statement = new RawStatement(); break; case NodeType.StatementClose: return(_statement); case NodeType.TransactionOpen: _currentTransaction = new RawTransaction(); break; case NodeType.TransactionClose: _statement.Transactions.Add(_currentTransaction); _currentTransaction = null; break; case NodeType.StatementProp: case NodeType.TransactionProp: currentMember = result.Member; break; default: break; } } else { currentMember = null; } } else { if (currentMember != null && currentMember is PropertyInfo) { var property = (PropertyInfo)currentMember; switch (property.DeclaringType.Name) { case "RawStatement": property.SetValue(_statement, token.Content); break; case "RawTransaction": property.SetValue(_currentTransaction, token.Content); break; default: break; } } } } return(_statement); }