Revision 34366eda
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/GL.pm | ||
---|---|---|
716 | 716 |
$main::lxdebug->leave_sub(); |
717 | 717 |
} |
718 | 718 |
|
719 |
sub get_chart_balances { |
|
720 |
$main::lxdebug->enter_sub(); |
|
721 |
|
|
722 |
my $self = shift; |
|
723 |
my %params = @_; |
|
724 |
|
|
725 |
Common::check_params(\%params, qw(charts)); |
|
726 |
|
|
727 |
my $myconfig = \%main::myconfig; |
|
728 |
my $form = $main::form; |
|
729 |
|
|
730 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
731 |
|
|
732 |
my @ids = map { $_->{id} } @{ $params{charts} }; |
|
733 |
|
|
734 |
if (!@ids) { |
|
735 |
$main::lxdebug->leave_sub(); |
|
736 |
return; |
|
737 |
} |
|
738 |
|
|
739 |
my $query = qq|SELECT chart_id, SUM(amount) AS sum |
|
740 |
FROM acc_trans |
|
741 |
WHERE chart_id IN (| . join(', ', ('?') x scalar(@ids)) . qq|) |
|
742 |
GROUP BY chart_id|; |
|
743 |
|
|
744 |
my %balances = selectall_as_map($form, $dbh, $query, 'chart_id', 'sum', @ids); |
|
745 |
|
|
746 |
foreach my $chart (@{ $params{charts} }) { |
|
747 |
$chart->{balance} = $balances{ $chart->{id} } || 0; |
|
748 |
} |
|
749 |
|
|
750 |
$main::lxdebug->leave_sub(); |
|
751 |
} |
|
752 |
|
|
753 |
|
|
719 | 754 |
1; |
Auch abrufbar als: Unified diff
Beim Dialogbuchen die Kontensalden zu den jeweils ausgewählten Konten anzeigen. Fix für Bug 548.