Bug 22037: (QA follow-up) Implement use of CHARGES_GUARANTEES
[koha-ffzg.git] / C4 / SIP / ILS / Patron.pm
index 3486650..96ec74a 100644 (file)
@@ -65,8 +65,12 @@ sub new {
     $dob and $dob =~ s/-//g;    # YYYYMMDD
     my $dexpiry     = $kp->{dateexpiry};
     $dexpiry and $dexpiry =~ s/-//g;    # YYYYMMDD
-    my $fines_amount = $patron->account->balance;
+
+    my $fines_amount = $flags->{CHARGES}->{amount}; # This "amount" is the negative balance or the one of the guarantees
     $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
+    my $guarantees_fines_amount = $flags->{CHARGES_GUARANTEES} ? $flags->{CHARGES_GUARANTEES}->{amount} : 0;
+    $fines_amount += $guarantees_fines_amount;
+
     my $fee_limit = _fee_limit();
     my $fine_blocked = $fines_amount > $fee_limit;
     my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" &&  defined $flags->{ODUES}->{itemlist} ) ? 1 : 0;
@@ -248,7 +252,7 @@ sub fee_amount {
     if ( $self->{fines} ) {
         return $self->{fines};
     }
-    return;
+    return 0;
 }
 
 sub fines_amount {
@@ -627,7 +631,6 @@ __END__
 | contactname         | mediumtext   | YES  |     | NULL    |                |
 | contactfirstname    | text         | YES  |     | NULL    |                |
 | contacttitle        | text         | YES  |     | NULL    |                |
-| guarantorid         | int(11)      | YES  | MUL | NULL    |                |
 | borrowernotes       | mediumtext   | YES  |     | NULL    |                |
 | relationship        | varchar(100) | YES  |     | NULL    |                |
 | ethnicity           | varchar(50)  | YES  |     | NULL    |                |