|
1 |
| -# Back End Test Project <img src="https://mediacdn.simonetti.com.br/media/logo/websites/1/header-logo-340_1.png" align="right" height="50px" /> |
2 |
| - |
3 |
| -You should see this challenge as an opportunity to create an application following modern development best practices (given the stack of your choice), but also feel free to use your own architecture preferences (coding standards, code organization, third-party libraries, etc). It’s perfectly fine to use vanilla code or any framework or libraries. |
4 |
| - |
5 |
| -## Scope |
6 |
| - |
7 |
| -In this challenge you should build an API for an application that stores and manages investments, it should have the following features: |
8 |
| - |
9 |
| -1. __Creation__ of an investment with an owner, a creation date and an amount. |
10 |
| - 1. The creation date of an investment can be today or a date in the past. |
11 |
| - 2. An investment should not be or become negative. |
12 |
| -2. __View__ of an investment with its initial amount and expected balance. |
13 |
| - 1. Expected balance should be the sum of the invested amount and the [gains][]. |
14 |
| - 2. If an investment was already withdrawn then the balance must reflect the gains of that investment |
15 |
| -3. __Withdrawal__ of a investment. |
16 |
| - 1. The withdraw will always be the sum of the initial amount and its gains, |
17 |
| - partial withdrawn is not supported. |
18 |
| - 2. Withdrawals can happen in the past or today, but can't happen before the investment creation or the future. |
19 |
| - 3. [Taxes][taxes] need to be applied to the withdrawals before showing the final value. |
20 |
| -4. __List__ of a person's investments |
21 |
| - 1. This list should have pagination. |
22 |
| - |
23 |
| -__NOTE:__ the implementation of an interface will not be evaluated. |
24 |
| - |
25 |
| -### Gain Calculation |
26 |
| - |
27 |
| -The investment will pay 0.52% every month in the same day of the investment creation. |
28 |
| - |
29 |
| -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. |
30 |
| - |
31 |
| -### Taxation |
32 |
| - |
33 |
| -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 the 200.00. |
34 |
| - |
35 |
| -The tax percentage changes according to the age of the investment: |
36 |
| -* If it is less than one year old, the percentage will be 22.5% (tax = 45.00). |
37 |
| -* If it is between one and two years old, the percentage will be 18.5% (tax = 37.00). |
38 |
| -* If older than two years, the percentage will be 15% (tax = 30.00). |
39 |
| - |
40 |
| -## Requirements |
41 |
| -1. Create project using any stack of your preference, but with PHP as its main language. It’s perfectly OK to use vanilla code or any framework or libraries; |
42 |
| -3. Although you can use as many dependencies as you want, you should manage them wisely; |
43 |
| -4. It is not necessary to send the notification emails, however, the code required for that would be welcome; |
44 |
| -5. The API must be documented in some way. |
45 |
| - |
46 |
| -## Deliverables |
47 |
| -The project source code and dependencies should be made available in GitHub. Here are the steps you should follow: |
48 |
| -1. Fork this repository to your GitHub account (create an account if you don't have one, you will need it working with us). |
49 |
| -2. Create a "development" branch and commit the code to it. Do not push the code to the main branch. |
50 |
| -3. Include a README file that describes: |
51 |
| - - Special build instructions, if any |
52 |
| - - List of third-party libraries used and short description of why/how they were used |
53 |
| - - A link to the API documentation. |
54 |
| -4. Once the work is complete, create a pull request from "development" into "main" and send us the link. |
55 |
| -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. |
56 |
| - |
57 |
| -## Coding Standards |
58 |
| -When working on the project be as clean and consistent as possible. |
59 |
| - |
60 |
| -## Project Deadline |
61 |
| -Ideally you'd finish the test project in 5 days. It shouldn't take you longer than a entire week. |
62 |
| - |
63 |
| -## Quality Assurance |
64 |
| -Use the following checklist to ensure high quality of the project. |
65 |
| - |
66 |
| -### General |
67 |
| -- First of all, the application should run without errors. |
68 |
| -- Are all requirements set above met? |
69 |
| -- Is coding style consistent? |
70 |
| -- The API is well documented? |
71 |
| -- The API has unit tests? |
72 |
| - |
73 |
| -## Submission |
74 |
| -1. A link to the Github repository. |
75 |
| -2. Briefly describe how you decided on the tools that you used. |
76 |
| - |
77 |
| -## Have Fun Coding 🤘 |
78 |
| -- This challenge description is intentionally vague in some aspects, but if you need assistance feel free to ask for help. |
79 |
| -- If any of the seems out of your current level, you may skip it, but remember to tell us about it in the pull request. |
80 |
| - |
81 |
| -## Credits |
82 |
| - |
83 |
| -This coding challenge was inspired on [kinvoapp/kinvo-back-end-test](https://github.com/kinvoapp/kinvo-back-end-test/blob/2f17d713de739e309d17a1a74a82c3fd0e66d128/README.md) |
84 |
| - |
85 |
| -[gains]: #gain-calculation |
86 |
| -[taxes]: #taxation |
87 |
| -[interest]: #interest-calculation |
88 |
| -[compound gain]: https://www.investopedia.com/terms/g/gain.asp |
| 1 | +# Teste Técnico de Desenvolvimento |
| 2 | + |
| 3 | +## Funcionalidades Implementadas |
| 4 | + |
| 5 | +1. **Criação de um investimento** |
| 6 | + - **Rota**: `POST /investments` |
| 7 | + - **Descrição**: Cria um novo investimento com um proprietário, uma data de criação e um valor. |
| 8 | + - **Validações**: |
| 9 | + - A data de criação pode ser hoje ou no passado. |
| 10 | + - O valor do investimento não pode ser negativo. |
| 11 | + - **Como testar**: |
| 12 | + ```bash |
| 13 | + curl -X POST http://localhost:3000/investments -H "Content-Type: application/json" -d '{"owner": "John Doe", "creationDate": "2023-01-01", "value": 1000}' |
| 14 | + ``` |
| 15 | + |
| 16 | +2. **Visualização de um investimento** |
| 17 | + - **Rota**: `GET /investments` |
| 18 | + - **Descrição**: Lista todos os investimentos com o valor inicial e o saldo esperado. |
| 19 | + - **Como testar**: |
| 20 | + ```bash |
| 21 | + curl -X GET http://localhost:3000/investments |
| 22 | + ``` |
| 23 | + |
| 24 | +3. **Retirada de um investimento** |
| 25 | + - **Rota**: `POST /investments/:id/withdraw` |
| 26 | + - **Descrição**: Realiza a retirada de um investimento, aplicando impostos sobre os ganhos. |
| 27 | + - **Regras**: |
| 28 | + - O saque inclui o valor inicial e os ganhos. |
| 29 | + - Os impostos são aplicados sobre os ganhos. |
| 30 | + - Saques parciais não são suportados. |
| 31 | + - **Como testar**: |
| 32 | + ```bash |
| 33 | + curl -X POST http://localhost:3000/investments/1/withdraw |
| 34 | + ``` |
| 35 | + |
| 36 | +4. **Lista de investimentos de uma pessoa** |
| 37 | + - **Rota**: `GET /investments` |
| 38 | + - **Descrição**: Lista todos os investimentos de uma pessoa. Atualmente, a lista não possui paginação. |
| 39 | + - **Como testar**: |
| 40 | + ```bash |
| 41 | + curl -X GET http://localhost:3000/investments |
| 42 | + ``` |
| 43 | + |
| 44 | +## Regras de Negócio |
| 45 | + |
| 46 | +- O investimento paga 0,52% ao mês, com ganhos compostos. |
| 47 | +- Os impostos são aplicados apenas sobre os ganhos no momento da retirada. |
| 48 | +- **Taxas de imposto**: |
| 49 | + - Menos de 1 ano: 22,5% |
| 50 | + - Entre 1 e 2 anos: 18,5% |
| 51 | + - Mais de 2 anos: 15% |
| 52 | + |
| 53 | +## Como Executar |
| 54 | + |
| 55 | +1. Instale as dependências: |
| 56 | + ```bash |
| 57 | + npm install |
| 58 | + ``` |
| 59 | + |
| 60 | +2. Inicie o servidor: |
| 61 | + ```bash |
| 62 | + npm start |
| 63 | + ``` |
| 64 | + |
| 65 | +3. Acesse a documentação da API: |
| 66 | + - URL: http://localhost:3000/docs |
| 67 | + |
| 68 | +## Relatório de Arquivos |
| 69 | + |
| 70 | +Para uma visão detalhada de cada arquivo do projeto e suas funções, consulte o arquivo [relatorio.md](./relatorio.md). |
| 71 | + |
| 72 | +## Visão Geral do Projeto |
| 73 | + |
| 74 | +Para uma explicação detalhada sobre os principais componentes do projeto e como eles interagem, consulte o arquivo [ProjectOverview.js](./src/ProjectOverview.js). |
| 75 | + |
| 76 | +## Testes |
| 77 | + |
| 78 | +Execute os testes com: |
| 79 | +```bash |
| 80 | +npm test |
| 81 | +``` |
| 82 | + |
| 83 | +## Créditos |
| 84 | + |
| 85 | +Este desafio de codificação foi inspirado em kinvoapp/kinvo-back-end-test. |
0 commit comments