diff --git a/Koha/Item.pm b/Koha/Item.pm
index 95968fa2dd..73a469fa79 100644
--- a/Koha/Item.pm
+++ b/Koha/Item.pm
@@ -927,13 +927,13 @@ sub get_transfers {
return Koha::Item::Transfers->_new_from_dbic($transfers_rs);
}
-=head3 last_returned_by_all
+=head3 last_borrowers
Returns all patrons who have returned this item, ordered by most recent first.
=cut
-sub last_returned_by_all {
+sub last_borrowers {
my ($self) = @_;
my $max_stored_borrowers = C4::Context->preference('StoreLastBorrower') || 0;
@@ -977,7 +977,7 @@ sub last_returned_by {
# If StoreLastBorrower is 0 or disabled, bail without storing anything. Also delete any remaining rows from the table.
if ( $max_stored_borrowers == 0 ) {
- $self->last_returned_by_all->delete;
+ $self->last_borrowers->delete;
return $self;
}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
index 5d28a6a93a..f9313d0dd2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
@@ -495,7 +495,7 @@
[% IF Koha.Preference('StoreLastBorrower') && Koha.Preference('StoreLastBorrower') > 0 %]
- [% SET all_borrowers = ITEM_DAT.object.last_returned_by_all %]
+ [% SET all_borrowers = ITEM_DAT.object.last_borrowers %]
[% IF all_borrowers.count > 0 %]
Last returned by:
diff --git a/t/db_dependent/Circulation/StoreLastBorrower.t b/t/db_dependent/Circulation/StoreLastBorrower.t
index f395e24d1b..9b40efe9fb 100755
--- a/t/db_dependent/Circulation/StoreLastBorrower.t
+++ b/t/db_dependent/Circulation/StoreLastBorrower.t
@@ -150,10 +150,10 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
my $item = $builder->build_sample_item;
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
- # Test last_returned_by_all with no borrowers
+ # Test last_borrowers with no borrowers
t::lib::Mocks::mock_preference( 'StoreLastBorrower', '3' );
- my $borrowers = $item->last_returned_by_all();
- is( $borrowers->count, 0, 'last_returned_by_all returns empty set when no borrowers stored' );
+ my $borrowers = $item->last_borrowers();
+ is( $borrowers->count, 0, 'last_borrowers returns empty set when no borrowers stored' );
# Add 3 borrowers for testing, checkout/check in
my @patrons;
@@ -182,8 +182,8 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
$item = $item->get_from_storage;
- # Test last_returned_by_all returns all borrowers
- $borrowers = $item->last_returned_by_all();
+ # Test last_borrowers returns all borrowers
+ $borrowers = $item->last_borrowers();
is( $borrowers->count, 3, 'Correctly returns 3 borrowers' );
# Test ordering
@@ -217,7 +217,7 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
}
$item = $item->get_from_storage;
- $borrowers = $item->last_returned_by_all();
+ $borrowers = $item->last_borrowers();
is(
$borrowers->count, 3,
'We only retain 3 borrowers when the sys pref is set to 3, even though there are 5 checkouts/checkins'
@@ -251,7 +251,7 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
);
$item = $item->get_from_storage;
- $borrowers = $item->last_returned_by_all();
+ $borrowers = $item->last_borrowers();
is( $borrowers->count, 2, 'StoreLastBorrower was reduced to 2, we should now only keep 2 in the table' );
@borrowers_array = $borrowers->as_list;
is(
@@ -286,8 +286,8 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
);
$item = $item->get_from_storage;
- $borrowers = $item->last_returned_by_all();
- is( $borrowers->count, 0, 'last_returned_by_all respects preference value 0' );
+ $borrowers = $item->last_borrowers();
+ is( $borrowers->count, 0, 'last_borrowers respects preference value 0' );
my $cleanup_patron = $builder->build(
{
@@ -312,7 +312,7 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
);
$item = $item->get_from_storage;
- $borrowers = $item->last_returned_by_all();
+ $borrowers = $item->last_borrowers();
is( $borrowers->count, 0, 'All entries cleared when preference is 0' );
is( $item->last_returned_by, undef, 'last_returned_by returns undef when no records' );