Example #1
0
        protected override Transaction CreateTransaction(TransactionType type)
        {
            Transaction transaction = null;

            transaction = new InvestmentTransaction();

            return(transaction);
        }
Example #2
0
        /// <summary>
        /// Creates a collection of investment transactions
        /// </summary>
        /// <param name="transactionItems">The transaction delimited string</param>
        /// <param name="config">The configuration to use while importing raw data</param>
        /// <returns>A collection of bank transactions</returns>
        public static List <InvestmentTransaction> Import(string transactionItems, Configuration config)
        {
            List <InvestmentTransaction> result = new List <InvestmentTransaction>();

            // Create a new bank transaction
            InvestmentTransaction it = new InvestmentTransaction();

            // Split the string by new lines
            string[] sEntries = Regex.Split(transactionItems, "$", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);

            // Iterate over the array
            for (int i = 0; i < sEntries.Length; i++)
            {
                // Extract a line entry
                string sEntry = sEntries[i].Replace("\r", "").Replace("\n", "");

                // If the string has a value
                if (sEntry.Length > 0)
                {
                    // Test the first value of the string
                    switch (sEntry[0].ToString())
                    {
                    case InvestmentAccountFields.Action:
                        // Set the date value
                        it.Action = sEntry.Substring(1);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.ClearedStatus:
                        // Set the amount value
                        it.ClearedStatus = sEntry.Substring(1);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.Commission:
                        // Set the cleared status value
                        it.Commission = sEntry.Substring(1).ParseDecimalString(config);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.Date:
                        // Set the number value
                        it.Date = sEntry.Substring(1).ParseDateString(config);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.Memo:
                        // Set the payee value
                        it.Memo = sEntry.Substring(1);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.Price:
                        // Set the memo value
                        it.Price = sEntry.Substring(1).ParseDecimalString(config);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.Quantity:
                        // Set the memo value
                        it.Quantity = sEntry.Substring(1).ParseDecimalString(config);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.Security:
                        // Set the memo value
                        it.Security = sEntry.Substring(1);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.TextFirstLine:
                        // Set the memo value
                        it.TextFirstLine = sEntry.Substring(1);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.TransactionAmount:
                        // Set the memo value
                        it.TransactionAmount = sEntry.Substring(1).ParseDecimalString(config);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.AccountForTransfer:
                        // Set the memo value
                        it.AccountForTransfer = sEntry.Substring(1);

                        // Stop processing
                        break;

                    case InvestmentAccountFields.AmountTransferred:
                        // Set the memo value
                        it.AmountTransferred = sEntry.Substring(1).ParseDecimalString(config);

                        // Stop processing
                        break;

                    case AccountInformationFields.EndOfEntry:
                        // Add the bank transaction instance to the collection
                        result.Add(it);

                        // Call the destructor
                        it = null;

                        // Create a new bank transaction
                        it = new InvestmentTransaction();

                        // Stop processing
                        break;
                    }
                }
            }

            return(result);
        }
Example #3
0
 public void Yield(QifDocument document)
 {
     document.AddTransaction(GetType().Name, item);
     item = new InvestmentTransaction();
 }
Example #4
0
 public void Yield(QifDocument document)
 {
     document.InvestmentTransactions.Add(item);
     item = new InvestmentTransaction();
 }