public void Credit(ExpenseItem expense, decimal amount) { var ledgerItem = new LedgerItem() { Expense = expense, Amount = (-1) * amount }; this.Add(ledgerItem); }
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); } }
public void Credit(ExpenseItem expense, decimal amount) { this.Expense = expense; this.Amount = (-1) * amount; }
// 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; }
public void Credit(ExpenseItem expenseItem, decimal amount) { this.LedgerItems.Credit(expenseItem, amount); }