예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SharpBooks.SplitData"/> class.
        /// </summary>
        /// <param name="split">The <see cref="SharpBooks.Split"/> from which to copy.</param>
        public SplitData(Split split)
        {
            if (split == null)
            {
                throw new ArgumentNullException("split");
            }

            this.TransactionId = split.Transaction.TransactionId;
            this.AccountId = split.Account.AccountId;
            this.SecurityId = split.Security.SecurityId;
            this.Amount = split.Amount;
            this.DateCleared = split.DateCleared;
            this.IsReconciled = split.IsReconciled;
            this.TransactionAmount = split.TransactionAmount;
        }
예제 #2
0
        /// <summary>
        /// Removes a previously added split from the transaction.
        /// </summary>
        /// <param name="split">The previously added split.</param>
        /// <param name="transactionLock">A <see cref="SharpBooks.TransactionLock"/> obtained from the <see cref="Lock" /> function.</param>
        public void RemoveSplit(Split split, TransactionLock transactionLock)
        {
            if (split == null)
            {
                throw new ArgumentNullException("split");
            }

            lock (this.lockMutex)
            {
                this.ValidateLock(transactionLock);

                if (!this.splits.Contains(split))
                {
                    throw new InvalidOperationException("Could not remove the split from the transaction, because the split is not a member of the transaction.");
                }

                this.splits.Remove(split);
                split.Transaction = null;
            }
        }
예제 #3
0
        /// <summary>
        /// Creates a new split and adds it to the transaction.
        /// </summary>
        /// <param name="transactionLock">A <see cref="SharpBooks.TransactionLock"/> obtained from the <see cref="SharpBooks.Transaction.Lock" /> function.</param>
        /// <returns>The newly created split.</returns>
        public Split AddSplit(TransactionLock transactionLock)
        {
            lock (this.lockMutex)
            {
                this.ValidateLock(transactionLock);

                var split = new Split(this);

                this.splits.Add(split);
                return split;
            }
        }