Schema/ResultSet/Tax.pm

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