File Coverage

blib/lib/Business/NAB/Australian/DirectEntry/Returns/DetailRecord.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 1 2 50.0
total 34 35 97.1


line stmt bran cond sub pod time code
1             package Business::NAB::Australian::DirectEntry::Returns::DetailRecord;
2             $Business::NAB::Australian::DirectEntry::Returns::DetailRecord::VERSION = '0.03';
3             =head1 NAME
4              
5             Business::NAB::Australian::DirectEntry::Returns::DetailRecord
6              
7             =head1 DESCRIPTION
8              
9             Class for detail record in the "Australian Direct Entry Payments"
10             returns file. Inherits all logic/attributes from
11             L<Business::NAB::Australian::DirectEntry::Payments::DetailRecord>.
12              
13             =cut
14              
15 1     1   858 use strict;
  1         4  
  1         42  
16 1     1   6 use warnings;
  1         2  
  1         69  
17 1     1   7 use feature qw/ signatures /;
  1         3  
  1         139  
18              
19 1     1   6 use Moose;
  1         2  
  1         10  
20             extends 'Business::NAB::Australian::DirectEntry::Payments::DetailRecord';
21 1     1   9239 no warnings qw/ experimental::signatures /;
  1         3  
  1         68  
22              
23 1         412 use Business::NAB::Types qw/
24             add_max_string_attribute
25 1     1   7 /;
  1         3  
26              
27 112     112 0 3123 sub record_type { 2 }
28              
29             sub _pack_template {
30 28     28   257 return "A1 A7 A9 A1 A2 A10 A32 A18 A7 A9 A16 A2 A6";
31             }
32              
33             =head1 ATTRIBUTES
34              
35             On top of those inherited from L<Business::NAB::Australian::DirectEntry::Payments::DetailRecord>.
36              
37             =over
38              
39             =item original_day_of_processing (NAB::Type::PositiveIntOrZero)
40              
41             =item original_user_id_number (NAB::Type::PositiveIntOrZero)
42              
43             =item return_code (NAB::Type::PositiveIntOrZero)
44              
45             =back
46              
47             =cut
48              
49             foreach my $str_attr (
50             'original_day_of_processing[2]',
51             'original_user_id_number[6]',
52             ) {
53             __PACKAGE__->add_max_string_attribute(
54             $str_attr,
55             is => 'ro',
56             required => $str_attr =~ /original/ ? 0 : 1,
57             );
58             }
59              
60             has [ qw/ return_code / ] => (
61             is => 'ro',
62             isa => 'NAB::Type::PositiveIntOrZero',
63             required => 0,
64             default => sub { 0 },
65             );
66              
67             =head1 METHODS
68              
69             =head2 return_code_description
70              
71             Returns a string describing the return code
72              
73             my $return_reason = $DetailRecord->return_code_description;
74              
75             =cut
76              
77 1     1 1 9249 sub return_code_description ( $self ) {
  1         4  
  1         4  
78              
79             return {
80             0 => undef,
81             1 => "Invalid BSB number",
82             2 => "Payment stopped",
83             3 => "Account closed",
84             4 => "Customer deceased",
85             5 => "No account or incorrect account number",
86             6 => "Refer to customer",
87             7 => undef,
88             8 => "Invalid User ID Number",
89             9 => "Technically invalid",
90 1         114 }->{ $self->return_code };
91             }
92              
93             __PACKAGE__->meta->make_immutable;