|
Lines 119-131
sub pay {
Link Here
|
| 119 |
|
119 |
|
| 120 |
# If we need to make a note of the item associated with this line, |
120 |
# If we need to make a note of the item associated with this line, |
| 121 |
# in order that we can potentially renew it, do so. |
121 |
# in order that we can potentially renew it, do so. |
| 122 |
if ( |
122 |
if (_fine_paid_renewable($new_amountoutstanding, $fine)) { |
| 123 |
$new_amountoutstanding == 0 && |
|
|
| 124 |
$fine->accounttype && |
| 125 |
$fine->accounttype eq 'OVERDUE' && |
| 126 |
$fine->status && |
| 127 |
$fine->status eq 'UNRETURNED' |
| 128 |
) { |
| 129 |
$overdue_unreturned->{$fine->itemnumber} = $fine; |
123 |
$overdue_unreturned->{$fine->itemnumber} = $fine; |
| 130 |
} |
124 |
} |
| 131 |
|
125 |
|
|
Lines 191-203
sub pay {
Link Here
|
| 191 |
|
185 |
|
| 192 |
# If we need to make a note of the item associated with this line, |
186 |
# If we need to make a note of the item associated with this line, |
| 193 |
# in order that we can potentially renew it, do so. |
187 |
# in order that we can potentially renew it, do so. |
| 194 |
if ( |
188 |
my $amt = $old_amountoutstanding - $amount_to_pay; |
| 195 |
$old_amountoutstanding - $amount_to_pay == 0 && |
189 |
if (_fine_paid_renewable($amt, $fine)) { |
| 196 |
$fine->accounttype && |
|
|
| 197 |
$fine->accounttype eq 'OVERDUE' && |
| 198 |
$fine->status && |
| 199 |
$fine->status eq 'UNRETURNED' |
| 200 |
) { |
| 201 |
$overdue_unreturned->{$fine->itemnumber} = $fine; |
190 |
$overdue_unreturned->{$fine->itemnumber} = $fine; |
| 202 |
} |
191 |
} |
| 203 |
|
192 |
|
|
Lines 284-315
sub pay {
Link Here
|
| 284 |
# If we have overdue unreturned items that have had payments made |
273 |
# If we have overdue unreturned items that have had payments made |
| 285 |
# against them, check whether the balance on those items is now zero |
274 |
# against them, check whether the balance on those items is now zero |
| 286 |
# and, if the syspref is set, renew them |
275 |
# and, if the syspref is set, renew them |
| 287 |
# Same logic exists in Koha::Account::Line::apply |
276 |
_maybe_renew($overdue_unreturned, $self->{patron_id}); |
| 288 |
if ( |
|
|
| 289 |
C4::Context->preference('RenewAccruingItemWhenPaid') && |
| 290 |
keys %{$overdue_unreturned} |
| 291 |
) { |
| 292 |
foreach my $itemnumber (keys %{$overdue_unreturned}) { |
| 293 |
# Only do something if this item has no fines left on it |
| 294 |
my $fine = C4::Overdues::GetFine( $itemnumber, $self->{patron_id} ); |
| 295 |
next if $fine && $fine > 0; |
| 296 |
|
| 297 |
my ( $renew_ok, $error ) = |
| 298 |
C4::Circulation::CanBookBeRenewed( |
| 299 |
$self->{patron_id}, $itemnumber |
| 300 |
); |
| 301 |
if ( $renew_ok ) { |
| 302 |
C4::Circulation::AddRenewal( |
| 303 |
$self->{patron_id}, |
| 304 |
$itemnumber, |
| 305 |
$library_id, |
| 306 |
undef, |
| 307 |
undef, |
| 308 |
1 |
| 309 |
); |
| 310 |
} |
| 311 |
} |
| 312 |
} |
| 313 |
|
277 |
|
| 314 |
if ( C4::Context->preference("FinesLog") ) { |
278 |
if ( C4::Context->preference("FinesLog") ) { |
| 315 |
logaction( |
279 |
logaction( |
|
Lines 760-765
sub reconcile_balance {
Link Here
|
| 760 |
return $self; |
724 |
return $self; |
| 761 |
} |
725 |
} |
| 762 |
|
726 |
|
|
|
727 |
=head3 _fine_paid_renewable |
| 728 |
|
| 729 |
my $bool = _fine_paid_renewable($amt, $fine); |
| 730 |
|
| 731 |
Given an outstanding amount and a fine object, determine if this item |
| 732 |
is potentially renewable as a result of the fine being paid off |
| 733 |
|
| 734 |
=cut |
| 735 |
|
| 736 |
sub _fine_paid_renewable { |
| 737 |
my ($amt, $fine) = @_; |
| 738 |
|
| 739 |
return ( |
| 740 |
$amt == 0 && |
| 741 |
$fine->accounttype && |
| 742 |
$fine->accounttype eq 'OVERDUE' && |
| 743 |
$fine->status && |
| 744 |
$fine->status eq 'UNRETURNED' |
| 745 |
) ? 1 : 0; |
| 746 |
} |
| 747 |
|
| 748 |
=head3 _maybe_renew |
| 749 |
|
| 750 |
my $result = _maybe_renew($overdue_unreturned, $patron_id, $library_id); |
| 751 |
|
| 752 |
If we have overdue unreturned items that have had payments made |
| 753 |
against them, check whether the balance on those items is now zero |
| 754 |
and, if the syspref is set, renew them |
| 755 |
|
| 756 |
=cut |
| 757 |
|
| 758 |
sub _maybe_renew { |
| 759 |
my ($items, $patron_id) = @_; |
| 760 |
|
| 761 |
if ( |
| 762 |
C4::Context->preference('RenewAccruingItemWhenPaid') && |
| 763 |
keys %{$items} |
| 764 |
) { |
| 765 |
foreach my $itemnumber (keys %{$items}) { |
| 766 |
# Only do something if this item has no fines left on it |
| 767 |
my $fine = C4::Overdues::GetFine( $itemnumber, $patron_id ); |
| 768 |
next if $fine && $fine > 0; |
| 769 |
|
| 770 |
my ( $renew_ok, $error ) = |
| 771 |
C4::Circulation::CanBookBeRenewed($patron_id, $itemnumber); |
| 772 |
if ( $renew_ok ) { |
| 773 |
my $due_date = C4::Circulation::AddRenewal( |
| 774 |
$patron_id, |
| 775 |
$itemnumber, |
| 776 |
$items->{$itemnumber}->{branchcode}, |
| 777 |
undef, |
| 778 |
undef, |
| 779 |
1 |
| 780 |
); |
| 781 |
return $due_date; |
| 782 |
} else { |
| 783 |
return $error; |
| 784 |
} |
| 785 |
} |
| 786 |
} |
| 787 |
} |
| 788 |
|
| 763 |
1; |
789 |
1; |
| 764 |
|
790 |
|
| 765 |
=head2 Name mappings |
791 |
=head2 Name mappings |