Esempio n. 1
0
 /// <summary>
 /// Adds a transaction to the <see cref="SaveTrack"/>.
 /// </summary>
 /// <param name="transaction">The transaction to add.</param>
 public void AddTransaction(TransactionData transaction)
 {
     this.actions.Add(new Action
     {
         ActionType = ActionType.AddTransaction,
         Item = transaction,
     });
 }
Esempio n. 2
0
        public void AddTransaction(TransactionData transaction)
        {
            lock (this)
            {
                var baseSecurity = this.destinationBook.Securities.Where(s => s.SecurityId == transaction.BaseSecurityId).Single();

                var newTransaction = new Transaction(
                    transaction.TransactionId,
                    baseSecurity);

                using (var tlock = newTransaction.Lock())
                {
                    newTransaction.SetDate(transaction.Date, tlock);

                    foreach (var split in transaction.Splits)
                    {
                        var newSplit = newTransaction.AddSplit(tlock);

                        var account = this.destinationBook.Accounts.Where(a => a.AccountId == split.AccountId).Single();
                        var security = this.destinationBook.Securities.Where(s => s.SecurityId == split.SecurityId).Single();

                        newSplit.SetAccount(account, tlock);
                        newSplit.SetSecurity(security, tlock);
                        newSplit.SetAmount(split.Amount, tlock);
                        newSplit.SetTransactionAmount(split.TransactionAmount, tlock);
                        newSplit.SetDateCleared(split.DateCleared, tlock);
                        newSplit.SetIsReconciled(split.IsReconciled, tlock);
                    }
                }

                this.destinationBook.AddTransaction(
                    newTransaction);
            }
        }