@@ -, +, @@ --- C4/Reserves.pm | 2 +- t/db_dependent/Reserves.t | 81 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -241,7 +241,7 @@ sub AddReserve { } #} - ($const eq "o" || $const eq "e") or return; # FIXME: why not have a useful return value? + ($const eq "o" || $const eq "e") or return $reserve_id; $query = qq{ INSERT INTO reserveconstraints (borrowernumber,biblionumber,reservedate,biblioitemnumber) --- a/t/db_dependent/Reserves.t +++ a/t/db_dependent/Reserves.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 56; +use Test::More tests => 63; use MARC::Record; use DateTime::Duration; @@ -528,6 +528,85 @@ $dbh->do( ); ok( !C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() disallowed" ); +# Tests for bug 14464 + +$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); +my ( undef, undef, $bz14464_fines ) = GetMemberIssuesAndFines( $borrowernumber ); +ok( !$bz14464_fines, 'Bug 14464 - No fines at beginning' ); + +# First, test cancelling a reserve when there's no charge configured. +t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 0); + +my $bz14464_reserve = AddReserve( + 'CPL', + $borrowernumber, + $bibnum, + 'a', + undef, + '1', + undef, + undef, + '', + $title, + $itemnumber, + 'W' +); + +ok( $bz14464_reserve, 'Bug 14464 - 1st reserve correctly created' ); + +CancelReserve({ reserve_id => $bz14464_reserve, charge_cancel_fee => 1 }); + +( undef, undef, $bz14464_fines ) = GetMemberIssuesAndFines( $borrowernumber ); +ok( !$bz14464_fines, 'Bug 14464 - No fines after cancelling reserve with no charge configured' ); + +# Then, test cancelling a reserve when there's no charge desired. +t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 42); + +$bz14464_reserve = AddReserve( + 'CPL', + $borrowernumber, + $bibnum, + 'a', + undef, + '1', + undef, + undef, + '', + $title, + $itemnumber, + 'W' +); + +ok( $bz14464_reserve, 'Bug 14464 - 2nd reserve correctly created' ); + +CancelReserve({ reserve_id => $bz14464_reserve }); + +( undef, undef, $bz14464_fines ) = GetMemberIssuesAndFines( $borrowernumber ); +ok( !$bz14464_fines, 'Bug 14464 - No fines after cancelling reserve with no charge desired' ); + +# Finally, test cancelling a reserve when there's a charge desired and configured. +$bz14464_reserve = AddReserve( + 'CPL', + $borrowernumber, + $bibnum, + 'a', + undef, + '1', + undef, + undef, + '', + $title, + $itemnumber, + 'W' +); + +ok( $bz14464_reserve, 'Bug 14464 - 1st reserve correctly created' ); + +CancelReserve({ reserve_id => $bz14464_reserve, charge_cancel_fee => 1 }); + +( undef, undef, $bz14464_fines ) = GetMemberIssuesAndFines( $borrowernumber ); +is( int( $bz14464_fines ), 42, 'Bug 14464 - Fine applied after cancelling reserve with charge desired and configured' ); + $dbh->rollback; sub count_hold_print_messages { --