Lines 519-525
sub UpdateFine {
Link Here
|
519 |
my $issue_id = $params->{issue_id}; |
519 |
my $issue_id = $params->{issue_id}; |
520 |
my $itemnum = $params->{itemnumber}; |
520 |
my $itemnum = $params->{itemnumber}; |
521 |
my $borrowernumber = $params->{borrowernumber}; |
521 |
my $borrowernumber = $params->{borrowernumber}; |
522 |
my $amount = $params->{amount}; |
522 |
my $amount = $params->{amount} * 100; |
523 |
my $due = $params->{due} // q{}; |
523 |
my $due = $params->{due} // q{}; |
524 |
|
524 |
|
525 |
$debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, due => $due, issue_id => $issue_id})"; |
525 |
$debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, due => $due, issue_id => $issue_id})"; |
Lines 538-544
sub UpdateFine {
Link Here
|
538 |
); |
538 |
); |
539 |
|
539 |
|
540 |
my $accountline; |
540 |
my $accountline; |
541 |
my $total_amount_other = 0.00; |
541 |
my $total_amount_other = 0; |
542 |
my $due_qr = qr/$due/; |
542 |
my $due_qr = qr/$due/; |
543 |
# Cycle through the fines and |
543 |
# Cycle through the fines and |
544 |
# - find line that relates to the requested $itemnum |
544 |
# - find line that relates to the requested $itemnum |
Lines 554-568
sub UpdateFine {
Link Here
|
554 |
$accountline = $overdue; |
554 |
$accountline = $overdue; |
555 |
} |
555 |
} |
556 |
} |
556 |
} |
557 |
$total_amount_other += $overdue->amountoutstanding; |
557 |
$total_amount_other += ( $overdue->amountoutstanding * 100 ); |
558 |
} |
558 |
} |
559 |
|
559 |
|
560 |
if ( my $maxfine = C4::Context->preference('MaxFine') ) { |
560 |
if ( my $maxfine = C4::Context->preference('MaxFine') ) { |
|
|
561 |
$maxfine = $maxfine * 100; |
561 |
my $maxIncrease = $maxfine - $total_amount_other; |
562 |
my $maxIncrease = $maxfine - $total_amount_other; |
562 |
return if $maxIncrease <= 0.00; |
563 |
return if $maxIncrease <= 0; |
563 |
if ($accountline) { |
564 |
if ($accountline) { |
564 |
if ( ( $amount - $accountline->amount ) > $maxIncrease ) { |
565 |
if ( ( $amount - ( $accountline->amount * 100 ) ) > $maxIncrease ) { |
565 |
my $new_amount = $accountline->amount + $maxIncrease; |
566 |
my $new_amount = ( $accountline->amount * 100 ) + $maxIncrease; |
566 |
$debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; |
567 |
$debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; |
567 |
$amount = $new_amount; |
568 |
$amount = $new_amount; |
568 |
} |
569 |
} |
Lines 574-583
sub UpdateFine {
Link Here
|
574 |
} |
575 |
} |
575 |
|
576 |
|
576 |
if ( $accountline ) { |
577 |
if ( $accountline ) { |
577 |
if ( $accountline->amount != $amount ) { |
578 |
if ( ( $accountline->amount * 100 ) != $amount ) { |
578 |
$accountline->adjust( |
579 |
$accountline->adjust( |
579 |
{ |
580 |
{ |
580 |
amount => $amount, |
581 |
amount => ( $amount / 100 ), |
581 |
type => 'overdue_update', |
582 |
type => 'overdue_update', |
582 |
interface => C4::Context->interface |
583 |
interface => C4::Context->interface |
583 |
} |
584 |
} |
Lines 595-601
sub UpdateFine {
Link Here
|
595 |
my $account = Koha::Account->new({ patron_id => $borrowernumber }); |
596 |
my $account = Koha::Account->new({ patron_id => $borrowernumber }); |
596 |
$accountline = $account->add_debit( |
597 |
$accountline = $account->add_debit( |
597 |
{ |
598 |
{ |
598 |
amount => $amount, |
599 |
amount => ( $amount / 100 ), |
599 |
description => $desc, |
600 |
description => $desc, |
600 |
note => undef, |
601 |
note => undef, |
601 |
user_id => undef, |
602 |
user_id => undef, |
602 |
- |
|
|