From be140718d71df9521dca38d51ebe0ee77d7efa9a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 20 Dec 2016 13:57:00 +0100 Subject: [PATCH] Bug 17796: Replace Koha::Issue[s] with Koha::Checkout[s] Koha::Issues and Koha::Checkouts have been added to the codebase to represent the same thing. In ODLIS the word Issue is never used in the sense we use it. Another problem with Issue is it has so many meaning in English (such as problem/bug) The word Checkout *is* in ODLIS, closer to what we use: http://www.abc-clio.com/ODLIS/odlis_c.aspx#checkoutslip Test plan: git grep Koha::Issue should not return any occurrences and the tests must still pass Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- Koha/Issue.pm | 28 -------------- Koha/Issues.pm | 33 ---------------- Koha/Patron.pm | 6 +-- Koha/REST/V1.pm | 6 +-- t/db_dependent/Circulation.t | 4 +- t/db_dependent/Koha/Issues.t | 60 ----------------------------- t/db_dependent/Koha/Patrons.t | 8 ++-- t/db_dependent/Template/Plugin/Categories.t | 4 +- 8 files changed, 14 insertions(+), 135 deletions(-) delete mode 100644 Koha/Issue.pm delete mode 100644 Koha/Issues.pm delete mode 100644 t/db_dependent/Koha/Issues.t diff --git a/Koha/Issue.pm b/Koha/Issue.pm deleted file mode 100644 index 8b67235..0000000 --- a/Koha/Issue.pm +++ /dev/null @@ -1,28 +0,0 @@ -package Koha::Issue; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use Koha::Database; - -use base qw(Koha::Object); - -sub _type { - return 'Issue'; -} - -1; diff --git a/Koha/Issues.pm b/Koha/Issues.pm deleted file mode 100644 index f0b2216..0000000 --- a/Koha/Issues.pm +++ /dev/null @@ -1,33 +0,0 @@ -package Koha::Issues; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use Koha::Database; -use Koha::Issue; - -use base qw(Koha::Objects); - -sub _type { - return 'Issue'; -} - -sub object_class { - return 'Koha::Issue'; -} - -1; diff --git a/Koha/Patron.pm b/Koha/Patron.pm index c1b5351..fe2d844 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -24,10 +24,10 @@ use Carp; use C4::Context; use C4::Log; +use Koha::Checkouts; use Koha::Database; use Koha::DateUtils; use Koha::Holds; -use Koha::Issues; use Koha::OldIssues; use Koha::Patron::Categories; use Koha::Patron::HouseboundProfile; @@ -257,7 +257,7 @@ sub do_check_for_previous_checkout { }; # Check current issues table - my $issues = Koha::Issues->search($criteria); + my $issues = Koha::Checkouts->search($criteria); return 1 if $issues->count; # 0 || N # Check old issues table @@ -512,7 +512,7 @@ Return the overdued items sub get_overdues { my ($self) = @_; my $dtf = Koha::Database->new->schema->storage->datetime_parser; - my $issues = Koha::Issues->search( + my $issues = Koha::Checkouts->search( { 'me.borrowernumber' => $self->borrowernumber, 'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) }, diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm index 76ae180..5e1eded 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -21,7 +21,7 @@ use Mojo::Base 'Mojolicious'; use C4::Auth qw( check_cookie_auth get_session haspermission ); use C4::Context; use Koha::Account::Lines; -use Koha::Issues; +use Koha::Checkouts; use Koha::Holds; use Koha::OldIssues; use Koha::Patrons; @@ -259,7 +259,7 @@ sub _object_ownership_by_borrowernumber { =head3 _object_ownership_by_checkout_id -First, attempts to find a Koha::Issue-object by C<$issue_id>. If we find one, +First, attempts to find a Koha::Checkout-object by C<$issue_id>. If we find one, compare its borrowernumber to currently logged in C<$user>. However, if an issue is not found, attempt to find a Koha::OldIssue-object instead and compare its borrowernumber to currently logged in C<$user>. @@ -269,7 +269,7 @@ borrowernumber to currently logged in C<$user>. sub _object_ownership_by_checkout_id { my ($c, $user, $issue_id) = @_; - my $issue = Koha::Issues->find($issue_id); + my $issue = Koha::Checkouts->find($issue_id); $issue = Koha::OldIssues->find($issue_id) unless $issue; return $issue && $issue->borrowernumber && $user->borrowernumber == $issue->borrowernumber; diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f29dcd0..5dc3dbf 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1049,7 +1049,7 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { set_userenv($holdingbranch); my $issue = AddIssue( $patron_1, $item->{barcode} ); - is( ref($issue), 'Koha::Schema::Result::Issue' ); # FIXME Should be Koha::Issue + is( ref($issue), 'Koha::Schema::Result::Issue' ); # FIXME Should be Koha::Checkout my ( $error, $question, $alerts ); @@ -1138,7 +1138,7 @@ subtest 'AddIssue & AllowReturnToBranch' => sub { set_userenv($holdingbranch); - my $ref_issue = 'Koha::Schema::Result::Issue'; # FIXME Should be Koha::Issue + my $ref_issue = 'Koha::Schema::Result::Issue'; # FIXME Should be Koha::Checkout my $issue = AddIssue( $patron_1, $item->{barcode} ); my ( $error, $question, $alerts ); diff --git a/t/db_dependent/Koha/Issues.t b/t/db_dependent/Koha/Issues.t deleted file mode 100644 index 38023c8..0000000 --- a/t/db_dependent/Koha/Issues.t +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2015 Koha Development team -# -# This file is part of Koha -# -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see . - -use Modern::Perl; - -use Test::More tests => 4; - -use Koha::Issue; -use Koha::Issues; -use Koha::Database; - -use t::lib::TestBuilder; - -my $schema = Koha::Database->new->schema; -$schema->storage->txn_begin; - -my $builder = t::lib::TestBuilder->new; -my $patron = $builder->build( { source => 'Borrower' } ); -my $item_1 = $builder->build( { source => 'Item' } ); -my $item_2 = $builder->build( { source => 'Item' } ); -my $nb_of_issues = Koha::Issues->search->count; -my $new_issue_1 = Koha::Issue->new( - { borrowernumber => $patron->{borrowernumber}, - itemnumber => $item_1->{itemnumber}, - } -)->store; -my $new_issue_2 = Koha::Issue->new( - { borrowernumber => $patron->{borrowernumber}, - itemnumber => $item_2->{itemnumber}, - } -)->store; - -like( $new_issue_1->issue_id, qr|^\d+$|, 'Adding a new issue should have set the issue_id' ); -is( Koha::Issues->search->count, $nb_of_issues + 2, 'The 2 issues should have been added' ); - -my $retrieved_issue_1 = Koha::Issues->find( $new_issue_1->issue_id ); -is( $retrieved_issue_1->itemnumber, $new_issue_1->itemnumber, 'Find a issue by id should return the correct issue' ); - -$retrieved_issue_1->delete; -is( Koha::Issues->search->count, $nb_of_issues + 1, 'Delete should delete the issue' ); - -$schema->storage->txn_rollback; - -1; diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index a5a718d..67506d2 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -146,11 +146,11 @@ subtest 'has_overdues' => sub { is( $retrieved_patron->has_overdues, 0, ); my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); - my $issue = Koha::Issue->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->{itemnumber}, date_due => $tomorrow, branchcode => $library->{branchcode} })->store(); + my $issue = Koha::Checkout->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->{itemnumber}, date_due => $tomorrow, branchcode => $library->{branchcode} })->store(); is( $retrieved_patron->has_overdues, 0, ); $issue->delete(); my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); - $issue = Koha::Issue->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->{itemnumber}, date_due => $yesterday, branchcode => $library->{branchcode} })->store(); + $issue = Koha::Checkout->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->{itemnumber}, date_due => $yesterday, branchcode => $library->{branchcode} })->store(); $retrieved_patron = Koha::Patrons->find( $new_patron_1->borrowernumber ); is( $retrieved_patron->has_overdues, 1, ); $issue->delete(); @@ -468,12 +468,12 @@ subtest 'get_overdues' => sub { $patron = Koha::Patrons->find( $patron->{borrowernumber} ); my $overdues = $patron->get_overdues; is( $overdues->count, 2, 'Patron should have 2 overdues'); - is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' ); + is( ref($overdues), 'Koha::Checkouts', 'Koha::Patron->get_overdues should return Koha::Checkouts' ); is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); # Clean stuffs - Koha::Issues->search( { borrowernumber => $patron->borrowernumber } )->delete; + Koha::Checkouts->search( { borrowernumber => $patron->borrowernumber } )->delete; $patron->delete; }; diff --git a/t/db_dependent/Template/Plugin/Categories.t b/t/db_dependent/Template/Plugin/Categories.t index afa8b20..5ae4a2f 100644 --- a/t/db_dependent/Template/Plugin/Categories.t +++ b/t/db_dependent/Template/Plugin/Categories.t @@ -21,7 +21,7 @@ use Test::More tests => 4; use t::lib::TestBuilder; use Koha::Patron::Categories; -use Koha::Issues; +use Koha::Checkouts; use Koha::Patrons; use Koha::Database; use Koha::Template::Plugin::Categories; @@ -30,7 +30,7 @@ my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; # Delete all categories -Koha::Issues->search->delete; +Koha::Checkouts->search->delete; Koha::Patrons->search->delete; Koha::Patron::Categories->search->delete; -- 2.1.4