line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package No::Giro; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12879
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3845
|
use PostScript::Simple; |
|
1
|
|
|
|
|
21311
|
|
|
1
|
|
|
|
|
73
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
13
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
775
|
|
9
|
|
|
|
|
|
|
our $AUTOLOAD; # it's a package global |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
No::Giro - Perl Module for generating Norwegian bank slips |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use No::Giro; |
22
|
|
|
|
|
|
|
use PostScript::Simple; |
23
|
|
|
|
|
|
|
my $p = new PostScript::Simple(papersize => "A4", |
24
|
|
|
|
|
|
|
colour => 0, |
25
|
|
|
|
|
|
|
eps => 0, |
26
|
|
|
|
|
|
|
units => "mm"); |
27
|
|
|
|
|
|
|
$p->newpage; |
28
|
|
|
|
|
|
|
my $giro = new No::Giro; |
29
|
|
|
|
|
|
|
$giro->kid(242345); |
30
|
|
|
|
|
|
|
$giro->belop(4534); |
31
|
|
|
|
|
|
|
$giro->tilkonto(12345678901); |
32
|
|
|
|
|
|
|
$giro->bettil(["Payme", 'Somewhere', '4932 Place']); |
33
|
|
|
|
|
|
|
my $e = $giro->eps; |
34
|
|
|
|
|
|
|
$p->importeps($e, 0,0); |
35
|
|
|
|
|
|
|
$p->output("giro.ps"); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
It provides some methods to enter data into a standard F60-1 GIRO |
41
|
|
|
|
|
|
|
slip. This is an A4 sheet with a standard layout and where data are |
42
|
|
|
|
|
|
|
entered at the bottom and there is some space to enter any information |
43
|
|
|
|
|
|
|
at the top. It returns an Encapsulated Postscript object that can be |
44
|
|
|
|
|
|
|
used in a Postscript document, which again is suitable to be printed. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Data Methods |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
These are the accessor methods, they serve only the purpose of setting and retrieving the values of the data fields of the object. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
These methods have Norwegian-looking names, except for that they are abbreviations and has not Norwegian characters, so I suppose you need to be Norwegian to understand them, or grab someone who is... |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The amount of money to be paid. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Date payment is due. Currently, it should be a simple string. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item C |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Name and address of the person or institution making the payment. It is an array where each element represents a line. It takes 3-4 lines and does not attempt to check that it is within bounds. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item C |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Name and address of the person or institution getting the payment. Like above, it is an array where each element representing a line. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item C |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Payment information. This field can contain comments without any particular semantics. It is an array of strings, where each element represents an array. Each element should not exceed 40 characters, but only a warning is issued if it does. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item C |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The customer identification number, or KID. You need agreements with the banking system to actually use this meaningfully. There are constraints on length of numbers and how they are to be computed. Contact your bank for details if you plan to use this. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item C |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The account number to be credited. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The account number of the payer. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item C |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Does nothing. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Does nothing. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my %fields = ( |
106
|
|
|
|
|
|
|
belop => undef, |
107
|
|
|
|
|
|
|
betkonto => undef, |
108
|
|
|
|
|
|
|
betinf => [], |
109
|
|
|
|
|
|
|
frist => undef, |
110
|
|
|
|
|
|
|
betav => [], |
111
|
|
|
|
|
|
|
bettil => [], |
112
|
|
|
|
|
|
|
belkonto => undef, |
113
|
|
|
|
|
|
|
kid => undef, |
114
|
|
|
|
|
|
|
tilkonto => undef, |
115
|
|
|
|
|
|
|
kvittering => 0, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 Other Methods |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item C |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The constructor of this class. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# Snip verbatim from perltoot by Tom Christiansen. |
132
|
|
|
|
|
|
|
sub new { |
133
|
0
|
|
|
0
|
1
|
|
my $that = shift; |
134
|
0
|
|
0
|
|
|
|
my $class = ref($that) || $that; |
135
|
0
|
|
|
|
|
|
my $self = { |
136
|
|
|
|
|
|
|
_permitted => \%fields, |
137
|
|
|
|
|
|
|
%fields, |
138
|
|
|
|
|
|
|
}; |
139
|
0
|
|
|
|
|
|
bless $self, $class; |
140
|
0
|
|
|
|
|
|
return $self; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Uhm, because of my autoload method, I don't know what to do with the destructor, so I just do this....: |
146
|
0
|
|
|
0
|
|
|
sub DESTROY { # Do nothing |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub AUTOLOAD { |
151
|
0
|
|
|
0
|
|
|
my $self = shift; |
152
|
0
|
0
|
|
|
|
|
my $type = ref($self) |
153
|
|
|
|
|
|
|
or croak "$self is not an object"; |
154
|
0
|
|
|
|
|
|
my $name = $AUTOLOAD; |
155
|
0
|
|
|
|
|
|
$name =~ s/.*://; # strip fully-qualified portion |
156
|
0
|
0
|
|
|
|
|
unless (exists $self->{_permitted}->{$name} ) { |
157
|
0
|
|
|
|
|
|
croak "Can't access `$name' field in class $type"; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
0
|
|
|
|
|
if (@_) { |
160
|
0
|
|
|
|
|
|
my $entry = shift; |
161
|
0
|
0
|
|
|
|
|
if ($name eq 'betinf') { |
162
|
0
|
|
|
|
|
|
my $i=1; |
163
|
0
|
|
|
|
|
|
foreach my $line (@{$entry}) { |
|
0
|
|
|
|
|
|
|
164
|
0
|
0
|
|
|
|
|
if (length($line) > 40) { |
165
|
0
|
|
|
|
|
|
carp("Length of line $i in betinf() is longer than 40 characters. This is discouraged"); |
166
|
0
|
|
|
|
|
|
$i++; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
0
|
|
|
|
|
|
return $self->{$name} = $entry; |
171
|
|
|
|
|
|
|
} else { |
172
|
0
|
|
|
|
|
|
return $self->{$name}; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item C |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This method uses whatever data that has been previously set by the data methods, and puts them in appropriate positions, and returns a L object. You may then use this object to import in a L document, save it to a file or whatever. Just remember that it has to be imported at the very bottom of the an A4 page. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub eps { |
184
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
185
|
0
|
|
|
|
|
|
my $eps = new PostScript::Simple( |
186
|
|
|
|
|
|
|
xsize => 206, |
187
|
|
|
|
|
|
|
ysize => 123, |
188
|
|
|
|
|
|
|
eps => 1, |
189
|
|
|
|
|
|
|
units => "pt"); |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $kroner = int($self->{belop}); |
192
|
0
|
|
|
|
|
|
my $ore = int(($self->{belop} - $kroner) * 100); |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
$eps->setfont("Courier-iso", 4); |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
$eps->text(1.8, 21.5, 'H'); |
197
|
0
|
|
|
|
|
|
$eps->text(20, 21.5, $self->{kid}); |
198
|
0
|
|
|
|
|
|
$eps->text(86, 21.5, $kroner); |
199
|
0
|
0
|
|
|
|
|
if ($ore > 0) { |
200
|
0
|
|
|
|
|
|
$eps->text(108, 21.5, $ore); |
201
|
|
|
|
|
|
|
} |
202
|
0
|
|
|
|
|
|
$eps->text(132, 21.5, $self->{tilkonto}); |
203
|
0
|
|
|
|
|
|
$eps->text(86, 106, $self->{belop}); |
204
|
0
|
|
|
|
|
|
$eps->text(132, 106, $self->{betkonto}); |
205
|
|
|
|
|
|
|
|
206
|
0
|
0
|
|
|
|
|
if($self->{betinf}) { |
207
|
0
|
|
|
|
|
|
my $feed = 93; |
208
|
0
|
|
|
|
|
|
foreach my $line (@{$self->{betinf}}) { |
|
0
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
$eps->text(15, $feed, $line); |
210
|
0
|
|
|
|
|
|
$feed-=4; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
0
|
0
|
|
|
|
|
if($self->{bettil}) { |
215
|
0
|
|
|
|
|
|
my $feed = 60; |
216
|
0
|
|
|
|
|
|
foreach my $line (@{$self->{bettil}}) { |
|
0
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
$eps->text(115, $feed, $line); |
218
|
0
|
|
|
|
|
|
$feed-=4; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
0
|
0
|
|
|
|
|
if($self->{betav}) { |
223
|
0
|
|
|
|
|
|
my $feed = 60; |
224
|
0
|
|
|
|
|
|
foreach my $line (@{$self->{betav}}) { |
|
0
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
$eps->text(15, $feed, $line); |
226
|
0
|
|
|
|
|
|
$feed-=4; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
$eps->text(170, 95, $self->{frist}); |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
return $eps->geteps(); |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; |
238
|
|
|
|
|
|
|
__END__ |