BudgetAnalyser.Engine.Statement.StatementModel.SplitTransaction C# (CSharp) Method

SplitTransaction() private method

private SplitTransaction ( [ originalTransaction, decimal splinterAmount1, decimal splinterAmount2, [ splinterBucket1, [ splinterBucket2 ) : void
originalTransaction [
splinterAmount1 decimal
splinterAmount2 decimal
splinterBucket1 [
splinterBucket2 [
return void
        internal virtual void SplitTransaction(
            [NotNull] Transaction originalTransaction,
            decimal splinterAmount1,
            decimal splinterAmount2,
            [NotNull] BudgetBucket splinterBucket1,
            [NotNull] BudgetBucket splinterBucket2)
        {
            ThrowIfDisposed();
            if (originalTransaction == null)
            {
                throw new ArgumentNullException(nameof(originalTransaction));
            }

            if (splinterBucket1 == null)
            {
                throw new ArgumentNullException(nameof(splinterBucket1));
            }

            if (splinterBucket2 == null)
            {
                throw new ArgumentNullException(nameof(splinterBucket2));
            }

            var splinterTransaction1 = originalTransaction.Clone();
            var splinterTransaction2 = originalTransaction.Clone();

            splinterTransaction1.Amount = splinterAmount1;
            splinterTransaction2.Amount = splinterAmount2;

            splinterTransaction1.BudgetBucket = splinterBucket1;
            splinterTransaction2.BudgetBucket = splinterBucket2;

            if (splinterAmount1 + splinterAmount2 != originalTransaction.Amount)
            {
                throw new ArgumentException("The two new amounts do not add up to the original transaction value.");
            }

            RemoveTransaction(originalTransaction);

            this.changeHash = Guid.NewGuid();
            if (AllTransactions == null)
            {
                AllTransactions = new List<Transaction>();
            }
            List<Transaction> mergedTransactions =
                AllTransactions.ToList().Merge(new[] { splinterTransaction1, splinterTransaction2 }).ToList();
            AllTransactions = mergedTransactions;
            splinterTransaction1.PropertyChanged += OnTransactionPropertyChanged;
            splinterTransaction2.PropertyChanged += OnTransactionPropertyChanged;
            this.duplicates = null;
            UpdateDuration();
            Filter(this.currentFilter);
        }