Lines 22-27
use Test::More tests => 50;
Link Here
|
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
|
|
25 |
use Test::Warn; |
25 |
|
26 |
|
26 |
use Data::Dumper; |
27 |
use Data::Dumper; |
27 |
use DateTime; |
28 |
use DateTime; |
Lines 2415-2421
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2415 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2416 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2416 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2417 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2417 |
|
2418 |
|
2418 |
subtest 'bug 22877' => sub { |
2419 |
subtest 'bug 22877 | Lost item return' => sub { |
2419 |
|
2420 |
|
2420 |
plan tests => 3; |
2421 |
plan tests => 3; |
2421 |
|
2422 |
|
Lines 2665-2670
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2665 |
}; |
2666 |
}; |
2666 |
}; |
2667 |
}; |
2667 |
|
2668 |
|
|
|
2669 |
subtest '_RestoreOverdueForLostAndFound' => sub { |
2670 |
|
2671 |
plan tests => 7; |
2672 |
|
2673 |
my $manager = $builder->build_object( { class => "Koha::Patrons" } ); |
2674 |
t::lib::Mocks::mock_userenv( |
2675 |
{ patron => $manager, branchcode => $manager->branchcode } ); |
2676 |
|
2677 |
my $patron = $builder->build_object( { class => "Koha::Patrons" } ); |
2678 |
my $item = $builder->build_sample_item(); |
2679 |
|
2680 |
# No fine found |
2681 |
my $result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); |
2682 |
is($result, 0, "0 returned when no overdue found"); |
2683 |
|
2684 |
# Fine not forgiven |
2685 |
my $account = $patron->account; |
2686 |
my $overdue = $account->add_debit( |
2687 |
{ |
2688 |
amount => 30.00, |
2689 |
user_id => $manager->borrowernumber, |
2690 |
library_id => $library2->{branchcode}, |
2691 |
interface => 'test', |
2692 |
item_id => $item->itemnumber, |
2693 |
type => 'OVERDUE', |
2694 |
} |
2695 |
)->store(); |
2696 |
$overdue->status('LOST')->store(); |
2697 |
|
2698 |
$result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); |
2699 |
is($result, 0, "0 returned when overdue found without forgival"); |
2700 |
$overdue->discard_changes; |
2701 |
is($overdue->status, 'RETURNED', 'Overdue status updated to RETURNED'); |
2702 |
|
2703 |
# Reset status |
2704 |
$overdue->status('LOST')->store(); |
2705 |
|
2706 |
# Fine forgiven |
2707 |
my $credit = $account->add_credit( |
2708 |
{ |
2709 |
amount => 30.00, |
2710 |
user_id => $manager->borrowernumber, |
2711 |
library_id => $library2->{branchcode}, |
2712 |
interface => 'test', |
2713 |
type => 'FORGIVEN', |
2714 |
item_id => $item->itemnumber |
2715 |
} |
2716 |
); |
2717 |
$credit->apply( { debits => [$overdue], offset_type => 'Forgiven' } ); |
2718 |
|
2719 |
$result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); |
2720 |
|
2721 |
is( ref($result), 'Koha::Account::Line', 'Return a Koha::Account::Line object on sucess'); |
2722 |
$overdue->discard_changes; |
2723 |
is($overdue->status, 'RETURNED', 'Overdue status updated to RETURNED'); |
2724 |
is($overdue->amountoutstanding, $overdue->amount, 'Overdue outstanding restored'); |
2725 |
|
2726 |
# Missing parameters |
2727 |
warning_like { |
2728 |
C4::Circulation::_RestoreOverdueForLostAndFound( undef ) |
2729 |
} |
2730 |
qr/_RestoreOverdueForLostAndFound\(\) not supplied valid itemnumber/, |
2731 |
"parameter warning received for missing itemnumbernumber"; |
2732 |
}; |
2733 |
|
2668 |
subtest '_FixOverduesOnReturn' => sub { |
2734 |
subtest '_FixOverduesOnReturn' => sub { |
2669 |
plan tests => 14; |
2735 |
plan tests => 14; |
2670 |
|
2736 |
|
Lines 2723-2729
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2723 |
|
2789 |
|
2724 |
is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' ); |
2790 |
is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' ); |
2725 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2791 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2726 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2792 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been set to returned ( status RETURNED )'); |
2727 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2793 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2728 |
is( $offset->amount + 0, -99, "Amount of offset is correct" ); |
2794 |
is( $offset->amount + 0, -99, "Amount of offset is correct" ); |
2729 |
my $credit = $offset->credit; |
2795 |
my $credit = $offset->credit; |
2730 |
- |
|
|