Contrato
```
{
"prolabore": 10000
"notasFiscais": [
{
"identificador": 1,
"anexo": "53, 35, 3, 5..."
"valor": "2000.00"
},
...
]
}
```
```
{
"faturamento": 10000,
"prolabore": 2800,
"impostosCalculados": {
"valorDas": 600,
"valorIrrf": 40,
"valorInss": 1100
},
"totalizadores": {
"totalImpostos": 952.10,
"faturamentoLiquido": 9047.90
},
"notasFiscais": [
{
"identificador": 1,
"aliquota": 15.5
}
...
]
}
```
``` javascript
function simulacaoImpostos(prolabore, notasFiscais) {
faturamento = calcularFaturamento(notasFiscais)
impostos = calcularTotalImpostos(notasFiscais, prolabore)
aliquotas = calcularAliquotasEfetivas(
notasFiscais,
prolabore
)
return {
faturamento: faturamento,
prolabore: prolabore,
impostosCalculados: {
valorDas: impostos.valorDas,
valorIrrf: impostos.valorIrrf,
valorInss: impostos.valorInss
},
totalizadores: {
totalImpostos:
impostos.valorDas +
impostos.valorIrrf +
impostos.valorInss,
faturamentoLiquido:
faturamento - (
impostos.valorDas +
impostos.valorIrrf +
impostos.valorInss
)
},
notasFiscais: notasFiscais.map { nf ->
NotaFiscalAliquota(
identificador: nf.identificador,
aliquota: aliquotas[nf.anexo].aliquota
)
}
}
}
```
``` javascript
calcularTotalImpostos(notasFiscais, prolabore) {
valorDas = calcularValorDas(notasFiscais, prolabore)
impostosFolha = calcularImpostosFolha(prolabore)
return ImpostosCalculados(
valorDas,
impostosFolha.valorInss,
impostosFolha.valorIrrf,
prolabore
)
}
```
``` javascript
function BigDecimal calcularValorDAS(todasNotasFiscais, prolabore) {
mapaAnexos = {
"53": [
// notas fiscais
],
"35": [
// notas fiscais
],
"3": [
// notas fiscais
]
}
valorDasPorAnexo = mapaAnexos.keys.map { anexo ->
notasFiscaisAnexo = mapaAnexo[anexo]
faturamentoTodasNotas = somar(todasNotasFiscais)
faturamentoMensal = somar(notasFiscaisAnexo)
faturamentoAnual = faturamentoTodasNotas * 12
faturamentoMensal = faturamentoMensal
valorDas = calcularDAS(faturamentoAnual, faturamentoMensal, anexo, prolabore)
}
return somarTudo(valorDasPorAnexo)
}
```
``` javascript
function ImpostoFolhaFatorrDTO calcularImpostosFolha(prolabore) {
// chamar o que já existe hoje
}
```
``` javascript
function Map<Anexo, BigDecimal> calcularAliquotasEfetivas() {
// Chamar a mesma coisa do calculo DAS só que usando a aliquotaEfetiva ao invés do valor
}
```