1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 #======================================================================
26 # this is a variation of the Lingua package
27 # written for check and receipt printing
28 # it returns a properly formatted text string
29 # for a number up to 10**12
34 %{ $self->{numbername} } =
74 my ($self, $amount) = @_;
76 return $self->{numbername}{0} unless $amount;
80 # split amount into chunks of 3
81 my @num = reverse split //, $amount;
91 push @numblock, join / /, reverse @a;
94 my $belowhundred = !$#numblock;
99 @num = split //, $numblock[$i];
104 if ($numblock[$i] == 0) {
109 if ($numblock[$i] > 99) {
110 # the one from hundreds
111 push @textnumber, $self->{numbername}{$num[0]};
113 # add hundred designation
114 push @textnumber, $self->{numbername}{10**2};
117 $numblock[$i] -= $num[0] * 100;
120 $appendn = 'en' if ($i == 2);
121 $appendn = 'n' if ($i > 2);
123 if ($numblock[$i] > 9) {
125 push @textnumber, $self->format_ten($numblock[$i], $belowhundred);
126 } elsif ($numblock[$i] > 1) {
128 push @textnumber, $self->{numbername}{$numblock[$i]};
129 } elsif ($numblock[$i] == 1) {
131 push @textnumber, $self->{numbername}{$numblock[$i]}.'s';
134 push @textnumber, $self->{numbername}{$numblock[$i]}.'e';
136 push @textnumber, $self->{numbername}{$numblock[$i]};
142 # add thousand, million
144 $amount = 10**($i * 3);
145 push @textnumber, $self->{numbername}{$amount}.$appendn;
152 join '', @textnumber;
158 my ($self, $amount, $belowhundred) = @_;
161 my @num = split //, $amount;
165 $textnumber = $self->{numbername}{$amount};
168 $amount = $num[0] * 10;
169 $textnumber = $self->{numbername}{$num[1]}.'und'.$self->{numbername}{$amount};
171 $amount = $num[0] * 10;
172 $textnumber = $self->{numbername}{$amount}.$self->{numbername}{$num[1]};
173 $textnumber .= 's' if ($num[1] == 1);
177 $textnumber = $self->{numbername}{$amount};