Bugzilla – Attachment 139899 Details for
Bug 30016
Remove GetOpenIssue subroutine
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30016: Remove GetOpenIssue subroutine
Bug-30016-Remove-GetOpenIssue-subroutine.patch (text/plain), 7.87 KB, created by
Katrin Fischer
on 2022-08-28 09:27:12 UTC
(
hide
)
Description:
Bug 30016: Remove GetOpenIssue subroutine
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2022-08-28 09:27:12 UTC
Size:
7.87 KB
patch
obsolete
>From 9b401a7535da0e0bffd9d460f08afc50ed5ca5b0 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 3 Feb 2022 13:14:33 +0000 >Subject: [PATCH] Bug 30016: Remove GetOpenIssue subroutine > >This patch adjusts the code that uses GetOpenIssue to use/find a Koha::Checkout object >instead > >To test: >1 - Add a course to course reserves >2 - Create an item with barcode TESTKOC >3 - Add the item to a course >4 - Checkout the item >5 - View course details on stff and opac and confirm item shows as checked out and due date displays >6 - prove t/db_dependent/Circulation/issue.t t/db_dependent/Circulation.t t/db_dependent/CourseReserves.t >7 - Browse to Circulation->Upload offline circulation >8 - Upload a file to return the item: https://wiki.koha-community.org/wiki/Koha_offline_circulation_file_format >9 - Confirm item is returned > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Circulation.pm | 33 +++++------------------------- > C4/CourseReserves.pm | 4 ++-- > offline_circ/process_koc.pl | 11 +++++----- > t/db_dependent/Circulation/issue.t | 10 ++------- > 4 files changed, 14 insertions(+), 44 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 87f892ab4b..58ceeae3d1 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -95,7 +95,6 @@ BEGIN { > GetBranchBorrowerCircRule > GetBranchItemRule > GetBiblioIssues >- GetOpenIssue > GetUpcomingDueIssues > CheckIfIssuedToPatron > IsItemIssued >@@ -2790,28 +2789,6 @@ sub _GetCircControlBranch { > return $branch; > } > >-=head2 GetOpenIssue >- >- $issue = GetOpenIssue( $itemnumber ); >- >-Returns the row from the issues table if the item is currently issued, undef if the item is not currently issued >- >-C<$itemnumber> is the item's itemnumber >- >-Returns a hashref >- >-=cut >- >-sub GetOpenIssue { >- my ( $itemnumber ) = @_; >- return unless $itemnumber; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" ); >- $sth->execute( $itemnumber ); >- return $sth->fetchrow_hashref(); >- >-} >- > =head2 GetUpcomingDueIssues > > my $upcoming_dues = GetUpcomingDueIssues( { days_in_advance => 4 } ); >@@ -4011,12 +3988,12 @@ sub ProcessOfflineReturn { > > if ( $item ) { > my $itemnumber = $item->itemnumber; >- my $issue = GetOpenIssue( $itemnumber ); >+ my $issue = $item->checkout; > if ( $issue ) { > my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; > ModDateLastSeen( $itemnumber, $leave_item_lost ); > MarkIssueReturned( >- $issue->{borrowernumber}, >+ $issue->borrowernumber, > $itemnumber, > $operation->{timestamp}, > ); >@@ -4043,11 +4020,11 @@ sub ProcessOfflineIssue { > return "Barcode not found."; > } > my $itemnumber = $item->itemnumber; >- my $issue = GetOpenIssue( $itemnumber ); >+ my $issue = $item->checkout; > >- if ( $issue and ( $issue->{borrowernumber} ne $patron->borrowernumber ) ) { # Item already issued to another patron mark it returned >+ if ( $issue and ( $issue->borrowernumber ne $patron->borrowernumber ) ) { # Item already issued to another patron mark it returned > MarkIssueReturned( >- $issue->{borrowernumber}, >+ $issue->borrowernumber, > $itemnumber, > $operation->{timestamp}, > ); >diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm >index 7f9a4aa7f6..fac8b849e2 100644 >--- a/C4/CourseReserves.pm >+++ b/C4/CourseReserves.pm >@@ -20,12 +20,12 @@ use Modern::Perl; > use List::MoreUtils qw( any ); > > use C4::Context; >-use C4::Circulation qw( GetOpenIssue ); > > use Koha::Courses; > use Koha::Course::Instructors; > use Koha::Course::Items; > use Koha::Course::Reserves; >+use Koha::Checkouts; > > use vars qw(@FIELDS); > our (@ISA, @EXPORT_OK); >@@ -873,7 +873,7 @@ sub GetCourseReserves { > $cr->{'item'} = $item; > $cr->{'biblio'} = $biblio; > $cr->{'biblioitem'} = $biblioitem; >- $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} ); >+ $cr->{'issue'} = Koha::Checkouts->find({ itemnumber => $cr->{'itemnumber'} }); > } > } > >diff --git a/offline_circ/process_koc.pl b/offline_circ/process_koc.pl >index b3dc48a54c..b99f5b29ee 100755 >--- a/offline_circ/process_koc.pl >+++ b/offline_circ/process_koc.pl >@@ -26,7 +26,7 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); > use C4::Context; > use C4::Accounts; >-use C4::Circulation qw( barcodedecode GetOpenIssue AddRenewal AddIssue MarkIssueReturned ); >+use C4::Circulation qw( barcodedecode AddRenewal AddIssue MarkIssueReturned ); > use C4::Items qw( ModDateLastSeen ); > use C4::Members; > use C4::Stats; >@@ -253,13 +253,12 @@ sub kocIssueItem { > > if ( $issue ) { ## Item is currently checked out to another person. > #warn "Item Currently Issued."; >- my $issue = GetOpenIssue( $item->itemnumber ); # FIXME Hum? That does not make sense, if it's in the issue table, the issue is open (i.e. returndate is null) > >- if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it. >+ if ( $issue->borrowernumber eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it. > #warn "Item issued to this member already, renewing."; > > C4::Circulation::AddRenewal( >- $issue->{'borrowernumber'}, # borrowernumber >+ $issue->borrowernumber, # borrowernumber > $item->itemnumber, # itemnumber > undef, # branch > undef, # datedue - let AddRenewal calculate it automatically >@@ -280,9 +279,9 @@ sub kocIssueItem { > > } else { > #warn "Item issued to a different member."; >- #warn "Date of previous issue: $issue->{'issuedate'}"; >+ #warn "Date of previous issue: $issue->issuedate"; > #warn "Date of this issue: $circ->{'date'}"; >- my ( $i_y, $i_m, $i_d ) = split( /-/, $issue->{'issuedate'} ); >+ my ( $i_y, $i_m, $i_d ) = split( /-/, $issue->issuedate ); > my ( $c_y, $c_m, $c_d ) = split( /-/, $circ->{'date'} ); > > if ( Date_to_Days( $i_y, $i_m, $i_d ) < Date_to_Days( $c_y, $c_m, $c_d ) ) { ## Current issue to a different persion is older than this issue, return and issue. >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index 81d5e6742c..5fc658b57f 100755 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -17,14 +17,14 @@ > > use Modern::Perl; > >-use Test::More tests => 50; >+use Test::More tests => 48; > use DateTime::Duration; > > use t::lib::Mocks; > use t::lib::TestBuilder; > > use C4::Biblio qw( AddBiblio ); >-use C4::Circulation qw( AddIssue AddIssuingCharge AddRenewal AddReturn GetIssuingCharges GetOpenIssue GetRenewCount GetUpcomingDueIssues ); >+use C4::Circulation qw( AddIssue AddIssuingCharge AddRenewal AddReturn GetIssuingCharges GetRenewCount GetUpcomingDueIssues ); > use C4::Context; > use C4::Items; > use C4::Reserves qw( AddReserve ); >@@ -49,7 +49,6 @@ can_ok( > AddRenewal > AddReturn > GetIssuingCharges >- GetOpenIssue > GetRenewCount > GetUpcomingDueIssues > ) >@@ -296,11 +295,6 @@ subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub { > } > }; > >-#Test GetOpenIssue >-is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" ); >-is( GetOpenIssue(-1), undef, >- "With wrong parameter GetOpenIssue returns undef" ); >-my $openissue = GetOpenIssue($borrower_id1, $item_id1); > > my @renewcount; > #Test GetRenewCount >-- >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 30016
:
130141
|
130142
|
130497
|
139400
|
139451
| 139899