|
Lines 1836-1842
patron who last borrowed the book.
Link Here
|
| 1836 |
=cut |
1836 |
=cut |
| 1837 |
|
1837 |
|
| 1838 |
sub AddReturn { |
1838 |
sub AddReturn { |
| 1839 |
my ( $barcode, $branch, $exemptfine, $dropbox, $return_date, $dropboxdate ) = @_; |
1839 |
my ( $barcode, $branch, $exemptfine, $return_date ) = @_; |
| 1840 |
|
1840 |
|
| 1841 |
if ($branch and not Koha::Libraries->find($branch)) { |
1841 |
if ($branch and not Koha::Libraries->find($branch)) { |
| 1842 |
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; |
1842 |
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; |
|
Lines 1943-1967
sub AddReturn {
Link Here
|
| 1943 |
my $is_overdue; |
1943 |
my $is_overdue; |
| 1944 |
die "The item is not issed and cannot be returned" unless $issue; # Just in case... |
1944 |
die "The item is not issed and cannot be returned" unless $issue; # Just in case... |
| 1945 |
$patron or warn "AddReturn without current borrower"; |
1945 |
$patron or warn "AddReturn without current borrower"; |
| 1946 |
if ($dropbox) { |
1946 |
$is_overdue = $issue->is_overdue( $return_date ); |
| 1947 |
$is_overdue = $issue->is_overdue( $dropboxdate ); |
|
|
| 1948 |
} else { |
| 1949 |
$is_overdue = $issue->is_overdue; |
| 1950 |
} |
| 1951 |
|
1947 |
|
| 1952 |
if ($patron) { |
1948 |
if ($patron) { |
| 1953 |
eval { |
1949 |
eval { |
| 1954 |
if ( $dropbox ) { |
1950 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy ); |
| 1955 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, |
|
|
| 1956 |
$dropboxdate, $patron->privacy ); |
| 1957 |
} |
| 1958 |
else { |
| 1959 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, |
| 1960 |
$return_date, $patron->privacy ); |
| 1961 |
} |
| 1962 |
}; |
1951 |
}; |
| 1963 |
unless ( $@ ) { |
1952 |
unless ( $@ ) { |
| 1964 |
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) { |
1953 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) { |
| 1965 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
1954 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
| 1966 |
} |
1955 |
} |
| 1967 |
} else { |
1956 |
} else { |
|
Lines 2035-2047
sub AddReturn {
Link Here
|
| 2035 |
|
2024 |
|
| 2036 |
# fix up the overdues in accounts... |
2025 |
# fix up the overdues in accounts... |
| 2037 |
if ($borrowernumber) { |
2026 |
if ($borrowernumber) { |
| 2038 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->itemnumber, $exemptfine, $dropbox); |
2027 |
my $fix = _FixOverduesOnReturn( $borrowernumber, $item->itemnumber, $exemptfine ); |
| 2039 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->itemnumber...) failed!"; # zero is OK, check defined |
2028 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->itemnumber...) failed!"; # zero is OK, check defined |
| 2040 |
|
2029 |
|
| 2041 |
if ( $issue and $issue->is_overdue ) { |
2030 |
if ( $issue and $issue->is_overdue ) { |
| 2042 |
# fix fine days |
2031 |
# fix fine days |
| 2043 |
$today = dt_from_string($return_date) if $return_date; |
2032 |
$today = $return_date if $return_date; |
| 2044 |
$today = $dropboxdate if $dropbox; |
|
|
| 2045 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $today ); |
2033 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $today ); |
| 2046 |
if ($reminder){ |
2034 |
if ($reminder){ |
| 2047 |
$messages->{'PrevDebarred'} = $debardate; |
2035 |
$messages->{'PrevDebarred'} = $debardate; |
|
Lines 2334-2340
Internal function
Link Here
|
| 2334 |
=cut |
2322 |
=cut |
| 2335 |
|
2323 |
|
| 2336 |
sub _FixOverduesOnReturn { |
2324 |
sub _FixOverduesOnReturn { |
| 2337 |
my ($borrowernumber, $item, $exemptfine, $dropbox ) = @_; |
2325 |
my ($borrowernumber, $item, $exemptfine ) = @_; |
| 2338 |
unless( $borrowernumber ) { |
2326 |
unless( $borrowernumber ) { |
| 2339 |
warn "_FixOverduesOnReturn() not supplied valid borrowernumber"; |
2327 |
warn "_FixOverduesOnReturn() not supplied valid borrowernumber"; |
| 2340 |
return; |
2328 |
return; |
|
Lines 2374-2403
sub _FixOverduesOnReturn {
Link Here
|
| 2374 |
if (C4::Context->preference("FinesLog")) { |
2362 |
if (C4::Context->preference("FinesLog")) { |
| 2375 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
2363 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
| 2376 |
} |
2364 |
} |
| 2377 |
} elsif ($dropbox && $accountline->lastincrement) { |
|
|
| 2378 |
my $outstanding = $accountline->amountoutstanding - $accountline->lastincrement; |
| 2379 |
my $amt = $accountline->amount - $accountline->lastincrement; |
| 2380 |
|
| 2381 |
Koha::Account::Offset->new( |
| 2382 |
{ |
| 2383 |
debit_id => $accountline->id, |
| 2384 |
type => 'Dropbox', |
| 2385 |
amount => $accountline->lastincrement * -1, |
| 2386 |
} |
| 2387 |
)->store(); |
| 2388 |
|
| 2389 |
if ( C4::Context->preference("FinesLog") ) { |
| 2390 |
&logaction( "FINES", 'MODIFY', $borrowernumber, |
| 2391 |
"Dropbox adjustment $amt, item $item" ); |
| 2392 |
} |
| 2393 |
|
| 2394 |
$accountline->accounttype('F'); |
| 2395 |
|
| 2396 |
if ( $outstanding >= 0 && $amt >= 0 ) { |
| 2397 |
$accountline->amount($amt); |
| 2398 |
$accountline->amountoutstanding($outstanding); |
| 2399 |
} |
| 2400 |
|
| 2401 |
} else { |
2365 |
} else { |
| 2402 |
$accountline->accounttype('F'); |
2366 |
$accountline->accounttype('F'); |
| 2403 |
} |
2367 |
} |
|
Lines 4124-4130
sub _CalculateAndUpdateFine {
Link Here
|
| 4124 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
4088 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
| 4125 |
: $issue->branchcode; |
4089 |
: $issue->branchcode; |
| 4126 |
|
4090 |
|
| 4127 |
my $date_returned = $return_date ? dt_from_string($return_date) : dt_from_string(); |
4091 |
my $date_returned = $return_date ? $return_date : dt_from_string(); |
| 4128 |
|
4092 |
|
| 4129 |
my ( $amount, $unitcounttotal, $unitcount ) = |
4093 |
my ( $amount, $unitcounttotal, $unitcount ) = |
| 4130 |
C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $datedue, $date_returned ); |
4094 |
C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $datedue, $date_returned ); |