File Coverage

blib/lib/Business/NAB/Acknowledgement/Issue.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 2 100.0
condition n/a
subroutine 27 27 100.0
pod n/a
total 54 54 100.0


line stmt bran cond sub pod time code
1             package Business::NAB::Acknowledgement::Issue;
2             $Business::NAB::Acknowledgement::Issue::VERSION = '0.03';
3             =head1 NAME
4              
5             Business::NAB::Acknowledgement::Issue
6              
7             =head1 SYNOPSIS
8              
9             my $Issue = Business::NAB::Acknowledgement::Issue->new(
10             code => "290049",
11             detail => "Uploaded Interchange 60063804 for ...",
12             );
13              
14             =head1 DESCRIPTION
15              
16             Class for NAB file acknowledgement issues. You probably don't want
17             to interact with this class and instead use the parent class
18             L<Business::NAB::Acknowledgement>.
19              
20             =cut
21              
22 2     2   1199339 use strict;
  2         5  
  2         94  
23 2     2   13 use warnings;
  2         4  
  2         191  
24 2     2   16 use feature qw/ signatures /;
  2         5  
  2         319  
25              
26 2     2   667 use Moose;
  2         587661  
  2         19  
27 2     2   20073 use Moose::Util::TypeConstraints;
  2         7  
  2         43  
28 2     2   6405 no warnings qw/ experimental::signatures /;
  2         6  
  2         174  
29 2     2   17 use namespace::autoclean;
  2         5  
  2         22  
30              
31             =head1 ATTRIBUTES
32              
33             =over
34              
35             =item code (Str)
36              
37             =item detail (Str)
38              
39             =item itemId (Int)
40              
41             =back
42              
43             =cut
44              
45             has [ qw/ code detail itemId type / ] => (
46             is => 'ro',
47             isa => 'Maybe[Str]',
48             required => 0,
49             );
50              
51             =head1 METHODS
52              
53             =head2 is_approved
54              
55             =head2 is_authorised
56              
57             =head2 is_changed
58              
59             =head2 is_checked
60              
61             =head2 is_corrected
62              
63             =head2 is_error
64              
65             =head2 is_failed
66              
67             =head2 is_held
68              
69             =head2 is_invalid
70              
71             =head2 is_partially_failed
72              
73             =head2 is_ready
74              
75             =head2 is_ready_for_auth
76              
77             =head2 is_referred
78              
79             =head2 is_released
80              
81             =head2 is_report
82              
83             =head2 is_reserved
84              
85             =head2 is_uploaded
86              
87             =head2 is_validated
88              
89             =head2 is_warning
90              
91             Boolean checks on the issue type
92              
93             =cut
94              
95             # type codes map to the transaction state, which is *inferred*
96             # from the detail in the text the Issue contains
97             my %type_lookup = (
98             error => 'is_error',
99             warning => 'is_warning',
100             2025 => 'is_uploaded',
101             5013 => 'is_corrected',
102             6010 => 'is_ready_for_auth',
103             6014 => 'is_authorised',
104             50040 => 'is_changed',
105             104503 => 'is_validated',
106             104506 => 'is_invalid',
107             112215 => 'is_invalid',
108             130000 => 'is_checked',
109             130001 => 'is_reserved',
110             130003 => 'is_referred',
111             133610 => 'is_failed',
112             140000 => 'is_reserved',
113             180004 => 'is_rejected',
114             180054 => 'is_referred',
115             180055 => 'is_approved',
116             180057 => 'is_approved',
117             181002 => 'is_validated',
118             181004 => 'is_invalid',
119             181015 => 'is_partially_failed',
120             181016 => 'is_invalid',
121             181026 => 'is_invalid',
122             181100 => 'is_held',
123             181104 => 'is_released',
124             181253 => 'is_authorised',
125             181258 => 'is_rejected',
126             181259 => 'is_authorised',
127             190108 => 'is_invalid',
128             181301 => 'is_ready',
129             194500 => 'is_report',
130             290049 => 'is_report',
131             );
132              
133             my %reverse_type_lookup = reverse( %type_lookup );
134              
135             foreach my $method ( keys %reverse_type_lookup ) {
136              
137 36         68 __PACKAGE__->meta()->add_method(
138             $method,
139 36     36   72 sub ( $self ) {
  36     36   49  
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
        36      
140 36 100       2016 return $type_lookup{ $self->type } eq $method
141             ? 1 : 0;
142             },
143             );
144             }
145              
146             =head1 SEE ALSO
147              
148             L<Business::NAB::Acknowledgement>
149              
150             =cut
151              
152             __PACKAGE__->meta->make_immutable;