1 package Koha::Account::Lines;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Koha::Account::Line;
24 use base qw(Koha::Objects);
28 Koha::Account::Lines - Koha Account Line Object set class
34 =head3 total_outstanding
36 my $lines = Koha::Account::Lines->search({ ... });
37 my $total = $lines->total_outstanding;
39 Returns the sum of the outstanding amounts of the resultset. If the resultset is
44 sub total_outstanding {
47 my $me = $self->_resultset()->current_source_alias . ".";
48 my $lines = $self->search(
51 select => [ { sum => $me.'amountoutstanding' } ],
52 as => ['total_amountoutstanding'],
57 ? $lines->next->get_column('total_amountoutstanding') + 0
63 my $lines = Koha::Account::Lines->search({ ... });
64 my $total = $lines->total;
66 Returns the sum of the amounts of the resultset. If the resultset is
72 my ( $self, $conditions ) = @_;
75 my $me = $self->_resultset()->current_source_alias . ".";
76 my $lines = $self->search(
79 select => [ { sum => $me.'amount' } ],
83 return $lines->count ? $lines->next->get_column('total') + 0 : 0;
88 my $lines = Koha::Account::Lines->search({ ... });
89 my $credits_total = $lines->credits_total;
91 Returns the sum of the amounts of the resultset. If the resultset is
97 my ( $self, $conditions ) = @_;
99 my $me = $self->_resultset()->current_source_alias . ".";
100 my $local_conditions = { $me.'amount' => { '<' => 0 } };
102 my $merged_conditions = { %{$conditions}, %{$local_conditions} };
104 my $lines = $self->search(
107 select => [ { sum => $me.'amount' } ],
111 return $lines->count ? $lines->next->get_column('total') + 0 : 0;
116 my $lines = Koha::Account::Lines->search({ ... });
117 my $debits_total = $lines->debits_total;
119 Returns the sum of the amounts of the resultset. If the resultset is
125 my ( $self, $conditions ) = @_;
127 my $me = $self->_resultset()->current_source_alias . ".";
128 my $local_conditions = { $me.'amount' => { '>' => 0 } };
130 my $merged_conditions = { %{$conditions}, %{$local_conditions} };
132 my $lines = $self->search(
135 select => [ { sum => $me.'amount' } ],
139 return $lines->count ? $lines->next->get_column('total') + 0 : 0;
142 =head2 Internal methods
149 return 'Accountline';
153 return 'Koha::Account::Line';