Metadata-Version: 2.1
Name: tabela-sac
Version: 2.0.0
Summary: Forma Simples de Gerar uma Tabela SAC
Home-page: https://github.com/joaopcnogueira/tabela-sac
Author: João Paulo Nogueira
Author-email: joaopcnogueira@gmail.com
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastcore
Requires-Dist: pandas
Provides-Extra: dev
Requires-Dist: jupyter ; extra == 'dev'

# tabela-sac

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Install

``` sh
pip install tabela_sac
```

## How to use

``` python
from tabela_sac.core import SACCalculator
```

``` python
sac = SACCalculator(valor_financiado=200000, 
                    prazo=360, 
                    taxa_anual=9.99)
```

``` python
tabela = sac.tabela()
tabela
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

|     | Parcela | Amortização | Juros   | Valor da Parcela | Saldo Devedor |
|-----|---------|-------------|---------|------------------|---------------|
| 0   | 1       | 555.56      | 1593.30 | 2148.86          | 199444.44     |
| 1   | 2       | 555.56      | 1588.87 | 2144.43          | 198888.89     |
| 2   | 3       | 555.56      | 1584.45 | 2140.00          | 198333.33     |
| 3   | 4       | 555.56      | 1580.02 | 2135.58          | 197777.78     |
| 4   | 5       | 555.56      | 1575.60 | 2131.15          | 197222.22     |
| ... | ...     | ...         | ...     | ...              | ...           |
| 355 | 356     | 555.56      | 22.13   | 577.68           | 2222.22       |
| 356 | 357     | 555.56      | 17.70   | 573.26           | 1666.67       |
| 357 | 358     | 555.56      | 13.28   | 568.83           | 1111.11       |
| 358 | 359     | 555.56      | 8.85    | 564.41           | 555.56        |
| 359 | 360     | 555.56      | 4.43    | 559.98           | 0.00          |

<p>360 rows × 5 columns</p>
</div>

Existe uma resolução que nos garante amortização extra, ou seja, podemos
realizar pagamentos a mais que será totalmente utilizado para amortecer
o saldo devedor e não será utilizado para juros. Com isso, podemos
diminuir o prazo do financiamento e também a quantidade de juros total
pago. Imaginando um cenário em que mensalmente, além do pagamento da
parcela, podemos amortizar de forma extra R\$ 5 mil do saldo devedor,
temos que o prazo do financiamento se reduz de 360 meses para 35 meses:

``` python
tabela_amortizacao_extra = sac.amortizacao_extra_mensal(valor_amortizado_extra_mensal=5000)
tabela_amortizacao_extra
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

|     | Parcela | Saldo Devedor Inicial | Amortização | Amortização Extra | Juros       | Valor da Parcela | Saldo Devedor Final |
|-----|---------|-----------------------|-------------|-------------------|-------------|------------------|---------------------|
| 0   | 1       | 200000.000000         | 555.555556  | 5000.0            | 1593.300789 | 2148.856344      | 194444.444444       |
| 1   | 2       | 194444.444444         | 555.555556  | 5000.0            | 1549.042433 | 2104.597989      | 188888.888889       |
| 2   | 3       | 188888.888889         | 555.555556  | 5000.0            | 1504.784078 | 2060.339634      | 183333.333333       |
| 3   | 4       | 183333.333333         | 555.555556  | 5000.0            | 1460.525723 | 2016.081278      | 177777.777778       |
| 4   | 5       | 177777.777778         | 555.555556  | 5000.0            | 1416.267368 | 1971.822923      | 172222.222222       |
| 5   | 6       | 172222.222222         | 555.555556  | 5000.0            | 1372.009012 | 1927.564568      | 166666.666667       |
| 6   | 7       | 166666.666667         | 555.555556  | 5000.0            | 1327.750657 | 1883.306213      | 161111.111111       |
| 7   | 8       | 161111.111111         | 555.555556  | 5000.0            | 1283.492302 | 1839.047857      | 155555.555556       |
| 8   | 9       | 155555.555556         | 555.555556  | 5000.0            | 1239.233947 | 1794.789502      | 150000.000000       |
| 9   | 10      | 150000.000000         | 555.555556  | 5000.0            | 1194.975591 | 1750.531147      | 144444.444444       |
| 10  | 11      | 144444.444444         | 555.555556  | 5000.0            | 1150.717236 | 1706.272792      | 138888.888889       |
| 11  | 12      | 138888.888889         | 555.555556  | 5000.0            | 1106.458881 | 1662.014437      | 133333.333333       |
| 12  | 13      | 133333.333333         | 555.555556  | 5000.0            | 1062.200526 | 1617.756081      | 127777.777778       |
| 13  | 14      | 127777.777778         | 555.555556  | 5000.0            | 1017.942170 | 1573.497726      | 122222.222222       |
| 14  | 15      | 122222.222222         | 555.555556  | 5000.0            | 973.683815  | 1529.239371      | 116666.666667       |
| 15  | 16      | 116666.666667         | 555.555556  | 5000.0            | 929.425460  | 1484.981016      | 111111.111111       |
| 16  | 17      | 111111.111111         | 555.555556  | 5000.0            | 885.167105  | 1440.722660      | 105555.555556       |
| 17  | 18      | 105555.555556         | 555.555556  | 5000.0            | 840.908750  | 1396.464305      | 100000.000000       |
| 18  | 19      | 100000.000000         | 555.555556  | 5000.0            | 796.650394  | 1352.205950      | 94444.444444        |
| 19  | 20      | 94444.444444          | 555.555556  | 5000.0            | 752.392039  | 1307.947595      | 88888.888889        |
| 20  | 21      | 88888.888889          | 555.555556  | 5000.0            | 708.133684  | 1263.689239      | 83333.333333        |
| 21  | 22      | 83333.333333          | 555.555556  | 5000.0            | 663.875329  | 1219.430884      | 77777.777778        |
| 22  | 23      | 77777.777778          | 555.555556  | 5000.0            | 619.616973  | 1175.172529      | 72222.222222        |
| 23  | 24      | 72222.222222          | 555.555556  | 5000.0            | 575.358618  | 1130.914174      | 66666.666667        |
| 24  | 25      | 66666.666667          | 555.555556  | 5000.0            | 531.100263  | 1086.655818      | 61111.111111        |
| 25  | 26      | 61111.111111          | 555.555556  | 5000.0            | 486.841908  | 1042.397463      | 55555.555556        |
| 26  | 27      | 55555.555556          | 555.555556  | 5000.0            | 442.583552  | 998.139108       | 50000.000000        |
| 27  | 28      | 50000.000000          | 555.555556  | 5000.0            | 398.325197  | 953.880753       | 44444.444444        |
| 28  | 29      | 44444.444444          | 555.555556  | 5000.0            | 354.066842  | 909.622397       | 38888.888889        |
| 29  | 30      | 38888.888889          | 555.555556  | 5000.0            | 309.808487  | 865.364042       | 33333.333333        |
| 30  | 31      | 33333.333333          | 555.555556  | 5000.0            | 265.550131  | 821.105687       | 27777.777778        |
| 31  | 32      | 27777.777778          | 555.555556  | 5000.0            | 221.291776  | 776.847332       | 22222.222222        |
| 32  | 33      | 22222.222222          | 555.555556  | 5000.0            | 177.033421  | 732.588977       | 16666.666667        |
| 33  | 34      | 16666.666667          | 555.555556  | 5000.0            | 132.775066  | 688.330621       | 11111.111111        |
| 34  | 35      | 11111.111111          | 555.555556  | 5000.0            | 88.516710   | 644.072266       | 5555.555556         |

</div>

``` python
len(tabela.index), len(tabela_amortizacao_extra.index)
```

    (360, 35)

``` python
# Comparação de juros pago.
# Sem amortização, pagamos R$ 287 mil de juros sobre um financiamento de R$ 200 mil.
# Com a amortização, pagamos apenas R$ 29 mil de juros.
tabela['Juros'].sum(), tabela_amortizacao_extra['Juros'].sum()
```

    (287590.8, 29431.806233791034)

``` python
# Comparação de valor total pago.
# Sem amortização, pagamos mais que o dobro.
# Com amortização, pagamos um pouco mais que 10% do valor financiado.
tabela['Valor da Parcela'].sum(), tabela_amortizacao_extra['Saldo Devedor Inicial'].loc[0] + tabela_amortizacao_extra['Juros'].sum()
```

    (487590.79, 229431.80623379102)

# CLI Interface

The nbdev cli system uses `fastcore.script` to build command line
interfaces. For further information, go to
<https://fastcore.fast.ai/script.html>

``` sh
$ gerar_tabela_sac --help

usage: gerar_tabela_sac [-h] [--path PATH] valor_financiado prazo taxa_juros

Gera a tabela SAC para o valor financiado, prazo e taxa de juros informados.

positional arguments:
  valor_financiado  Valor financiado
  prazo             Prazo em meses
  taxa_juros        Taxa de juros ao ano (ex: 12 para uma taxa de 12% ao ano)

optional arguments:
  -h, --help        show this help message and exit
  --path PATH       (default: .)
```

Usage:

``` sh
$ gerar_tabela_sac 100000 360 12
```
