|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
use utf8; |
19 |
use utf8; |
| 20 |
|
20 |
|
| 21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
| 22 |
use Test::More tests => 83; |
22 |
use Test::More tests => 84; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use Test::Deep qw( cmp_deeply ); |
25 |
use Test::Deep qw( cmp_deeply ); |
|
Lines 1185-1191
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1185 |
); |
1185 |
); |
| 1186 |
|
1186 |
|
| 1187 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1187 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 1188 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1188 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1189 |
my $issue = AddIssue( |
1189 |
my $issue = AddIssue( |
| 1190 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
1190 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
| 1191 |
undef, { auto_renew => 1 } |
1191 |
undef, { auto_renew => 1 } |
|
Lines 1335-1341
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1335 |
); |
1335 |
); |
| 1336 |
|
1336 |
|
| 1337 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1337 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 1338 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1338 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1339 |
my $issue = AddIssue( |
1339 |
my $issue = AddIssue( |
| 1340 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
1340 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
| 1341 |
undef, { auto_renew => 1 } |
1341 |
undef, { auto_renew => 1 } |
|
Lines 1445-1451
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1445 |
); |
1445 |
); |
| 1446 |
|
1446 |
|
| 1447 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1447 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 1448 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1448 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1449 |
|
1449 |
|
| 1450 |
# Patron is expired and BlockExpiredPatronOpacActions='' |
1450 |
# Patron is expired and BlockExpiredPatronOpacActions='' |
| 1451 |
# => auto renew is allowed |
1451 |
# => auto renew is allowed |
|
Lines 1497-1503
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1497 |
); |
1497 |
); |
| 1498 |
|
1498 |
|
| 1499 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1499 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 1500 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1500 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1501 |
my $issue = AddIssue( |
1501 |
my $issue = AddIssue( |
| 1502 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
1502 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
| 1503 |
undef, { auto_renew => 1 } |
1503 |
undef, { auto_renew => 1 } |
|
Lines 1618-1624
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1618 |
); |
1618 |
); |
| 1619 |
|
1619 |
|
| 1620 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1620 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 1621 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1621 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1622 |
my $issue = AddIssue( |
1622 |
my $issue = AddIssue( |
| 1623 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
1623 |
$renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, |
| 1624 |
undef, { auto_renew => 1 } |
1624 |
undef, { auto_renew => 1 } |
|
Lines 1969-1975
subtest "GetUpcomingDueIssues" => sub {
Link Here
|
| 1969 |
my $a_borrower = Koha::Patrons->find($a_borrower_borrowernumber); |
1969 |
my $a_borrower = Koha::Patrons->find($a_borrower_borrowernumber); |
| 1970 |
|
1970 |
|
| 1971 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
1971 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
| 1972 |
my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 ); |
1972 |
my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 ); |
| 1973 |
my $today = DateTime->today( time_zone => C4::Context->tz() ); |
1973 |
my $today = DateTime->today( time_zone => C4::Context->tz() ); |
| 1974 |
|
1974 |
|
| 1975 |
my $issue = AddIssue( $a_borrower, $item_1->barcode, $yesterday ); |
1975 |
my $issue = AddIssue( $a_borrower, $item_1->barcode, $yesterday ); |
|
Lines 2846-2851
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
| 2846 |
); |
2846 |
); |
| 2847 |
}; |
2847 |
}; |
| 2848 |
|
2848 |
|
|
|
2849 |
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { |
| 2850 |
plan tests => 6; |
| 2851 |
|
| 2852 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
| 2853 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
| 2854 |
my $patron = |
| 2855 |
$builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
| 2856 |
|
| 2857 |
my $item = $builder->build_sample_item( |
| 2858 |
{ |
| 2859 |
homebranch => $homebranch->{branchcode}, |
| 2860 |
holdingbranch => $homebranch->{branchcode}, |
| 2861 |
} |
| 2862 |
); |
| 2863 |
|
| 2864 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
| 2865 |
set_userenv($homebranch); |
| 2866 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 2867 |
my ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch ); |
| 2868 |
is( 1, $allowed, 'with AllowReturnToBranch = anywhere and no limits return to other is allowed' ); |
| 2869 |
is( undef, $message, 'without limits provides no message' ); |
| 2870 |
|
| 2871 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); |
| 2872 |
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); |
| 2873 |
|
| 2874 |
# set limit |
| 2875 |
my $limit = Koha::Item::Transfer::Limit->new( |
| 2876 |
{ |
| 2877 |
toBranch => $otherbranch->{branchcode}, |
| 2878 |
fromBranch => $item->homebranch, |
| 2879 |
itemtype => $item->effective_itemtype, |
| 2880 |
} |
| 2881 |
)->store(); |
| 2882 |
|
| 2883 |
( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch ); |
| 2884 |
is( 0, $allowed, 'With transfer limits cannot return to otherbranch' ); |
| 2885 |
is( $homebranch->{branchcode}, $message, 'With transfer limits asks return to homebranch' ); |
| 2886 |
|
| 2887 |
( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $homebranch ); |
| 2888 |
is( 1, $allowed, 'With transfer limits can return to homebranch' ); |
| 2889 |
is( undef, $message, 'With transfer limits and homebranch provides no message' ); |
| 2890 |
}; |
| 2891 |
|
| 2849 |
subtest 'Statistic patrons "X"' => sub { |
2892 |
subtest 'Statistic patrons "X"' => sub { |
| 2850 |
plan tests => 15; |
2893 |
plan tests => 15; |
| 2851 |
|
2894 |
|
|
Lines 3881-3887
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
| 3881 |
is( $line->status, 'RETURNED', "Overdue fine is fixed" ); |
3924 |
is( $line->status, 'RETURNED', "Overdue fine is fixed" ); |
| 3882 |
$line = $lines->next; |
3925 |
$line = $lines->next; |
| 3883 |
is( $line->amount + 0, -2, "Original payment amount remains as 2" ); |
3926 |
is( $line->amount + 0, -2, "Original payment amount remains as 2" ); |
| 3884 |
is( $line->amountoutstanding + 0, 0, "Original payment remains applied" ); |
3927 |
is( $line->amountoutstanding + 0, 0, "Original payment remains applied" ); |
| 3885 |
$line = $lines->next; |
3928 |
$line = $lines->next; |
| 3886 |
is( $line->amount + 0, -1, "Refund amount correctly set to 1" ); |
3929 |
is( $line->amount + 0, -1, "Refund amount correctly set to 1" ); |
| 3887 |
is( $line->amountoutstanding + 0, -1, "Refund amount outstanding unspent" ); |
3930 |
is( $line->amountoutstanding + 0, -1, "Refund amount outstanding unspent" ); |
|
Lines 4835-4841
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
| 4835 |
my $credit = $offset->credit; |
4878 |
my $credit = $offset->credit; |
| 4836 |
is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" ); |
4879 |
is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" ); |
| 4837 |
is( $credit->amount + 0, -99, "Credit amount is set correctly" ); |
4880 |
is( $credit->amount + 0, -99, "Credit amount is set correctly" ); |
| 4838 |
is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); |
4881 |
is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); |
| 4839 |
|
4882 |
|
| 4840 |
# Bug 25417 - Only forgive fines where there is an amount outstanding to forgive |
4883 |
# Bug 25417 - Only forgive fines where there is an amount outstanding to forgive |
| 4841 |
$accountline->set( |
4884 |
$accountline->set( |
|
Lines 7586-7592
subtest 'NoRefundOnLostFinesPaidAge' => sub {
Link Here
|
| 7586 |
{ |
7629 |
{ |
| 7587 |
borrowernumber => $patron->id, |
7630 |
borrowernumber => $patron->id, |
| 7588 |
date => '1970-01-01 14:00:01', |
7631 |
date => '1970-01-01 14:00:01', |
| 7589 |
amountoutstanding => 0, |
7632 |
amountoutstanding => 0, |
| 7590 |
amount => -5, |
7633 |
amount => -5, |
| 7591 |
interface => 'commandline', |
7634 |
interface => 'commandline', |
| 7592 |
credit_type_code => 'PAYMENT' |
7635 |
credit_type_code => 'PAYMENT' |
|
Lines 7642-7648
subtest 'NoRefundOnLostFinesPaidAge' => sub {
Link Here
|
| 7642 |
borrowernumber => $patron2->id, |
7685 |
borrowernumber => $patron2->id, |
| 7643 |
date => '1970-01-01 14:00:01', |
7686 |
date => '1970-01-01 14:00:01', |
| 7644 |
amount => -5, |
7687 |
amount => -5, |
| 7645 |
amountoutstanding => 0, |
7688 |
amountoutstanding => 0, |
| 7646 |
interface => 'commandline', |
7689 |
interface => 'commandline', |
| 7647 |
credit_type_code => 'PAYMENT' |
7690 |
credit_type_code => 'PAYMENT' |
| 7648 |
} |
7691 |
} |
| 7649 |
- |
|
|