From acc560c716a8e9dbd9a51fb3a69f6ef6708ad209 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Fri, 19 Nov 2021 20:02:41 -0300 Subject: [PATCH 1/2] (feat): no partial withdraws --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ad7410add..d78423ad8 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,14 @@ In this challenge you should build an API for an application that stores and man 1. __Creation__ of an investment with an owner, a creation date and an amount. 1. The creation date of an investment can be today or a date in the past. 2. An investment should not be or become negative. -2. __View__ of an investment with its withdrawals and current balance. - 1. Current balance should be the sum of the invested amount, the [gains] and withdrawals. -3. Partial or total __withdrawal__ of the investment amount. - 1. Should not be able to withdraw more than the available balance. - 2. Withdrawals in the past can be created, but can't happen before the investment creation or previously created withdrawals. - 3. Should show the amount paid on [taxes]. +2. __View__ of an investment with its initial amount and expected balance. + 1. Expected balance should be the sum of the invested amount and the [gains][]. +3. __Withdrawal__ of a investment. + 1. The withdraw will always be the sum of the initial amount and its gains, + partial withdrawn is not supported. + 2. Withdrawals can have made with a date in the past or today, but can't happen before the investment creation or the future. + 3. [Taxes][taxes] need to be applied to the withdrawn before showing the + final value. 4. __List__ of a person's investments 1. This list should have pagination. @@ -22,13 +24,13 @@ __NOTE:__ the implementation of an interface will not be evaluated. ### Gain Calculation -The investment will pay 0.52% every month in the same day of the investment creation, if a withdrawal is made then in that month nothing will be paid. +The investment will pay 0.52% every month in the same day of the investment creation. -Given that the gain is paid every month, it should be treated as as [compound gain], which means that gain that is not withdrawn will become part of the investment balance for the next payment. +Given that the gain is paid every month, it should be treated as as [compound gain][], which means that every new "birthday" the amount gained will become part of the investment balance for the next payment. ### Taxation -When money is withdrawn, tax is triggered. Taxes apply only to the profit/gain portion of the money withdrawn. For example, if the initial investment was 1000.00, the current balance is 1200.00, and you withdraw 150.00, then the taxes will be applied to 16.67% = (200/1200) of the amount withdrawn. Meaning that you should apply tax on 25.00 (150 x 16,67%). +When money is withdrawn, tax is triggered. Taxes apply only to the profit/gain portion of the money withdrawn. For example, if the initial investment was 1000.00, the current balance is 1200.00, then the taxes will be applied to 16.67% = (200/1200) of the balance. Meaning that you should apply tax on 33.34 (150 x 16,67%). The tax percentage changes according to the age of the investment: * If it is less than one year old, the percentage will be 22.5% @@ -49,8 +51,8 @@ The project source code and dependencies should be made available in GitHub. Her - Special build instructions, if any - List of third-party libraries used and short description of why/how they were used - A link to the API documentation. -4. Once the work is complete, create a pull request from "development" into "master" and send us the link. -5. Avoid using huge commits hiding your progress. Feel free to work on a branch and use rebase to adjust your commits before submitting the final version. +4. Once the work is complete, create a pull request from "development" into "main" and send us the link. +5. Avoid using huge commits hiding your progress. Feel free to work on a branch and use `git rebase` to adjust your commits before submitting the final version. ## Coding Standards When working on the project be as clean and consistent as possible. @@ -80,6 +82,7 @@ Use the following checklist to ensure high quality of the project. This coding challenge was inspired on [kinvoapp/kinvo-back-end-test](https://github.com/kinvoapp/kinvo-back-end-test/blob/2f17d713de739e309d17a1a74a82c3fd0e66d128/README.md) +[gains]: #gain-calculation [taxes]: #taxation [interest]: #interest-calculation [compound gain]: https://www.investopedia.com/terms/g/gain.asp From 3ddeaab24d7b52a03bbbb18651a9ca278b6eeb5d Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Sat, 20 Nov 2021 06:10:26 -0300 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Julia Possamai --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d78423ad8..8ae497c88 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ In this challenge you should build an API for an application that stores and man 3. __Withdrawal__ of a investment. 1. The withdraw will always be the sum of the initial amount and its gains, partial withdrawn is not supported. - 2. Withdrawals can have made with a date in the past or today, but can't happen before the investment creation or the future. - 3. [Taxes][taxes] need to be applied to the withdrawn before showing the + 2. Withdrawals can happen in the past or today, but can't happen before the investment creation or the future. + 3. [Taxes][taxes] need to be applied to the withdrawals before showing the final value. 4. __List__ of a person's investments 1. This list should have pagination. @@ -26,11 +26,11 @@ __NOTE:__ the implementation of an interface will not be evaluated. The investment will pay 0.52% every month in the same day of the investment creation. -Given that the gain is paid every month, it should be treated as as [compound gain][], which means that every new "birthday" the amount gained will become part of the investment balance for the next payment. +Given that the gain is paid every month, it should be treated as [compound gain][], which means that every new period (month) the amount gained will become part of the investment balance for the next payment. ### Taxation -When money is withdrawn, tax is triggered. Taxes apply only to the profit/gain portion of the money withdrawn. For example, if the initial investment was 1000.00, the current balance is 1200.00, then the taxes will be applied to 16.67% = (200/1200) of the balance. Meaning that you should apply tax on 33.34 (150 x 16,67%). +When money is withdrawn, tax is triggered. Taxes apply only to the profit/gain portion of the money withdrawn. For example, if the initial investment was 1000.00, the current balance is 1200.00, then the taxes will be applied to 16.67% = (200/1200) of the balance. Meaning that you should apply tax on 33.34 (200 x 16,67%). The tax percentage changes according to the age of the investment: * If it is less than one year old, the percentage will be 22.5%