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
}
}
+ 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 } );
}
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
}
);
}
+ 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,
type:
- boolean
- "null"
+ ignore_holds:
+ type:
+ - boolean
+ - "null"
additionalProperties: false
.empty()
.attr('class', 'alert alert-danger')
.append(__x('Failure: Item {barcode} cannot be checked in', { barcode }))
+ } else if (response.error_code === 'reserved') {
+ const button = $('<button type="button">')
+ .addClass('btn btn-xs')
+ .text(__('Ignore holds and add to bundle'))
+ .on('click', function () {
+ addToBundle(url, { external_id: barcode, ignore_holds: true });
+ });
+ $('#addResult')
+ .empty()
+ .attr('class', 'alert alert-warning')
+ .append(__x('Warning: Item {barcode} is reserved', { barcode }))
+ .append(' ', button);
} else {
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
}