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 2447-2453
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2447 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2448 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2448 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2449 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2449 |
|
2450 |
|
2450 |
subtest 'bug 22877' => sub { |
2451 |
subtest 'bug 22877 | Lost item return' => sub { |
2451 |
|
2452 |
|
2452 |
plan tests => 3; |
2453 |
plan tests => 3; |
2453 |
|
2454 |
|
Lines 2697-2702
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2697 |
}; |
2698 |
}; |
2698 |
}; |
2699 |
}; |
2699 |
|
2700 |
|
|
|
2701 |
subtest '_RestoreOverdueForLostAndFound' => sub { |
2702 |
|
2703 |
plan tests => 7; |
2704 |
|
2705 |
my $manager = $builder->build_object( { class => "Koha::Patrons" } ); |
2706 |
t::lib::Mocks::mock_userenv( |
2707 |
{ patron => $manager, branchcode => $manager->branchcode } ); |
2708 |
|
2709 |
my $patron = $builder->build_object( { class => "Koha::Patrons" } ); |
2710 |
my $item = $builder->build_sample_item(); |
2711 |
|
2712 |
# No fine found |
2713 |
my $result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); |
2714 |
is($result, 0, "0 returned when no overdue found"); |
2715 |
|
2716 |
# Fine not forgiven |
2717 |
my $account = $patron->account; |
2718 |
my $overdue = $account->add_debit( |
2719 |
{ |
2720 |
amount => 30.00, |
2721 |
user_id => $manager->borrowernumber, |
2722 |
library_id => $library2->{branchcode}, |
2723 |
interface => 'test', |
2724 |
item_id => $item->itemnumber, |
2725 |
type => 'OVERDUE', |
2726 |
} |
2727 |
)->store(); |
2728 |
$overdue->status('LOST')->store(); |
2729 |
|
2730 |
$result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); |
2731 |
is($result, 0, "0 returned when overdue found without forgival"); |
2732 |
$overdue->discard_changes; |
2733 |
is($overdue->status, 'RETURNED', 'Overdue status updated to RETURNED'); |
2734 |
|
2735 |
# Reset status |
2736 |
$overdue->status('LOST')->store(); |
2737 |
|
2738 |
# Fine forgiven |
2739 |
my $credit = $account->add_credit( |
2740 |
{ |
2741 |
amount => 30.00, |
2742 |
user_id => $manager->borrowernumber, |
2743 |
library_id => $library2->{branchcode}, |
2744 |
interface => 'test', |
2745 |
type => 'FORGIVEN', |
2746 |
item_id => $item->itemnumber |
2747 |
} |
2748 |
); |
2749 |
$credit->apply( { debits => [$overdue], offset_type => 'Forgiven' } ); |
2750 |
|
2751 |
$result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); |
2752 |
|
2753 |
is( ref($result), 'Koha::Account::Line', 'Return a Koha::Account::Line object on sucess'); |
2754 |
$overdue->discard_changes; |
2755 |
is($overdue->status, 'RETURNED', 'Overdue status updated to RETURNED'); |
2756 |
is($overdue->amountoutstanding, $overdue->amount, 'Overdue outstanding restored'); |
2757 |
|
2758 |
# Missing parameters |
2759 |
warning_like { |
2760 |
C4::Circulation::_RestoreOverdueForLostAndFound( undef ) |
2761 |
} |
2762 |
qr/_RestoreOverdueForLostAndFound\(\) not supplied valid itemnumber/, |
2763 |
"parameter warning received for missing itemnumbernumber"; |
2764 |
}; |
2765 |
|
2700 |
subtest '_FixOverduesOnReturn' => sub { |
2766 |
subtest '_FixOverduesOnReturn' => sub { |
2701 |
plan tests => 14; |
2767 |
plan tests => 14; |
2702 |
|
2768 |
|
Lines 2755-2761
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2755 |
|
2821 |
|
2756 |
is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' ); |
2822 |
is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' ); |
2757 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2823 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2758 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2824 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been set to returned ( status RETURNED )'); |
2759 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2825 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2760 |
is( $offset->amount + 0, -99, "Amount of offset is correct" ); |
2826 |
is( $offset->amount + 0, -99, "Amount of offset is correct" ); |
2761 |
my $credit = $offset->credit; |
2827 |
my $credit = $offset->credit; |
2762 |
- |
|
|