1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
9 # Contributors: Mario R. Pizzolanti <mario@zavood.ee>
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 #======================================================================
25 # written for check and receipt printing
26 # it returns a properly formatted text string
27 # for a number up to 10**9
32 %{ $self->{numbername} } =
55 my ($self, $amount) = @_;
57 return $self->{numbername}{0} unless $amount;
61 # split amount into chunks of 3
62 my @num = reverse split //, abs($amount);
72 push @numblock, join / /, reverse @a;
78 @num = split //, $numblock[$i];
84 if ($numblock[$i] == 0) {
89 if ($numblock[$i] > 99) {
90 # the one from hundreds
91 push @textnumber, "$self->{numbername}{$num[0]}$self->{numbername}{10**2}";
94 $numblock[$i] -= $num[0] * 100;
97 if ($numblock[$i] > 19) {
99 push @textnumber, "$self->{numbername}{$num[1]}kümmend";
100 @num = split //, $numblock[$i];
101 push @textnumber, $self->{numbername}{$num[1]} if $num[1] > 0;
103 } elsif ($numblock[$i] > 10) {
105 push @textnumber, "$self->{numbername}{$num[1]}teist";
107 } elsif ($numblock[$i] > 1) {
109 push @textnumber, $self->{numbername}{$numblock[$i]};
111 } elsif ($numblock[$i] == 1) {
112 push @textnumber, $self->{numbername}{$num[0]};
117 # add thousand, million
119 $amount = 10**($i * 3);
120 $appendit = ($i == 1) ? "" : $appendit;
121 push @textnumber, "$self->{numbername}{$amount}$appendit";
128 join ' ', @textnumber;