1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #=====================================================================
31 # this is the default code for the Check package
33 #=====================================================================
38 %{ $self->{numbername} } = (0 => 'Zero',
70 10**12 => 'Trillion',);
75 my ($self, $amount) = @_;
77 return $self->{numbername}{0} unless $amount;
81 # split amount into chunks of 3
82 my @num = reverse split //, $amount;
90 push(@a, shift(@num));
92 push(@numblock, join(" ", reverse @a));
98 @num = split(//, $numblock[$i]);
100 if ($numblock[$i] == 0) {
105 if ($numblock[$i] > 99) {
107 # the one from hundreds
108 push(@textnumber, $self->{numbername}{ $num[0] });
110 # add hundred designation
111 push(@textnumber, $self->{numbername}{ 10**2 });
114 $numblock[$i] -= $num[0] * 100;
120 if ($numblock[$i] > 9) {
123 push(@textnumber, $self->format_ten($numblock[$i]));
124 } elsif ($numblock[$i] > 0) {
127 push(@textnumber, $self->{numbername}{ $numblock[$i] });
130 # add thousand, million
133 push(@textnumber, $self->{numbername}{$num});
140 join(' ', @textnumber);
145 my ($self, $amount) = @_;
148 my @num = split(//, $amount);
151 $textnumber = $self->{numbername}{ $num[0] * 10 };
154 $textnumber = $self->{numbername}{$amount};
158 $textnumber .= " " . $self->{numbername}{$amount} if $amount;