Exemplo n.º 1
0
        void view_OnCreateNewTransaction(object sender, NewTransactionEventArgs e)
        {
            var t = travel.CreateTransaction(e.Details, e.Currency, e.Date);

            t.Currency.ExchangeRate = e.ExchangeRate;
            switch (e.Type)
            {
            case TransactionType.SingleExpense:
                paymentsEngine.Expense(t, e.Creditor, e.Amount, travel.BaseCurrency);
                break;

            case TransactionType.CollectiveExpense:
                bool includeCreditor = e.Debtors.Contains(e.Creditor);
                paymentsEngine.PayEquallyFor(t, e.Creditor, includeCreditor, e.Amount, travel.BaseCurrency, e.Debtors.Where(d => d != e.Creditor).ToArray());
                break;

            case TransactionType.InternalTransaction:
                paymentsEngine.GiveMoneyTo(t, e.Creditor, e.Debtors.First(), e.Amount, travel.BaseCurrency);
                break;
            }

            view.RefreshTransactions();
        }