- #=====================================================================
- # LedgerSMB Small Medium Business Accounting
- # Copyright (C) 2001
- #
- # Author: Dieter Simader
- # Email: dsimader@sql-ledger.org
- # Web: http://sourceforge.net/projects/ledger-smb/
- # Modified by: Medgyesi Aniko
- # **********************************
- # *#MEA1 * Hungarian version *
- # **********************************
- # Contributors:
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #=====================================================================
- #
- # this is the default code for the Check package
- #
- #=====================================================================
- sub init {
- my $self = shift;
- #MEA1 English number ignored
- # %{ $self->{numbername} } =
- # (0 => 'Zero',
- # 1 => 'One',
- # 2 => 'Two',
- # 3 => 'Three',
- # 4 => 'Four',
- # 5 => 'Five',
- # 6 => 'Six',
- # 7 => 'Seven',
- # 8 => 'Eight',
- # 9 => 'Nine',
- # 10 => 'Ten',
- # 11 => 'Eleven',
- # 12 => 'Twelve',
- # 13 => 'Thirteen',
- # 14 => 'Fourteen',
- # 15 => 'Fifteen',
- # 16 => 'Sixteen',
- # 17 => 'Seventeen',
- # 18 => 'Eighteen',
- # 19 => 'Nineteen',
- # 20 => 'Twenty',
- # 30 => 'Thirty',
- # 40 => 'Forty',
- # 50 => 'Fifty',
- # 60 => 'Sixty',
- # 70 => 'Seventy',
- # 80 => 'Eighty',
- # 90 => 'Ninety',
- # 10**2 => 'Hundred',
- # 10**3 => 'Thousand',
- # 10**6 => 'Million',
- # 10**9 => 'Billion',
- # 10**12 => 'Trillion',
- # );
- #MEA1BEG Hungarian numbers
- %{ $self->{numbername} } =
- (0 => 'Nulla',
- 1 => 'egy',
- 2 => 'kettő',
- 3 => 'három',
- 4 => 'négy',
- 5 => 'öt',
- 6 => 'hat',
- 7 => 'hét',
- 8 => 'nyolc',
- 9 => 'kilenc',
- 10 => 'tíz',
- 11 => 'tizenegy',
- 12 => 'tizenkettő',
- 13 => 'tizenhárom',
- 14 => 'tizennégy',
- 15 => 'tizenöt',
- 16 => 'tizenhat',
- 17 => 'tizenhét',
- 18 => 'tizennyolc',
- 19 => 'tizenkilenc',
- 20 => 'húsz',
- 21 => 'huszonegy',
- 22 => 'huszonkettő',
- 23 => 'huszonhárom',
- 24 => 'huszonnégy',
- 25 => 'huszonöt',
- 26 => 'huszonhat',
- 27 => 'huszonhét',
- 28 => 'huszonnyolc',
- 29 => 'huszonkilenc',
- 30 => 'harminc',
- 40 => 'negyven',
- 50 => 'ötven',
- 60 => 'hatvan',
- 70 => 'hetven',
- 80 => 'nyolcvan',
- 90 => 'kilencven',
- 10**2 => 'száz',
- 10**3 => 'ezer',
- 10**6 => 'millió',
- 10**9 => 'milliárd',
- 10**12 => 'billió',
- );
- #MEA1END
- }
- sub num2text {
- my ($self, $amount) = @_;
- return $self->{numbername}{0} unless $amount;
- my @textnumber = ();
- # split amount into chunks of 3
- my @num = reverse split //, abs($amount);
- my @numblock = ();
- my @a;
- my $i;
- #MEA1BEG
- my $res;
- #MEA1END
- while (@num) {
- @a = ();
- for (1 .. 3) {
- push @a, shift @num;
- }
- push @numblock, join / /, reverse @a;
- }
- while (@numblock) {
- $i = $#numblock;
- @num = split //, $numblock[$i];
- if ($numblock[$i] == 0) {
- pop @numblock;
- next;
- }
- if ($numblock[$i] > 99) {
- push @textnumber, $self->{numbername}{$num[0]};
- # add hundred designation
- push @textnumber, $self->{numbername}{10**2};
- # reduce numblock
- $numblock[$i] -= $num[0] * 100;
- }
- $numblock[$i] *= 1;
- if ($numblock[$i] > 9) {
- # tens
- push @textnumber, $self->format_ten($numblock[$i]);
- } elsif ($numblock[$i] > 0) {
- # ones
- push @textnumber, $self->{numbername}{$numblock[$i]};
- }
- # add thousand, million
- if ($i) {
- #MEA1BEG above 2000 need hyphen between treegroups
- # if ($numblock[$i] > 9) {
- # push @textnumber, $self->format_ten($numblock[$i]);
- # } elsif ($numblock[$i] > 0) {
- # push @textnumber, $self->{numbername}{$numblock[$i]};
- # }
- if ($i==1 && $amount < 2000){
- $num = 10**($i * 3);
- push @textnumber, $self->{numbername}{$num};
- } else {
- $num = 10**($i * 3);
- push @textnumber, $self->{numbername}{$num}."-";
- }
- #MEA1END
- }
- pop @numblock;
- }
- #MEA1BEG First charachter is uppercase
- # join '', @textnumber;
- $res=ucfirst join '', @textnumber;
- #MEA1END
- #MEA1BEG remove last hyphen
- $res=~s/(\-)$//;
- return $res;
- #MEA1END
- }
- sub format_ten {
- my ($self, $amount) = @_;
- my $textnumber = "";
- my @num = split //, $amount;
- #MEA1BEG above 30 not above 20
- # if ($amount > 30) {
- if ($amount > 30) {
- #MEA1END
- $textnumber = $self->{numbername}{$num[0]*10};
- $amount = $num[1];
- } else {
- $textnumber = $self->{numbername}{$amount};
- $amount = 0;
- }
- $textnumber .= "".$self->{numbername}{$amount} if $amount;
- $textnumber;
- }
- 1;
|