public void WhenTransactionExecutedOnhierarchicalAccountsThenParametersCalculated() { var rootAccount = new Account("root"); var accIncome = rootAccount.CreateSubaccount("income") .CreateSubaccount("income2"); var accOutcome = rootAccount.CreateSubaccount("expences"); const decimal amount1 = 42.0m; const decimal amount2 = 77.0m; new AccountingTransaction("tx1", accIncome, accOutcome, amount1).Execute(); new AccountingTransaction("tx2", accOutcome, accIncome, amount2).Execute(); Assert.AreEqual(amount2, accIncome.CreditTurnover); Assert.AreEqual(amount1, accIncome.DebtTurnover); Assert.AreEqual(amount2-amount1, accIncome.GetBalance()); Assert.AreEqual(amount2, accOutcome.DebtTurnover); Assert.AreEqual(amount1, accOutcome.CreditTurnover); Assert.AreEqual(amount1-amount2, accOutcome.GetBalance()); Assert.AreEqual(0.0m, rootAccount.GetBalance()); Assert.AreEqual(2* (amount1+amount2), rootAccount.GetTurnover()); }
public void WhenTransactionCreditAndDebtThenAccountSaldoAndTurnoverAreOk() { var acc = new Account("root"); acc.TransactCredit(10.0m); acc.TransactDebt(5.0m); Assert.AreEqual(10.0m, acc.CreditTurnover); Assert.AreEqual(5.0m, acc.DebtTurnover); Assert.AreEqual(15.0m, acc.GetTurnover()); Assert.AreEqual(5.0, acc.GetBalance()); }
public void WhenTransactionCreditAndDebtThenParentAccountSaldoAndTurnoverAreOk() { var acc = new Account("root"); var acc1 = acc.CreateSubaccount("expence"); var acc2 = acc.CreateSubaccount("income"); acc1.TransactDebt(6.0m); acc2.TransactCredit(17.0m); Assert.AreEqual(17.0m, acc.CreditTurnover); Assert.AreEqual(6.0m, acc.DebtTurnover); Assert.AreEqual(23.0m, acc.GetTurnover()); Assert.AreEqual(11.0, acc.GetBalance()); }
public void WhenTransactionExecutedOnPairedAccountsThenParametersCalculated() { var rootAccount = new Account("root"); var accIncome = rootAccount.CreateSubaccount("income"); var accOutcome = rootAccount.CreateSubaccount("expences"); const decimal amount = 77.0m; var tx = new AccountingTransaction("tx1", accIncome, accOutcome, amount); tx.Execute(); Assert.AreEqual(0.0m, accIncome.CreditTurnover); Assert.AreEqual(amount, accIncome.DebtTurnover); Assert.AreEqual(-amount, accIncome.GetBalance()); Assert.AreEqual(0.0m, accOutcome.DebtTurnover); Assert.AreEqual(amount, accOutcome.CreditTurnover); Assert.AreEqual(amount, accOutcome.GetBalance()); Assert.AreEqual(0.0m, rootAccount.GetBalance()); Assert.AreEqual(2 * amount, rootAccount.GetTurnover()); }