Giter Site home page Giter Site logo

simple_credit_kata's Introduction

simple_credit_kata

Kata demoing how a very simple line of credit product might work.

#Initial description of the problem:

Create an implementation of the following:

A line of credit product. This is like a credit card except theres no card. It should work like this:

  • Have a built in APR and credit limit
  • Be able to draw ( take out money ) and make payments.
  • Keep track of principal balance and interest on the line of credit
  • APR Calculation based on the outstanding principal balance over real number of days.
  • Interest is not compounded, so it is only charged on outstanding principal.
  • Keep track of transactions such as payments and draws on the line and when they occured.
  • 30 day payment periods. Basically what this means is that interest will not be charged until the closing of a 30 day payment period. However, when it is charged, it should still be based on the principal balance over actual number of days outstanding during the period, not just ending principal balance.

Couple of Scenarios how it would play out:

Scenario 1:

Someone creates a line of credit for 1000$ and 35% APR.

He draws 500$ on day one so his remaining credit limit is 500$ and his balance is 500$.
He keeps the money drawn for 30 days. He should owe 500$ * 0.35 / 365 * 30 = 14.38$ worth of interest on day 30. Total payoff amount would be 514.38$

Scenario 2:

Someone creates a line of credit for 1000$ and 35% APR.

He draws 500$ on day one so his remaining credit limit is 500$ and his balance is 500$. He pays back 200$ on day 15 and then draws another 100$ on day 25. His total owed interest on day 30 should be 500 * 0.35 / 365 * 15 + 300 * 0.35 / 365 * 10 + 400 * 0.35 / 365 * 5 which is 11.99. Total payment should be 411.99.

Just double checking the math here... 15 days of $500 at 35% 500 * 0.35 / 365 * 15 = $7.19

Pays down $200 at day 15 so we have $300 balance 300 * 0.35 /365 * 10 = $2.88

Draws another $100 on day 25 so we have $400 balance 400 * 0.35 / 365 * 5 = $1.92

simple_credit_kata's People

Contributors

kennydrobnack avatar

Watchers

 avatar James Cloos 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.