Example #1
0
        public void Credit(ExpenseItem expense, decimal amount)
        {
            var ledgerItem = new LedgerItem()
            {
                Expense = expense, Amount = (-1) * amount
            };

            this.Add(ledgerItem);
        }
Example #2
0
        public void EnterExpense(Person payer, IEnumerable <Person> expenseFor, ExpenseItem expenseItem, decimal amount)
        {
            payer.Debit(expenseItem, amount); //crediting since amount is flowing from payer to expense

            var amountToBeDebited = (amount / expenseFor.Count());
            var total             = 0m;

            foreach (var person in expenseFor)
            {
                total += amountToBeDebited;
                person.Credit(expenseItem, amountToBeDebited);
            }

            var diff = amount - total;

            if (diff > 0)
            {
                expenseFor.FirstOrDefault().Debit(expenseItem, diff);
            }
        }
Example #3
0
 public void Credit(ExpenseItem expense, decimal amount)
 {
     this.Expense = expense;
     this.Amount  = (-1) * amount;
 }
Example #4
0
        // can have negative value,
        // Negative value - represent liability
        // positive value - represent money that person has to give.

        public void Debit(ExpenseItem expense, decimal amount)
        {
            this.Expense = Expense;
            this.Amount  = amount;
        }
Example #5
0
 public void Credit(ExpenseItem expenseItem, decimal amount)
 {
     this.LedgerItems.Credit(expenseItem, amount);
 }