Bugzilla – Attachment 180214 Details for
Bug 35292
Define itemtype specific rules in the UpdateNotForLoanStatusOnCheckOut system preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35292: Have UpdateNotForLoanStatusOnCheckOut and UpdateNotForLoanStatusOnCheckIn use the same function
Bug-35292-Have-UpdateNotForLoanStatusOnCheckOut-an.patch (text/plain), 6.25 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-04-01 15:27:50 UTC
(
hide
)
Description:
Bug 35292: Have UpdateNotForLoanStatusOnCheckOut and UpdateNotForLoanStatusOnCheckIn use the same function
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-04-01 15:27:50 UTC
Size:
6.25 KB
patch
obsolete
>From f96206ef675006cf062a905dfdd39d6c5e2cd9d0 Mon Sep 17 00:00:00 2001 >From: Baptiste <baptiste.wojtkowski@biblibre.com> >Date: Wed, 4 Dec 2024 16:43:15 +0100 >Subject: [PATCH] Bug 35292: Have UpdateNotForLoanStatusOnCheckOut and > UpdateNotForLoanStatusOnCheckIn use the same function > >Both sysprefs use the same codebase. Hence the recent upgrades for >UpdateNotForLoanStatusOnCheckOut were not applyied to checkout. >In this patch, we refacto code in order to have them both use the same >function. > >Test plan: >Do not apply patch: >1 - Set UpdateNotForLoanStatusOnCheckout to >0: 2 >2 - Set UpdateNotForLoanStatusOnCheckin to >_ALL_: > 2: 0 >3 - Check out a book -> Its notforloan status is set to 2 >4 - Check in the book -> Its notforloan status is set to 0, you get a > notification >6 - APPLY PATCH >7 - Set UpdateNotForLoanStatusOnCheckin to >_ALL_: > 2: 0 > >BK: > 3: 0 > >CR: > 4: 0 > >8 - Set UpdateNotForLoanStatusOnCheckOut to >_ALL_: > 2: 0 > >BK: > 3: 0 > >CR: > 4: 0 > >8 - Check out a book -> Its notforloan status is set to 3 >9 - Check in the book -> Its notforloan status is set to 0, you get a >10 - Check out a continuing resource -> Its notforloan status is set to 4 >11 - Check in a continuing resource -> Its notforloan status is set to 0 >11 - Check out another type of resource -> Its notforloan status is set to 2 >12 - Check in the document -> Its notforloan status is set to 0 > notification >--- > C4/Circulation.pm | 73 +++++++++++++++++++++++------------------------ > 1 file changed, 35 insertions(+), 38 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 31794b7c02f..79b6beb8a15 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1836,17 +1836,7 @@ sub AddIssue { > $item_unblessed->{charge} = $charge; > } > } >- >- my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckout'); >- if ($rules) { >- foreach my $key ( keys %$rules ) { >- if ( $item_object->notforloan eq $key ) { >- $item_object->notforloan( $rules->{$key} ) >- ->store( { log_action => 0, skip_record_index => 1 } ); >- last; >- } >- } >- } >+ _updateNotForLoanFromYaml( $item_object, 'UpdateNotForLoanStatusOnCheckout' ); > > # Record the fact that this book was issued. > C4::Stats::UpdateStats( >@@ -2175,7 +2165,7 @@ sub AddReturn { > $branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default > my $return_date_specified = !!$return_date; > $return_date //= dt_from_string(); >- my $messages; >+ my $messages = {}; > my $patron; > my $doreturn = 1; > my $validTransfer = 1; >@@ -2256,32 +2246,7 @@ sub AddReturn { > $messages->{$loc_msg_key} = $loc_messages->{$loc_msg_key}; > } > >- my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckin'); >- if ($rules) { >- if ( defined $rules->{ $item->itype } ) { >- foreach my $notloan_rule_key ( keys %{ $rules->{ $item->itype } } ) { >- if ( $item->notforloan eq $notloan_rule_key ) { >- $messages->{'NotForLoanStatusUpdated'} = >- { from => $item->notforloan, to => $rules->{ $item->itype }->{$notloan_rule_key} }; >- $item->notforloan( $rules->{ $item->itype }->{$notloan_rule_key} ) >- ->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) >- unless $rules->{ $item->itype }->{$notloan_rule_key} eq 'ONLYMESSAGE'; >- last; >- } >- } >- } elsif ( defined $rules->{'_ALL_'} ) { >- foreach my $notloan_rule_key ( keys %{ $rules->{'_ALL_'} } ) { >- if ( $item->notforloan eq $notloan_rule_key ) { >- $messages->{'NotForLoanStatusUpdated'} = >- { from => $item->notforloan, to => $rules->{'_ALL_'}->{$notloan_rule_key} }; >- $item->notforloan( $rules->{'_ALL_'}->{$notloan_rule_key} ) >- ->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) >- unless $rules->{'_ALL_'}->{$notloan_rule_key} eq 'ONLYMESSAGE'; >- last; >- } >- } >- } >- } >+ _updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin', $messages ); > > # check if the return is allowed at this branch > my ( $returnallowed, $message ) = CanBookBeReturned( $item->unblessed, $branch ); >@@ -4807,6 +4772,38 @@ sub _CanBookBeAutoRenewed { > return "ok"; > } > >+sub _updateNotForLoanFromYaml { >+ my ( $item, $NotForLoanUpdatePreference, $messages ) = @_; >+ >+ >+ my $rules = C4::Context->yaml_preference($NotForLoanUpdatePreference); >+ if ($rules) { >+ if ( defined $rules->{ $item->itype } ) { >+ foreach my $notloan_rule_key ( keys %{ $rules->{ $item->itype } } ) { >+ if ( $item->notforloan eq $notloan_rule_key ) { >+ $messages->{'NotForLoanStatusUpdated'} = >+ { from => $item->notforloan, to => $rules->{ $item->itype }->{$notloan_rule_key} }; >+ $item->notforloan( $rules->{ $item->itype }->{$notloan_rule_key} ) >+ ->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) >+ unless $rules->{ $item->itype }->{$notloan_rule_key} eq 'ONLYMESSAGE'; >+ last; >+ } >+ } >+ } elsif ( defined $rules->{'_ALL_'} ) { >+ foreach my $notloan_rule_key ( keys %{ $rules->{'_ALL_'} } ) { >+ if ( $item->notforloan eq $notloan_rule_key ) { >+ $messages->{'NotForLoanStatusUpdated'} = >+ { from => $item->notforloan, to => $rules->{'_ALL_'}->{$notloan_rule_key} }; >+ $item->notforloan( $rules->{'_ALL_'}->{$notloan_rule_key} ) >+ ->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) >+ unless $rules->{'_ALL_'}->{$notloan_rule_key} eq 'ONLYMESSAGE'; >+ last; >+ } >+ } >+ } >+ } >+} >+ > 1; > > __END__ >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35292
:
175201
|
175202
|
175203
|
175316
|
175317
|
175318
|
175319
|
175320
|
175321
|
175322
|
179818
|
179819
|
179820
|
179821
|
179822
|
179823
|
179824
|
180101
|
180102
|
180103
|
180104
|
180105
|
180106
|
180181
|
180182
|
180183
|
180184
|
180185
|
180186
|
180210
|
180212
|
180213
|
180214
|
180215
|
180216
|
180217
|
180218
|
180632
|
180633
|
180634
|
180635
|
180636
|
180637
|
180638
|
180646