X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a4c9e42f40e9fa3145b7d9bee88ab42becf4512a..0a0656c7d5656ad1eb1d59c04b47e92a4c876531:/SL/RP.pm diff --git a/SL/RP.pm b/SL/RP.pm index ad8be971d..87b2ade92 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -669,6 +669,19 @@ sub trial_balance { } if ($options{beginning_balances}) { + foreach my $prefix (qw(from to)) { + next if ($form->{"${prefix}date"}); + + my $min_max = $prefix eq 'from' ? 'min' : 'max'; + $query = qq|SELECT ${min_max}(transdate) + FROM acc_trans ac + $dpt_join + WHERE (1 = 1) + $dpt_where + $project|; + ($form->{"${prefix}date"}) = selectfirst_array_query($form, $dbh, $query); + } + # get beginning balances $query = qq|SELECT c.accno, c.category, SUM(ac.amount) AS amount, c.description @@ -680,7 +693,7 @@ sub trial_balance { $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->{fromtdate}); while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {