NAB/BPAY/Remittance/File/HeaderRecord.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 95.9% 47 / 49 CC 2 SCAR 1.9
CC
2
Cov
95%
new_from_record
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« NAB/AccountInformation/Transaction.pm ↑ Summary NAB/Australian/DirectEntry/Report/HeaderRecord.pm »
1 package Business::NAB::BPAY::Remittance::File::HeaderRecord;
2 1 $Business::NAB::BPAY::Remittance::File::HeaderRecord::VERSION = '0.11';
3 =head1 NAME
4  
5 Business::NAB::BPAY::Remittance::File::HeaderRecord
6  
7 =head1 SYNOPSIS
8  
9 use Business::NAB::BPAY::Remittance::File::HeaderRecord;
10  
11 # parse
12 my $Header = Business::NAB::BPAY::Remittance::File::HeaderRecord
13 ->new_from_record( $line );
14  
15 # create
16 my $Header = Business::NAB::BPAY::Remittance::File::HeaderRecord->new(
17 biller_code => ...
18 biller_short_name => ...
19 biller_credit_bsb => ...
20 biller_credit_account => ...
21 file_creation_date => ...
22 file_creation_time => ...
23 );
24  
25 my $line = $Header->to_record;
26  
27 =head1 DESCRIPTION
28  
29 Class for header record in the "BPAY Remittance File"
30  
31 =cut;
32  
33 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use feature qw/ signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use Business::NAB::Types qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
40 add_max_string_attribute
41 1 /;
42  
43 1 ▶no warnings qw/ experimental::signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 =head1 ATTRIBUTES
46  
47 =over
48  
49 =item biller_code (Str, max length 10)
50  
51 =item biller_short_name (Str, max length 20)
52  
53 =item biller_credit_bsb (NAB::Type::BSBNumberNoDash)
54  
55 =item biller_credit_account (NAB::Type::AccountNumber)
56  
57 =item file_creation_date (NAB::Type::StatementDate)
58  
59 =item file_creation_time (Str, max length 6)
60  
61 =back
62  
63 =cut
64  
65 1 foreach my $str_attr (
66 'biller_code[10]',
67 'biller_short_name[20]',
68 'file_creation_time[6]',
69 ) {
70 3 __PACKAGE__->add_max_string_attribute(
71 $str_attr,
72 is => 'ro',
73 required => 1,
74 );
75 }
76  
77 1 has [ qw/ biller_credit_bsb / ] => (
78 is => 'ro',
79 isa => 'NAB::Type::BSBNumberNoDash',
80 required => 1,
81 coerce => 1,
82 );
83  
84 1 has [ qw/ biller_credit_account / ] => (
85 is => 'ro',
86 isa => 'NAB::Type::AccountNumber',
87 required => 1,
88 );
89  
90 1 has [
91 qw/
92 file_creation_date
93 /
94 ] => (
95 is => 'ro',
96 isa => 'NAB::Type::StatementDate',
97 required => 1,
98 coerce => 1,
99 );
100  
101 4 ▶sub _pack_template {
Subroutine _pack_template: called CC=1 SCAR=0.0
102 4 return "A2 A10 A20 A6 A9 A8 A6";
103 }
104  
105 =head1 METHODS
106  
107 =head2 new_from_record
108  
109 Returns a new instance of the class with attributes populated from
110 the result of parsing the passed line:
111  
112 my $Record = Business::NAB::BPAY::Remittance::File::HeaderRecord
113 ->new_from_record( $line );
114  
115 =cut
116  
117 1 ▶sub new_from_record ( $class, $line ) {
Subroutine new_from_record: called CC=2 SCAR=7.6
Pod documented
118  
119 # undef being "this space intentionally left blank"
120 my (
121 1 $record_type,
122 $biller_code,
123 $biller_short_name,
124 $biller_credit_bsb,
125 $biller_credit_account,
126 $file_creation_date,
127 $file_creation_time,
128 ) = unpack( $class->_pack_template(), $line );
129  
130 1 ▶ if ( $record_type ne '00' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record_type ne "00") 0 1 1
131 0 croak( "unsupported record type ($record_type)" );
132 }
133  
134 1 return $class->new(
135 biller_code => $biller_code,
136 biller_short_name => $biller_short_name,
137 biller_credit_bsb => $biller_credit_bsb,
138 biller_credit_account => $biller_credit_account,
139 file_creation_date => $file_creation_date,
140 file_creation_time => $file_creation_time,
141 );
142 }
143  
144 =head2 to_record
145  
146 Returns a string constructed from the object's attributes, representing
147 the record for use in a batch file:
148  
149 my $line = $Header->to_record;
150  
151 =cut
152  
153 3 ▶sub to_record ( $self ) {
Subroutine to_record: called CC=1 SCAR=0.0
Pod documented
154  
155 3 my $record = pack(
156 $self->_pack_template(),
157 "00",
158 $self->biller_code,
159 $self->biller_short_name,
160 $self->biller_credit_bsb,
161 $self->biller_credit_account,
162 $self->file_creation_date->ymd( '' ),
163 $self->file_creation_time,
164 );
165  
166 3 return $record;
167 }
168  
169 =head1 SEE ALSO
170  
171 L<Business::NAB::Types>
172  
173 =cut
174  
175 1 __PACKAGE__->meta->make_immutable;
« NAB/AccountInformation/Transaction.pm ↑ Summary NAB/Australian/DirectEntry/Report/HeaderRecord.pm »