Bug 21909

Summary: Koha::Account::outstanding_* methods should preserve call context
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: minor    
Priority: P5 - low CC: jonathan.druart, josef.moravec, kyle, lucas, martin.renvoize, nick, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 20946, 20990    
Bug Blocks:    
Attachments: Bug 21909: Unit tests
Bug 21909: Make Koha::Account::outstanding_* preserve context
Bug 21909: Add return type explanation to POD
Bug 21909: Unit tests
Bug 21909: Make Koha::Account::outstanding_* preserve context
Bug 21909: Add return type explanation to POD
Bug 21909: Unit tests
Bug 21909: Make Koha::Account::outstanding_* preserve context
Bug 21909: Add return type explanation to POD
Bug 21909: Unit tests
Bug 21909: Make Koha::Account::outstanding_* preserve context
Bug 21909: Add return type explanation to POD

Description Tomás Cohen Arazi (tcohen) 2018-11-29 12:51:34 UTC
They should return lists in list context, and the iterator in scalar, as other methods like '->lines'.
Comment 1 Tomás Cohen Arazi (tcohen) 2018-11-29 15:16:09 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi (tcohen) 2018-11-29 15:16:16 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi (tcohen) 2018-11-29 15:16:22 UTC Comment hidden (obsolete)
Comment 4 Martin Renvoize (ashimema) 2018-11-29 15:37:51 UTC Comment hidden (obsolete)
Comment 5 Martin Renvoize (ashimema) 2018-11-29 15:37:55 UTC Comment hidden (obsolete)
Comment 6 Martin Renvoize (ashimema) 2018-11-29 15:37:58 UTC Comment hidden (obsolete)
Comment 7 Martin Renvoize (ashimema) 2018-11-29 15:38:21 UTC
Nice catch, works as expected.. Signing Off.
Comment 8 Josef Moravec 2018-11-30 16:52:43 UTC Comment hidden (obsolete)
Comment 9 Josef Moravec 2018-11-30 16:52:48 UTC Comment hidden (obsolete)
Comment 10 Josef Moravec 2018-11-30 16:52:52 UTC Comment hidden (obsolete)
Comment 11 Nick Clemens (kidclamp) 2018-12-26 15:59:29 UTC
Simple rebase needed
Comment 12 Tomás Cohen Arazi (tcohen) 2018-12-26 17:51:02 UTC
Created attachment 83511 [details] [review]
Bug 21909: Unit tests

This patch introduces regression tests for the behaviour to be
introduced. Both outstanding_credits and outstanding_debits methods
should return a Koha::Account::Lines object in scalar context, and a
list of Koha::Account::Line objects in list context.

To test:
- Apply this patch
- Run
  $ kshell
 k$ prove t/db_dependent/Koha/Account.t
=> FAIL: The current behaviour doesn't match the described

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 13 Tomás Cohen Arazi (tcohen) 2018-12-26 17:51:07 UTC
Created attachment 83512 [details] [review]
Bug 21909: Make Koha::Account::outstanding_* preserve context

This patch modifies the methods so they preserve the caller's context
(list and scalar).

To test:
- Apply the first patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/Account.t
=> FAIL: outstanding_credits and outstanding_debits tests fail
- Apply this patch
- Run:
 k$ prove t/db_dependent/Koha/Account.t
=> SUCCESS: We are so happy now :-D
- Sign off :-D

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

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 14 Tomás Cohen Arazi (tcohen) 2018-12-26 17:51:11 UTC
Created attachment 83513 [details] [review]
Bug 21909: Add return type explanation to POD

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

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 15 Tomás Cohen Arazi (tcohen) 2018-12-26 17:51:43 UTC
(In reply to Nick Clemens from comment #11)
> Simple rebase needed

Tests count mismatch, done!
Comment 16 Nick Clemens (kidclamp) 2019-01-02 21:10:24 UTC
Awesome work all!

Pushed to master for 19.05
Comment 17 Martin Renvoize (ashimema) 2019-01-07 15:02:37 UTC
I'm changing this from 'enhancement' to 'minor' as I believe it was a mistake and thus a bug in the first place for the caller context to be lost..  as such:

Pushed to 18.11.x for 18.11.02.
Comment 18 Lucas Gass (lukeg) 2019-01-08 23:21:12 UTC
cannot cleanly apply this for 18.05. if this is needed in 18.05 can we please rebase.
Comment 19 Tomás Cohen Arazi (tcohen) 2019-01-09 09:51:46 UTC
(In reply to Lucas Gass from comment #18)
> cannot cleanly apply this for 18.05. if this is needed in 18.05 can we
> please rebase.

You can skip it, Lucas.