Bug 19832 - SIP checkout removes extra hold on same biblio
Summary: SIP checkout removes extra hold on same biblio
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-19 09:04 UTC by Petter Goksøyr Åsen
Modified: 2019-10-14 19:59 UTC (History)
6 users (show)

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


Attachments
Bug 19832: Unit tests (3.88 KB, patch)
2019-01-16 13:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 19832: Don't fill holds in SIP/Transaction/Checkout.pm (1.89 KB, patch)
2019-01-16 13:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 19832: Unit tests (3.93 KB, patch)
2019-01-18 10:28 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 19832: Don't fill holds in SIP/Transaction/Checkout.pm (1.95 KB, patch)
2019-01-18 10:28 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 19832: Unit tests (4.09 KB, patch)
2019-02-15 10:12 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 19832: Don't fill holds in SIP/Transaction/Checkout.pm (2.05 KB, patch)
2019-02-15 10:12 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 19832: (QA follow-up) Remove obsolete pending_queue call (1011 bytes, patch)
2019-02-15 10:12 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Petter Goksøyr Åsen 2017-12-19 09:04:50 UTC
C4/SIP/ILS/Transaction/Checkout.pm includes the following bit of code which remove any hold that that matches the biblio and bilbionumber in checkout:

# Fill any reserves the patron had on the item.  
    # TODO: this logic should be pulled internal to AddIssue for all Koha. 
    $debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]';
    foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) {
        $debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): "
            . sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate});
        ModReserveFill($_);
        # TODO: adjust representation in $self->item
    }


As far as I can tell, this code is completely unnecessary, since C4::Circulation::AddIssue allread calls C4::Reserves::MoveReserve which fullfills the hold. What's more, if the borrower has multiple holds on the same biblio, all of them will be removed. This is clearly wrong.

I purpose to remove the code above, unless someone can explain why SIP checkout should behave different than normal checkout in this case.
Comment 1 Liz Rea 2018-01-19 00:22:34 UTC
This is clearly wrong, I have a library having this exact problem right now.

Will give your solution a go and see what happens.

Cheers,
Liz
Comment 2 Nick Clemens 2019-01-16 13:25:44 UTC
Created attachment 84070 [details] [review]
Bug 19832: Unit tests
Comment 3 Nick Clemens 2019-01-16 13:25:47 UTC
Created attachment 84071 [details] [review]
Bug 19832: Don't fill holds in SIP/Transaction/Checkout.pm

AddIssue already checks for holds in the item being issued and deals with them

The sip code, additionally, does not consider that multiple holds per bib
is allowed

To test:
 0 - Apply only first patch (unit tests)
 1 - Place two holds for a patron on a bib
 2 - Checkout that item via sip_cli_emulator
 3 - Note all holds are cancelled/filled
 4 - prove -v t/db_dependent/SIP/Transaction.t
 5 - it fails
 6 - Apply second patch
 7 - prove tests, all green
 8 - Place two holds on a single bib for one patron again
 9 - Checkout the item via sip_cli_emulator
10 - Only one holds is filled
Comment 4 Martin Renvoize 2019-01-18 10:28:49 UTC
Created attachment 84180 [details] [review]
Bug 19832: Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2019-01-18 10:28:52 UTC
Created attachment 84181 [details] [review]
Bug 19832: Don't fill holds in SIP/Transaction/Checkout.pm

AddIssue already checks for holds in the item being issued and deals with them

The sip code, additionally, does not consider that multiple holds per bib
is allowed

To test:
 0 - Apply only first patch (unit tests)
 1 - Place two holds for a patron on a bib
 2 - Checkout that item via sip_cli_emulator
 3 - Note all holds are cancelled/filled
 4 - prove -v t/db_dependent/SIP/Transaction.t
 5 - it fails
 6 - Apply second patch
 7 - prove tests, all green
 8 - Place two holds on a single bib for one patron again
 9 - Checkout the item via sip_cli_emulator
10 - Only one holds is filled

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2019-01-18 10:29:24 UTC
Code seems sound and passes tests.  Signing Off.
Comment 7 Marcel de Rooy 2019-02-15 10:12:50 UTC
Created attachment 85149 [details] [review]
Bug 19832: Unit tests

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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Amended: maxissueqty      => 10.
Replaced dot by comma.
Comment 8 Marcel de Rooy 2019-02-15 10:12:54 UTC
Created attachment 85150 [details] [review]
Bug 19832: Don't fill holds in SIP/Transaction/Checkout.pm

AddIssue already checks for holds in the item being issued and deals with them

The sip code, additionally, does not consider that multiple holds per bib
is allowed

To test:
 0 - Apply only first patch (unit tests)
 1 - Place two holds for a patron on a bib
 2 - Checkout that item via sip_cli_emulator
 3 - Note all holds are cancelled/filled
 4 - prove -v t/db_dependent/SIP/Transaction.t
 5 - it fails
 6 - Apply second patch
 7 - prove tests, all green
 8 - Place two holds on a single bib for one patron again
 9 - Checkout the item via sip_cli_emulator
10 - Only one holds is filled

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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2019-02-15 10:12:58 UTC
Created attachment 85151 [details] [review]
Bug 19832: (QA follow-up) Remove obsolete pending_queue call

Only use of $pending was removed in the former patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 10 Marcel de Rooy 2019-02-15 10:13:34 UTC
Nick++ for unit tests
Comment 11 Nick Clemens 2019-02-15 18:48:34 UTC
Awesome work all!

Pushed to master for 19.05
Comment 12 Martin Renvoize 2019-02-25 13:28:19 UTC
Pushed to 18.11.x for 18.11.04