Lines 2071-2076
sub AddReturn {
Link Here
|
2071 |
$messages->{'LostItemFeeCharged'} = 1; |
2071 |
$messages->{'LostItemFeeCharged'} = 1; |
2072 |
} |
2072 |
} |
2073 |
elsif ( $lostreturn_policy eq 'restore' ) { |
2073 |
elsif ( $lostreturn_policy eq 'restore' ) { |
|
|
2074 |
_RestoreOverdueForLostAndFound( $item->itemnumber, |
2075 |
$borrowernumber ); |
2074 |
$messages->{'LostItemFeeRestored'} = 1; |
2076 |
$messages->{'LostItemFeeRestored'} = 1; |
2075 |
} |
2077 |
} |
2076 |
} |
2078 |
} |
Lines 2477-2491
sub _FixOverduesOnReturn {
Link Here
|
2477 |
|
2479 |
|
2478 |
$credit->apply({ debits => [ $accountline ], offset_type => 'Forgiven' }); |
2480 |
$credit->apply({ debits => [ $accountline ], offset_type => 'Forgiven' }); |
2479 |
|
2481 |
|
2480 |
$accountline->status('FORGIVEN'); |
|
|
2481 |
|
2482 |
if (C4::Context->preference("FinesLog")) { |
2482 |
if (C4::Context->preference("FinesLog")) { |
2483 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
2483 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
2484 |
} |
2484 |
} |
2485 |
} else { |
|
|
2486 |
$accountline->status($status); |
2487 |
} |
2485 |
} |
2488 |
|
2486 |
|
|
|
2487 |
$accountline->status($status); |
2489 |
return $accountline->store(); |
2488 |
return $accountline->store(); |
2490 |
} |
2489 |
} |
2491 |
); |
2490 |
); |
Lines 2582-2587
sub _FixAccountForLostAndFound {
Link Here
|
2582 |
return ($credit) ? $credit->id : undef; |
2581 |
return ($credit) ? $credit->id : undef; |
2583 |
} |
2582 |
} |
2584 |
|
2583 |
|
|
|
2584 |
=head2 _RestoreOverdueForLostAndFound |
2585 |
|
2586 |
&_RestoreOverdueForLostAndFound($borrowernumber, $itemnumber ); |
2587 |
|
2588 |
C<$borrowernumber> borrowernumber |
2589 |
|
2590 |
C<$itemnumber> itemnumber |
2591 |
|
2592 |
Internal function |
2593 |
|
2594 |
=cut |
2595 |
|
2596 |
sub _RestoreOverdueForLostAndFound { |
2597 |
my ( $borrowernumber, $item ) = @_; |
2598 |
|
2599 |
unless( $borrowernumber ) { |
2600 |
warn "_RestoreOverdueForLostAndFound() not supplied valid borrowernumber"; |
2601 |
return; |
2602 |
} |
2603 |
unless( $item ) { |
2604 |
warn "_RestoreOverdueForLostAndFound() not supplied valid itemnumber"; |
2605 |
return; |
2606 |
} |
2607 |
|
2608 |
my $schema = Koha::Database->schema; |
2609 |
|
2610 |
my $result = $schema->txn_do( |
2611 |
sub { |
2612 |
# check for lost overdue fine |
2613 |
my $accountlines = Koha::Account::Lines->search( |
2614 |
{ |
2615 |
borrowernumber => $borrowernumber, |
2616 |
itemnumber => $item, |
2617 |
debit_type_code => 'OVERDUE', |
2618 |
status => 'LOST' |
2619 |
}, |
2620 |
{ |
2621 |
order_by => { '-desc' => 'date' }, |
2622 |
rows => 1 |
2623 |
} |
2624 |
); |
2625 |
return 0 unless $accountlines->count; # no warning, there's just nothing to fix |
2626 |
|
2627 |
# Find related forgive credit |
2628 |
my $overdue = $accountlines->next; |
2629 |
my $refunds = $overdue->credits( |
2630 |
{ |
2631 |
credit_type_code => 'FORGIVEN', |
2632 |
itemnumber => $item, |
2633 |
status => { '!=' => 'VOID' } |
2634 |
}, |
2635 |
{ order_by => { '-desc' => 'date' }, rows => 1 } |
2636 |
); |
2637 |
return 0 unless $refunds->count; # no warning, there's just nothing to fix |
2638 |
|
2639 |
# Revert the forgive credit |
2640 |
my $refund = $refunds->next; |
2641 |
return $refund->void(); |
2642 |
} |
2643 |
); |
2644 |
|
2645 |
return $result; |
2646 |
} |
2585 |
=head2 _GetCircControlBranch |
2647 |
=head2 _GetCircControlBranch |
2586 |
|
2648 |
|
2587 |
my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower); |
2649 |
my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower); |
2588 |
- |
|
|