Bugzilla – Attachment 181962 Details for
Bug 31698
Add ability to move a hold to a new bibliographic record/item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31698: Disallow moving waiting or intransit holds
Bug-31698-Disallow-moving-waiting-or-intransit-hol.patch (text/plain), 7.57 KB, created by
Lucas Gass (lukeg)
on 2025-05-05 22:39:04 UTC
(
hide
)
Description:
Bug 31698: Disallow moving waiting or intransit holds
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-05-05 22:39:04 UTC
Size:
7.57 KB
patch
obsolete
>From 688dd1cbcd801b9397c86e28f764638d1c05ec6e Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 5 May 2025 22:16:02 +0000 >Subject: [PATCH] Bug 31698: Disallow moving waiting or intransit holds > >--- > Koha/Hold.pm | 10 +++++++ > .../prog/en/includes/holds_table.inc | 2 ++ > .../prog/en/modules/reserve/request.tt | 13 +++++--- > t/db_dependent/Koha/Hold.t | 30 +++++++++++++++++-- > 4 files changed, 49 insertions(+), 6 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index f76c0189580..3d4e7becb4f 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -190,6 +190,16 @@ sub move_hold { > my $original = $self; > my $original_biblionumber = $self->biblionumber; > >+ my $found = $original->found // ''; >+ >+ if ( $found eq 'W' ) { >+ return { success => 0, error => 'Cannot move a waiting hold' }; >+ } >+ >+ if ( $found eq 'T' ) { >+ return { success => 0, error => 'Cannot move a hold in transit' }; >+ } >+ > my $patron = Koha::Patrons->find( { borrowernumber => $self->borrowernumber } ); > return { success => 0, error => 'Missing patron or target' } unless $patron; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index 0d26304999e..3791386d3a3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -57,6 +57,8 @@ > data-item_level_hold="[% hold.item_level_hold | html %]" > data-itemnumber="[% hold.itemnumber | html %]" > data-biblionumber="[% hold.biblionumber | html %]" >+ data-waiting="[% hold.atdestination | html %]" >+ data-intransit="[% hold.intransit | html %]" > /></td> > <td> > <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 9e536bd171d..3f6d2b835f8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -2117,9 +2117,11 @@ > let reserve_biblionumber = $(this).data('biblionumber'); > let reserve_itemnumber = $(this).data('itemnumber'); > let item_level_hold = $(this).data('item_level_hold'); >- let error_message = $(this).data('item_level_hold') ? "" : _("Cannot move a waiting or record level hold"); >+ let item_waiting = $(this).data('waiting'); >+ let item_intransit = $(this).data('intransit'); >+ let error_message = $(this).data('item_level_hold') ? "" : _("Cannot move a waiting, in transit, or record level hold"); > let found_status = $(this).data('found'); >- if ( item_level_hold ) { >+ if ( item_level_hold && ( !item_waiting || !item_intransit ) ) { > $('#move_hold_item_selection table').append(`<tr><td><input type="checkbox" name="move_hold_id" value="${reserve_id}" checked /></td><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a> Itemnumber: <a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${reserve_biblionumber}#item${reserve_itemnumber}">${reserve_itemnumber}</a></td><td>${error_message}</td></tr>`) > } else { > $('#move_hold_item_selection table').append(`<tr><td><input type="checkbox" name="move_hold_id" value="${reserve_id}" disabled /></td><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a> Itemnumber: <a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${reserve_biblionumber}#item${reserve_itemnumber}">${reserve_itemnumber}</a></td><td>${error_message}</td></tr>`) >@@ -2140,9 +2142,12 @@ > let reserve_biblionumber = $(this).data('biblionumber'); > let reserve_itemnumber = $(this).data('itemnumber'); > let item_level_hold = $(this).data('item_level_hold'); >- let error_message = $(this).data('item_level_hold') ? _("Cannot move a waiting or item level hold") : ""; >+ let item_status = $(this).data('status'); >+ let item_waiting = $(this).data('waiting'); >+ let item_intransit = $(this).data('intransit'); >+ let error_message = $(this).data('item_level_hold') ? _("Cannot move a waiting, in transit, or item level hold") : ""; > let found_status = $(this).data('found'); >- if ( !item_level_hold ) { >+ if ( !item_level_hold && ( !item_waiting || !item_intransit ) ) { > $('#move_hold_biblio_selection table').append(`<tr><td><input type="checkbox" name="move_hold_id" value="${reserve_id}" checked /><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a></td><td>${error_message}</td></tr>`) > } else { > $('#move_hold_biblio_selection table').append(`<tr><td><input type="checkbox" name="move_hold_id" value="${reserve_id}" disabled /><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a></td><td>${error_message}</td></tr>`) >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index 610691e6924..51934fbcc16 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -1163,7 +1163,7 @@ subtest 'change_type() tests' => sub { > }; > > subtest 'move_hold() tests' => sub { >- plan tests => 11; >+ plan tests => 13; > $schema->storage->txn_begin; > > my $patron = Koha::Patron->new( >@@ -1306,7 +1306,33 @@ subtest 'move_hold() tests' => sub { > is( $logs_2->count, 1, 'Hold modification was logged' ); > > #disable HoldsLog >- t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); >+ t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); >+ >+ my $hold_6 = Koha::Hold->new( >+ { >+ borrowernumber => $patron_4->borrowernumber, >+ biblionumber => $biblio4->biblionumber, >+ itemnumber => $item_4->itemnumber, >+ branchcode => 'CPL', >+ found => 'W', >+ } >+ )->store; >+ >+ my $result_4 = $hold_6->move_hold( { new_biblionumber => $biblio1->biblionumber } ); >+ is( $result_4->{error}, 'Cannot move a waiting hold', 'Correct error for waiting hold' ); >+ >+ my $hold_7 = Koha::Hold->new( >+ { >+ borrowernumber => $patron_4->borrowernumber, >+ biblionumber => $biblio4->biblionumber, >+ itemnumber => $item_4->itemnumber, >+ branchcode => 'CPL', >+ found => 'T', >+ } >+ )->store; >+ >+ my $result_5 = $hold_7->move_hold( { new_biblionumber => $biblio1->biblionumber } ); >+ is( $result_5->{error}, 'Cannot move a hold in transit', 'Correct error for hold instransit' ); > > $schema->storage->txn_rollback; > }; >-- >2.39.5
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 31698
:
179226
|
179235
|
179236
|
179279
|
179287
|
179290
|
179291
|
179292
|
179295
|
179704
|
179711
|
179713
|
181222
|
181223
|
181224
|
181225
|
181226
|
181228
|
181229
|
181230
|
181231
|
181232
|
181233
|
181234
|
181929
|
181930
|
181944
|
181945
|
181946
|
181947
|
181948
|
181951
|
181952
|
181953
|
181954
|
181955
|
181956
|
181957
|
181958
|
181959
|
181960
|
181961
|
181962
|
182639
|
182640
|
182641