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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #======================================================================
29 %{ $self->{numbername} } =
82 my ($self, $amount) = @_;
84 return $self->{numbername}{0} unless $amount;
88 # split amount into chunks of 3
89 my @num = reverse split //, $amount;
100 push @numblock, join / /, reverse @a;
103 # special case for 1000
104 if ($numblock[1] eq '1' && $numblock[0] gt '000') {
105 # remove first array element from textnumber
112 @num = split //, $numblock[$i];
116 if ($numblock[$i] == 0) {
121 if ($numblock[$i] > 99) {
123 push @textnumber, $self->{numbername}{10**2};
125 # special case for 500, 700, 900
126 if (grep /$num[0]/, (5,7,9)) {
127 push @textnumber, $self->{numbername}{"${num[0]}00"};
131 # the one from hundreds, append cientos
132 push @textnumber, $self->{numbername}{$num[0]}.$self->{numbername}{10**2}.'s';
138 $numblock[$i] -= $num[0] * 100;
141 if ($numblock[$i] > 9) {
143 push @textnumber, $self->format_ten($numblock[$i], $i);
144 } elsif ($numblock[$i] > 0) {
146 $num = $numblock[$i];
147 $num .= 'o' if ($num == 1 && $i == 0);
148 push @textnumber, $self->{numbername}{$num};
151 # add thousand, million
154 if ($numblock[$i] > 1) {
155 if ($i == 2 || $i == 4) {
156 $a = $self->{numbername}{$num}."es";
158 push @textnumber, $a;
161 $a = "$self->{10**3} $self->{numbername}{$num}"."es";
163 push @textnumber, $a;
166 push @textnumber, $self->{numbername}{$num};
168 push @textnumber, $self->{numbername}{$num}.'s';
172 push @textnumber, $self->{numbername}{$num};
180 shift @textnumber if $stripun;
182 join ' ', @textnumber;
188 my ($self, $amount, $i) = @_;
191 my @num = split //, $amount;
194 $textnumber = $self->{numbername}{$num[0]*10};
197 $amount .= 'o' if ($num[1] == 1 && $i == 0);
198 $textnumber = $self->{numbername}{$amount};
202 $textnumber .= " y ".$self->{numbername}{$amount} if $amount;