From 87b7c2bb24a6ab0b99c8691bd9d715b557500d26 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Mar 2017 10:59:41 -0300 Subject: [PATCH] Bug 17560: Improve strenght of hold existence test This patch is a QA follow-up to fix several issues: - 1 call to GetReserveFee was wrong in ModReserveFill - Update DB entry was wrong and insufficient - Add robustness to the tests in sco-main --- C4/Reserves.pm | 2 +- installer/data/mysql/atomicupdate/bug_XXXXX.sql | 3 ++- opac/sco/sco-main.pl | 25 +++++++++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 4e68eea..96efb4a 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1249,7 +1249,7 @@ sub ModReserveFill { $hold->delete(); if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) { - my $reserve_fee = GetReserveFee( $hold->borrowernumber ); + my $reserve_fee = GetReserveFee( $hold->borrowernumber, $hold->biblionumber ); ChargeReserveFee( $hold->borrowernumber, $reserve_fee, $hold->biblio->title ); } diff --git a/installer/data/mysql/atomicupdate/bug_XXXXX.sql b/installer/data/mysql/atomicupdate/bug_XXXXX.sql index f7526e1..96c142f 100644 --- a/installer/data/mysql/atomicupdate/bug_XXXXX.sql +++ b/installer/data/mysql/atomicupdate/bug_XXXXX.sql @@ -1 +1,2 @@ -UPDATE systempreferences SET options="any_time_is_placed|not_always|any_time_is_collected" WHERE value="HoldFeeMode"; +UPDATE systempreferences SET options="any_time_is_placed|not_always|any_time_is_collected" WHERE variable="HoldFeeMode"; +UPDATE systempreferences SET value="any_time_is_placed" WHERE variable="HoldFeeMode" AND value="always"; diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index e4c77e0..b313df9 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -200,12 +200,22 @@ elsif ( $op eq "checkout" ) { } } else { if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues. - my $hold_existed; + my ( $hold_existed, $item ); if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) { # There is no easy way to know if the patron has been charged for this item. # So we check if a hold existed for this item before the check in - my $item = Koha::Items->find({ barcode => $barcode }); - $hold_existed = Koha::Holds->search({ -or => { 'biblionumber' => $item->biblionumber, 'itemnumber' => $item->itemnumber}})->count; + $item = Koha::Items->find({ barcode => $barcode }); + $hold_existed = Koha::Holds->search( + { + -and => { + borrowernumber => $borrower->{borrowernumber}, + -or => { + biblionumber => $item->biblionumber, + itemnumber => $item->itemnumber + } + } + } + )->count; } AddIssue( $borrower, $barcode ); @@ -214,7 +224,14 @@ elsif ( $op eq "checkout" ) { $template->param( # If the hold existed before the check in, let's confirm that the charge line exists # Note that this should not be needed but since we do not have proper exception handling here we do it this way - patron_has_hold_fee => Koha::Account::Lines->search({ borrowernumber => $borrower->{borrowernumber}, accounttype => 'Res', date => $dtf->format_date( dt_from_string ) })->count, + patron_has_hold_fee => Koha::Account::Lines->search( + { + borrowernumber => $borrower->{borrowernumber}, + accounttype => 'Res', + description => 'Reserve Charge - ' . $item->biblio->title, + date => $dtf->format_date(dt_from_string) + } + )->count, ); } } else { -- 2.9.3