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 <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-12-20 13:57:00 +01:00 committed by Kyle M Hall
parent d4b15e40b0
commit be140718d7
8 changed files with 14 additions and 135 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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) },

View File

@ -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;

View File

@ -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 );

View File

@ -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 <http://www.gnu.org/licenses>.
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;

View File

@ -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;
};

View File

@ -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;