Skip to content

Commit 72c00a1

Browse files
authored
Merge pull request #6 from LibreCodeCoop/feat/2026-tax-updates
Feat/2026 tax updates
2 parents 54eeba5 + 2bacec4 commit 72c00a1

File tree

5 files changed

+162
-19
lines changed

5 files changed

+162
-19
lines changed

src/Service/IRPF.php

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class IRPF
3636
private array $tabelaProgressiva;
3737
private array $tabela;
3838
private string $tipoDeducao = '';
39+
private float $rendimentoTributavel = 0;
3940

4041
public function __construct(
4142
private int $anoBase,
@@ -101,7 +102,8 @@ public function getFaixa(float $base): array
101102

102103
public function calculaBase(float $bruto, float $inss, int $dependentes): float
103104
{
104-
if ($this->anoBase >= 2023 && $this->mes >= 5) {
105+
$this->rendimentoTributavel = $bruto;
106+
if ($this->usaDeducaoFavoravel()) {
105107
$deducao = $this->calculaDeducaoFavoravel($inss, $dependentes);
106108
} else {
107109
$this->tipoDeducao = 'tradicional';
@@ -111,7 +113,16 @@ public function calculaBase(float $bruto, float $inss, int $dependentes): float
111113
if ($base < 0) {
112114
$base = 0;
113115
}
114-
return $base;
116+
return round($base, 3);
117+
}
118+
119+
private function usaDeducaoFavoravel(): bool
120+
{
121+
if ($this->anoBase > 2023) {
122+
return true;
123+
}
124+
125+
return $this->anoBase === 2023 && $this->mes >= 5;
115126
}
116127

117128
private function calculaDeducaoFavoravel(float $inss, int $dependentes): float
@@ -148,6 +159,41 @@ private function calculaDeducaoTradicional(float $inss, int $dependentes): float
148159
public function calcula(float $base, int $dependentes): float
149160
{
150161
$faixa = $this->getFaixa($base);
151-
return $base * $faixa['aliquota'] - ($faixa['deducao']);
162+
$imposto = $base * $faixa['aliquota'] - ($faixa['deducao']);
163+
$reducao = $this->calculaReducao($imposto);
164+
return $imposto - $reducao;
165+
}
166+
167+
private function calculaReducao(float $imposto): float
168+
{
169+
if ($imposto <= 0 || !array_key_exists('reducao', $this->tabela)) {
170+
return 0;
171+
}
172+
173+
foreach ($this->tabela['reducao'] as $reducao) {
174+
if ($this->rendimentoTributavel < $reducao['min']) {
175+
continue;
176+
}
177+
if (!is_null($reducao['max']) && $this->rendimentoTributavel > $reducao['max']) {
178+
continue;
179+
}
180+
181+
if ($reducao['tipo'] === 'zerar') {
182+
return $imposto;
183+
}
184+
185+
if ($reducao['tipo'] === 'formula') {
186+
$valor = $reducao['valor_base'] - $reducao['coeficiente'] * $this->rendimentoTributavel;
187+
if ($valor < 0) {
188+
return 0;
189+
}
190+
if ($valor > $imposto) {
191+
return $imposto;
192+
}
193+
return $valor;
194+
}
195+
}
196+
197+
return 0;
152198
}
153199
}

src/Service/modeloTabelaINSS.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
"2025": {
1111
"0.11": 8157.41,
1212
"0.2": 8157.41
13+
},
14+
"2026": {
15+
"0.11": 8475.55,
16+
"0.2": 8475.55
1317
}
1418
}

src/Service/modeloTabelaIRPF.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,58 @@
189189
}
190190
]
191191
}
192+
],
193+
"2026": [
194+
{
195+
"mes_inicio": 1,
196+
"mes_fim": null,
197+
"deducao_por_dependente": 189.59,
198+
"reducao": [
199+
{
200+
"min": 0,
201+
"max": 5000,
202+
"tipo": "zerar"
203+
},
204+
{
205+
"min": 5000.01,
206+
"max": 7350,
207+
"tipo": "formula",
208+
"valor_base": 978.62,
209+
"coeficiente": 0.133145
210+
}
211+
],
212+
"aliquotas": [
213+
{
214+
"min": 0,
215+
"max": 2428.80,
216+
"aliquota": 0,
217+
"deducao": 0
218+
},
219+
{
220+
"min": 2428.81,
221+
"max": 2826.65,
222+
"aliquota": 0.075,
223+
"deducao": 182.16
224+
},
225+
{
226+
"min": 2826.66,
227+
"max": 3751.05,
228+
"aliquota": 0.15,
229+
"deducao": 394.16
230+
},
231+
{
232+
"min": 3751.06,
233+
"max": 4664.68,
234+
"aliquota": 0.225,
235+
"deducao": 675.49
236+
},
237+
{
238+
"min": 4664.69,
239+
"max": null,
240+
"aliquota": 0.275,
241+
"deducao": 908.73
242+
}
243+
]
244+
}
192245
]
193246
}

tests/php/Service/INSSTest.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,24 @@ public function testCalcula(float $base, int $ano, float $aliquota, float $expec
4242

4343
public static function providerCalcula(): array
4444
{
45-
$ano = 2023;
46-
$aliquota = 0.2;
4745
return [
48-
[-100, $ano, $aliquota, 0],
49-
[-50, $ano, $aliquota, 0],
50-
[0, $ano, $aliquota, 0],
51-
[1000, $ano, $aliquota, 200],
52-
[7000, $ano, $aliquota, 1400],
53-
[7087.16, $ano, $aliquota, 1417.43],
54-
[7087.17, $ano, $aliquota, 1417.43],
46+
[-100, 2023, 0.2, 0],
47+
[-50, 2023, 0.2, 0],
48+
[0, 2023, 0.2, 0],
49+
[1000, 2023, 0.2, 200],
50+
[7000, 2023, 0.2, 1400],
51+
[7087.16, 2023, 0.2, 1417.43],
52+
[7087.17, 2023, 0.2, 1417.43],
5553
// Arredondamentos de centavos da base máxima começa aqui
56-
[7087.18, $ano, $aliquota, 1417.44],
57-
[7087.19, $ano, $aliquota, 1417.44],
58-
[7088, $ano, $aliquota, 1417.44],
59-
[8000, $ano, $aliquota, 1417.44],
60-
[100000, $ano, $aliquota, 1417.44],
54+
[7087.18, 2023, 0.2, 1417.44],
55+
[7087.19, 2023, 0.2, 1417.44],
56+
[7088, 2023, 0.2, 1417.44],
57+
[8000, 2023, 0.2, 1417.44],
58+
[100000, 2023, 0.2, 1417.44],
59+
[8475.54, 2026, 0.2, 1695.11],
60+
[8475.55, 2026, 0.2, 1695.11],
61+
[8475.56, 2026, 0.2, 1695.11],
62+
[100000, 2026, 0.2, 1695.11],
6163
];
6264
}
6365
}

tests/php/Service/IRPFTest.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,40 @@ public static function providerGetFaixa(): array
124124
'deducao' => 884.96,
125125
],
126126
],
127+
[
128+
'ano' => 2026,
129+
'mes' => 1,
130+
'base' => 2428.80,
131+
'faixa' => [
132+
'aliquota' => 0,
133+
'deducao' => 0,
134+
],
135+
],
136+
[
137+
'ano' => 2026,
138+
'mes' => 1,
139+
'base' => 2826.65,
140+
'faixa' => [
141+
'aliquota' => 0.075,
142+
'deducao' => 182.16,
143+
],
144+
],
145+
[
146+
'ano' => 2026,
147+
'mes' => 1,
148+
'base' => 4664.69,
149+
'faixa' => [
150+
'aliquota' => 0.275,
151+
'deducao' => 908.73,
152+
],
153+
],
127154
];
128155
}
129156

130157
#[DataProvider('providerCalculaBase')]
131158
public function testCalculaBase(int $ano, int $mes, float $bruto, int $dependentes, float $valor, string $tipoDeducao): void
132159
{
133-
$inss = (new INSS(2023))->calcula($bruto);
160+
$inss = (new INSS($ano))->calcula($bruto);
134161
$IRPF = new IRPF($ano, $mes);
135162
$atual = $IRPF->calculaBase($bruto, $inss, $dependentes);
136163
$tipoDeducaoAtual = $IRPF->getTipoDeducao();
@@ -147,13 +174,18 @@ public static function providerCalculaBase(): array
147174
[2023, 5, 9000, 0, 7582.556, 'tradicional'],
148175
[2023, 5, 2600, 0, 2072, 'simplificada'],
149176
[2023, 4, 2600, 0, 2080, 'tradicional'],
177+
[2026, 1, 300, 0, 0, 'simplificada'],
178+
[2026, 1, 1000, 0, 392.8, 'simplificada'],
179+
[2026, 1, 3000, 0, 2392.8, 'simplificada'],
180+
[2026, 1, 5000, 0, 4000, 'tradicional'],
181+
[2026, 1, 6000, 0, 4800, 'tradicional'],
150182
];
151183
}
152184

153185
#[DataProvider('providerCalculaImposto')]
154186
public function testCalculaImposto(int $ano, int $mes, float $bruto, int $dependentes, float $valor, string $tipoDeducao): void
155187
{
156-
$inss = (new INSS(2023))->calcula($bruto);
188+
$inss = (new INSS($ano))->calcula($bruto);
157189
$IRPF = new IRPF($ano, $mes);
158190
$base = $IRPF->calculaBase($bruto, $inss, $dependentes);
159191
$atual = $IRPF->calcula($base, $dependentes);
@@ -183,6 +215,12 @@ public static function providerCalculaImposto(): array
183215
[2023, 5, 9000, 2, 1095.97, 'tradicional'],
184216
[2023, 5, 2600, 2, 0, 'simplificada'],
185217
[2023, 4, 2600, 2, 0, 'tradicional'],
218+
[2026, 1, 1000, 0, 0, 'simplificada'],
219+
[2026, 1, 3000, 0, 0, 'simplificada'],
220+
[2026, 1, 5000, 0, 0, 'tradicional'],
221+
[2026, 1, 5200, 0, 0, 'tradicional'],
222+
[2026, 1, 6000, 0, 231.52, 'tradicional'],
223+
[2026, 1, 8000, 0, 851.27, 'tradicional'],
186224
];
187225
}
188226
}

0 commit comments

Comments
 (0)