Exemple #1
0
        private void AddInvestment(Account a, Investment i)
        {
            if (a == null)
            {
                throw new Exception("Cannot add investments before we find account information in the imported xml file");
            }

            long id;

            if (!remappedIds.TryGetValue(i.Id, out id))
            {
                throw new Exception("Cannot find original transaction mentioned by this investment");
            }

            string name = i.SecurityName;

            i.Security = Money.Securities.FindSecurity(name, true);

            Transaction u = Money.Transactions.FindTransactionById(id);

            if (u != null)
            {
                Investment j = u.GetOrCreateInvestment();
                j.Merge(i);
            }
            else
            {
                throw new Exception("Cannot add investment on a transaction that doesn't exist yet");
            }
        }