From 138255b0f5442d2f414bd702d88a4e600562a6b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20K=C3=B6hler?= Date: Sat, 26 Nov 2005 16:24:37 +0000 Subject: [PATCH] Merge von 607-609 aus unstable: Bugfix zu UBL -Unbalanced Ledger Workaround... Betr. Bugzilla ID 124 -Neuer Patch gegen den Unbalanced Ledger! Betr. Bugzilla ID 124 -Neuer Patch gegen den Unbalanced Ledger! Test ob Demodatenbank den Unbalanced ist... Betr. Bugzilla ID 124 --- SL/GL.pm | 89 +++++++++++++++++++++++++---------------------- bin/mozilla/gl.pl | 18 ++++++---- 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/SL/GL.pm b/SL/GL.pm index 455066079..aacd602ff 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -424,47 +424,54 @@ sub all_transactions { $ref->{credit_taxkey}{$l} = $ref->{taxkey}; } } - - while (abs($balance) >= 0.015) { - my $ref2 = $sth->fetchrow_hashref(NAME_lc) - || $form->error("Unbalanced ledger!"); - - $balance = - (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000; - print(STDERR $balance, " BAlance\n"); - if ($ref2->{amount} < 0) { - if ($ref2->{chart_id} > 0) { - if ($ref->{debit_tax_accno}{$i} ne "") { - $i++; - } - $ref->{debit_tax}{$i} = $ref2->{amount} * -1; - $ref->{debit_tax_accno}{$i} = $ref2->{accno}; - } else { - if ($ref->{debit_accno}{$k} ne "") { - $k++; - } - $ref->{debit}{$k} = $ref2->{amount} * -1; - $ref->{debit_accno}{$k} = $ref2->{accno}; - $ref->{debit_taxkey}{$k} = $ref2->{taxkey}; - } - } else { - if ($ref2->{chart_id} > 0) { - if ($ref->{credit_tax_accno}{$j} ne "") { - $j++; - } - $ref->{credit_tax}{$j} = $ref2->{amount}; - $ref->{credit_tax_accno}{$j} = $ref2->{accno}; - } else { - if ($ref->{credit_accno}{$l} ne "") { - $l++; - } - $ref->{credit}{$l} = $ref2->{amount}; - $ref->{credit_accno}{$l} = $ref2->{accno}; - $ref->{credit_taxkey}{$l} = $ref2->{taxkey}; - } - } - } - +# if ($form->{accno} eq ''){ # flo & udo: if general report, +# # then check balance +# while (abs($balance) >= 0.015) { +# my $ref2 = $sth->fetchrow_hashref(NAME_lc) +# || $form->error("Unbalanced ledger!"); +# +# $balance = +# (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000; +# print(STDERR $balance, " BAlance\n"); +# print(STDERR $ref2->{amount}, " Ref2->amount\n"); +# if ($ref2->{amount} < 0) { +# if ($ref2->{chart_id} > 0) { +# if ($ref->{debit_tax_accno}{$i} ne "") { +# $i++; +# } +# $ref->{debit_tax}{$i} = $ref2->{amount} * -1; +# $ref->{debit_tax_accno}{$i} = $ref2->{accno}; +# } else { +# if ($ref->{debit_accno}{$k} ne "") { +# $k++; +# } +# $ref->{debit}{$k} = $ref2->{amount} * -1; +# $ref->{debit_accno}{$k} = $ref2->{accno}; +# $ref->{debit_taxkey}{$k} = $ref2->{taxkey}; +# } +# } else { +# if ($ref2->{chart_id} > 0) { +# if ($ref->{credit_tax_accno}{$j} ne "") { +# $j++; +# } +# $ref->{credit_tax}{$j} = $ref2->{amount}; +# $ref->{credit_tax_accno}{$j} = $ref2->{accno}; +# } else { +# if ($ref->{credit_accno}{$l} ne "") { +# $l++; +# } +# $ref->{credit}{$l} = $ref2->{amount}; +# $ref->{credit_accno}{$l} = $ref2->{accno}; +# $ref->{credit_taxkey}{$l} = $ref2->{taxkey}; +# } +# } +# } +# } else { +# # if account-report, then calculate the Balance?! +# # ToDo: Calculate the Balance +# 1; +# } + # print(STDERR Dumper($ref)); push @{ $form->{GL} }, $ref; $balance = 0; diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index f7c3ee5d5..7962daf9c 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -399,7 +399,7 @@ sub generate_report { $form->{title} = $locale->text('General Ledger'); - $ml = ($form->{ml} =~ /(A|E)/) ? -1 : 1; + $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1; unless ($form->{category} eq 'X') { $form->{title} .= " : " . $locale->text($acctype{ $form->{category} }); @@ -624,18 +624,18 @@ sub generate_report { |; } - + $form->{balance} *= $ml; foreach $ref (@{ $form->{GL} }) { - + $form->{balance} *= $ml; # if item ne sort print subtotal if ($form->{l_subtotal} eq 'Y') { if ($sameitem ne $ref->{ $form->{sort} }) { &gl_subtotal; } } - foreach $key (sort keys(%{ $ref->{amount} })) { - $form->{balance} += $ref->{amount}{$key}; - } + #foreach $key (sort keys(%{ $ref->{amount} })) { + # $form->{balance} += $ref->{amount}{$key}; + #} $debit = ""; foreach $key (sort keys(%{ $ref->{debit} })) { @@ -647,6 +647,7 @@ sub generate_report { $debit .= "
" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key}); } $credit = ""; @@ -659,6 +660,7 @@ sub generate_report { $credit .= "
" . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs( $ref->{credit}{$key}); } $debittax = ""; @@ -672,6 +674,7 @@ sub generate_report { $debittax .= "
" . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key}); } $credittax = ""; @@ -685,6 +688,7 @@ sub generate_report { $credittax .= "
" . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key}); } $debitaccno = ""; @@ -777,7 +781,7 @@ sub generate_report { "{gifi_accno}&callback=$callback>$ref->{gifi_accno} "; $column_data{balance} = "" - . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) + . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . ""; $i++; -- 2.20.1