From 62e9307af1ee6eb211cbab19c73d179c6d3ceb38 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 13 Feb 2014 13:49:24 -0500 Subject: [PATCH] Bug 11629 [QA Followup 2] - Move code to inside of doreturn if statement --- C4/Circulation.pm | 43 ++++++++++++++++++++++--------------------- 1 files changed, 22 insertions(+), 21 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 28ffb37..dcf29a9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1755,26 +1755,6 @@ sub AddReturn { my $borrowernumber = $borrower->{'borrowernumber'} || undef; # we don't know if we had a borrower or not - my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); - if ($yaml) { - $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt - my $rules; - eval { $rules = YAML::Load($yaml); }; - if ($@) { - warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; - } - else { - foreach my $key ( keys %$rules ) { - if ( $item->{notforloan} eq $key ) { - $messages->{'NotForLoanStatusUpdated'} = { from => $item->{notforloan}, to => $rules->{$key} }; - ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber ); - last; - } - } - } - } - - # check if the book is in a permanent collection.... # FIXME -- This 'PE' attribute is largely undocumented. afaict, there's no user interface that reflects this functionality. if ( $hbr ) { @@ -1846,7 +1826,28 @@ sub AddReturn { } - ModItem({ onloan => undef }, $issue->{'biblionumber'}, $item->{'itemnumber'}); + my $fields = { onloan => undef }; + + my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); + if ($yaml) { + $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt + my $rules; + eval { $rules = YAML::Load($yaml); }; + if ($@) { + warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; + } + else { + foreach my $key ( keys %$rules ) { + if ( $item->{notforloan} eq $key ) { + $messages->{'NotForLoanStatusUpdated'} = { from => $item->{notforloan}, to => $rules->{$key} }; + $fields->{notforloan} = $rules->{$key}; + last; + } + } + } + } + + ModItem( $fields, $issue->{'biblionumber'}, $item->{'itemnumber'} ); } # the holdingbranch is updated if the document is returned to another location. -- 1.7.2.5