Bug 21999: Move attributes to a variable to not dup them
Avoid c/p as much as possible :) Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
eb979680d7
commit
f8544ba579
1 changed files with 13 additions and 19 deletions
|
@ -1356,30 +1356,24 @@ sub AddIssue {
|
||||||
}
|
}
|
||||||
$datedue->truncate( to => 'minute' );
|
$datedue->truncate( to => 'minute' );
|
||||||
|
|
||||||
$issue =
|
my $issue_attributes = {
|
||||||
Koha::Checkouts->find( { itemnumber => $item->{'itemnumber'} } );
|
|
||||||
if ($issue) {
|
|
||||||
$issue->set(
|
|
||||||
{
|
|
||||||
borrowernumber => $borrower->{'borrowernumber'},
|
borrowernumber => $borrower->{'borrowernumber'},
|
||||||
issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'),
|
issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'),
|
date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
branchcode => C4::Context->userenv->{'branch'},
|
branchcode => C4::Context->userenv->{'branch'},
|
||||||
onsite_checkout => $onsite_checkout,
|
onsite_checkout => $onsite_checkout,
|
||||||
auto_renew => $auto_renew ? 1 : 0
|
auto_renew => $auto_renew ? 1 : 0,
|
||||||
}
|
};
|
||||||
)->store;
|
|
||||||
|
$issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
|
||||||
|
if ($issue) {
|
||||||
|
$issue->set($issue_attributes)->store;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$issue = Koha::Checkout->new(
|
$issue = Koha::Checkout->new(
|
||||||
{
|
{
|
||||||
borrowernumber => $borrower->{'borrowernumber'},
|
itemnumber => $item->{itemnumber},
|
||||||
itemnumber => $item->{'itemnumber'},
|
%$issue_attributes,
|
||||||
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;
|
)->store;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue