1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
9 # Language: Spanish UTF-8
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #======================================================================
30 %{ $self->{numbername} } =
83 my ($self, $amount) = @_;
85 return $self->{numbername}{0} unless $amount;
89 # split amount into chunks of 3
90 my @num = reverse split //, abs($amount);
101 push @numblock, join / /, reverse @a;
104 # special case for 1000
105 if ($numblock[1] eq '1' && $numblock[0] gt '000') {
106 # remove first array element from textnumber
113 @num = split //, $numblock[$i];
117 if ($numblock[$i] == 0) {
122 if ($numblock[$i] > 99) {
124 push @textnumber, $self->{numbername}{10**2};
126 # special case for 500, 700, 900
127 if (grep /$num[0]/, (5,7,9)) {
128 push @textnumber, $self->{numbername}{"${num[0]}00"};
132 # the one from hundreds, append cientos
133 push @textnumber, $self->{numbername}{$num[0]}.$self->{numbername}{10**2}.'s';
139 $numblock[$i] -= $num[0] * 100;
142 if ($numblock[$i] > 9) {
144 push @textnumber, $self->format_ten($numblock[$i], $i);
145 } elsif ($numblock[$i] > 0) {
147 $num = $numblock[$i];
148 $num .= 'o' if ($num == 1 && $i == 0);
149 push @textnumber, $self->{numbername}{$num};
152 # add thousand, million
155 if ($numblock[$i] > 1) {
156 if ($i == 2 || $i == 4) {
157 $a = $self->{numbername}{$num}."es";
159 push @textnumber, $a;
162 $a = "$self->{10**3} $self->{numbername}{$num}"."es";
164 push @textnumber, $a;
167 push @textnumber, $self->{numbername}{$num};
169 push @textnumber, $self->{numbername}{$num}.'s';
173 push @textnumber, $self->{numbername}{$num};
181 shift @textnumber if $stripun;
183 join ' ', @textnumber;
189 my ($self, $amount, $i) = @_;
192 my @num = split //, $amount;
195 $textnumber = $self->{numbername}{$num[0]*10};
198 $amount .= 'o' if ($num[1] == 1 && $i == 0);
199 $textnumber = $self->{numbername}{$amount};
203 $textnumber .= " y ".$self->{numbername}{$amount} if $amount;