From b986ae573ccaf84d462e40a8f2480cd0dc14a928 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Thu, 26 Mar 2020 06:30:09 +0000 Subject: [PATCH] Bug 24101: Enable renewals for on-site checkouts To test: 1. Enable system preference OnSiteCheckouts 2. Set renewalsallowed circulation rule for on-site checkouts via circulation rules interface to value 0 3. Perform an on-site checkout 4. Try to renew the loan 5. Observe a similar error dialog: "Cannot renew on-site checkout: test / ( test ) has been renewed the maximum number of times by ( admin )" 6. Set renewalsallowed circulation rule for on-site checkouts via circulation rules interface to value 0 7. Perform an on-site checkout 8. Try to renew the loan 9. Observe success Run unit tests: 1. prove t/db_dependent/Circulation.t --- C4/Circulation.pm | 1 - .../prog/en/modules/circ/renew.tt | 6 ++-- t/db_dependent/Circulation.t | 32 +------------------ 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ab7bad3bd1..2009fbd812 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2679,7 +2679,6 @@ sub CanBookBeRenewed { my $item = Koha::Items->find($itemnumber) or return ( 0, 'no_item' ); my $issue = $item->checkout or return ( 0, 'no_checkout' ); - return ( 0, 'onsite_checkout' ) if $issue->is_onsite_checkout; return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item }); my $patron = $issue->patron or return; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt index 608ed5c84d..042b83cd57 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -2,6 +2,7 @@ [% USE Asset %] [% USE Koha %] [% USE KohaDates %] +[% USE Checkouts %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -30,7 +31,7 @@ [% IF error %]
-

Cannot renew:

+

Cannot renew[% IF issue.checkout_type == Checkouts.checkout_type.onsite_checkout %] on-site checkout[% END %]:

[% IF error == "no_item" %] @@ -134,9 +135,6 @@

Item is not allowed renewal.

- [% ELSIF error == "onsite_checkout" %] -

Item cannot be renewed because it's an onsite checkout

- [% ELSE %] [% error | html %] diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index fd942f7919..5099e4f5c5 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 48; +use Test::More tests => 46; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -1538,36 +1538,6 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); }; -{ - # Don't allow renewing onsite checkout - my $branch = $library->{branchcode}; - - #Create another record - my $biblio = $builder->build_sample_biblio(); - - my $item = $builder->build_sample_item( - { - biblionumber => $biblio->biblionumber, - library => $branch, - itype => $itemtype, - } - ); - - my $borrowernumber = Koha::Patron->new({ - firstname => 'fn', - surname => 'dn', - categorycode => $patron_category->{categorycode}, - branchcode => $branch, - })->store->borrowernumber; - - my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; - - my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); - my ( $renewed, $error ) = CanBookBeRenewed( $borrowernumber, $item->itemnumber ); - is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); - is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); -} - { my $library = $builder->build({ source => 'Branch' }); -- 2.17.1