Bugzilla – Attachment 92948 Details for
Bug 23355
Add a 'cashup' process to accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23355: Add summation methods to Koha::Account::Lines
Bug-23355-Add-summation-methods-to-KohaAccountLine.patch (text/plain), 2.98 KB, created by
Martin Renvoize (ashimema)
on 2019-09-18 14:59:18 UTC
(
hide
)
Description:
Bug 23355: Add summation methods to Koha::Account::Lines
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-09-18 14:59:18 UTC
Size:
2.98 KB
patch
obsolete
>From 31e43ca24f987d1be611440e4a9d321dfc41b9d2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 13 Sep 2019 14:05:45 +0100 >Subject: [PATCH] Bug 23355: Add summation methods to Koha::Account::Lines > >This patch adds a number of summation methods to Koha::Account::Lines >giving quick access to overall total, total credits and total debits. >--- > Koha/Account/Lines.pm | 82 +++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 80 insertions(+), 2 deletions(-) > >diff --git a/Koha/Account/Lines.pm b/Koha/Account/Lines.pm >index 75225fcfeb..07c6f0b24b 100644 >--- a/Koha/Account/Lines.pm >+++ b/Koha/Account/Lines.pm >@@ -43,13 +43,13 @@ empty it returns 0. > =cut > > sub total_outstanding { >- my ( $self ) = @_; >+ my ($self) = @_; > > my $lines = $self->search( > {}, > { > select => [ { sum => 'amountoutstanding' } ], >- as => ['total_amountoutstanding'], >+ as => ['total_amountoutstanding'], > } > ); > >@@ -58,6 +58,84 @@ sub total_outstanding { > : 0; > } > >+=head3 total >+ >+ my $lines = Koha::Account::Lines->search({ ... }); >+ my $total = $lines->total; >+ >+Returns the sum of the amounts of the resultset. If the resultset is >+empty it returns 0. >+ >+=cut >+ >+sub total { >+ my ( $self, $conditions ) = @_; >+ >+ $conditions //= {}; >+ my $lines = $self->search( >+ $conditions, >+ { >+ select => [ { sum => 'me.amount' } ], >+ as => ['total'] >+ } >+ ); >+ return $lines->count ? $lines->next->get_column('total') + 0 : 0; >+} >+ >+=head3 credits_total >+ >+ my $lines = Koha::Account::Lines->search({ ... }); >+ my $credits_total = $lines->credits_total; >+ >+Returns the sum of the amounts of the resultset. If the resultset is >+empty it returns 0. >+ >+=cut >+ >+sub credits_total { >+ my ( $self, $conditions ) = @_; >+ >+ my $local_conditions = { 'me.amount' => { '<' => 0 } }; >+ $conditions //= {}; >+ my $merged_conditions = { %{$conditions}, %{$local_conditions} }; >+ >+ my $lines = $self->search( >+ $merged_conditions, >+ { >+ select => [ { sum => 'me.amount' } ], >+ as => ['total'] >+ } >+ ); >+ return $lines->count ? $lines->next->get_column('total') + 0 : 0; >+} >+ >+=head3 debits_total >+ >+ my $lines = Koha::Account::Lines->search({ ... }); >+ my $debits_total = $lines->debits_total; >+ >+Returns the sum of the amounts of the resultset. If the resultset is >+empty it returns 0. >+ >+=cut >+ >+sub debits_total { >+ my ( $self, $conditions ) = @_; >+ >+ my $local_conditions = { 'me.amount' => { '>' => 0 } }; >+ $conditions //= {}; >+ my $merged_conditions = { %{$conditions}, %{$local_conditions} }; >+ >+ my $lines = $self->search( >+ $merged_conditions, >+ { >+ select => [ { sum => 'me.amount' } ], >+ as => ['total'] >+ } >+ ); >+ return $lines->count ? $lines->next->get_column('total') + 0 : 0; >+} >+ > =head2 Internal methods > > =head3 _type >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23355
:
92941
|
92942
|
92943
|
92944
|
92945
|
92946
|
92947
|
92948
|
92949
|
92950
|
92951
|
92952
|
92953
|
97031
|
97032
|
97033
|
97034
|
97035
|
97036
|
97037
|
97038
|
97039
|
97040
|
97041
|
97043
|
97044
|
97045
|
97046
|
97047
|
97048
|
97049
|
97050
|
97051
|
97052
|
97053
|
97054
|
97077
|
97078
|
97079
|
97080
|
97081
|
97082
|
97083
|
97084
|
97085
|
97086
|
97087
|
97088
|
97089
|
97706
|
97707
|
97708
|
97709
|
97710
|
97711
|
97712
|
97713
|
97714
|
97715
|
97716
|
97784
|
97785
|
97786
|
97787
|
97788
|
97789
|
97790
|
97791
|
97792
|
97793
|
97794
|
97816
|
97817
|
97818
|
97819
|
97820
|
97821
|
97822
|
97823
|
98026
|
98027
|
98028
|
98835
|
98836
|
98837
|
98838
|
98839
|
98840
|
98841
|
98842
|
100009
|
100010
|
100011
|
100012
|
100013
|
100014
|
100015
|
100016
|
100017
|
100018
|
100019
|
100020
|
100021
|
100030
|
100090
|
101685