Lines 515-539
sub UpdateFine {
Link Here
|
515 |
my $data; |
515 |
my $data; |
516 |
my $total_amount_other = 0.00; |
516 |
my $total_amount_other = 0.00; |
517 |
my $due_qr = qr/$due/; |
517 |
my $due_qr = qr/$due/; |
|
|
518 |
# Cycle through the fines and |
519 |
# - find line that relates to the requested $itemnum |
520 |
# - accumulate fines for other items |
521 |
# so we can update $itemnum fine taking in account fine caps |
518 |
while (my $rec = $sth->fetchrow_hashref) { |
522 |
while (my $rec = $sth->fetchrow_hashref) { |
519 |
if ($rec->{itemnumber} == $itemnum && $rec->{description} =~ /$due_qr/) { |
523 |
if ($rec->{itemnumber} == $itemnum && $rec->{description} =~ /$due_qr/) { |
520 |
if ($data) { |
524 |
if ($data) { |
521 |
warn "Not a unique accountlines record for item $itemnum borrower $borrowernumber"; |
525 |
warn "Not a unique accountlines record for item $itemnum borrower $borrowernumber"; |
522 |
} else { |
526 |
} else { |
523 |
$data = $rec; |
527 |
$data = $rec; |
524 |
next; |
528 |
next; |
|
|
529 |
} |
525 |
} |
530 |
} |
526 |
} |
531 |
$total_amount_other += $rec->{'amount'}; |
527 |
$total_amount_other += $rec->{'amount'}; |
|
|
528 |
} |
532 |
} |
529 |
if (my $maxfine = C4::Context->preference('MaxFine')) { |
533 |
if (my $maxfine = C4::Context->preference('MaxFine')) { |
530 |
if ($total_amount_other + $amount > $maxfine) { |
534 |
if ($total_amount_other + $amount > $maxfine) { |
531 |
my $new_amount = $maxfine - $total_amount_other; |
535 |
my $new_amount = $maxfine - $total_amount_other; |
532 |
warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; |
536 |
warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; |
533 |
return if $new_amount <= 0.00; |
537 |
return if $new_amount <= 0.00; |
534 |
|
538 |
|
535 |
$amount = $new_amount; |
539 |
$amount = $new_amount; |
536 |
} |
540 |
} |
537 |
} |
541 |
} |
538 |
|
542 |
|
539 |
if ( $data ) { |
543 |
if ( $data ) { |
540 |
- |
|
|