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} } =
80 my ($self, $amount) = @_;
82 return $self->{numbername}{0} unless $amount;
86 # split amount into chunks of 3
87 my @num = reverse split //, $amount;
98 push @numblock, join / /, reverse @a;
101 # special case for 1000
102 if ($numblock[1] eq '1' && $numblock[0] gt '000') {
103 # remove first array element from textnumber
110 @num = split //, $numblock[$i];
114 if ($numblock[$i] == 0) {
119 if ($numblock[$i] > 99) {
121 push @textnumber, $self->{numbername}{10**2};
123 # the one from hundreds, append cientos
124 push @textnumber, $self->{numbername}{$num[0]}.$self->{numbername}{10**2}.'s';
128 $numblock[$i] -= $num[0] * 100;
131 if ($numblock[$i] > 9) {
133 push @textnumber, $self->format_ten($numblock[$i], $i);
134 } elsif ($numblock[$i] > 0) {
136 $num = $numblock[$i];
137 $num .= 'o' if ($num == 1 && $i == 0);
138 push @textnumber, $self->{numbername}{$num};
141 # add thousand, million
144 if ($numblock[$i] > 1) {
145 if ($i == 2 || $i == 4) {
146 $a = $self->{numbername}{$num}."es";
148 push @textnumber, $a;
151 push @textnumber, $self->{numbername}{$num};
153 push @textnumber, $self->{numbername}{$num}.'s';
157 push @textnumber, $self->{numbername}{$num};
165 shift @textnumber if $stripun;
167 join ' ', @textnumber;
173 my ($self, $amount, $i) = @_;
176 my @num = split //, $amount;
179 $textnumber = $self->{numbername}{$num[0]*10};
182 $amount .= 'o' if ($num[1] == 1 && $i == 0);
183 $textnumber = $self->{numbername}{$amount};
187 $textnumber .= " y ".$self->{numbername}{$amount} if $amount;