@@ -, +, @@ item bundle You should see a message saying that the item is reserved. Next to this message should be a button "Ignore holds and add to bundle". was added to the bundle. added to the bundle --- Koha/Exceptions/Item/Bundle.pm | 4 ++++ Koha/Item.pm | 7 +++++++ Koha/REST/V1/Items.pm | 18 ++++++++++++++++-- api/v1/swagger/definitions/bundle_link.yaml | 4 ++++ .../prog/en/modules/catalogue/detail.tt | 12 ++++++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) --- a/Koha/Exceptions/Item/Bundle.pm +++ a/Koha/Exceptions/Item/Bundle.pm @@ -31,6 +31,10 @@ use Exception::Class ( isa => 'Koha::Exceptions::Item::Bundle', description => 'Someone tried to add a checked out item to a bundle', }, + 'Koha::Exceptions::Item::Bundle::ItemHasHolds' => { + isa => 'Koha::Exceptions::Item::Bundle', + description => 'Someone tried to add a reserved item to a bundle', + }, ); =head1 NAME --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -1734,6 +1734,13 @@ sub add_to_bundle { } } + my $holds = $bundle_item->current_holds; + if ($holds->count) { + unless ($options->{ignore_holds}) { + Koha::Exceptions::Item::Bundle::ItemHasHolds->throw(); + } + } + $self->_result->add_to_item_bundles_hosts( { item => $bundle_item->itemnumber } ); --- a/Koha/REST/V1/Items.pm +++ a/Koha/REST/V1/Items.pm @@ -277,8 +277,13 @@ sub add_to_bundle { } return try { - my $force_checkin = $c->validation->param('body')->{'force_checkin'}; - my $link = $item->add_to_bundle($bundle_item, { force_checkin => $force_checkin }); + my $body = $c->validation->param('body'); + my $options = { + force_checkin => $body->{force_checkin}, + ignore_holds => $body->{ignore_holds}, + }; + + my $link = $item->add_to_bundle($bundle_item, $options); return $c->render( status => 201, openapi => $bundle_item @@ -314,6 +319,15 @@ sub add_to_bundle { } ); } + elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemHasHolds' ) { + return $c->render( + status => 409, + openapi => { + error => 'Item is reserved', + error_code => 'reserved' + } + ); + } elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) { return $c->render( status => 400, --- a/api/v1/swagger/definitions/bundle_link.yaml +++ a/api/v1/swagger/definitions/bundle_link.yaml @@ -15,4 +15,8 @@ properties: type: - boolean - "null" + ignore_holds: + type: + - boolean + - "null" additionalProperties: false --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1803,6 +1803,18 @@ Note that permanent location is a code, and location may be an authval. .empty() .attr('class', 'alert alert-danger') .append(__x('Failure: Item {barcode} cannot be checked in', { barcode })) + } else if (response.error_code === 'reserved') { + const button = $('