Bug 22837

Summary: Koha::Account::Line->apply should not require a 'set' of debits
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: Architecture, internals, and plumbingAssignee: Martin Renvoize <martin.renvoize>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi <tomascohen>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00
Bug Depends on: 21607    
Bug Blocks:    
Attachments: Bug 22837: Update apply to accept an arrayref
Bug 22837: Update callers to use new signature
Bug 22837: Update apply to accept an arrayref
Bug 22837: Update callers to use new signature
Bug 22837: Update apply to accept an arrayref
Bug 22837: Update callers to use new signature
Bug 22837: (follow-up) Fix some tests
Bug 22837: (follow-up) Fix POD
Bug 22837: Update apply to accept an arrayref
Bug 22837: Update callers to use new signature
Bug 22837: (follow-up) Fix some tests
Bug 22837: (follow-up) Fix POD
Bug 22837: Update apply to accept an arrayref
Bug 22837: Update callers to use new signature
Bug 22837: (follow-up) Fix some tests
Bug 22837: (follow-up) Fix POD

Description Martin Renvoize 2019-05-03 11:54:56 UTC
As it stands the apply method in Koha::Account::Line requires a Koha::Account resultset to be passed in as the list of debits to be applied against.  This is suboptimal when the method is often required to apply against the results of a Koha::Account::Line->find (single not set) as one needs to rework the query.

We should accept an arrayref of results rather than requiring a resultset as converting from a set to an arrayref is simple (->as_list), but converting for a single record up to a set is considerably more challenging (both coding wise and DB hits wise).
Comment 1 Martin Renvoize 2019-05-03 12:31:44 UTC
Created attachment 89314 [details] [review]
Bug 22837: Update apply to accept an arrayref

This patch update the signature of Koha::Account::Line->apply to accept
an arrayref of debits to apply against a credit instead of requireing a
Koha::Objects set.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 2 Martin Renvoize 2019-05-03 12:31:47 UTC
Created attachment 89315 [details] [review]
Bug 22837: Update callers to use new signature
Comment 3 Martin Renvoize 2019-05-03 14:13:14 UTC
Created attachment 89316 [details] [review]
Bug 22837: Update apply to accept an arrayref

This patch update the signature of Koha::Account::Line->apply to accept
an arrayref of debits to apply against a credit instead of requireing a
Koha::Objects set.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2019-05-03 14:13:16 UTC
Created attachment 89317 [details] [review]
Bug 22837: Update callers to use new signature

Test plan:
Run t/db_dependent/Circulation.t, t/db_dependent/Koha/Account.t,
t/db_dependent/Koha/Account/Lines.t and
t/db_dependent/api/v1/patrons_accounts.t and all should pass.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2019-05-08 11:36:27 UTC
Created attachment 89468 [details] [review]
Bug 22837: Update apply to accept an arrayref

This patch update the signature of Koha::Account::Line->apply to accept
an arrayref of debits to apply against a credit instead of requireing a
Koha::Objects set.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2019-05-08 11:36:30 UTC
Created attachment 89469 [details] [review]
Bug 22837: Update callers to use new signature

Test plan:
Run t/db_dependent/Circulation.t, t/db_dependent/Koha/Account.t,
t/db_dependent/Koha/Account/Lines.t and
t/db_dependent/api/v1/patrons_accounts.t and all should pass.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Tomás Cohen Arazi 2019-09-19 18:41:32 UTC
Created attachment 92972 [details] [review]
Bug 22837: (follow-up) Fix some tests
Comment 8 Tomás Cohen Arazi 2019-09-19 18:45:14 UTC
Created attachment 92973 [details] [review]
Bug 22837: (follow-up) Fix POD
Comment 9 Liz Rea 2019-09-19 18:54:15 UTC
Created attachment 92977 [details] [review]
Bug 22837: Update apply to accept an arrayref

This patch update the signature of Koha::Account::Line->apply to accept
an arrayref of debits to apply against a credit instead of requireing a
Koha::Objects set.

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

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Comment 10 Liz Rea 2019-09-19 18:54:30 UTC
Created attachment 92978 [details] [review]
Bug 22837: Update callers to use new signature

Test plan:
Run t/db_dependent/Circulation.t, t/db_dependent/Koha/Account.t,
t/db_dependent/Koha/Account/Lines.t and
t/db_dependent/api/v1/patrons_accounts.t and all should pass.

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

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Comment 11 Liz Rea 2019-09-19 18:54:33 UTC
Created attachment 92979 [details] [review]
Bug 22837: (follow-up) Fix some tests

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Comment 12 Liz Rea 2019-09-19 18:54:36 UTC
Created attachment 92980 [details] [review]
Bug 22837: (follow-up) Fix POD

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Comment 13 Tomás Cohen Arazi 2019-09-19 18:59:11 UTC
Created attachment 92981 [details] [review]
Bug 22837: Update apply to accept an arrayref

This patch update the signature of Koha::Account::Line->apply to accept
an arrayref of debits to apply against a credit instead of requireing a
Koha::Objects set.

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

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 14 Tomás Cohen Arazi 2019-09-19 18:59:15 UTC
Created attachment 92982 [details] [review]
Bug 22837: Update callers to use new signature

Test plan:
Run t/db_dependent/Circulation.t, t/db_dependent/Koha/Account.t,
t/db_dependent/Koha/Account/Lines.t and
t/db_dependent/api/v1/patrons_accounts.t and all should pass.

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

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 15 Tomás Cohen Arazi 2019-09-19 18:59:20 UTC
Created attachment 92983 [details] [review]
Bug 22837: (follow-up) Fix some tests

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 16 Tomás Cohen Arazi 2019-09-19 18:59:23 UTC
Created attachment 92984 [details] [review]
Bug 22837: (follow-up) Fix POD

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 17 Martin Renvoize 2019-09-23 10:09:54 UTC
Nice work!

Pushed to master for 19.11.00
Comment 18 Fridolin Somers 2019-09-24 07:02:01 UTC
Enhancement not pushed to 19.05.x