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