From 1a043534972eda91d606554e1836b00916ce30ee Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 23 Jun 2017 12:27:19 +0000 Subject: [PATCH] Bug 18572 - Improper branchcode set during OPAC renewal Content-Type: text/plain; charset=utf-8 To test: 1 - Set 'OpacRenewalBranch' to various settings 2 - Renew an item for a ptron under each setting 3 - Confirm action_log entries reflect the correct branch for each secnario 4 - prove t/db_dependent/Circulation/issue.t Signed-off-by: David Kuhn Signed-off-by: Marcel de Rooy --- C4/Circulation.pm | 7 ++++++- opac/opac-renew.pl | 2 +- t/db_dependent/Circulation/issue.t | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0c5585a..b66af9b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2815,6 +2815,7 @@ sub AddRenewal { my $branch = shift; my $datedue = shift; my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); + my $opacrenewal = shift; my $item = GetItem($itemnumber) or return; my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item @@ -2915,10 +2916,14 @@ sub AddRenewal { DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); } + unless ( $opacrenewal ) { #if from opac we are obeying OpacRenewalBranch as calculated in opac-renew.pl + $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : $branch; + } + # Add the renewal to stats UpdateStats( { - branch => C4::Context->userenv ? C4::Context->userenv->{branch} : $branch, + branch => $branch, type => 'renew', amount => $charge, itemnumber => $itemnumber, diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl index ad9cacf..580faab 100755 --- a/opac/opac-renew.pl +++ b/opac/opac-renew.pl @@ -82,7 +82,7 @@ else { else { $branchcode = 'OPACRenew'; } - AddRenewal( $borrowernumber, $itemnumber, $branchcode ); + AddRenewal( $borrowernumber, $itemnumber, $branchcode, undef, undef, 1 ); push( @renewed, $itemnumber ); } else { diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index 67195ed..e06882a 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 30; +use Test::More tests => 31; use DateTime::Duration; use t::lib::Mocks; @@ -230,6 +230,21 @@ like( my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 ); ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" ); +#Let's do an opac renewal - whatever branchcode we send should be used +my $opac_renew_issue = $builder->build({ source=>"Issue",value=>{ + date_due => '2017-01-01', + branch => $branchcode_1, + itype => $itemtype, + borrowernumber => $borrower_id1 + } + }); + +my $datedue4 = AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, "Stavromula", $datedue1, $daysago10, 1 ); + +$stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, "Stavromula" ); +ok( $stat, "Bug 18572 - 'Bug 18572 - OpacRenewalBranch is now respected" ); + + #Test GetBiblioIssues is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); -- 2.1.4