File Coverage

blib/lib/Business/RO/TaxDeduction/Role/Utils.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Business::RO::TaxDeduction::Role::Utils;
2             $Business::RO::TaxDeduction::Role::Utils::VERSION = '0.012';
3             # ABSTRACT: A utility role
4              
5 5     5   8994 use Moo::Role;
  5         12  
  5         30  
6 5         52 use Business::RO::TaxDeduction::Types qw(
7             Int
8             TaxPersons
9 5     5   1623 );
  5         10  
10              
11             has 'persons' => (
12             is => 'ro',
13             isa => TaxPersons,
14             required => 1,
15             coerce => sub {
16             $_[0] >= 4 ? 4 : $_[0];
17             },
18             default => sub { 0 },
19             );
20              
21             has 'year' => (
22             is => 'ro',
23             isa => Int,
24             default => sub { 2018 },
25             );
26              
27             has 'base_year' => (
28             is => 'ro',
29             isa => Int,
30             lazy => 1,
31             default => sub {
32             my $self = shift;
33             if ($self->year >= 2018) {
34             return 2018;
35             }
36             if ($self->year >= 2016) {
37             return 2016;
38             }
39             elsif ($self->year >= 2005) {
40             return 2005;
41             }
42             else {
43             die "The tax deduction does not apply before 2005!";
44             }
45             },
46             );
47              
48             1;
49              
50             __END__