bug 2758: don't confirm checkout if fine balance is 0
authorGalen Charlton <galen.charlton@liblime.com>
Tue, 2 Dec 2008 16:58:40 +0000 (10:58 -0600)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 10 Dec 2008 13:27:04 +0000 (14:27 +0100)
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 <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
C4/Circulation.pm
t/lib/KohaTest/Circulation/AddIssue.pm

index 017d2d3..d3ea550 100644 (file)
@@ -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 );
         }
     }
index 73cf7b2..2c3e393 100644 (file)
@@ -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" );