| 1 | package Business::Westpac::PaymentsPlus::Australian::Payment::Import::Remittance; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | Business::Westpac::PaymentsPlus::Australian::Payment::Import::Remittance | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | use Business::Westpac::PaymentsPlus::Australian::Payment::Import::Remittance; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | my $Remittance = Business::Westpac::PaymentsPlus::Australian::Payment::Import::Remittance->new( | ||||||||||||||||||||||||||||||||||||||||||
| 11 | remittance_delivery_type => 'EMAIL', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | payee_name => 'Payee 01', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | addressee_name => 'Addressee 01', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | street_1 => 'Level 1', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | street_2 => 'Wallsend Plaza', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | city => 'Wallsend', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | state => 'NSW', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | post_code => '2287', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | country => 'AU', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | email => 'test@test.com', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | remittance_layout_code => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | return_to_address_identifier => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | pass_through_data => "Some pass through data", | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | my @csv = $Header->to_csv; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | Class for modeling remittance details in the context of Westpac CSV files. | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use feature qw/ signatures /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | use Types::Standard qw/ Enum /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | with 'Business::Westpac::Role::CSV'; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | no warnings qw/ experimental::signatures /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | use Carp qw/ croak /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use Business::Westpac::Types qw/ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | add_max_string_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | /; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | All attributes are optional, except were stated, and are read only | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | =item remittance_delivery_type (Enum, required) | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | One of: POST, POST_RETURN, POST_OS, POST_MULTI, FAX, EMAIL, NONE | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | =item remittance_layout_code (PositiveInt) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | =item payee_name (Str, max 35 chars, required) | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | =item addressee_name (Str, max 35 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | =item street_1 (Str, max 35 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | =item street_2 (Str, max 35 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | =item street_3 (Str, max 35 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =item city (Str, max 40 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | =item state (Str, max 3 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | =item post_code (Str, max 9 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =item country (Str, max 2 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =item fax (Str, max 15 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | =item email (Str, max 128 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | =item return_to_address_identifier (Str, max 1 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =item pass_through_data (Str, max 120 chars) | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 6 | ▶ | sub record_type { 'R' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | has 'remittance_delivery_type' => ( | |||||||||||||||||||||||||||||||||||||||||
| 91 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | isa => Enum[ qw/ | ||||||||||||||||||||||||||||||||||||||||||
| 93 | POST | ||||||||||||||||||||||||||||||||||||||||||
| 94 | POST_RETURN | ||||||||||||||||||||||||||||||||||||||||||
| 95 | POST_OS | ||||||||||||||||||||||||||||||||||||||||||
| 96 | POST_MULTI | ||||||||||||||||||||||||||||||||||||||||||
| 97 | FAX | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | NONE | ||||||||||||||||||||||||||||||||||||||||||
| 100 | / ], | ||||||||||||||||||||||||||||||||||||||||||
| 101 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | has 'remittance_layout_code' => ( | |||||||||||||||||||||||||||||||||||||||||
| 105 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 106 | isa => 'PositiveInt', | ||||||||||||||||||||||||||||||||||||||||||
| 107 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | foreach my $str_attr ( | |||||||||||||||||||||||||||||||||||||||||
| 111 | 'PayeeName[35]', | ||||||||||||||||||||||||||||||||||||||||||
| 112 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | __PACKAGE__->add_max_string_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 114 | $str_attr, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 116 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | foreach my $str_attr ( | |||||||||||||||||||||||||||||||||||||||||
| 121 | 'AddresseeName[35]', | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | ( map { "Street_" . $_ . "[35]" } 1 .. 3 ), | |||||||||||||||||||||||||||||||||||||||||
| 123 | 'City[40]', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 'State[3]', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 'PostCode[9]', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 'Country[2]', | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 'Fax[15]', | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 'Email[128]', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 'ReturnToAddressIdentifier[1]', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 22 | __PACKAGE__->add_max_string_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 132 | $str_attr, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 134 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # Pass through data appears on a distinct "Remittance Pass-through record" | ||||||||||||||||||||||||||||||||||||||||||
| 139 | # (RP) however it can only appear after a Remittance record (R), i.e. this | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # class. Given the RP line currently *only* contains a single field, the | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # pass through data, it seems overkill to have an entire distinct class for | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # it. So for now it's just an attribute on *this* class. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | __PACKAGE__->add_max_string_attribute( | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | 'PassThroughData[120]', | |||||||||||||||||||||||||||||||||||||||||
| 145 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 146 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 18 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 18 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 18 | my $rdt = $self->remittance_delivery_type; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 18 | my $error = "is required when remittance_delivery_type is $rdt"; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 18 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$rdt eq "POST" or $rdt eq "POST_OS" or $rdt eq "POST_MULTI"
$rdt eq "POST" or $rdt eq "POST_OS"
MC/DC100%3/3
$rdt eq "POST" or $rdt eq "POST_OS" or $rdt eq "POST_MULTI"
$rdt eq "POST"
$rdt eq "POST_OS"
$rdt eq "POST_MULTI"
Truth table100%4/4
A or B or C
A= $rdt eq "POST"B= $rdt eq "POST_OS"C= $rdt eq "POST_MULTI"
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | $rdt eq 'POST' | ||||||||||||||||||||||||||||||||||||||||||
| 157 | || $rdt eq 'POST_OS' | ||||||||||||||||||||||||||||||||||||||||||
| 158 | || $rdt eq 'POST_MULTI' | ||||||||||||||||||||||||||||||||||||||||||
| 159 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 11 | ▶ | $self->_has_street_1 || croak( "street_1 $error" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | ▶ | $self->_has_city || croak( "city $error" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 5 | ▶ | length( $self->city ) <= 25 || croak( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | "city is limited to 25 chars for remittance_delivery_type of $rdt" | ||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | ▶ | unless ( $rdt eq 'POST_OS' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | $self->_has_state || croak( "state $error" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | ▶ | $self->_has_post_code || croak( "post_code $error" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | ▶ | $rdt eq 'FAX' && !$self->_has_fax && croak( "fax $error" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$rdt eq "FAX" and not $self->_has_fax
MC/DC50%1/2
$rdt eq "FAX" and not $self->_has_fax
$rdt eq "FAX"
not $self->_has_fax
Truth table66%2/3
A and not(B)
A= $rdt eq "FAX"B= not $self->_has_fax
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 7 | ▶ | $rdt eq 'EMAIL' && !$self->_has_email && croak( "email $error" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$rdt eq "EMAIL" and not $self->_has_email
MC/DC100%2/2
$rdt eq "EMAIL" and not $self->_has_email
$rdt eq "EMAIL"
not $self->_has_email
Truth table100%3/3
A and not(B)
A= $rdt eq "EMAIL"B= not $self->_has_email
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =head2 to_csv | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | Convert the attributes to CSV line(s): | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | my @csv = $Header->to_csv; | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | If pass_through_data has content then the CSV will contain | ||||||||||||||||||||||||||||||||||||||||||
| 186 | multiple lines | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | ▶ | sub to_csv ( $self ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_csv: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 6 | my @csv_str = $self->attributes_to_csv( | |||||||||||||||||||||||||||||||||||||||||
| 193 | qw/ | ||||||||||||||||||||||||||||||||||||||||||
| 194 | record_type | ||||||||||||||||||||||||||||||||||||||||||
| 195 | remittance_delivery_type | ||||||||||||||||||||||||||||||||||||||||||
| 196 | payee_name | ||||||||||||||||||||||||||||||||||||||||||
| 197 | addressee_name | ||||||||||||||||||||||||||||||||||||||||||
| 198 | street_1 | ||||||||||||||||||||||||||||||||||||||||||
| 199 | street_2 | ||||||||||||||||||||||||||||||||||||||||||
| 200 | street_3 | ||||||||||||||||||||||||||||||||||||||||||
| 201 | city | ||||||||||||||||||||||||||||||||||||||||||
| 202 | state | ||||||||||||||||||||||||||||||||||||||||||
| 203 | post_code | ||||||||||||||||||||||||||||||||||||||||||
| 204 | country | ||||||||||||||||||||||||||||||||||||||||||
| 205 | fax | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | remittance_layout_code | ||||||||||||||||||||||||||||||||||||||||||
| 208 | return_to_address_identifier | ||||||||||||||||||||||||||||||||||||||||||
| 209 | / | ||||||||||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # add the "Remittance Pass-through record" if present | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | ▶ | if ( $self->_has_pass_through_data ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | push( @csv_str, $self->values_to_csv( | |||||||||||||||||||||||||||||||||||||||||
| 215 | "RP",$self->pass_through_data | ||||||||||||||||||||||||||||||||||||||||||
| 216 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | return @csv_str; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | L<Business::Westpac::Types> | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||