Bug 41438: Do not always unsuspend holds when using batch modify holds tool

If one modifies suspended holds e.g. changes their pickup library, holds
are unsuspended. This happens due error in logic of checking if "Suspend
holds" selection is empty. This patch fixes this by moving the if statement
for checking new suspended status before doing anything else for the value.

To reproduce:
1. Navigate to Tools->Batch modify holds.
2. Search suspended holds.
3. Select a hold to modify and change it's pickup library, but leave
"Suspend holds" selection empty.
4. Press "Modify holds".
=> Note that hold is now unsuspended.
5. Apply this patch, start services again if needed.
6. Repeat steps from 2. to 4.
=> Note that hold is not suspended.
=> Confirm that suspending and unsuspending with and without suspend date
still works as expected.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Emmi Takkinen 2025-12-12 12:58:22 +02:00 committed by Lucas Gass
parent 9e7401ea1b
commit 8798d60bec
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 11 additions and 9 deletions

View File

@ -74,19 +74,21 @@ if ( $op eq 'cud-form' ) {
$hold->branchcode($new_pickup_loc)->store;
}
if ( $new_suspend_status && $new_suspend_status ne "" && !$hold->is_found ) {
$hold->suspend(1)->store;
if ($new_suspend_date) {
if ( $new_suspend_status ne "" ) {
if ( $new_suspend_status && !$hold->is_found ) {
$hold->suspend(1)->store;
if ($new_suspend_date) {
$hold->suspend_until($new_suspend_date)->store;
} else {
$hold->suspend_until(undef)->store;
}
} elsif ( !$new_suspend_status && $new_suspend_date ) {
$hold->suspend(1)->store;
$hold->suspend_until($new_suspend_date)->store;
} else {
$hold->suspend(0)->store;
$hold->suspend_until(undef)->store;
}
} elsif ( !$new_suspend_status && $new_suspend_date ) {
$hold->suspend(1)->store;
$hold->suspend_until($new_suspend_date)->store;
} else {
$hold->suspend(0)->store;
$hold->suspend_until(undef)->store;
}
if ($new_hold_note) {