From e8d3abc53767189894bb3af3dc8e8a26b20068cd Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 2 Aug 2022 17:05:39 +1200 Subject: [PATCH] Bug 25560: Define item-type specific rules in UpdateNotForLoanStatusOnCheckin This enhancement respects the 'item-level_itypes' syspref, so will look at the authoritative item type when determining to update the notforloan status. Test plan: 1. Set -1 to 'Ordered', and 1 to 'Not for Loan' in Administration > Authorised values > NOT_LOAN 2. Make sure the 'item-level_itypes' syspref is set to 'specific item' 3. Add the following rules in UpdateNotForLoanStatusOnCheckin system preference: -1: 0 4. Apply patch & update database cd installer/data/mysql sudo koha-shell ./updatedatabase.pl 5. Restart plack 6. Observe the UpdateNotForLoanStatusOnCheckin syspref values have updated to the following format: : -1: 0 : -1: 0 etc. Each item type setup in Koha has the existing rule(s) listed under it 7. Check in an 'Ordered' item of any item type and confirm it is changed to 'Available for loan' 8. Reset the UpdateNotForLoanStatusOnCheckin syspref to: BK: -1: 0 CD: 1: 0 9. Check-in an 'ordered' BK item (item level itype='BK') and observe the item's notforloan status updates 10. Check-in a 'Not for Loan' CD item (item level itype='CD') and observe the item's notforloan status updates 11. Check-in an 'ordered' DVD item (item level itype='DVD') and observe the items notforloan status does not change Sponsored-By: Waikato Institute of Technology, NZ --- C4/Circulation.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9cb56f79d32..ebafbc01e62 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2141,10 +2141,16 @@ sub AddReturn { } else { foreach my $key ( keys %$rules ) { - if ( $item->notforloan eq $key ) { - $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; - $item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }); - last; + + # Check and apply rules for the item type being returned + if ( $item->itype eq $key ) { + foreach my $itype_rule_key ( keys %{ $rules->{$key}} ) { + if ( $item->notforloan eq $itype_rule_key ) { + $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key}->{$itype_rule_key} }; + $item->notforloan($rules->{$key}->{$itype_rule_key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }); + last; + } + } } } } -- 2.20.1