From bb5ee43d0ddff8f8b57ce0f15a5664b26c110d1f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 6 May 2009 09:59:13 +0000 Subject: [PATCH] =?utf8?q?Nur=20beim=20Erzeugen=20der=20Summen-/Saldenlist?= =?utf8?q?e=20auch=20die=20Er=C3=B6ffnungsbilanzwerte=20auslesen,=20weil?= =?utf8?q?=20dies=20bei=20Projektbuchungen=20nicht=20notwendig=20ist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/RP.pm | 64 ++++++++++++++++++++++++----------------------- bin/mozilla/rp.pl | 2 +- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/SL/RP.pm b/SL/RP.pm index e5f432797..ad8be971d 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -609,7 +609,7 @@ sub get_accounts_g { sub trial_balance { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $form) = @_; + my ($self, $myconfig, $form, %options) = @_; my $dbh = $form->dbconnect($myconfig); @@ -668,36 +668,37 @@ sub trial_balance { # $ar_ap_cash_where = qq| AND (a.datepaid>='$form->{fromdate}' AND a.datepaid<='$form->{todate}') |; } - # get beginning balances - $query = - qq|SELECT c.accno, c.category, SUM(ac.amount) AS amount, c.description - FROM acc_trans ac - LEFT JOIN chart c ON (ac.chart_id = c.id) - $dpt_join - WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) AND ac.ob_transaction $acc_cash_where - $dpt_where - $project - GROUP BY c.accno, c.category, c.description |; + if ($options{beginning_balances}) { + # get beginning balances + $query = + qq|SELECT c.accno, c.category, SUM(ac.amount) AS amount, c.description + FROM acc_trans ac + LEFT JOIN chart c ON (ac.chart_id = c.id) + $dpt_join + WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) AND ac.ob_transaction $acc_cash_where + $dpt_where + $project + GROUP BY c.accno, c.category, c.description |; - $sth = prepare_execute_query($form, $dbh, $query, $form->{fromdate}); + $sth = prepare_execute_query($form, $dbh, $query, $form->{fromdate}); - while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { - if ($ref->{amount} != 0 || $form->{all_accounts}) { - $trb{ $ref->{accno} }{description} = $ref->{description}; - $trb{ $ref->{accno} }{charttype} = 'A'; + if ($ref->{amount} != 0 || $form->{all_accounts}) { + $trb{ $ref->{accno} }{description} = $ref->{description}; + $trb{ $ref->{accno} }{charttype} = 'A'; - if ($ref->{amount} > 0) { - $trb{ $ref->{accno} }{haben_eb} = $ref->{amount}; - } else { - $trb{ $ref->{accno} }{soll_eb} = $ref->{amount} * -1; + if ($ref->{amount} > 0) { + $trb{ $ref->{accno} }{haben_eb} = $ref->{amount}; + } else { + $trb{ $ref->{accno} }{soll_eb} = $ref->{amount} * -1; + } + $trb{ $ref->{accno} }{category} = $ref->{category}; } - $trb{ $ref->{accno} }{category} = $ref->{category}; - } + } + $sth->finish; } - $sth->finish; - # get headings $query = @@ -783,7 +784,7 @@ sub trial_balance { $glwhere) )|; $saldowhere .= -qq| AND ((ac.trans_id IN (SELECT id from ar) AND + qq| AND ((ac.trans_id IN (SELECT id from ar) AND ac.trans_id IN ( SELECT trans_id @@ -809,7 +810,7 @@ qq| AND ((ac.trans_id IN (SELECT id from ar) AND $glsaldowhere) )|; $sumwhere .= -qq| AND ((ac.trans_id IN (SELECT id from ar) AND + qq| AND ((ac.trans_id IN (SELECT id from ar) AND ac.trans_id IN ( SELECT trans_id @@ -1115,12 +1116,13 @@ qq| AND ((ac.trans_id IN (SELECT id from ar) AND foreach my $accno (@headingaccounts) { foreach $ref (@{ $form->{TB} }) { if ($accno eq $ref->{accno}) { - $ref->{debit} = $trb{$accno}{debit}; - $ref->{credit} = $trb{$accno}{credit}; - $ref->{soll_saldo} = $trb{$accno}{soll_saldo}; - $ref->{haben_saldo} = $trb{$accno}{haben_saldo}; + $ref->{debit} = $trb{$accno}{debit}; + $ref->{credit} = $trb{$accno}{credit}; + $ref->{soll_saldo} = $trb{$accno}{soll_saldo}; + $ref->{haben_saldo} = $trb{$accno}{haben_saldo}; $ref->{soll_kumuliert} = $trb{$accno}{soll_kumuliert}; - $ref->{haben_kumuliert} = $trb{$accno}{haben_kumuliert}; } + $ref->{haben_kumuliert} = $trb{$accno}{haben_kumuliert}; + } } } diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 98a0aba59..a2672e8fc 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -1256,7 +1256,7 @@ sub generate_trial_balance { # get for each account initial balance, debits and credits - RP->trial_balance(\%myconfig, \%$form); + RP->trial_balance(\%myconfig, \%$form, 'beginning_balances' => 1); $form->{rowcount} = scalar @{ $form->{TB} }; -- 2.20.1