|
Lines 272-279
sub CalcFine {
Link Here
|
| 272 |
} else { |
272 |
} else { |
| 273 |
# a zero (or null) chargeperiod or negative units_minus_grace value means no charge. |
273 |
# a zero (or null) chargeperiod or negative units_minus_grace value means no charge. |
| 274 |
} |
274 |
} |
|
|
275 |
|
| 275 |
$amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap}; |
276 |
$amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap}; |
|
|
277 |
$amount = $item->{'replacementprice'} if ( C4::Context->preference('MaxFineIsReplacementPrice') && $item->{'replacementprice'} && $amount > $item->{'replacementprice'} ); |
| 278 |
|
| 276 |
$debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units); |
279 |
$debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units); |
|
|
280 |
|
| 277 |
return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units); |
281 |
return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units); |
| 278 |
# FIXME: chargename is NEVER populated anywhere. |
282 |
# FIXME: chargename is NEVER populated anywhere. |
| 279 |
} |
283 |
} |
|
Lines 546-561
sub UpdateFine {
Link Here
|
| 546 |
} |
550 |
} |
| 547 |
$total_amount_other += $rec->{'amount'}; |
551 |
$total_amount_other += $rec->{'amount'}; |
| 548 |
} |
552 |
} |
|
|
553 |
|
| 554 |
if ( C4::Context->preference('MaxFineIsReplacementPrice') ) { |
| 555 |
my $item = C4::Items::GetItem( $itemnum ); |
| 556 |
if ( $item->{'replacementprice'} && $amount > $item->{'replacementprice'} ) { |
| 557 |
$debug && warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $item->{'replacementprice'} - Fine exceeds replacement price"; |
| 558 |
$amount = $item->{'replacementprice'}; |
| 559 |
} |
| 560 |
} |
| 561 |
|
| 549 |
if (my $maxfine = C4::Context->preference('MaxFine')) { |
562 |
if (my $maxfine = C4::Context->preference('MaxFine')) { |
| 550 |
if ($total_amount_other + $amount > $maxfine) { |
563 |
if ($total_amount_other + $amount > $maxfine) { |
| 551 |
my $new_amount = $maxfine - $total_amount_other; |
564 |
my $new_amount = $maxfine - $total_amount_other; |
| 552 |
warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; |
565 |
$debug && warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; |
| 553 |
return if $new_amount <= 0.00; |
566 |
return if $new_amount <= 0.00; |
| 554 |
|
567 |
|
| 555 |
$amount = $new_amount; |
568 |
$amount = $new_amount; |
| 556 |
} |
569 |
} |
| 557 |
} |
570 |
} |
| 558 |
|
571 |
|
|
|
572 |
|
| 559 |
if ( $data ) { |
573 |
if ( $data ) { |
| 560 |
|
574 |
|
| 561 |
# we're updating an existing fine. Only modify if amount changed |
575 |
# we're updating an existing fine. Only modify if amount changed |