public bool Withdraw(ITransaction transaction) { if ((Balance - transaction.Amount) < 0) { return(false); } else if ((Balance - transaction.Amount) > 0 && (DateTime.Now < DateOfMaturity)) { if (((transaction.Amount * PenaltyInterestRate) + transaction.Amount) > Balance) { TotalPenalty = transaction.Amount * PenaltyInterestRate; transaction.Amount = Balance - transaction.Amount * PenaltyInterestRate; Balance = 0; AccountTransactions.Add(transaction); } else { Balance -= (transaction.Amount * PenaltyInterestRate) + transaction.Amount; TotalPenalty += transaction.Amount * PenaltyInterestRate; AccountTransactions.Add(transaction); } } else { Balance -= transaction.Amount; AccountTransactions.Add(transaction); } return(true); }
public bool Withdraw(ITransaction transaction) { if ((Balance - transaction.Amount) < 0 && Type == TypeFactory.CheckingAccount) { return(false); } else if ((Balance - transaction.Amount) < 0 && Type == TypeFactory.BusinessAccount) { if (OverDraftLoan == null) { OverDraftLoan = new BankLoan(.1, transaction.Amount - Balance, TypeFactory.GenerateLoanID(), TypeFactory.OverdraftLoan); AccountLoans.Add(OverDraftLoan); AccountTransactions.Add(transaction); Balance = 0; } else { OverDraftLoan.Amount += transaction.Amount; AccountLoans.Add(OverDraftLoan); } } else { Balance -= transaction.Amount; AccountTransactions.Add(transaction); } return(true); }
public void Save(AccountTransaction accountTransaction) { using (var core = new StandardBusinessLayer(this)) { core.Connect(); bool newTransaction = accountTransaction.No == 0; core.Save(accountTransaction); if (newTransaction) { AccountTransactions.Add(accountTransaction); } else { for (int i = 0; i < AccountTransactions.Count(); i++) { if (AccountTransactions[i].No == accountTransaction.No) { AccountTransactions[i] = accountTransaction; break; } } } FillVerification(Verifications.First(v => v.No == accountTransaction.VerificationNo)); } }
public override void withdraw(string description, double withdrawAmount) { //create transaction Transaction transaction = new Transaction("Withdraw", description, DateTime.Now.ToString("M-dd-yyyy/HH:mm:ss"), withdrawAmount); //add transactions to savings account List AccountTransactions.Add(transaction); balance -= Math.Round(withdrawAmount, 2); }
public void BalanceAndTransactionConsistencyCheck() { var trans1 = new AccountTransaction(); trans1.Amount = 100; var trans2 = new AccountTransaction(); trans2.Amount = 0.5m; var trans3 = new AccountTransaction(); trans3.Amount = -10; AccountTransactions list = new AccountTransactions(); list.Add(trans1); list.Add(trans2); list.Add(trans3); }
public override void deposit(string description, double depositAmount) { //create transaction Transaction transaction = new Transaction("Deposit", description, DateTime.Now.ToString("M-dd-yyyy/HH:mm:ss"), depositAmount); //add transactions to checking account List AccountTransactions.Add(transaction); balance += Math.Round(depositAmount, 2); }
private void AddTransactionHistory(TransactionType transactionType, decimal amount, string remarks = "", string accountNumberReceiver = "") { if (AccountTransactions == null) { AccountTransactions = new List <Transaction>(); } Transaction trans = new Transaction(Id, transactionType, amount, accountNumberReceiver, remarks); AccountTransactions.Add(trans); }
public AccountTransaction PostAccountTransaction(AccountTransaction accountTransaction) { var item = AccountTransactions.FirstOrDefault(c => c.AccountTransactionId == accountTransaction.AccountTransactionId); if (item != null) { item = accountTransaction; return(item); } else { accountTransaction.AccountTransactionId = GenerateAccontTransactionId(); AccountTransactions.Add(accountTransaction); return(accountTransaction); } }
public bool Deposit(ITransaction transaction) { if (OverDraftLoan != null && OverDraftLoan.Amount > 0) { if (OverDraftLoan.Amount > transaction.Amount) { OverDraftLoan.Amount -= transaction.Amount; AccountTransactions.Add(transaction); return(true); } else { Balance += transaction.Amount - OverDraftLoan.Amount; OverDraftLoan.Amount = 0; AccountTransactions.Add(transaction); return(true); } } Balance += transaction.Amount; AccountTransactions.Add(transaction); return(true); }