|
Lines 2402-2450
sub add_to_bundle {
Link Here
|
| 2402 |
|
2402 |
|
| 2403 |
my $BundleNotLoanValue = C4::Context->preference('BundleNotLoanValue'); |
2403 |
my $BundleNotLoanValue = C4::Context->preference('BundleNotLoanValue'); |
| 2404 |
|
2404 |
|
| 2405 |
try { |
2405 |
$schema->txn_do( |
| 2406 |
$schema->txn_do( |
2406 |
sub { |
| 2407 |
sub { |
2407 |
try { |
|
|
2408 |
$schema->safe_do( |
| 2409 |
sub { |
| 2408 |
|
2410 |
|
| 2409 |
Koha::Exceptions::Item::Bundle::BundleIsCheckedOut->throw if $self->checkout; |
2411 |
Koha::Exceptions::Item::Bundle::BundleIsCheckedOut->throw if $self->checkout; |
| 2410 |
|
2412 |
|
| 2411 |
my $checkout = $bundle_item->checkout; |
2413 |
my $checkout = $bundle_item->checkout; |
| 2412 |
if ($checkout) { |
2414 |
if ($checkout) { |
| 2413 |
unless ( $options->{force_checkin} ) { |
2415 |
unless ( $options->{force_checkin} ) { |
| 2414 |
Koha::Exceptions::Item::Bundle::ItemIsCheckedOut->throw(); |
2416 |
Koha::Exceptions::Item::Bundle::ItemIsCheckedOut->throw(); |
| 2415 |
} |
2417 |
} |
| 2416 |
|
2418 |
|
| 2417 |
my $branchcode = C4::Context->userenv->{'branch'}; |
2419 |
my $branchcode = C4::Context->userenv->{'branch'}; |
| 2418 |
my ($success) = C4::Circulation::AddReturn( $bundle_item->barcode, $branchcode ); |
2420 |
my ($success) = C4::Circulation::AddReturn( $bundle_item->barcode, $branchcode ); |
| 2419 |
|
2421 |
|
| 2420 |
if ($success) { |
2422 |
if ($success) { |
| 2421 |
|
2423 |
|
| 2422 |
# HoldsQueue doesn't seem to mind bundles, not sure if this is correct, but rebuild for now |
2424 |
# HoldsQueue doesn't seem to mind bundles, not sure if this is correct, but rebuild for now |
| 2423 |
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( |
2425 |
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( |
| 2424 |
{ biblio_ids => [ $self->biblionumber ] } ) |
2426 |
{ biblio_ids => [ $self->biblionumber ] } ) |
| 2425 |
if C4::Context->preference('RealTimeHoldsQueue'); |
2427 |
if C4::Context->preference('RealTimeHoldsQueue'); |
| 2426 |
} else { |
2428 |
} else { |
| 2427 |
Koha::Exceptions::Checkin::FailedCheckin->throw(); |
2429 |
Koha::Exceptions::Checkin::FailedCheckin->throw(); |
| 2428 |
} |
2430 |
} |
| 2429 |
} |
2431 |
} |
| 2430 |
|
2432 |
|
| 2431 |
my $holds = $bundle_item->current_holds; |
2433 |
my $holds = $bundle_item->current_holds; |
| 2432 |
if ( $holds->count ) { |
2434 |
if ( $holds->count ) { |
| 2433 |
unless ( $options->{ignore_holds} ) { |
2435 |
unless ( $options->{ignore_holds} ) { |
| 2434 |
Koha::Exceptions::Item::Bundle::ItemHasHolds->throw(); |
2436 |
Koha::Exceptions::Item::Bundle::ItemHasHolds->throw(); |
| 2435 |
} |
2437 |
} |
| 2436 |
} |
2438 |
} |
| 2437 |
|
2439 |
|
| 2438 |
$self->_result->add_to_item_bundles_hosts( { item => $bundle_item->itemnumber } ); |
2440 |
$self->_result->add_to_item_bundles_hosts( { item => $bundle_item->itemnumber } ); |
| 2439 |
|
2441 |
|
| 2440 |
$bundle_item->notforloan($BundleNotLoanValue)->store(); |
2442 |
$bundle_item->notforloan($BundleNotLoanValue)->store(); |
| 2441 |
} |
2443 |
} |
| 2442 |
); |
2444 |
); |
| 2443 |
} catch { |
2445 |
} catch { |
| 2444 |
|
2446 |
|
| 2445 |
# Use centralized exception translation instead of duplicated code |
2447 |
# Propagate any exception (already translated by safe_do if needed) |
| 2446 |
$schema->translate_exception($_); |
2448 |
$_->rethrow(); |
| 2447 |
}; |
2449 |
}; |
|
|
2450 |
} |
| 2451 |
); |
| 2448 |
} |
2452 |
} |
| 2449 |
|
2453 |
|
| 2450 |
=head3 remove_from_bundle |
2454 |
=head3 remove_from_bundle |
| 2451 |
- |
|
|