File Coverage

blib/lib/Finance/Salary/Rate.pm
Criterion Covered Total %
statement 27 29 93.1
branch n/a
condition n/a
subroutine 11 12 91.6
pod 1 7 14.2
total 39 48 81.2


line stmt bran cond sub pod time code
1 1     1   1119 use utf8;
  1         13  
  1         4  
2             package Finance::Salary::Rate;
3             our $VERSION = '0.001';
4 1     1   477 use Moo;
  1         9700  
  1         5  
5 1     1   1725 use Types::Standard qw(Num);
  1         64279  
  1         9  
6 1     1   1441 use namespace::autoclean;
  1         11439  
  1         4  
7              
8             # ABSTRACT: Calculate hourly rates for small businesses
9              
10             has monthly_income => (
11             is => 'ro',
12             isa => Num,
13             required => 1,
14             );
15              
16             has vacation_perc => (
17             is => 'ro',
18             isa => Num,
19             default => 0,
20             );
21              
22             has tax_perc => (
23             is => 'ro',
24             isa => Num,
25             default => 0,
26             );
27              
28             has healthcare_perc => (
29             is => 'ro',
30             isa => Num,
31             default => 0,
32             );
33              
34             has declarable_days_perc => (
35             is => 'ro',
36             isa => Num,
37             default => 60,
38             );
39              
40             has working_days => (
41             is => 'ro',
42             isa => Num,
43             default => 230,
44             );
45              
46             has expenses => (
47             is => 'ro',
48             isa => Num,
49             default => 0,
50             );
51              
52             sub gross_income {
53 7     7 0 9 my $self = shift;
54 7         13 return $self->income * (1 + $self->_get_perc($self->tax_perc));
55             }
56              
57             sub _get_perc {
58 20     20   30 my ($self, $perc) = @_;
59 20         70 return $perc / 100;
60             }
61              
62             sub get_healthcare_fee {
63 1     1 0 3 my $self = shift;
64 1         3 return $self->gross_income * $self->_get_perc($self->healthcare_perc)
65             }
66              
67             sub workable_hours {
68 3     3 0 6 my $self = shift;
69             return
70 3         19 $self->working_days * 8
71             * $self->_get_perc($self->declarable_days_perc);
72             }
73              
74             sub required_income {
75 3     3 0 5 my $self = shift;
76 3         13 return $self->gross_income + $self->expenses;
77             }
78              
79             sub hourly_rate {
80 1     1 0 2 my $self = shift;
81 1         7 return $self->required_income / $self->workable_hours;
82             }
83              
84             sub vacation_pay {
85 0     0 0 0 my $self = shift;
86 0         0 return $self->_get_perc($self->healthcare_perc)
87             }
88              
89             sub income {
90 9     9 1 5207 my $self = shift;
91 9         17 my $income = $self->monthly_income * 12;
92 9         19 return $income * ( 1 + $self->_get_perc($self->vacation_perc));
93             }
94              
95             1;
96              
97             __END__