Exemple #1
0
        public void Deposit_Execute_BalanceUpdatesOK()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            Assert.Equal(200, account.Balance);
        }
Exemple #2
0
        public TransactionDetailDto AsTransactionDetailDto(Transaction transaction)
        {
            TransactionDetailDto dto = new TransactionDetailDto();

            switch (transaction.Type)
            {
            case "Deposit":
                DepositTransaction deposit = transaction as DepositTransaction;
                dto.ToAccountId = deposit.Account.Id;
                break;

            case "Withdraw":
                WithdrawTransaction withdraw = transaction as WithdrawTransaction;
                dto.FromAccountId = withdraw.Account.Id;
                break;

            case "Transfer":
                TransferTransaction transfer = transaction as TransferTransaction;
                dto.FromAccountId = transfer.From.Id;
                dto.ToAccountId   = transfer.To.Id;
                break;

            default:
                break;
            }
            dto.Id        = transaction.Id;
            dto.Type      = transaction.Type;
            dto.Amount    = transaction.Amount;
            dto.DateStamp = transaction.DateStamp;
            dto.Status    = transaction.Status;

            return(dto);
        }
Exemple #3
0
    private static void DoDeposit(Bank toBank)
    {
        Account toAccount = FindAccount(toBank);

        if (toAccount == null)
        {
            return;
        }

        try
        {
            decimal amount;
            Console.Write("Please enter the amount to deposit: ");

            amount = Convert.ToDecimal(Console.ReadLine());

            DepositTransaction deposit = new DepositTransaction(toAccount, amount);

            Bank.ExecuteTransaction(deposit);
        }
        catch (Exception e)
        {
            Console.WriteLine("Deposit error!");
            Console.WriteLine(e.Message);
        }
    }
Exemple #4
0
//        private List<DepositTransaction> Extract()
//        {
//            return (from t in _db.TransWithTags
//                    where
//                        t.MyAccount == _deposit.ParentAccount
//                    orderby t.Timestamp
//                    join r in _db.CurrencyRates on new { t.Timestamp.Date, Currency = t.Currency.GetValueOrDefault() } equals new { r.BankDay.Date, r.Currency } into g
//                    from rate in g.DefaultIfEmpty()
//                    select new DepositTransaction
//                    {
//                        Amount = t.Amount,
//                        Timestamp = t.Timestamp,
//                        Currency = t.Currency.GetValueOrDefault(),
//                        Counteragent = GetDepositCounteragent(t),
//                        Comment = t.Comment != "" ? t.Comment : t.Operation == OperationType.Обмен ? "снятие с обменом валюты" : t.Operation == OperationType.Доход ? "проценты" : "частичное снятие",
//                        AmountInUsd = rate != null ? t.Amount / (decimal)rate.Rate : t.Amount,
//                        TransactionType = GetDepositOperationType(t, _deposit.ParentAccount)
//                    }).ToList();
//        }

        private IEnumerable <DepositTransaction> Extract()
        {
            var trans = _db.TransWithTags.Where(t => t.MyAccount == _deposit.ParentAccount).ToList();

            foreach (var tran in trans)
            {
                var rate = _db.CurrencyRates.FirstOrDefault(r =>
                                                            r.BankDay.Date == tran.Timestamp.Date && r.Currency == tran.Currency);
                var depoTran = new DepositTransaction()
                {
                    Amount       = tran.Amount,
                    Timestamp    = tran.Timestamp,
                    Currency     = tran.Currency.GetValueOrDefault(),
                    Counteragent = GetDepositCounteragent(tran),
                    Comment      = tran.Comment != ""
                        ? tran.Comment
                        : tran.Operation == OperationType.Обмен
                            ? "снятие с обменом валюты"
                            : tran.Operation == OperationType.Доход
                                ? "проценты"
                                : "частичное снятие",
                    AmountInUsd     = rate != null ? tran.Amount / (decimal)rate.Rate : tran.Amount,
                    TransactionType = GetDepositOperationType(tran, _deposit.ParentAccount)
                };
                yield return(depoTran);
            }
        }
Exemple #5
0
    private static void DoDeposit(Bank toBank)
    {
        Account toAccount = FindAccount(toBank);

        if (toAccount == null)
        {
            return;
        }

        String  input;
        decimal deposit = 0;

        Console.WriteLine("How much would you like to deposit?: ");

        try
        {
            input   = Console.ReadLine();
            deposit = Convert.ToDecimal(input);
        }
        catch (System.FormatException)
        {
            Console.WriteLine("Not a number");
        }

        DepositTransaction depositT = new DepositTransaction(toAccount, deposit);

        toBank.ExecuteTransaction(depositT);
        depositT.Print();
    }
Exemple #6
0
//        private IEnumerable<DepositTransaction> ExtractSecondPart()
//        {
//            return from t in _db.TransWithTags
//                   where
//                       (t.MySecondAccount != null && t.MySecondAccount == _deposit.ParentAccount)
//                   orderby t.Timestamp
//                   join r in _db.CurrencyRates on new { t.Timestamp.Date, Currency = t.CurrencyInReturn.GetValueOrDefault() } equals
//                       new { r.BankDay.Date, r.Currency } into g
//                   from rate in g.DefaultIfEmpty()
//                   select new DepositTransaction
//                   {
//                       Amount = t.Operation == OperationType.Обмен ? t.AmountInReturn : t.Amount,
//                       Timestamp = t.Timestamp,
//                       Currency = t.CurrencyInReturn.GetValueOrDefault(),
//                       Counteragent = GetDepositCounteragent(t),
//                       Comment = t.Operation == OperationType.Обмен ? "обмен с пополнением депозита" : "пополнение депозита",
//                       AmountInUsd = rate != null ? t.AmountInReturn / (decimal)rate.Rate : t.AmountInReturn,
//                       TransactionType = DepositTransactionTypes.Явнес,
//                   };
//        }

        private IEnumerable <DepositTransaction> ExtractSecondPart()
        {
            var trans = _db.TransWithTags.Where(t => t.MySecondAccount == _deposit.ParentAccount).ToList();

            foreach (var tran in trans)
            {
                var currency = tran.Operation == OperationType.Перенос ? tran.Currency : tran.CurrencyInReturn;
                var rate     = _db.CurrencyRates.FirstOrDefault(r =>
                                                                r.BankDay.Date == tran.Timestamp.Date && r.Currency == currency);
                var rateValue = rate == null ? 1 : rate.Rate;
                var depoTran  = new DepositTransaction()
                {
                    Amount       = tran.Operation == OperationType.Обмен ? tran.AmountInReturn : tran.Amount,
                    Timestamp    = tran.Timestamp,
                    Currency     = tran.CurrencyInReturn.GetValueOrDefault(),
                    Counteragent = GetDepositCounteragent(tran),
                    Comment      = tran.Comment != ""
                        ? tran.Comment
                        : tran.Operation == OperationType.Обмен
                            ? "обмен с пополнением депозита"
                            : "пополнение депозита",
                    AmountInUsd     = tran.Operation == OperationType.Перенос ? tran.Amount / (decimal)rateValue : tran.AmountInReturn / (decimal)rateValue,
                    TransactionType = DepositTransactionTypes.Явнес,
                };
                yield return(depoTran);
            }
        }
Exemple #7
0
        public override DepositTransaction Deposit(Decimal amount)
        {
            var transaction = new DepositTransaction(amount, this);

            transaction.Initiate();
            return(transaction);
        }
Exemple #8
0
    private static void DoDeposit(Bank toBank)
    {
        Decimal DepositAmount;

        Account toAccount = FindAccount(toBank);

        if (toAccount == null)
        {
            return;
        }

        try
        {
            Console.WriteLine("How much would you like to Deposit? ");
            //Read in the amount
            DepositAmount = Convert.ToDecimal(Console.ReadLine());
        }
        catch
        {
            DepositAmount = 0;
        }
        //create the deposit transaction
        DepositTransaction deposittransac = new DepositTransaction(toAccount, DepositAmount);

        //tell toBank to run the transaction
        toBank.ExecuteTransaction(deposittransac);
        //Ask the transaction to Print.
        deposittransac.Print();
    }
Exemple #9
0
        public void Deposit_Executes_ExecutedIsTrue()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            Assert.True(deposit.Executed);
        }
    private static void DoDeposit(Bank toBank)
    {
        decimal amount;

        do
        {
            try
            {
                Account toAccount = FindAccount(toBank);

                if (toAccount == null)
                {
                    return;
                }

                Console.WriteLine(" Enter amount to deposit: ");

                amount = Convert.ToDecimal(Console.ReadLine());

                DepositTransaction deposit = new DepositTransaction(toAccount, amount);

                toBank.ExecuteTransaction(deposit);
            }
            catch (System.Exception)
            {
                Console.Error.WriteLine(" You have entered an invalid value! ");

                amount = -1;
            }
        }  while(amount < 1);
    }
Exemple #11
0
        public void Deposit_SetId_OK()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            deposit.SetId(1);
            Assert.Equal(1, deposit.Id);
        }
Exemple #12
0
        public void Deposit_Execute_StatusComplete()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            Assert.Equal("Complete", deposit.Status);
        }
 public TransferTransaction(Account fromAccount, Account toAccount, decimal amount)
 {
     _fromAccount = fromAccount;
     _toAccount   = toAccount;
     _amount      = amount;
     _theWithdraw = new WithdrawTransaction(fromAccount, amount);
     _theDeposit  = new DepositTransaction(toAccount, amount);
 }
Exemple #14
0
        public void Deposit_Rollback_OK()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            _ = deposit.Rollback();
            Assert.True(deposit.Reversed);
        }
        public async Task <JsonResult> DepositTransaction(DepositTransaction depositTransaction, string tenantUid)
        {
            var origin = TenantHelper.GetCurrentTenantUrl(contentService, tenantUid);
            var token  = Request.Cookies["token"].Value;

            var response = (DepositTransactionResponseContent)await _transactionHistoryService.DepositTransaction(tenantUid, token, origin, depositTransaction);

            return(Json(response));
        }
        public Transaction NewDeposit(Account account, decimal amount)
        {
            DepositTransaction deposit = new DepositTransaction(account, amount);

            CreateTransaction(deposit);
            Execute(deposit);
            _transactionRepository.Update(deposit);
            return(deposit);
        }
        private void buttonDeposit_Click(object sender, EventArgs e)
        {
            toolStripStatusLabelInfoMessage.Text = "Enter a Deposit";
            DepositOrWithdrawDialog depositDlg = new DepositOrWithdrawDialog();

            depositDlg.Title = "Deposit";
            Transaction transaction = new DepositTransaction();

            doFullTransaction(transaction, depositDlg);
        }
Exemple #18
0
        public void Deposit_Rollback_InsufficientFundsThrowsInsufficientFundsException()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();

            WithdrawTransaction withdraw = new WithdrawTransaction(account, 150);

            _ = withdraw.Execute();

            Assert.Throws <InsufficientFundsException>(() => deposit.Rollback());
        }
Exemple #19
0
        public Transaction NewDeposit(Account account, decimal amount)
        {
            Guard.Against.Null(account, "Account");
            Guard.Against.Negative(amount, "Amount");

            DepositTransaction deposit = new DepositTransaction(account, amount);

            CreateTransaction(deposit);
            Execute(deposit);

            return(deposit);
        }
 private void DepositarATM()
 {
     try
     {
         ITransaction transacao = new DepositTransaction(new ATMUI(300));
         transacao.Execute();
         Console.WriteLine("Valor depositado com sucesso.");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        public async Task RecordDepositTransactionAsync(Guid bankingAccountId, decimal amount, CancellationToken cancellationToken = default(CancellationToken))
        {
            var account = await accountRepository.GetByIdAsync(bankingAccountId, cancellationToken);

            if (account == null)
            {
                throw new AccountNotFoundException(bankingAccountId);
            }

            var depositTransaction = new DepositTransaction(account, amount);

            transactionManager.AddTransaction(depositTransaction);

            await transactionManager.ProcessTransactionsAsync();
        }
Exemple #22
0
        private static void ExportLineData(Worksheet ws, int i, DepositTransaction line, ref decimal total)
        {
            ws.Cells[i, 2] = line.Timestamp;
            ws.Cells[i, 3] = total;

            if (line.IsIncome())
            {
                ws.Cells[i, 4] = line.Amount;
            }
            else
            {
                ws.Cells[i, 5] = line.Amount;
            }
            total          = total + line.Amount * line.Destination();
            ws.Cells[i, 6] = total;

            ws.Cells[i, 7] = line.Counteragent;
            ws.Cells[i, 8] = line.Comment;
        }
        static void TemplatePattern()
        {
            Console.WriteLine("Template Pattern");
            Console.WriteLine("---------------");

            Console.WriteLine("*****ATM - Deposit Transaction*****");
            ATM deposit = new DepositTransaction();
            deposit.PerformTransaction();

            Console.WriteLine("*****ATM - Withdrawal Transaction*****");
            ATM withdraw = new WithdrawalTranaction();
            withdraw.PerformTransaction();
    

            Console.WriteLine(Environment.NewLine);

            Console.WriteLine("**********************");
            Console.ReadLine();

        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                decimal.TryParse(txtAmount.Text, out amount);

                // Create a new transaction
                Transaction transaction = new DepositTransaction(customer.Accounts[selectedAccount], amount);
                transaction.DoTransaction();

                // Add the transaction to the transaction history.
                this.customer.TransactionHistory.Add(transaction);

                // This will close the dialog with a positive result.
                this.DialogResult = DialogResult.OK;
            }
            catch (AccountInactiveException exception)
            {
                MessageBox.Show(exception.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (InvalidTransactionAmtException exception)
            {
                // Make sure the input is numeric.
                if (!decimal.TryParse(txtAmount.Text, out amount))
                {
                    MessageBox.Show("Invalid amount. Please enter a numeric value.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show(exception.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemple #25
0
        public void Deposit_Create_NotNull()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            Assert.NotNull(deposit);
        }
Exemple #26
0
 public void Func()
 {
     var dt = new DepositTransaction(gui);
 }
Exemple #27
0
 public virtual TransactionResult deposit(DepositTransaction depositTransaction)
 {
     balance += depositTransaction.TransactionAmount;
     transactionHistories.Add(depositTransaction);
     return TransactionResult.SUCCESS;
 }
Exemple #28
0
 void f()
 {
     DepositTransaction dt = new DepositTransaction(Gui);
 }
Exemple #29
0
 private void ExecuteTransaction(DepositTransaction DepositTransaction)
 {
     DepositTransaction.Execute();
 }
Exemple #30
0
        public void Deposit_Type_IsDeposit()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            Assert.Equal("Deposit", deposit.Type);
        }
Exemple #31
0
 public void Apply(DepositTransaction d)
 {
     Balance = Balance + d.DepositAmount;
 }
Exemple #32
0
        public void Deposit_CreateWithPositiveAmount_CreatesOKWithPendingStatus()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            Assert.Equal("Pending", deposit.Status);
        }