Bug 13098: Sum at DBMS level
Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
3db4926db3
commit
5c90aae36a
1 changed files with 11 additions and 4 deletions
|
@ -18,7 +18,6 @@ package Koha::Account::Offsets;
|
|||
use Modern::Perl;
|
||||
|
||||
use Carp;
|
||||
use List::Util qw(sum0);
|
||||
|
||||
use Koha::Database;
|
||||
|
||||
|
@ -41,11 +40,19 @@ Account offsets track the changes made to the balance of account lines
|
|||
=cut
|
||||
|
||||
sub total {
|
||||
my ( $self ) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
my $total = sum0( $self->get_column('amount') );
|
||||
my $offsets = $self->search(
|
||||
{},
|
||||
{
|
||||
select => [ { sum => 'amount' } ],
|
||||
as => ['total_amount'],
|
||||
}
|
||||
);
|
||||
|
||||
return $total;
|
||||
return $offsets->count
|
||||
? $offsets->next->get_column('total_amount') + 0
|
||||
: 0;
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
Loading…
Reference in a new issue