Bugzilla – Attachment 157648 Details for
Bug 21284
ILS-DI: Allow GetPatronInfo to tell if a checked out item is on hold for someone else
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21284: ILS-DI: Allow GetPatronInfo to tell if a loaned item is on hold by someone else.
Bug-21284-ILS-DI-Allow-GetPatronInfo-to-tell-if-a-.patch (text/plain), 9.04 KB, created by
Matthias Meusburger
on 2023-10-23 13:18:06 UTC
(
hide
)
Description:
Bug 21284: ILS-DI: Allow GetPatronInfo to tell if a loaned item is on hold by someone else.
Filename:
MIME Type:
Creator:
Matthias Meusburger
Created:
2023-10-23 13:18:06 UTC
Size:
9.04 KB
patch
obsolete
>From 391f806a8dfa423dde9cfe377a0176ee5bcfee41 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Fri, 27 Apr 2018 16:22:28 +0200 >Subject: [PATCH] Bug 21284: ILS-DI: Allow GetPatronInfo to tell if a loaned > item is on hold by someone else. > >This patch adds two new entries in the loans section of GetPatronInfo response: > > - itemonhold: number of holds on this specific item. > - recordonhold: number of holds on the record. > >It allows an ILS-DI client to know if a loaned item is already on hold by someone else, and how many holds there are. > >Test plan: >1. Apply the patch. >2. Enable the ILS-DI system preference. >3. Check out an item for a patron and make sure there no other holds at either an item or record level. >4. Check that the new itemonhold and recordonhold entries displayed are equal to zero (example: http://127.0.0.1:8080/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=19&show_contact=0&show_loans=1). >5. Add either a record or item level hold for the record used in step 2. >6. Check that itemonhold and recordonhold values are incremented accordingly. > Note: a hold at an item level counts as a hold at a record level, but not vice-versa. >7. Run the tests and make sure they pass: prove t/db_dependent/ILSDI_Services.t >8. Sign-off! >--- > C4/ILSDI/Services.pm | 7 ++ > .../opac-tmpl/bootstrap/en/modules/ilsdi.tt | 4 ++ > t/db_dependent/ILSDI_Services.t | 72 ++++++++----------- > 3 files changed, 42 insertions(+), 41 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 77243a882a..17d0f1e1a9 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -529,6 +529,13 @@ sub GetPatronInfo { > # FIXME We should only retrieve what is needed in the template > my $issue = $c->unblessed_all_relateds; > delete $issue->{'more_subfields_xml'}; >+ >+ # Is the item already on hold by another user? >+ $issue->{'itemonhold'} = Koha::Holds->search({ itemnumber => $issue->{'itemnumber'} })->count; >+ >+ # Is the record (next available item) on hold by another user? >+ $issue->{'recordonhold'} = Koha::Holds->search({ biblionumber => $issue->{'biblionumber'} })->count; >+ > push @checkouts, $issue > } > $borrower->{'loans'}->{'loan'} = \@checkouts; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt >index c08fa7e97f..033a4cff69 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt >@@ -650,6 +650,8 @@ > <location>Salle de lecture</location> > <itemlost>0</itemlost> > <publicationyear>1985</publicationyear> >+ <recordonhold>0</recordonhold> >+ <itemonhold>0</itemonhold> > <issues>1</issues> > <homebranch>BIB</homebranch> > <holdingbranch>BIB</holdingbranch> >@@ -688,6 +690,8 @@ > <location>Salle de lecture</location> > <itemlost>0</itemlost> > <publicationyear>2007</publicationyear> >+ <recordonhold>1</recordonhold> >+ <itemonhold>1</itemonhold> > <issues>1</issues> > <homebranch>BIB</homebranch> > <holdingbranch>BIB</holdingbranch> >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 4b380ff0b7..003c827ba6 100755 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use Test::More tests => 12; >+use Test::More tests => 13; > use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -146,60 +146,45 @@ subtest 'GetPatronInfo test for holds' => sub { > # Configure Koha to enable ILS-DI server > t::lib::Mocks::mock_preference( 'ILS-DI', 1 ); > >- # Set up a library/branch for our user to belong to: >- my $branchcode = 'T_ILSDI'; >- my $lib = $builder->build( { >- source => 'Branch', >- value => { >- branchcode => $branchcode, >- } >- } ); >- >- # Create a new category for user to belong to: >- my $cat = $builder->build( { >- source => 'Category', >- value => { >- category_type => 'A', >- BlockExpiredPatronOpacActions => -1, >- } >- } ); >+ my $library = $builder->build_object({ >+ class => 'Koha::Libraries', >+ }); > > # Create new users: >- my $brwr = $builder->build( { >- source => 'Borrower', >+ my $brwr = $builder->build_object( { >+ class => 'Koha::Patrons', > value => { >- categorycode => $cat->{'categorycode'}, >- branchcode => $lib->{'branchcode'}, >+ branchcode => $library->branchcode, > } > } ); >- my $brwr2 = $builder->build( { >- source => 'Borrower', >+ my $brwr2 = $builder->build_object( { >+ class => 'Koha::Patrons', > value => { >- categorycode => $cat->{'categorycode'}, >- branchcode => $lib->{'branchcode'}, >+ branchcode => $library->branchcode, > } > } ); >- my $brwr3 = $builder->build( { >- source => 'Borrower', >+ my $brwr3 = $builder->build_object( { >+ class => 'Koha::Patrons', > value => { >- categorycode => $cat->{'categorycode'}, >- branchcode => $lib->{'branchcode'}, >+ branchcode => $library->branchcode, > } > } ); > >+ my $module = Test::MockModule->new('C4::Context'); >+ $module->mock('userenv', sub { { branch => $library->branchcode } }); > > # Place a loan >- my $biblio = $builder->build( { source => 'Biblio', } ); >- my $item = $builder->build( { source => 'Item', value => { biblionumber => $biblio->{biblionumber}, barcode => "mybarcode"} } ); >- my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); >- $userenv = { flags => 1, id => $brwr->{borrowernumber}, branch => 'T_ILSDI' }; >- my $issue = AddIssue($brwr, $item->{barcode}); >+ my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >+ my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio->biblionumber } } ); >+ my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library->branchcode, itype => $itemtype->itemtype }); >+ $userenv = { flags => 1, id => $brwr->borrowernumber, branch => $library->branchcode }; >+ my $issue = AddIssue($brwr, $item->barcode); > > # Prepare and send web request for IL-SDI server: > my $query = new CGI; > $query->param( 'service', 'GetPatronInfo' ); >- $query->param( 'patron_id', $brwr->{'borrowernumber'} ); >- $query->param( 'show_attributes', '0' ); >+ $query->param( 'patron_id', $brwr->borrowernumber ); > $query->param( 'show_loans', '1' ); > my $reply = C4::ILSDI::Services::GetPatronInfo( $query ); > >@@ -207,8 +192,9 @@ subtest 'GetPatronInfo test for holds' => sub { > is ( $reply->{loans}->{loan}[0]->{recordonhold}, "0", "Record is not on hold"); > is ( $reply->{loans}->{loan}[0]->{itemonhold}, "0", "Item is not on hold"); > >+ # Place a loan > # Add a hold on the biblio >- my $biblioreserve = AddReserve($branchcode, $brwr2->{'borrowernumber'}, $biblio->{biblionumber}); >+ my $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr2->borrowernumber, biblionumber => $biblio->biblionumber }); > > # Check that it is on hold on biblio level > $reply = C4::ILSDI::Services::GetPatronInfo( $query ); >@@ -219,8 +205,12 @@ subtest 'GetPatronInfo test for holds' => sub { > $schema->resultset( 'Reserve' )->delete_all; > > # Add a hold on the item >- my $itemreserve = AddReserve($branchcode, $brwr2->{'borrowernumber'}, $biblio->{biblionumber}, >- [$biblio->{biblionumber}], undef, undef, undef, undef, undef, $item->{itemnumber}); >+ my $itemreserve = AddReserve({ >+ branchcode => $library->branchcode, >+ borrowernumber => $brwr2->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item->itemnumber >+ }); > > # When a specific item has a reserve, the item is on hold as well as the record > $reply = C4::ILSDI::Services::GetPatronInfo( $query ); >@@ -228,7 +218,7 @@ subtest 'GetPatronInfo test for holds' => sub { > is ( $reply->{loans}->{loan}[0]->{itemonhold}, "1", "Item is on hold"); > > # Add another hold on the biblio >- $biblioreserve = AddReserve($branchcode, $brwr3->{'borrowernumber'}, $biblio->{biblionumber}); >+ $biblioreserve = AddReserve({ branchcode => $library->branchcode, borrowernumber => $brwr3->borrowernumber, biblionumber => $biblio->biblionumber }); > > # Check that there are 2 holds on the biblio and 1 on this specific item > $reply = C4::ILSDI::Services::GetPatronInfo( $query ); >-- >2.30.2
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 21284
:
78268
|
78269
|
90326
|
109438
|
109439
|
157648
|
157727
|
157728
|
158351
|
158352
|
158353
|
158899