示例#1
0
        public LedgerTransaction CreateLedgerTransaction(LedgerBook ledgerBook, LedgerEntryLine reconciliation, LedgerEntry ledgerEntry,
                                                         decimal amount, string narrative)
        {
            if (reconciliation == null)
            {
                throw new ArgumentNullException(nameof(reconciliation));
            }

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

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

            LedgerTransaction newTransaction = new CreditLedgerTransaction();

            newTransaction.WithAmount(amount).WithNarrative(narrative);
            newTransaction.Date = reconciliation.Date;

            // ledgerEntry.AddTransactionForPersistenceOnly(newTransaction);
            List <LedgerTransaction> replacementTxns = ledgerEntry.Transactions.ToList();

            replacementTxns.Add(newTransaction);
            ledgerEntry.SetTransactionsForReconciliation(replacementTxns);
            ledgerEntry.RecalculateClosingBalance(ledgerBook);
            return(newTransaction);
        }
        public void WithAmountMinus50ShouldCreateADebitOf50()
        {
            var subject = new CreditLedgerTransaction();

            LedgerTransaction result = subject.WithAmount(-50);

            Assert.AreEqual(-50M, result.Amount);
        }
        public void WithAmount50ShouldReturnSameObjectForChaining()
        {
            var subject = new CreditLedgerTransaction();

            LedgerTransaction result = subject.WithAmount(50);

            Assert.AreSame(subject, result);
        }