blib/lib/ACH.pm untested

filter: Statementstmt 0.0% 0 / 100 Branchbran 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 112 CC 3 SCAR 18.4
CC
3
Cov
0%
printAllData
12.0
new
2.0
getData
2.0
CRAP 6.3
1 package ACH;
2
3 $VERSION = '0.01'; # Version number
4
5 use strict;
6 use warnings;
7
8 =head1 NAME
9
10 ACH - ACH perl object
11
12 =head1 VERSION
13
14 Version: 0.01
15 May 2006
16
17 =head1 DESCRIPTION
18
19 ACH is a simple, generic perl object that contains the data necesary to
20 create an ACH file. It's intentional use is for testing purposes ONLY.
21 ACH will allow a developer to manipulate specific data fields in an ACH
22 formatted object.
23
24 =head1 USING ACH
25
26 my $ACH = new ACH;
27
28 =cut
29
30 ### Variables and functions
31
32 ## Arrays that store sizes of the various records in the ACH file ##
33 # File Header Format fields and field sizes
34 my @fileFormat = ({'File Header Record' => 1}, {'Priority Code' => 2},
35 {'Immediate Destination' => 10}, {'Immediate Origin' => 10}, {'File Creation Date' => 6},
36 {'Creation Time' => 4}, {'File ID Modifier' => 1}, {'Record size' => 3}, {'Blocking Factor' => 2},
37 {'Format Code' => 1}, {'Destination' => 23}, {'Origin' => 23}, {'Reference Code' => 8});
38
39 # Batch Record fields and field sizes
40 my @batchFormat = ({'Batch Header Record' => 1}, {'Service Class Code' => 3},
41 {'Company Name' => 16}, {'Company Discretionary Data' => 20}, {'Company Identification' => 10},
42 {'Standard Entry Classes' => 3}, {'Company Entry Description' => 10},
43 {'Company Descriptive Date' => 6}, {'Effective Entry Date' => 6}, {'Settlement Date' => 3},
44 {'Originator Status Code' => 1}, {'Originating DFI Identification' => 8}, {'Batch #' => 7});
45
46 # Detail Record fields and field sizes
47 my @detailFormat = ({'Entry Detail Record' => 1}, {'Transaction Code' => 2},
48 {'Individual Bank ID' => 8}, {'Check Digit' => 1}, {'Bank Acct. Number' => 17}, {'Amount' => 10},
49 {'Individual ID Number' => 15}, {'Individual Name' => 22}, {'Bank Discretionary Data' => 2},
50 {'Addenda Record Indicator' => 1}, {'Trace Number' => 15});
51
52 # Addenda Format fields and field sizes
53 my @addendaFormat = ({'Addenda Record' => 1}, {'Addenda Type Code' => 2},
54 {'Payment Related Information' => 80}, {'Special Addenda Sequence Number' => 4},
55 {'Entry Detail Sequence Number' => 7});
56
57 # Batch Control Format fields and field sizes
58 my @controlFormat = ({'Batch Control Record' => 1}, {'Service Class Codes' => 3},
59 {'Entry/Addenda Count' => 6}, {'Entry Hash' => 10}, {'Total Debit Entry Dollar Amount' => 12},
60 {'Total Credit Entry Dollar Amount' => 12}, {'Company Identification' => 10}, {'Blank' => 19},
61 {'Blank' => 6}, {'Originating Financial Institution' => 8}, {'Batch Number' => 7});
62
63 # File Control fields and field sizes
64 my @fileControl = ({'File Control Record' => 1}, {'Batch Count' => 6}, {'Block Count' => 6},
65 {'Entry/Addenda Count' => 8}, {'Entry Hash' => 10}, {'Total Debit Entry Dollar Amount' => 12},
66 {'Total Credit Entry Dollar Amount' => 12}, {'Reserved/Blank' => 39});
67
68 # All of the ACH File Formats
69 my %achFormats = (1 => \@fileFormat, 5 => \@batchFormat, 6 => \@detailFormat,
70 7 => \@addendaFormat, 8 => \@controlFormat, 9 => \@fileControl);
71 ##
72
73 # ACH data
74 my @achData;
75
76 =head1 METHODS
77
78 =head2 new
79
80 Creates a new ACH object
81
82 =cut
83
84 # Create a new ACH object
85 sub new {
86 my $class = shift;
87 my $self = {}; # allocate new hash for object
88
89 bless {
90 _achData => [],
91 _achFormats => \%achFormats,
92 }, $class;
93 }
94
95 =head2 printAllData
96
97 Prints all the ACH data
98
99 =cut
100
101 # Print all data from the ACH object
102 sub printAllData {
103 my $self = shift;
104 foreach my $item (@{$self->{_achData}}) { # Array of ACH file Sections
105 my @achSections = map { defined $_ ? $_ : '' } @{$item};
106 foreach my $section (@achSections) { # Array of ACH file Section data
107 my %hash = map { defined $_ ? $_ : '' } %{$section};
108 foreach my $hashItem (keys (%hash)) { # Hash containing the ACH field name and value
109 print "$hashItem: $hash{$hashItem}\n";
110 }
111 }
112 }
113 }
114
115 =head2 getData
116
117 Returns the ACH data
118
119 =cut
120
121 # Get data
122 sub getData {
123 my $self = shift;
124 return \@{$self->{_achData}};
125 }
126
127
128 =head2 CAVEATS
129
130 This package is created for testing purposes only. It shouldn't be used
131 for production programs or scripts. There are other commercial products
132 out there that may be a more efficient solution for accomplishing your
133 goals.
134
135 All records in an ACH file must be formatted in the following sequence
136 of records. IF the file is not formatted in this exact sequence, it
137 may be rejected.
138
139 ACH File Layout:
140 1 - File Header Record
141 5 - First Company/Batch Header Record
142 6 - First Entry Detail Record
143 7 - First Entry Detail Addenda Record (optional)
144 |
145 Multiples of Entry Detail Records
146 |
147 6 - Last Entry Detail Record
148 7 - Last Entry Detail Addenda Record (optional)
149 8 - First Company/Batch Control Record
150 |
151 Multiples of Company/Batches
152 |
153 5 - Last Company/Batch Header Record
154 6 - First Entry Detail Record
155 7 - First Entry Detail Addenda Record (optional)
156 |
157 Multiples of Entry Detail Records
158 |
159 6 - Last Entry Detail Record
160 7 - Last Entry Detail Addenda Record (optional)
161 8 - Last Company/Batch Control Record
162 9 - File Control Record
163 9999...9999 (optional)
164
165 =head1 AUTHOR
166
167 Author: Christopher Kois
168 Date: May, 2006
169 Contact: cpkois@cpan.org
170
171 =head1 COPYRIGHTS
172
173 The ACH module is Copyright (c) May, 2006 by Christopher Kois.
174 http://www.christopherkois.com All rights reserved. You may distribute
175 this module under the terms of GNU General Public License (GPL).
176
177 =head1 SUPPORT/WARRANTY
178
179 ACH is free Open Source software. IT COMES WITHOUT WARRANTY OR SUPPORT OF ANY KIND.
180
181 =head1 KNOWN BUGS
182
183 This is version 0.01 of ACH. There are currently no known bugs.
184
185 =head1 SEE ALSO
186
187 L<ACH::Generator>. L<ACH::Parser>
188
189 =cut
190
191 1;