File Coverage

blib/lib/Business/Westpac/PaymentsPlus/Australian/Payment/Import/FileHeader.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 1 4 25.0
total 28 31 90.3


line stmt bran cond sub pod time code
1             package Business::Westpac::PaymentsPlus::Australian::Payment::Import::FileHeader;
2              
3             =head1 NAME
4              
5             Business::Westpac::PaymentsPlus::Australian::Payment::Import::FileHeader
6              
7             =head1 SYNOPSIS
8              
9             use Business::Westpac::PaymentsPlus::Australian::Payment::Import::FileHeader;
10             my $Header = Business::Westpac::PaymentsPlus::Australian::Payment::Import::FileHeader->new(
11             customer_code => 'TESTPAYER',
12             customer_name => 'TESTPAYER NAME',
13             customer_file_reference => 'TESTFILE001',
14             scheduled_date => '26082016',
15             );
16              
17             my @csv = $Header->to_csv;
18              
19             =head1 DESCRIPTION
20              
21             Class for Westpac Australian payment import CSV file header
22              
23             =cut
24              
25 2     2   439132 use feature qw/ signatures /;
  2         7  
  2         306  
26              
27 2     2   757 use Moose;
  2         640130  
  2         37  
28             with 'Business::Westpac::Role::CSV';
29 2     2   19486 no warnings qw/ experimental::signatures /;
  2         4  
  2         142  
30              
31 2         696 use Business::Westpac::Types qw/
32             add_max_string_attribute
33 2     2   839 /;
  2         26  
34              
35             =head1 ATTRIBUTES
36              
37             All attributes are required and are read only
38              
39             =head2 customer_code (Str, max 10 chars)
40              
41             =head2 customer_name (Str, max 40 chars)
42              
43             =head2 customer_file_reference (Str, max 20 chars)
44              
45             =head2 scheduled_date (DateTime, or coerced from DDMMYYYY)
46              
47             =cut
48              
49 1     1 0 4 sub record_type { 'H' }
50 1     1 0 4 sub currency { 'AUD' }
51 1     1 0 7 sub version { '6' }
52              
53             foreach my $str_attr (
54             'CustomerCode[10]',
55             'CustomerName[40]',
56             'CustomerFileReference[20]',
57             ) {
58             __PACKAGE__->add_max_string_attribute(
59             $str_attr,
60             is => 'ro',
61             required => 1,
62             );
63             }
64              
65             has 'scheduled_date' => (
66             is => 'ro',
67             isa => 'WestpacDate',
68             required => 1,
69             coerce => 1,
70             handles => {
71             csv_date => [ strftime => '%d%m%C%y' ],
72             },
73             );
74              
75             =head1 METHODS
76              
77             =head2 to_csv
78              
79             Convert the attributes to CSV line(s):
80              
81             my @csv = $Header->to_csv;
82              
83             =cut
84              
85 1     1 1 3 sub to_csv ( $self ) {
  1         3  
  1         2  
86              
87 1         8 return $self->attributes_to_csv(
88             qw/
89             record_type
90             customer_code
91             customer_name
92             customer_file_reference
93             csv_date
94             currency
95             version
96             /
97             );
98             }
99              
100             =head1 SEE ALSO
101              
102             L<Business::Westpac::Types>
103              
104             =cut
105              
106             __PACKAGE__->meta->make_immutable;