From 1ad014fcb57533ef1366c3e2d1199cd099f3b2c7 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 21 Jul 2017 11:44:46 +0200 Subject: [PATCH] Bug 1xxxx: Use autoincrement in AddIssue Content-Type: text/plain; charset=utf-8 --- C4/Circulation.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index cb60da3..bde3458 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1361,8 +1361,7 @@ sub AddIssue { } $datedue->truncate( to => 'minute' ); - $issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( - { + my $cols = { borrowernumber => $borrower->{'borrowernumber'}, itemnumber => $item->{'itemnumber'}, issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), @@ -1370,8 +1369,12 @@ sub AddIssue { branchcode => C4::Context->userenv->{'branch'}, onsite_checkout => $onsite_checkout, auto_renew => $auto_renew ? 1 : 0 - } - ); + }; + unless( Koha::Checkouts->search({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'} }) ) { + my $id = Koha::Autoincrements->find('issues')->increment; + $cols->{issue_id} = $id; + } + $issue = Koha::Database->new->schema->resultset('Issue')->update_or_create( $cols ); if ( C4::Context->preference('ReturnToShelvingCart') ) { # ReturnToShelvingCart is on, anything issued should be taken off the cart. -- 2.1.4