public void Withdraw_Execute_BalanceUpdatesOK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            Assert.Equal(0, account.Balance);
        }
        public void Withdraw_Executes_ExecutedIsTrue()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            Assert.True(withdraw.Executed);
        }
        public void Withdraw_Execute_StatusComplete()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            Assert.Equal("Complete", withdraw.Status);
        }
Esempio n. 4
0
    private static void DoWithdraw(Bank fromBank)
    {
        Account fromAccount = FindAccount(fromBank);

        if (fromAccount == null)
        {
            return;
        }

        decimal amount;

        Console.Write("Please enter the amount to withdraw: ");
        try
        {
            amount = Convert.ToDecimal(Console.ReadLine());

            WithdrawTransaction withdraw = new WithdrawTransaction(fromAccount, amount);

            Bank.ExecuteTransaction(withdraw);
        }
        catch (Exception e)
        {
            Console.WriteLine("Withdrawal error!");
            Console.WriteLine(e.Message);
        }
    }
        public void Withdraw_SetId_OK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            withdraw.SetId(1);
            Assert.Equal(1, withdraw.Id);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public TransferTransaction(Account sourceAccount, Account destinationAccount, double amount)
     : base(destinationAccount, amount)
 {
     SetDescription("Transfer In");
     _withdrawTransaction = new WithdrawTransaction(sourceAccount, amount);
     _withdrawTransaction.SetDescription("Transfer Out");
 }
Esempio n. 8
0
    private static void DoWithdraw(Bank fromBank)
    {
        Account toBank = FindAccount(fromBank);

        if (toBank == null)
        {
            return;
        }

        String  input;
        decimal withdraw = 0;

        Console.WriteLine("How much would you like to withdraw?: ");
        input    = Console.ReadLine();
        withdraw = Convert.ToDecimal(input);

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

        WithdrawTransaction withdrawT = new WithdrawTransaction(toBank, withdraw);

        fromBank.ExecuteTransaction(withdrawT);
        withdrawT.Print();
    }
Esempio n. 9
0
    private static void DoWithdraw(Bank toBank)
    {
        Decimal WithdrawAmount;


        Account toAccount = FindAccount(toBank);

        if (toAccount == null)
        {
            return;
        }

        try
        {
            Console.WriteLine("How much would you like to Withdraw? ");
            WithdrawAmount = Convert.ToDecimal(Console.ReadLine());
        }
        catch
        {
            WithdrawAmount = 0;
        }

        WithdrawTransaction withdrawtransac = new WithdrawTransaction(toAccount, WithdrawAmount);

        toBank.ExecuteTransaction(withdrawtransac);
        withdrawtransac.Print();
    }
    private static void DoWithdraw(Bank toBank)
    {
        decimal amount;

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

                if (toAccount == null)
                {
                    return;
                }

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

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

                WithdrawTransaction withdraw = new WithdrawTransaction(toAccount, amount);

                toBank.ExecuteTransaction(withdraw);
            }

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

                amount = -1;
            }
        }  while(amount < 1);
    }
        public void Withdraw_Rollback_BalanceUpdatesOK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            withdraw.Execute();
            withdraw.Rollback();
            Assert.Equal(100, account.Balance);
        }
Esempio n. 12
0
    public TransferTransaction(Account fromAccount, Account targetAccount, double transactionAmount)
        : base(targetAccount, transactionAmount)
    {
        Memo = "Transfer In";

        withdrawTransacation = new WithdrawTransaction(fromAccount, transactionAmount);
        withdrawTransacation.Memo = "Transfer Out";
    }
Esempio n. 13
0
 public TransferTransaction(Account fromAccount, Account toAccount, decimal amount)
 {
     _fromAccount = fromAccount;
     _toAccount   = toAccount;
     _amount      = amount;
     _theWithdraw = new WithdrawTransaction(fromAccount, amount);
     _theDeposit  = new DepositTransaction(toAccount, amount);
 }
        public void Withdraw_Rollback_OK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            _ = withdraw.Rollback();
            Assert.True(withdraw.Reversed);
        }
        public Transaction NewWithdraw(Account account, decimal amount)
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, amount);

            CreateTransaction(withdraw);
            Execute(withdraw);
            _transactionRepository.Update(withdraw);
            return(withdraw);
        }
        public async Task <JsonResult> WithdrawTransaction(WithdrawTransaction withdrawTransaction, string tenantUid)
        {
            var origin = TenantHelper.GetCurrentTenantUrl(contentService, tenantUid);
            var token  = Request.Cookies["token"].Value;

            var response = (WithdrawTransactionResponseContent)await _transactionHistoryService.WithdrawTransaction(tenantUid, token, origin, withdrawTransaction);

            return(Json(response));
        }
Esempio n. 17
0
    public virtual TransactionResult withdraw(WithdrawTransaction withdrawTransaction)
    {
        if (withdrawTransaction.TransactionAmount > this.balance)
        {
            return TransactionResult.INSUFFICIENT_FUND;
        }
        balance -= withdrawTransaction.TransactionAmount;
        transactionHistories.Add(withdrawTransaction);

        return TransactionResult.SUCCESS;
    }
Esempio n. 18
0
        public Transaction NewWithdraw(Account account, decimal amount)
        {
            Guard.Against.Null(account, "Account");
            Guard.Against.Negative(amount, "Amount");

            WithdrawTransaction withdraw = new WithdrawTransaction(account, amount);

            CreateTransaction(withdraw);
            Execute(withdraw);

            return(withdraw);
        }
        public void Transfer_RollbackWithInsufficientFunds_ThrowsInsufficientFundsException()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();

            WithdrawTransaction withdraw = new WithdrawTransaction(to, to.Balance);

            withdraw.Execute();

            Assert.Throws <InsufficientFundsException>(() => transfer.Rollback());
        }
Esempio n. 20
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());
        }
        public async Task RecordWithdrawTransactionAsync(Guid bankingAccountId, decimal amount, CancellationToken cancellationToken = default(CancellationToken))
        {
            var account = await accountRepository.GetByIdAsync(bankingAccountId, cancellationToken);

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

            var withDrawTransaction = new WithdrawTransaction(account, amount);

            transactionManager.AddTransaction(withDrawTransaction);

            await transactionManager.ProcessTransactionsAsync();
        }
        public async Task <IResponseContent> WithdrawTransaction(string tenantUid, string token, string origin, WithdrawTransaction withdrawTransaction)
        {
            var customerGuid = DecodeJwt(token).CustomerGuid;

            withdrawTransaction.CustomerGuid = customerGuid;

            var response = await SubmitPostAsync(URL_API_WITHDRAW_TRANSACTION, origin, withdrawTransaction, token, tenantUid);

            var responseContent = AssertResponseContent <WithdrawTransactionResponseContent>(response);

            return(responseContent);
        }
Esempio n. 23
0
 public static void ExecuteTransaction(WithdrawTransaction transaction)
 {
     transaction.Execute();
     transaction.Print();
 }
Esempio n. 24
0
 public void ExecuteTransaction(WithdrawTransaction transaction)
 {
     transaction.Execute();
 }
        public void Withdraw_Create_NotNull()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            Assert.NotNull(withdraw);
        }
Esempio n. 26
0
 private void ExecuteTransaction(WithdrawTransaction WithdrawTransaction)
 {
     WithdrawTransaction.Execute();
 }
        public void Withdraw_Type_IsWithdraw()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            Assert.Equal("Withdraw", withdraw.Type);
        }
        public void Withdraw_CreateWithPositiveAmount_CreatesOKWithPendingStatus()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

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