From f8544ba5799c457057d42aefc63c88e15a08b096 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Dec 2018 18:26:47 -0300 Subject: [PATCH] Bug 21999: Move attributes to a variable to not dup them Avoid c/p as much as possible :) Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- C4/Circulation.pm | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0afed47e11..5581a84f5a 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1356,30 +1356,24 @@ sub AddIssue { } $datedue->truncate( to => 'minute' ); - $issue = - Koha::Checkouts->find( { itemnumber => $item->{'itemnumber'} } ); + my $issue_attributes = { + borrowernumber => $borrower->{'borrowernumber'}, + issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), + date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), + branchcode => C4::Context->userenv->{'branch'}, + onsite_checkout => $onsite_checkout, + auto_renew => $auto_renew ? 1 : 0, + }; + + $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); if ($issue) { - $issue->set( - { - borrowernumber => $borrower->{'borrowernumber'}, - issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), - date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), - branchcode => C4::Context->userenv->{'branch'}, - onsite_checkout => $onsite_checkout, - auto_renew => $auto_renew ? 1 : 0 - } - )->store; + $issue->set($issue_attributes)->store; } else { $issue = Koha::Checkout->new( { - borrowernumber => $borrower->{'borrowernumber'}, - itemnumber => $item->{'itemnumber'}, - issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), - date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), - branchcode => C4::Context->userenv->{'branch'}, - onsite_checkout => $onsite_checkout, - auto_renew => $auto_renew ? 1 : 0 + itemnumber => $item->{itemnumber}, + %$issue_attributes, } )->store; } -- 2.39.2