Schema/ResultSet/Tax.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 36 / 36 CC 3 SCAR 5.6
CC
3
Cov
100%
current_tax
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« Schema/Candy.pm ↑ Summary Schema/Result/Attribute.pm »
1 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Interchange6::Schema::ResultSet::Tax;
4  
5 =head1 NAME
6  
7 Interchange6::Schema::ResultSet::Tax
8  
9 =cut
10  
11 =head1 SYNOPSIS
12  
13 Provides extra accessor methods for L<Interchange6::Schema::Result::Tax>
14  
15 =cut
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶use parent 'Interchange6::Schema::ResultSet';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =head1 METHODS
25  
26 =head2 current_tax( $tax_name )
27  
28 Given a valid tax_name will return the Tax row for the current date
29  
30 =cut
31  
32 sub current_tax {
33 7 ▶ my ( $self, $tax_name ) = @_;
Subroutine current_tax: called CC=3 SCAR=11.0
Pod documented
34  
35 7 my $schema = $self->result_source->schema;
36 7 my $dtf = $schema->storage->datetime_parser;
37 7 my $dt = DateTime->today;
38  
39 7 ▶ $schema->throw_exception("tax_name not supplied") unless defined $tax_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tax_name 1 6 7
40  
41 6 my $rset = $self->search(
42 {
43 tax_name => $tax_name,
44 valid_from => { '<=', $dtf->format_datetime($dt) },
45 valid_to => [ undef, { '>=', $dtf->format_datetime($dt) } ],
46 }
47 );
48  
49 6 ▶ if ( $rset->count == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rset->count == 1) { } 4 2 6
50 4 return $rset->next;
51 }
52 else {
53 2 $schema->throw_exception(
54 "current_tax not found for tax_name: " . $tax_name );
55 }
56 }
57  
58 2 1;
« Schema/Candy.pm ↑ Summary Schema/Result/Attribute.pm »