GithubHelp home page GithubHelp logo

bank-tech-test's Introduction

Bank tech test

Project setup steps:

  1. Initialised git, created a Gemfile through 'bundle init'.
  2. Installed SimpleCov.
  3. Installed Rubocop.

Design approach:

  1. I first developed the following user stories:

       As a bank customer, 
       So that I can keep my money at the bank, 
       I want to to be able to deposit funds.
    
       As a bank customer, 
       So that I can access my money, 
       I want to be able to withdraw funds.
    
       As a bank customer, 
       So that I can see all my transactions and balance, 
       I want to print a bank statement. 
    
  2. As initial step, I identified the actions/verbs and nouns from the user stories and the acceptance criteria. ACTIONS: deposit, withdraw, and print statements. NOUNS: date, amount, balance. I drew a class diagram:

        --------------------------
        |        Account         |
        --------------------------
        |  Attributes:           |
        |  @balance              |   
        |  @transactions         |           
        --------------------------
        |  Methods:              |
        |  deposit(date, amount) |
        |  withdraw(date, amount)|
        --------------------------
    
        --------------------------
        |        Printer         |
        --------------------------
        |  Methods:              |
        |  formatting            |
        |  print_statement       |
        --------------------------    
    
  3. I developed some acceptance crtieria based on the ones provided in the specifications:

    • For each deposit, date and amount should be recorded.
    • For each withdrawal, date and amount should be recorded.
    • The bank statement should have the following headers (in this order): date, credit, debit, balance. Each column should be separated by "||" and each transaction should show on a separate line.
    • If the transaction was a withdrawal, the "deposit" column should be empty and viceversa.
    • The statement should show the transaction in reverse order, i.e. the last one first. The date is passed in as an argument, and its default value is Time.now,
    • Date formatting on the statement should be DD/MM/YYYY, but the input might be DD-MM-YYYY.
    • Amounts should be floats with two decimal places.
    • The initial balance would be zero by default, but the class could be instantiated with a different initial balance (ideally I would have like to clarify this requirement).

    Edge cases/required validations:

    • The amount for a deposit/withdrawal can only be greater than zero.
    • The maximum amount that can be withdrawn is equivalent to the available balance (I have assumed this, but ideally this should be clarified).
    • Transaction date cannot be a future date.

Structure:

I would have two classes:

  • Account, which would be responsible for managing all transactions.
  • Printer, which would format the statement and print it.

How to install and run code and tests:

The program can be run in IRB by requiring the account.rb file. Tests can be run thorugh the rspec command in the terminal (from root folder).

Example from IRB:

    2.6.5 :002 > account = Account.new
    => #<Account:0x00007fca298e3730 @balance=0, @transactions=[]> 
    2.6.5 :003 > account.deposit(100)
    => [["18/12/2019", "||", 100, "|| ||", 100]] 
    2.6.5 :004 > account.deposit(500)
    => [["18/12/2019", "||", 500, "|| ||", 600], ["18/12/2019", "||", 100, "|| ||", 100]] 
    2.6.5 :005 > account.withdraw(100)
    => [["18/12/2019", "|| ||", 100, "||", 500], ["18/12/2019", "||", 500, "|| ||", 600], ["18/12/2019", "||", 100, "|| ||", 100]] 
    2.6.5 :006 > account.print_statement
    date || credit || debit || balance
    18/12/2019 || || 100.00 || 500.00
    18/12/2019 || 500.00 || || 600.00
    18/12/2019 || 100.00 || || 100.00

Possible extensions:

If I had more time, I would have liked to add a 'filter' to the 'print_statement' method, i.e. add two arguments so that the method would take a date range - this way the customer could print all the transactions in the specific date range.

I would have liked to work on a 'Bank' class, within which a customer could hold multiple accounts and print statements for each account.

I would have also like to refactor the error messages to make them more specific.

bank-tech-test's People

Contributors

sarar0 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.