From 33888b26b5580655ae778a7590b68a2f17030521 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 2 Dec 2008 10:58:40 -0600 Subject: [PATCH] bug 2758: don't confirm checkout if fine balance is 0 Fixes problem where if the IssuingInProcess preference is ON, the operator is always required to confirm a checkout if the patron has had any fine transactions at all, even if the patron's balance is 0. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Circulation.pm | 2 +- t/lib/KohaTest/Circulation/AddIssue.pm | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 017d2d3ba4..d3ea550b8a 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -688,7 +688,7 @@ sub CanBookBeIssued { if ( $amount > $amountlimit && !$inprocess ) { $issuingimpossible{DEBT} = sprintf( "%.2f", $amount ); } - elsif ( $amount <= $amountlimit && !$inprocess ) { + elsif ( $amount > 0 && $amount <= $amountlimit && !$inprocess ) { $needsconfirmation{DEBT} = sprintf( "%.2f", $amount ); } } diff --git a/t/lib/KohaTest/Circulation/AddIssue.pm b/t/lib/KohaTest/Circulation/AddIssue.pm index 73cf7b2c93..2c3e3932ce 100644 --- a/t/lib/KohaTest/Circulation/AddIssue.pm +++ b/t/lib/KohaTest/Circulation/AddIssue.pm @@ -17,7 +17,7 @@ broken as we go along. =cut -sub basic_usage : Test( 11 ) { +sub basic_usage : Test( 13 ) { my $self = shift; my $borrowernumber = $self->{'memberid'}; @@ -43,6 +43,21 @@ sub basic_usage : Test( 11 ) { is( scalar keys %$needsconfirmation, 0, '...and the transaction does not needsconfirmation' ) or diag( Data::Dumper->Dump( [ $issuingimpossible, $needsconfirmation ], [ qw( issuingimpossible needsconfirmation ) ] ) ); + # bug 2758 don't ask for confirmation if patron has $0.00 account balance + # and IssuingInProcess is on + my $orig_issuing_in_process = C4::Context->preference('IssuingInProcess'); + my $dbh = C4::Context->dbh; + $dbh->do("UPDATE systempreferences SET value = 1 WHERE variable = 'IssuingInProcess'"); + C4::Context->clear_syspref_cache(); # FIXME not needed after a syspref mutator is written + ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $borrower, $barcode ); + is( scalar keys %$issuingimpossible, 0, 'the item CanBookBeIssued with IssuingInProcess ON (bug 2758)' ) + or diag( Data::Dumper->Dump( [ $issuingimpossible, $needsconfirmation ], [ qw( issuingimpossible needsconfirmation ) ] ) ); + is( scalar keys %$needsconfirmation, 0, + '...and the transaction does not needsconfirmation with IssuingInProcess ON (bug 2758)' ) + or diag( Data::Dumper->Dump( [ $issuingimpossible, $needsconfirmation ], [ qw( issuingimpossible needsconfirmation ) ] ) ); + $dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'IssuingInProcess'", {}, $orig_issuing_in_process); + C4::Context->clear_syspref_cache(); # FIXME not needed after a syspref mutator is written + my $datedue = C4::Circulation::AddIssue( $borrower, $barcode ); ok( $datedue, "the item has been issued and it is due: $datedue" ); -- 2.39.2