Skip to content

Commit acb1dc8

Browse files
committed
Adicionando Teste Técnico de Desenvolvimento Moveis Simonetti
1 parent 569fb3b commit acb1dc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+7212
-88
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
APP_ENV=dev
2+
APP_SECRET=ThisIsNotASecretChangeIt
3+
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ignorar logs
2+
logs/
3+
*.log
4+
5+
# Ignorar dependências
6+
node_modules/
7+
vendor/
8+
var/
9+
10+
# Ignorar arquivos de ambiente
11+
.env
12+
13+
# Ignorar arquivos de debug
14+
npm-debug.log*
15+
yarn-error.log*

README.md

Lines changed: 85 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,85 @@
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.

bin/console

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
9+
}
10+
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
12+
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
15+
16+
return new Application($kernel);
17+
};

composer.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"minimum-stability": "stable",
5+
"prefer-stable": true,
6+
"require": {
7+
"php": ">=8.2",
8+
"ext-ctype": "*",
9+
"ext-iconv": "*",
10+
"doctrine/doctrine-bundle": "^2.11",
11+
"doctrine/doctrine-migrations-bundle": "^3.3",
12+
"doctrine/orm": "^2.17",
13+
"symfony/console": "7.0.*",
14+
"symfony/dotenv": "7.0.*",
15+
"symfony/flex": "^2",
16+
"symfony/framework-bundle": "7.0.*",
17+
"symfony/runtime": "7.0.*",
18+
"symfony/serializer": "7.0.*",
19+
"symfony/yaml": "7.0.*",
20+
"symfony/routing": "^7.0",
21+
"symfony/http-foundation": "^6.4.5 || ^7.0.5"
22+
},
23+
"config": {
24+
"allow-plugins": {
25+
"php-http/discovery": true,
26+
"symfony/flex": true,
27+
"symfony/runtime": true
28+
},
29+
"sort-packages": true
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"App\\": "src/"
34+
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"App\\Tests\\": "tests/"
39+
}
40+
},
41+
"replace": {
42+
"symfony/polyfill-ctype": "*",
43+
"symfony/polyfill-iconv": "*",
44+
"symfony/polyfill-php72": "*",
45+
"symfony/polyfill-php73": "*",
46+
"symfony/polyfill-php74": "*",
47+
"symfony/polyfill-php80": "*",
48+
"symfony/polyfill-php81": "*",
49+
"symfony/polyfill-php82": "*"
50+
},
51+
"scripts": {
52+
"auto-scripts": {
53+
"cache:clear": "symfony-cmd",
54+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
55+
},
56+
"post-install-cmd": [
57+
"@auto-scripts"
58+
],
59+
"post-update-cmd": [
60+
"@auto-scripts"
61+
]
62+
},
63+
"conflict": {
64+
"symfony/symfony": "*"
65+
},
66+
"extra": {
67+
"symfony": {
68+
"allow-contrib": false,
69+
"require": "7.0.*"
70+
}
71+
},
72+
"require-dev": {
73+
"symfony/maker-bundle": "^1.52"
74+
}
75+
}

0 commit comments

Comments
 (0)