Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 48; |
21 |
use Test::More tests => 47; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Deep qw( cmp_deeply ); |
23 |
use Test::Deep qw( cmp_deeply ); |
24 |
|
24 |
|
Lines 2349-2355
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
2349 |
|
2349 |
|
2350 |
|
2350 |
|
2351 |
subtest 'AddReturn | is_overdue' => sub { |
2351 |
subtest 'AddReturn | is_overdue' => sub { |
2352 |
plan tests => 7; |
2352 |
plan tests => 8; |
2353 |
|
2353 |
|
2354 |
t::lib::Mocks::mock_preference('MarkLostItemsAsReturned', 'batchmod|moredetail|cronjob|additem|pendingreserves|onpayment'); |
2354 |
t::lib::Mocks::mock_preference('MarkLostItemsAsReturned', 'batchmod|moredetail|cronjob|additem|pendingreserves|onpayment'); |
2355 |
t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1); |
2355 |
t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1); |
Lines 2570-2575
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2570 |
AddReturn( $item->{barcode}, $library->{branchcode}, 1, $one_day_ago ); |
2570 |
AddReturn( $item->{barcode}, $library->{branchcode}, 1, $one_day_ago ); |
2571 |
is( int( $patron->account->balance() ), |
2571 |
is( int( $patron->account->balance() ), |
2572 |
0, "Overdue fine should be annulled" ); |
2572 |
0, "Overdue fine should be annulled" ); |
|
|
2573 |
|
2574 |
# Cleanup |
2575 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2576 |
}; |
2577 |
|
2578 |
subtest 'bug 24075 | backdated return with return datetime matching due datetime' => sub { |
2579 |
plan tests => 7; |
2580 |
|
2581 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
2582 |
|
2583 |
my $due_date = dt_from_string; |
2584 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $due_date ); |
2585 |
|
2586 |
# Add fine |
2587 |
UpdateFine( |
2588 |
{ |
2589 |
issue_id => $issue->issue_id, |
2590 |
itemnumber => $item->{itemnumber}, |
2591 |
borrowernumber => $patron->borrowernumber, |
2592 |
amount => 0.25, |
2593 |
due => output_pref($due_date) |
2594 |
} |
2595 |
); |
2596 |
is( $patron->account->balance(), |
2597 |
0.25, 'Overdue fine of $0.25 recorded' ); |
2598 |
|
2599 |
# Backdate return to exact due date and time |
2600 |
my ( undef, $message ) = |
2601 |
AddReturn( $item->{barcode}, $library->{branchcode}, |
2602 |
undef, $due_date ); |
2603 |
|
2604 |
my $accountline = |
2605 |
Koha::Account::Lines->find( { issue_id => $issue->id } ); |
2606 |
ok( !$accountline, 'accountline removed as expected' ); |
2607 |
|
2608 |
# Re-issue |
2609 |
$issue = AddIssue( $patron->unblessed, $item->{barcode}, $due_date ); |
2610 |
|
2611 |
# Add fine |
2612 |
UpdateFine( |
2613 |
{ |
2614 |
issue_id => $issue->issue_id, |
2615 |
itemnumber => $item->{itemnumber}, |
2616 |
borrowernumber => $patron->borrowernumber, |
2617 |
amount => .25, |
2618 |
due => output_pref($due_date) |
2619 |
} |
2620 |
); |
2621 |
is( $patron->account->balance(), |
2622 |
0.25, 'Overdue fine of $0.25 recorded' ); |
2623 |
|
2624 |
# Partial pay accruing fine |
2625 |
my $lines = Koha::Account::Lines->search( |
2626 |
{ |
2627 |
borrowernumber => $patron->borrowernumber, |
2628 |
issue_id => $issue->id |
2629 |
} |
2630 |
); |
2631 |
my $debit = $lines->next; |
2632 |
my $credit = $patron->account->add_credit( |
2633 |
{ |
2634 |
amount => .20, |
2635 |
type => 'PAYMENT', |
2636 |
interface => 'test', |
2637 |
} |
2638 |
); |
2639 |
$credit->apply( { debits => [$debit], offset_type => 'Payment' } ); |
2640 |
|
2641 |
is( $patron->account->balance(), .05, 'Overdue fine reduced to $0.05' ); |
2642 |
|
2643 |
# Backdate return to exact due date and time |
2644 |
( undef, $message ) = |
2645 |
AddReturn( $item->{barcode}, $library->{branchcode}, |
2646 |
undef, $due_date ); |
2647 |
|
2648 |
$lines = Koha::Account::Lines->search( |
2649 |
{ |
2650 |
borrowernumber => $patron->borrowernumber, |
2651 |
issue_id => $issue->id |
2652 |
} |
2653 |
); |
2654 |
my $accountline = $lines->next; |
2655 |
is( $accountline->amountoutstanding + 0, |
2656 |
0, 'Partially paid fee amount outstanding was reduced to 0' ); |
2657 |
is( $accountline->amount + 0, |
2658 |
0, 'Partially paid fee amount was reduced to 0' ); |
2659 |
is( $patron->account->balance(), -0.20, 'Patron refund recorded' ); |
2660 |
|
2661 |
# Cleanup |
2662 |
Koha::Account::Lines->search( |
2663 |
{ borrowernumber => $patron->borrowernumber } )->delete; |
2573 |
}; |
2664 |
}; |
2574 |
}; |
2665 |
}; |
2575 |
|
2666 |
|
Lines 3886-3934
subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub {
Link Here
|
3886 |
$itemtype->rentalcharge_daily('0')->store; |
3977 |
$itemtype->rentalcharge_daily('0')->store; |
3887 |
}; |
3978 |
}; |
3888 |
|
3979 |
|
3889 |
subtest "Test Backdating of Returns" => sub { |
|
|
3890 |
plan tests => 2; |
3891 |
|
3892 |
my $branch = $library2->{branchcode}; |
3893 |
my $biblio = $builder->build_sample_biblio(); |
3894 |
my $item = $builder->build_sample_item( |
3895 |
{ |
3896 |
biblionumber => $biblio->biblionumber, |
3897 |
library => $branch, |
3898 |
itype => $itemtype, |
3899 |
} |
3900 |
); |
3901 |
|
3902 |
my %a_borrower_data = ( |
3903 |
firstname => 'Kyle', |
3904 |
surname => 'Hall', |
3905 |
categorycode => $patron_category->{categorycode}, |
3906 |
branchcode => $branch, |
3907 |
); |
3908 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
3909 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
3910 |
|
3911 |
my $due_date = dt_from_string; |
3912 |
my $issue = AddIssue( $borrower, $item->barcode, $due_date ); |
3913 |
UpdateFine( |
3914 |
{ |
3915 |
issue_id => $issue->id(), |
3916 |
itemnumber => $item->itemnumber, |
3917 |
borrowernumber => $borrowernumber, |
3918 |
amount => .25, |
3919 |
amountoutstanding => .25, |
3920 |
type => q{} |
3921 |
} |
3922 |
); |
3923 |
|
3924 |
|
3925 |
my ( undef, $message ) = AddReturn( $item->barcode, $branch, undef, $due_date ); |
3926 |
|
3927 |
my $accountline = Koha::Account::Lines->find( { issue_id => $issue->id } ); |
3928 |
is( $accountline->amountoutstanding+0, 0, 'Fee amount outstanding was reduced to 0' ); |
3929 |
is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' ); |
3930 |
}; |
3931 |
|
3932 |
subtest 'Do not return on renewal (LOST charge)' => sub { |
3980 |
subtest 'Do not return on renewal (LOST charge)' => sub { |
3933 |
plan tests => 1; |
3981 |
plan tests => 1; |
3934 |
|
3982 |
|
3935 |
- |
|
|