|
Lines 2338-2382
sub _FixOverduesOnReturn {
Link Here
|
| 2338 |
return; |
2338 |
return; |
| 2339 |
} |
2339 |
} |
| 2340 |
|
2340 |
|
| 2341 |
# check for overdue fine |
2341 |
my $schema = Koha::Database->schema; |
| 2342 |
my $accountlines = Koha::Account::Lines->search( |
|
|
| 2343 |
{ |
| 2344 |
borrowernumber => $borrowernumber, |
| 2345 |
itemnumber => $item, |
| 2346 |
accounttype => 'OVERDUE', |
| 2347 |
status => 'UNRETURNED' |
| 2348 |
} |
| 2349 |
); |
| 2350 |
return 0 unless $accountlines->count; # no warning, there's just nothing to fix |
| 2351 |
|
2342 |
|
| 2352 |
my $accountline = $accountlines->next; |
2343 |
my $result = $schema->txn_do( |
| 2353 |
if ($exemptfine) { |
2344 |
sub { |
| 2354 |
my $amountoutstanding = $accountline->amountoutstanding; |
2345 |
# check for overdue fine |
|
|
2346 |
my $accountlines = Koha::Account::Lines->search( |
| 2347 |
{ |
| 2348 |
borrowernumber => $borrowernumber, |
| 2349 |
itemnumber => $item, |
| 2350 |
accounttype => 'OVERDUE', |
| 2351 |
status => 'UNRETURNED' |
| 2352 |
} |
| 2353 |
); |
| 2354 |
return 0 unless $accountlines->count; # no warning, there's just nothing to fix |
| 2355 |
|
2355 |
|
| 2356 |
my $account = Koha::Account->new({patron_id => $borrowernumber}); |
2356 |
my $accountline = $accountlines->next; |
| 2357 |
my $credit = $account->add_credit( |
2357 |
if ($exemptfine) { |
| 2358 |
{ |
2358 |
my $amountoutstanding = $accountline->amountoutstanding; |
| 2359 |
amount => $amountoutstanding, |
|
|
| 2360 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
| 2361 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
| 2362 |
interface => C4::Context->interface, |
| 2363 |
type => 'forgiven', |
| 2364 |
item_id => $item |
| 2365 |
} |
| 2366 |
); |
| 2367 |
|
2359 |
|
| 2368 |
$credit->apply({ debits => $accountlines->reset, offset_type => 'Forgiven' }); |
2360 |
my $account = Koha::Account->new({patron_id => $borrowernumber}); |
|
|
2361 |
my $credit = $account->add_credit( |
| 2362 |
{ |
| 2363 |
amount => $amountoutstanding, |
| 2364 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
| 2365 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
| 2366 |
interface => C4::Context->interface, |
| 2367 |
type => 'forgiven', |
| 2368 |
item_id => $item |
| 2369 |
} |
| 2370 |
); |
| 2369 |
|
2371 |
|
| 2370 |
$accountline->status('FORGIVEN'); |
2372 |
$credit->apply({ debits => $accountlines->reset, offset_type => 'Forgiven' }); |
|
|
2373 |
|
| 2374 |
$accountline->status('FORGIVEN'); |
| 2375 |
|
| 2376 |
if (C4::Context->preference("FinesLog")) { |
| 2377 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
| 2378 |
} |
| 2379 |
} else { |
| 2380 |
$accountline->status('RETURNED'); |
| 2381 |
} |
| 2371 |
|
2382 |
|
| 2372 |
if (C4::Context->preference("FinesLog")) { |
2383 |
return $accountline->store(); |
| 2373 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
|
|
| 2374 |
} |
2384 |
} |
| 2375 |
} else { |
2385 |
); |
| 2376 |
$accountline->status('RETURNED'); |
|
|
| 2377 |
} |
| 2378 |
|
2386 |
|
| 2379 |
return $accountline->store(); |
2387 |
return $result; |
| 2380 |
} |
2388 |
} |
| 2381 |
|
2389 |
|
| 2382 |
=head2 _FixAccountForLostAndReturned |
2390 |
=head2 _FixAccountForLostAndReturned |
| 2383 |
- |
|
|