Bug 21681 - Remove C4::Accounts::getcharges
Summary: Remove C4::Accounts::getcharges
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Josef Moravec
QA Contact: Testopia
URL:
Keywords:
Depends on: 21694
Blocks: 21683 21696
  Show dependency treegraph
 
Reported: 2018-10-26 10:04 UTC by Josef Moravec
Modified: 2020-01-06 20:15 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 21681: Remove C4::Accounts::getcharges (2.88 KB, patch)
2018-10-26 10:11 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 21681: Remove C4::Accounts::getcharges (2.97 KB, patch)
2018-10-26 14:42 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21681: (follow-up) Don't use Koha::Account::Line directly (1.50 KB, patch)
2018-10-26 15:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21681: (follow-up) Add tests for Koha::Account->lines (2.23 KB, patch)
2018-10-26 17:35 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21681: Remove C4::Accounts::getcharges (2.96 KB, patch)
2018-10-26 18:27 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21681: Add tests for GetPatronInfo (2.02 KB, patch)
2018-10-26 18:27 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21681: Improve the account lines fetch (987 bytes, patch)
2018-10-26 18:27 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21681: Remove C4::Accounts::getcharges (3.03 KB, patch)
2018-10-26 18:48 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21681: Add tests for GetPatronInfo (2.09 KB, patch)
2018-10-26 18:48 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21681: Improve the account lines fetch (1.03 KB, patch)
2018-10-26 18:48 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Josef Moravec 2018-10-26 10:04:20 UTC
C4::Accounts::getcharges is only used on one place and could be easily rewritten using objects
Comment 1 Josef Moravec 2018-10-26 10:11:34 UTC
Created attachment 81269 [details] [review]
Bug 21681: Remove C4::Accounts::getcharges

Test plan:
0) Do not apply the patch
1) Enable ILS-DI
2) Go to
<opac_url>/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=51&show_fines=1
use patron with some paid and unpaid fines
3) Save the page for later usage
4) Apply the patch
5) Repeat 2 with same patron and compare the saved result with the new
one, they should be same
6) git grep getcharges should return no occurance
7) prove t/db_dependent/Accounts.t
Comment 2 Martin Renvoize 2018-10-26 14:42:50 UTC
Created attachment 81298 [details] [review]
Bug 21681: Remove C4::Accounts::getcharges

Test plan:
0) Do not apply the patch
1) Enable ILS-DI
2) Go to
<opac_url>/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=51&show_fines=1
use patron with some paid and unpaid fines
3) Save the page for later usage
4) Apply the patch
5) Repeat 2 with same patron and compare the saved result with the new
one, they should be same
6) git grep getcharges should return no occurance
7) prove t/db_dependent/Accounts.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize 2018-10-26 14:44:01 UTC
Simples..
Comment 4 Martin Renvoize 2018-10-26 15:07:17 UTC
With my QA hat on.. I'm less happy with this.

1) We should not use Koha::Account::Lines directly.. the intention is to use Koha::Account as an intermediary for dealing with all account actions.
2) If we do the above, there is a method directly from the Koha::Patron object you have in ILSDI already ($patron->account->*)
3) I don't really believe ILSDI should return ALL accountlines associated to a patron.  In reality, the intention is for outstanding debits (and possibly outstanding credits) to be usable.  However, that would be a change of the api, and so is probably out of scope.  As such, we could add a 'lines' method to Koha::Account which would return all accountlines filtered by the user.
Comment 5 Martin Renvoize 2018-10-26 15:11:58 UTC
I'm working on the followup myself
Comment 6 Martin Renvoize 2018-10-26 15:24:10 UTC
Created attachment 81306 [details] [review]
Bug 21681: (follow-up) Don't use Koha::Account::Line directly
Comment 7 Josef Moravec 2018-10-26 15:41:22 UTC
(In reply to Martin Renvoize from comment #5)
> I'm working on the followup myself

Oh, you were really fast!

Thanks!

I agreee with you, that it does not make much sense to return all accountlines in getpatroninfo method of ilsdi, but it is definetaly out of scope of this report.
Comment 8 Martin Renvoize 2018-10-26 15:48:27 UTC
I just need to add a test for Koha::Account->lines now then i'll get Tomas to do a final QA on it ;)

Be really nice to clean up this area.
Comment 9 Martin Renvoize 2018-10-26 17:35:37 UTC
Created attachment 81322 [details] [review]
Bug 21681: (follow-up) Add tests for Koha::Account->lines
Comment 10 Jonathan Druart 2018-10-26 18:03:18 UTC
I will move the 2 last patches to their own bug report, see bug 21694
Comment 11 Jonathan Druart 2018-10-26 18:27:42 UTC
Created attachment 81325 [details] [review]
Bug 21681: Remove C4::Accounts::getcharges

Test plan:
0) Do not apply the patch
1) Enable ILS-DI
2) Go to
<opac_url>/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=51&show_fines=1
use patron with some paid and unpaid fines
3) Save the page for later usage
4) Apply the patch
5) Repeat 2 with same patron and compare the saved result with the new
one, they should be same
6) git grep getcharges should return no occurance
7) prove t/db_dependent/Accounts.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 12 Jonathan Druart 2018-10-26 18:27:48 UTC
Created attachment 81326 [details] [review]
Bug 21681: Add tests for GetPatronInfo

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 13 Jonathan Druart 2018-10-26 18:27:53 UTC
Created attachment 81327 [details] [review]
Bug 21681: Improve the account lines fetch

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 14 Jonathan Druart 2018-10-26 18:35:01 UTC
I have squashed the first 2 patches (wrong manip), sorry Martin!
Comment 15 Martin Renvoize 2018-10-26 18:36:48 UTC
Loving the code golf here.. nice teamwork!
Comment 16 Martin Renvoize 2018-10-26 18:44:24 UTC
Yup, tested and all works as expected still, code looks great after that golfing session and Jonthans added ILSDI tests too.. can't ask for more.. lets PQA it as there's now three QA team eyes here ;)
Comment 17 Martin Renvoize 2018-10-26 18:48:23 UTC
Created attachment 81329 [details] [review]
Bug 21681: Remove C4::Accounts::getcharges

Test plan:
0) Do not apply the patch
1) Enable ILS-DI
2) Go to
<opac_url>/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=51&show_fines=1
use patron with some paid and unpaid fines
3) Save the page for later usage
4) Apply the patch
5) Repeat 2 with same patron and compare the saved result with the new
one, they should be same
6) git grep getcharges should return no occurance
7) prove t/db_dependent/Accounts.t

Co-authored-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 18 Martin Renvoize 2018-10-26 18:48:27 UTC
Created attachment 81330 [details] [review]
Bug 21681: Add tests for GetPatronInfo

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Martin Renvoize 2018-10-26 18:48:30 UTC
Created attachment 81331 [details] [review]
Bug 21681: Improve the account lines fetch

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 20 Nick Clemens 2018-10-31 15:04:57 UTC
Awesome work all!

Pushed to master for 18.11
Comment 21 Martin Renvoize 2018-11-09 16:11:14 UTC
Architectural enhancement, will not be backported to 18.05.x series.