public static void Overdraft(string accId, decimal ammount, out bool canOverdraft, out decimal deposit) { canOverdraft = true; if (AccountStore.StoredAccounts[accId].CanOverdraft) { Console.WriteLine("You have overdrafted on account: " + accId); if (AccountStore.StoredAccounts[accId]._AssociatedAccountId is null) { deposit = ammount; ammount -= AccountBalance.Balance[accId]; TransactionStore.AddTransferTransaction(accId, null, AccountStore.AccCharToId[accId[0]], 2, AccountBalance.Balance[accId]); AccountBalance.Balance[accId] = 0; AccCreator.OverCreator(accId, ammount); Console.WriteLine("You now have an overdraft faucility: " + AccountStore.StoredAccounts[accId]._AssociatedAccountId + " associated with account: " + accId + " for $" + ammount); } else { deposit = ammount; string AaccId = AccountStore.StoredAccounts[accId]._AssociatedAccountId; AccountBalance.Balance[AaccId] += ammount; TransactionStore.AddTransferTransaction(AaccId, null, 4, 2, ammount); Console.WriteLine("You now owe $" + AccountBalance.Balance[AccountStore.StoredAccounts[accId]._AssociatedAccountId] + " on account: " + accId); } } else { Console.WriteLine("You cannot overdraft from a " + AccountStore.AccCharToName[accId[0]] + " account!"); canOverdraft = false; deposit = 0; } }
public static void Deposit(string accId, decimal ammount) { { TransactionStore.AddTransferTransaction(accId, null, AccountStore.AccCharToId[accId[0]], 1, ammount); AccountBalance.Balance[accId] += ammount; } }
public static void AccountCloser(string accId) { TransactionStore.AddCloseTransaction(accId); AccountStore.StoredAccounts.Remove(accId); AccountBalance.Balance.Remove(accId); Console.WriteLine("Account " + accId + " has been closed!"); }
public static void Deposit(string accId) { Console.WriteLine("Note: enter a decimal number with no symbles. " + "Any decimal past the 2nd decimal place will be rounded up."); while (true) { bool exit = false; Console.WriteLine("How much would you like to deposit?\nCurrent balance is: $" + AccountBalance.Balance[accId]); input = Console.ReadLine(); parsed = decimal.TryParse(input, out _checkedInput); if (parsed && _checkedInput >= 0) { _checkedInput = Math.Round(_checkedInput, 2); OverdraftChecker(accId, _checkedInput, out _checkedInput, out bool didClose); if (didClose == true) { AccountStore.StoredAccounts[accId]._AssociatedAccountId = null; } AccountBalance.Balance[accId] += _checkedInput; TransactionStore.AddTransferTransaction(accId, null, AccountStore.AccCharToId[accId[0]], 1, _checkedInput); Console.WriteLine("Your new balance is: $" + AccountBalance.Balance[accId] + "\nWould you like to deposit more? (y/n)"); Parsers.YNCheck(); exit = Parsers.YNtoBool[Parsers.parsedYN]; if (!exit == true) { break; } } else { Parsers.InvalidInput(); } } }
public static void AccountCloser() { AccViewer.getAccounts(); while (true) { Console.WriteLine("Please enter the account Id you wish to close..."); AccId = Console.ReadLine(); if (AccountStore.StoredAccounts.ContainsKey(AccId)) { break; } else { Parsers.InvalidInput(); } } if (AccountBalance.Balance[AccId] != 0 || !(AccountStore.StoredAccounts[AccId]._AssociatedAccountId is null)) { Console.WriteLine("You cannot close an account with an outstanding balance!\nAccount " + AccId + " has a balance of $" + AccountBalance.Balance[AccId]); if (!(AccountStore.StoredAccounts[AccId]._AssociatedAccountId is null)) { Console.WriteLine("and the associated account " + AccountStore.StoredAccounts[AccId]._AssociatedAccountId + " has a balance of $" + AccountBalance.Balance[AccountStore.StoredAccounts[AccId]._AssociatedAccountId]); } } else { TransactionStore.AddCloseTransaction(AccId); AccountStore.StoredAccounts.Remove(AccId); AccountBalance.Balance.Remove(AccId); Console.WriteLine("Account " + AccId + " has been closed!"); } }
public static void OverCreator(string AssociatedAccountId, decimal ammount) { AccountStore.addAccountid('o'); AccId = AccountStore.lastmadeAccId; InterestRate = AccountStore.StoredAccounts[AssociatedAccountId].InterestRate; OverdraftFaucility newOverdraft = new OverdraftFaucility(AccId, AssociatedAccountId, ammount); AccountStore.addAccount(AccId, newOverdraft); AccountStore.StoredAccounts[AssociatedAccountId]._AssociatedAccountId = AccId; TransactionStore.AddTransferTransaction(AccId, AssociatedAccountId, 4, 0, ammount); }
public static void TermMature(string TermaccId, decimal ammount) { AccountStore.addAccountid('c'); string AccId = AccountStore.lastmadeAccId; Checking newChecking = new Checking(AccId); AccountStore.addAccount(AccId, newChecking); AccountBalance.setBalance(AccId, ammount); AccountBalance.setBalance(TermaccId, 0); TransactionStore.AddTransferTransaction(AccId, null, 0, 0, ammount); TransactionStore.AddTransferTransaction(TermaccId, null, 3, 5, ammount); AccCreator.AccountCloser(TermaccId); }
public static void simInterest() { int countMonth = 0; countMonth++; foreach (KeyValuePair <string, Account> entry in AccountStore.StoredAccounts) { decimal interest = decimal.Round(AccountBalance.Balance[entry.Key] * AccountStore.StoredAccounts[entry.Key].InterestRate, 2); if (entry.Value.InstallmentTypeId == 0) { AccountBalance.Balance[entry.Key] += interest; TransactionStore.AddTransferTransaction(entry.Key, null, AccountStore.AccCharToId[entry.Key[0]], 6, interest); } else if (entry.Value.InstallmentTypeId == 1 && countMonth % 12 == 0) { AccountBalance.Balance[entry.Key] += interest; TransactionStore.AddTransferTransaction(entry.Key, null, AccountStore.AccCharToId[entry.Key[0]], 6, interest); } } }
public static void Withdraw(string accId, out decimal deposit) { Console.WriteLine("Note: enter a decimal number with no symbles. " + "Any decimal past the 2nd decimal place will be rounded up."); while (true) { Console.WriteLine("How much would you like to withdraw?\nCurrent balance is: $" + AccountBalance.Balance[accId]); input = Console.ReadLine(); parsed = decimal.TryParse(input, out _checkedInput); if (parsed && _checkedInput >= 0) { _checkedInput = Math.Round(_checkedInput, 2); if (AccountBalance.Balance[accId] - _checkedInput < 0) { bool canOverdraft; Overdraft(accId, _checkedInput, out canOverdraft, out deposit); if (canOverdraft) { Console.WriteLine("Your new balance is: $" + AccountBalance.Balance[accId]); } break; } else { AccountBalance.Balance[accId] -= _checkedInput; TransactionStore.AddTransferTransaction(accId, null, AccountStore.AccCharToId[accId[0]], 2, _checkedInput); Console.WriteLine("Your new balance is: $" + AccountBalance.Balance[accId]); deposit = _checkedInput; break; } } else { Parsers.InvalidInput(); } } }
public static void Pay(string accId, decimal ammount) { TransactionStore.AddTransferTransaction(accId, null, AccountStore.AccCharToId[accId[0]], 4, ammount); AccountBalance.Balance[accId] -= ammount; }
public static void Creator(int selection) { void StateCreated() { Console.WriteLine("\nAccount " + AccountStore.lastmadeAccId + " has been created!"); AccountBalance.getBalance(AccountStore.lastmadeAccId); } switch (selection) { case 0: AccountStore.addAccountid('c'); AccId = AccountStore.lastmadeAccId; Checking newChecking = new Checking(AccId); AccountStore.addAccount(AccId, newChecking); BalanceTransact.Deposit(); AccountBalance.setBalance(AccId, BalanceTransact.checkedInput); StateCreated(); TransactionStore.AddTransferTransaction(AccId, null, 0, 0, BalanceTransact.checkedInput); break; case 1: AccountStore.addAccountid('b'); AccId = AccountStore.lastmadeAccId; Business newBusiness = new Business(AccId); AccountStore.addAccount(AccId, newBusiness); BalanceTransact.Deposit(); AccountBalance.setBalance(AccId, BalanceTransact.checkedInput); StateCreated(); TransactionStore.AddTransferTransaction(AccId, null, 1, 0, BalanceTransact.checkedInput); break; case 2: AccountStore.addAccountid('l'); AccId = AccountStore.lastmadeAccId; AccCreator.setInterest(); AccCreator.setInstallment(); AccCreator.setInitialAmount(); Loan newLoan = new Loan(AccId, AccCreator.InterestRate, AccCreator.InstallmentTypeId, AccCreator.InitialAmount); AccountStore.addAccount(AccId, newLoan); AccountBalance.setBalance(AccId, AccCreator.InitialAmount); StateCreated(); TransactionStore.AddTransferTransaction(AccId, null, 2, 0, AccCreator.InitialAmount); break; case 3: AccountStore.addAccountid('t'); AccId = AccountStore.lastmadeAccId; AccCreator.setInterest(); AccCreator.setInitialAmount(); TermDeposit newCD = new TermDeposit(AccId, InterestRate); AccountStore.addAccount(AccId, newCD); AccountBalance.setBalance(AccId, AccCreator.InitialAmount); StateCreated(); TransactionStore.AddTransferTransaction(AccId, null, 3, 0, AccCreator.InitialAmount); break; default: Console.WriteLine("That is not a valid selection"); return; } }