lib/Finance/Tax/Aruba/Role/Income/TaxYear.pm

filter: Statementstmt 93.5% 174 / 186 Branchbran 83.3% 25 / 30 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 96.0% 48 / 50 Podpod 3.7% 1 / 27 totaltotal 84.3% 254 / 301 CC 22 SCAR 13.3
CC
22
Cov
92%
__ANON__
15.0
reparatietoeslag_monthly
4.0
_get_tax_bracket
3.0
CRAP 3.8
« script/loon.pl ↑ Summary lib/Finance/Tax/Aruba/BBO/2025.pm »
1 package Finance::Tax::Aruba::Role::Income::TaxYear;
2 13 our $VERSION = '0.015';
3 13 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: A role that implements income tax logic
6  
7 13 requires qw(
8 _build_tax_bracket
9 is_year
10 );
11  
12 13 has children => (
13 is => 'ro',
14 isa => 'Int',
15 default => 0,
16 );
17  
18 13 has dependents => (
19 is => 'ro',
20 isa => 'Int',
21 default => 0,
22 );
23  
24 13 has children_study_abroad => (
25 is => 'ro',
26 isa => 'Int',
27 default => 0,
28 );
29  
30 # Child (<18) not going to school
31 13 has child_deduction_amount => (
32 is => 'ro',
33 isa => 'Num',
34 default => 700,
35 );
36  
37 # School going > 16 < 27 with severe handicap which is unable
38 # to work
39 13 has dependent_deduction_amount => (
40 is => 'ro',
41 isa => 'Num',
42 default => 1200,
43 );
44  
45 13 has additional_deduction_amount => (
46 is => 'ro',
47 isa => 'Num',
48 default => 3800,
49 );
50  
51 13 has pension_employee_perc => (
52 is => 'ro',
53 isa => 'Num',
54 default => 3,
55 );
56  
57 13 has pension_employer_perc => (
58 is => 'ro',
59 isa => 'Num',
60 default => 3,
61 );
62  
63 13 has income => (
64 is => 'ro',
65 isa => 'Num',
66 required => 1,
67 );
68  
69 13 has yearly_income => (
70 is => 'ro',
71 isa => 'Num',
72 lazy => 1,
73 builder => '_build_yearly_income',
74 predicate => 'has_yearly_income',
75 init_arg => undef,
76 );
77  
78 13 has pension_employee => (
79 is => 'ro',
80 isa => 'Num',
81 lazy => 1,
82 builder => '_build_pension_employee',
83 predicate => 'has_pension_employee',
84 init_arg => undef,
85 );
86  
87 13 has pension_employer => (
88 is => 'ro',
89 isa => 'Num',
90 lazy => 1,
91 builder => '_build_pension_employer',
92 predicate => 'has_pension_employer',
93 init_arg => undef,
94 );
95  
96 13 has bonus => (
97 is => 'ro',
98 isa => 'Num',
99 default => 0,
100 );
101  
102 13 has fringe => (
103 is => 'ro',
104 isa => 'Num',
105 default => 0,
106 );
107  
108 13 has tax_free => (
109 is => 'ro',
110 isa => 'Num',
111 default => 0,
112 );
113  
114 13 has yearly_income_gross => (
115 is => 'ro',
116 isa => 'Num',
117 lazy => 1,
118 builder => '_build_yearly_income_gross',
119 predicate => 'has_yearly_income_gross',
120 );
121  
122 13 has months => (
123 is => 'ro',
124 isa => 'Int',
125 default => 12,
126 );
127  
128 13 has wervingskosten_max => (
129 is => 'ro',
130 isa => 'Num',
131 default => 1500,
132 );
133  
134 13 has wervingskosten_percentage => (
135 is => 'ro',
136 isa => 'Num',
137 default => 3,
138 );
139  
140 13 has wervingskosten => (
141 is => 'ro',
142 isa => 'Num',
143 lazy => 1,
144 builder => '_build_wervingskosten',
145 );
146  
147 13 has aov_max => (
148 is => 'ro',
149 isa => 'Num',
150 default => 85_000,
151 );
152  
153 13 has azv_max => (
154 is => 'ro',
155 isa => 'Num',
156 default => 85_000,
157 );
158  
159 13 has taxfree_max => (
160 is => 'ro',
161 isa => 'Num',
162 default => 28_861,
163 );
164  
165 13 has taxfree_amount => (
166 is => 'ro',
167 isa => 'Num',
168 builder => '_build_taxfree_amount',
169 lazy => 1,
170 );
171  
172 13 has aov_percentage_employer => (
173 is => 'ro',
174 isa => 'Num',
175 default => 10.5,
176 );
177  
178 13 has aov_percentage_employee => (
179 is => 'ro',
180 isa => 'Num',
181 default => 5,
182 );
183  
184 13 has aov_yearly_income => (
185 is => 'ro',
186 isa => 'Num',
187 lazy => 1,
188 builder => '_get_aov_yearly_income',
189 );
190  
191 13 has azv_percentage_employee => (
192 is => 'ro',
193 isa => 'Num',
194 default => 1.6,
195 );
196  
197 13 has azv_percentage_employer => (
198 is => 'ro',
199 isa => 'Num',
200 default => 8.9,
201 );
202  
203 13 has azv_yearly_income => (
204 is => 'ro',
205 isa => 'Num',
206 lazy => 1,
207 builder => '_get_aov_yearly_income',
208 );
209  
210 has reparatietoeslag_table => (
211 is => 'ro',
212 isa => 'ArrayRef',
213 34 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
214 13 );
215  
216 13 has tax_brackets => (
217 is => 'ro',
218 isa => 'ArrayRef',
219 lazy => 1,
220 builder => '_build_tax_bracket',
221 );
222  
223 13 has tax_bracket => (
224 is => 'ro',
225 isa => 'HashRef',
226 lazy => 1,
227 builder => '_get_tax_bracket',
228 );
229  
230 13 has tax_rate => (
231 is => 'ro',
232 isa => 'Num',
233 lazy => 1,
234 builder => '_get_tax_rate',
235 );
236  
237 13 has tax_fixed => (
238 is => 'ro',
239 isa => 'Num',
240 lazy => 1,
241 builder => '_get_tax_fixed',
242 );
243  
244 13 has tax_minimum => (
245 is => 'ro',
246 isa => 'Num',
247 lazy => 1,
248 builder => '_get_tax_minimum',
249 );
250  
251 13 has tax_maximum => (
252 is => 'ro',
253 isa => 'Defined',
254 lazy => 1,
255 builder => '_get_tax_maximum',
256 );
257  
258 13 has tax_variable => (
259 is => 'ro',
260 isa => 'Num',
261 lazy => 1,
262 builder => '_get_tax_variable',
263 );
264  
265 13 has taxable_amount => (
266 is => 'ro',
267 isa => 'Num',
268 lazy => 1,
269 builder => '_get_taxable_amount',
270 );
271  
272 188 ▶sub _get_max {
Subroutine _get_max: called CC=2 SCAR=6.9
273 188 my ($max, $value) = @_;
274 188 ▶ return $value > $max ? $max : $value;
Branch: 1 branch
BranchTrueFalseTotal
$value > $max ? : 110 78 188
275 }
276  
277 47 ▶sub _build_pension_employee {
Subroutine _build_pension_employee: called CC=1 SCAR=0.0
278 47 my $self = shift;
279 47 return $self->get_cost($self->yearly_income_gross - $self->fringe - $self->bonus,
280 $self->pension_employee_perc);
281 }
282  
283 45 ▶sub _build_pension_employer {
Subroutine _build_pension_employer: called CC=1 SCAR=0.0
284 45 my $self = shift;
285 45 return $self->get_cost($self->yearly_income_gross - $self->fringe - $self->bonus,
286 $self->pension_employer_perc);
287 }
288  
289 62 ▶sub _build_yearly_income_gross {
Subroutine _build_yearly_income_gross: called CC=1 SCAR=0.0
290 62 my $self = shift;
291 62 return $self->income + $self->fringe + $self->bonus;
292 }
293  
294 47 ▶sub _build_yearly_income {
Subroutine _build_yearly_income: called CC=1 SCAR=0.0
295 47 my $self = shift;
296 47 return $self->yearly_income_gross - $self->wervingskosten
297 - $self->pension_employee;
298 }
299  
300 47 ▶sub _get_tax_bracket {
Subroutine _get_tax_bracket: called CC=3 SCAR=11.0
301 47 my $self = shift;
302  
303 47 foreach (@{ $self->tax_brackets }) {
304 98 ▶ return $_ if $self->taxable_wage < $_->{max};
Branch: 1 branch
BranchTrueFalseTotal
if $self->taxable_wage < $_->{"max"} 47 51 98
305 }
306 }
307  
308 47 ▶sub _get_tax_rate {
Subroutine _get_tax_rate: called CC=1 SCAR=0.0
309 47 my $self = shift;
310 47 return $self->tax_bracket->{rate};
311 }
312  
313 47 ▶sub _get_tax_fixed {
Subroutine _get_tax_fixed: called CC=1 SCAR=0.0
314 47 my $self = shift;
315 47 return $self->tax_bracket->{fixed};
316 }
317  
318 47 ▶sub _get_tax_minimum {
Subroutine _get_tax_minimum: called CC=1 SCAR=0.0
319 47 my $self = shift;
320 47 return $self->tax_bracket->{min};
321 }
322  
323 0 ▶sub _get_tax_maximum {
Subroutine _get_tax_maximum: not called CC=1 SCAR=6.9
324 0 my $self = shift;
325 0 return $self->tax_bracket->{max} * 1;
326 }
327  
328 47 ▶sub _get_taxable_amount {
Subroutine _get_taxable_amount: called CC=1 SCAR=0.0
329 47 my $self = shift;
330 47 return _format_perc($self->taxable_wage - $self->tax_minimum);
331 }
332  
333 47 ▶sub _get_tax_variable {
Subroutine _get_tax_variable: called CC=1 SCAR=0.0
334 47 my $self = shift;
335 47 return $self->get_cost($self->taxable_amount, $self->tax_rate);
336 }
337  
338 50 ▶sub gross_period_income {
Subroutine gross_period_income: called CC=1 SCAR=0.0
Pod undocumented
339 50 my $self = shift;
340 50 return $self->yearly_income_gross / $self->months;
341 }
342  
343 50 ▶sub reparatietoeslag_monthly {
Subroutine reparatietoeslag_monthly: called CC=4 SCAR=13.9
Pod undocumented
344 50 my $self = shift;
345 50 my $income = $self->gross_period_income;
346  
347 50 foreach (@{ $self->reparatietoeslag_table }) {
348 171 ▶ return $_->{amount} if $income >= $_->{min} && $income < $_->{max};
Branch: 1 branch
BranchTrueFalseTotal
if $income >= $_->{"min"} and $income < $_->{"max"} 29 142 171
Condition100%3/3
$income >= $_->{"min"} and $income < $_->{"max"}
!ll&&!rl&&r
1812429
MC/DC100%2/2
$income >= $_->{"min"} and $income < $_->{"max"}
$income >= $_->{"min"} $income < $_->{"max"}
Truth table100%3/3
A and B
A= $income >= $_->{"min"}B= $income < $_->{"max"}
ABresult
0X0
100
111
349 }
350 21 return 0;
351 }
352  
353 36 ▶sub reparatietoeslag {
Subroutine reparatietoeslag: called CC=1 SCAR=0.0
Pod undocumented
354 36 my $self = shift;
355 36 return $self->reparatietoeslag_monthly * $self->months;
356 }
357  
358 232 ▶sub income_tax {
Subroutine income_tax: called CC=1 SCAR=0.0
Pod undocumented
359 232 my $self = shift;
360 232 return int($self->tax_variable + $self->tax_fixed);
361 }
362  
363 3 ▶sub _credit_left {
Subroutine _credit_left: called CC=2 SCAR=6.9
364 3 my ($self, @used) = @_;
365 3 my $left = $self->reparatietoeslag;
366 3 $left -= $_ for @used;
367 3 return $left;
368 }
369  
370 7 ▶sub _min { return $_[0] < $_[1] ? $_[0] : $_[1] }
Subroutine _min: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] < $_[1] ? : 3 4 7
371  
372 4 ▶sub reparatietoeslag_tax {
Subroutine reparatietoeslag_tax: called CC=1 SCAR=0.0
Pod undocumented
373 4 my $self = shift;
374 4 return _min($self->reparatietoeslag, $self->income_tax);
375 }
376  
377 2 ▶sub reparatietoeslag_aov_employer {
Subroutine reparatietoeslag_aov_employer: called CC=1 SCAR=0.0
Pod undocumented
378 2 my $self = shift;
379 2 return _min($self->_credit_left($self->reparatietoeslag_tax),
380 $self->aov_employer);
381 }
382  
383 2 ▶sub reparatie_kosten {
Subroutine reparatie_kosten: called CC=1 SCAR=0.0
Pod documented
384 2 my $self = shift;
385 2 return $self->reparatietoeslag;
386 }
387  
388 1 ▶sub reparatietoeslag_azv_employer {
Subroutine reparatietoeslag_azv_employer: called CC=1 SCAR=0.0
Pod undocumented
389 1 my $self = shift;
390 1 return _min(
391 $self->_credit_left(
392 $self->reparatietoeslag_tax, $self->reparatietoeslag_aov_employer
393 ),
394 $self->azv_employer
395 );
396 }
397  
398 47 ▶sub _build_wervingskosten {
Subroutine _build_wervingskosten: called CC=1 SCAR=0.0
399 47 my $self = shift;
400 47 my $wervingskosten = $self->get_cost($self->yearly_income_gross,
401 $self->wervingskosten_percentage);
402 47 return _get_max($self->wervingskosten_max, $wervingskosten);
403 }
404  
405 1532 ▶sub get_cost {
Subroutine get_cost: called CC=1 SCAR=0.0
Pod undocumented
406 1532 my ($self, $costs, $perc) = @_;
407 1532 return _format_perc($costs * ($perc / 100));
408 }
409  
410 1579 ▶sub _format_perc {
Subroutine _format_perc: called CC=1 SCAR=0.0
411 1579 return sprintf("%.02f", shift) + 0;
412 }
413  
414 47 ▶sub _build_taxfree_amount {
Subroutine _build_taxfree_amount: called CC=1 SCAR=0.0
415 47 my $self = shift;
416  
417 47 my $max = _get_max($self->taxfree_max, $self->zuiver_jaarloon);
418 47 return $max * ($self->months / 12);
419 }
420  
421 94 ▶sub _get_aov_yearly_income {
Subroutine _get_aov_yearly_income: called CC=1 SCAR=0.0
422 94 my $self = shift;
423 94 return _get_max($self->aov_max, $self->yearly_income);
424 }
425  
426 614 ▶sub aov_employee {
Subroutine aov_employee: called CC=1 SCAR=0.0
Pod undocumented
427 614 my $self = shift;
428 614 return $self->get_cost($self->aov_yearly_income,
429 $self->aov_percentage_employee);
430 }
431  
432 50 ▶sub aov_employer {
Subroutine aov_employer: called CC=1 SCAR=0.0
Pod undocumented
433 50 my $self = shift;
434 50 return $self->get_cost($self->aov_yearly_income,
435 $self->aov_percentage_employer);
436 }
437  
438 3 ▶sub pension_premium {
Subroutine pension_premium: called CC=1 SCAR=0.0
Pod undocumented
439 3 my $self = shift;
440 3 return $self->get_cost($self->yearly_income_gross - $self->fringe - $self->bonus,
441 $self->pension_employee_perc + $self->pension_employer_perc);
442 }
443  
444 8 ▶sub aov_premium {
Subroutine aov_premium: called CC=1 SCAR=0.0
Pod undocumented
445 8 my $self = shift;
446 8 return $self->get_cost($self->aov_yearly_income,
447 $self->aov_percentage_employee + $self->aov_percentage_employer);
448 }
449  
450 8 ▶sub azv_premium {
Subroutine azv_premium: called CC=1 SCAR=0.0
Pod undocumented
451 8 my $self = shift;
452 8 return $self->get_cost($self->azv_yearly_income,
453 $self->azv_percentage_employee + $self->azv_percentage_employer);
454 }
455  
456 0 ▶sub _get_azv_yearly_income {
Subroutine _get_azv_yearly_income: not called CC=1 SCAR=6.9
457 0 my $self = shift;
458 0 return _get_max($self->azv_max, $self->yearly_income);
459 }
460  
461 614 ▶sub azv_employee {
Subroutine azv_employee: called CC=1 SCAR=0.0
Pod undocumented
462 614 my $self = shift;
463 614 return $self->get_cost($self->azv_yearly_income,
464 $self->azv_percentage_employee);
465 }
466  
467 49 ▶sub azv_employer {
Subroutine azv_employer: called CC=1 SCAR=0.0
Pod undocumented
468 49 my $self = shift;
469 49 return $self->get_cost($self->azv_yearly_income,
470 $self->azv_percentage_employer);
471 }
472  
473 81 ▶sub net_yearly_income {
Subroutine net_yearly_income: called CC=1 SCAR=0.0
Pod undocumented
474 81 my $self = shift;
475 81 return $self->zuiver_jaarloon;
476 }
477  
478 368 ▶sub child_deductions {
Subroutine child_deductions: called CC=1 SCAR=0.0
Pod undocumented
479 368 my $self = shift;
480  
481 return
482 368 ($self->children * $self->child_deduction_amount)
483 + ($self->dependents * $self->dependent_deduction_amount)
484 + ($self->children_study_abroad * $self->additional_deduction_amount);
485 }
486  
487 362 ▶sub zuiver_jaarloon {
Subroutine zuiver_jaarloon: called CC=1 SCAR=0.0
Pod undocumented
488 362 my $self = shift;
489  
490 362 return $self->yearly_income - $self->aov_employee - $self->azv_employee
491 - $self->child_deductions;
492 }
493  
494 231 ▶sub taxable_wage {
Subroutine taxable_wage: called CC=2 SCAR=7.1
Pod undocumented
495 231 my $self = shift;
496 231 my $taxable_wage = $self->zuiver_jaarloon - $self->taxfree_amount;
497 231 ▶ return $taxable_wage < 0 ? 0 : $taxable_wage;
Branch: 1 branch
BranchTrueFalseTotal
$taxable_wage < 0 ? : 0 231 231
498 }
499  
500 133 ▶sub employee_income_deductions {
Subroutine employee_income_deductions: called CC=1 SCAR=0.0
Pod undocumented
501 133 my $self = shift;
502 133 return $self->aov_employee + $self->azv_employee + $self->income_tax;
503 }
504  
505 3 ▶sub pension_total {
Subroutine pension_total: called CC=1 SCAR=0.0
Pod undocumented
506 3 my $self = shift;
507 3 return $self->pension_premium;
508 }
509  
510 48 ▶sub tax_free_wage {
Subroutine tax_free_wage: called CC=2 SCAR=6.9
Pod undocumented
511 48 my $self = shift;
512  
513 48 my $wage =
514 $self->yearly_income
515 - $self->employee_income_deductions
516 - $self->taxfree_amount
517 - $self->fringe;
518  
519 48 ▶ return $wage > 0 ? $wage : 0;
Branch: 1 branch
BranchTrueFalseTotal
$wage > 0 ? : 40 8 48
520 }
521  
522 5 ▶sub net_income {
Subroutine net_income: called CC=1 SCAR=0.0
Pod undocumented
523 5 my $self = shift;
524 return
525 5 $self->tax_free_wage
526 + $self->taxfree_amount
527 + $self->wervingskosten
528 + $self->tax_free
529 + $self->reparatietoeslag;
530 }
531  
532 5 ▶sub company_costs {
Subroutine company_costs: called CC=1 SCAR=0.0
Pod undocumented
533 5 my $self = shift;
534 return
535 5 $self->yearly_income_gross
536 + $self->aov_employer
537 + $self->azv_employer
538 + $self->pension_employer;
539 }
540  
541 8 ▶sub government_costs {
Subroutine government_costs: called CC=1 SCAR=0.0
Pod undocumented
542 8 my $self = shift;
543 8 return $self->aov_premium + $self->azv_premium + $self->income_tax
544 - $self->reparatietoeslag;
545 }
546  
547 3 ▶sub social_costs {
Subroutine social_costs: called CC=1 SCAR=0.0
Pod undocumented
548 3 my $self = shift;
549 3 return $self->government_costs + $self->pension_total;
550 }
551  
552 64 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=12 SCAR=27.1
553 64 my $orig = shift;
554 64 my $self = shift;
555 64 my %args = @_;
556  
557 64 foreach (qw(income fringe tax-free)) {
558 192 ▶ next unless exists $args{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{$_} 124 68 192
559 68 ▶ $args{$_} *= ($args{months} // 12);
Condition50%1/2
$args{"months"} // 12
l!l
068
MC/DC0%0/1
$args{"months"} // 12
$args{"months"}
Truth table50%1/2
A
A= $args{"months"}
Aresult
11
00
560 }
561  
562 64 ▶ if ($args{as_np}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"as_np"}) 0 64 64
563 0 $args{pension_employer_perc} = 0;
564 0 $args{pension_employee_perc} = 0;
565  
566 0 $self->_offset_values('aov_percentage_employer', 0,
567 'aov_percentage_employee', \%args);
568 0 $self->_offset_values('azv_percentage_employer', 0,
569 'azv_percentage_employee', \%args);
570 0 return $self->$orig(%args);
571 }
572  
573 64 ▶ if ($args{premiums_employer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'premiums_employer'}) { } 6 58 64
574 6 $self->_offset_values('aov_percentage_employee', 0,
575 'aov_percentage_employer', \%args);
576 6 $self->_offset_values('azv_percentage_employee', 0,
577 'azv_percentage_employer', \%args);
578 6 $args{pension_by_employer} = 1;
579 }
580 else {
581 58 ▶ if ($args{azv_by_employer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"azv_by_employer"}) 0 58 58
582 0 $self->_offset_values(
583 'azv_percentage_employee', 0,
584 'azv_percentage_employer', \%args
585 );
586 }
587  
588 58 ▶ if ($args{aov_by_employer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"aov_by_employer"}) 0 58 58
589 0 $self->_offset_values(
590 'aov_percentage_employee', 0,
591 'aov_percentage_employer', \%args
592 );
593 }
594 }
595  
596 64 ▶ if ($args{no_pension}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($args{'no_pension'}) { } 3 61 64
elsif ($args{'pension_by_employer'}) { } 3 58 61
elsif (exists $args{'pension_employee_perc'}) { } 4 54 58
elsif (exists $args{'pension_employer_perc'}) { } 0 54 54
597 3 $args{pension_employer_perc} = 0;
598 3 $args{pension_employee_perc} = 0;
599 }
600 elsif ($args{pension_by_employer}) {
601 3 $self->_offset_values(
602 'pension_employee_perc', 0,
603 'pension_employer_perc', \%args
604 );
605 }
606 elsif (exists $args{pension_employee_perc}) {
607 $self->_offset_values('pension_employee_perc',
608 $args{pension_employee_perc},
609 4 'pension_employer_perc', \%args);
610 }
611 elsif (exists $args{pension_employer_perc}) {
612 $self->_offset_values('pension_employer_perc',
613 $args{pension_employer_perc},
614 0 'pension_employee_perc', \%args);
615 }
616  
617 64 return $self->$orig(%args);
618  
619 13 };
620  
621 19 ▶sub _offset_values {
Subroutine _offset_values: called CC=1 SCAR=0.0
622 19 my $self = shift;
623 19 my $source = $self->meta->find_attribute_by_name(shift);
624 19 my $value = shift;
625 19 my $target = $self->meta->find_attribute_by_name(shift);
626 19 my $args = shift;
627  
628 19 my $diff = $value - $source->default;
629 19 my $t = $target->default + (-1 * $diff);
630  
631 19 $args->{ $source->name } = $value;
632 19 $args->{ $target->name } = $t;
633 19 return;
634 }
635  
636 13 1;
637  
638 __END__
« script/loon.pl ↑ Summary lib/Finance/Tax/Aruba/BBO/2025.pm »