View | Details | Raw Unified | Return to bug 7376
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-13 / +55 lines)
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 => 76;
22
use Test::More tests => 77;
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 1182-1188 subtest "CanBookBeRenewed tests" => sub { Link Here
1182
        );
1182
        );
1183
1183
1184
        my $ten_days_before = dt_from_string->add( days => -10 );
1184
        my $ten_days_before = dt_from_string->add( days => -10 );
1185
        my $ten_days_ahead  = dt_from_string->add( days => 10 );
1185
        my $ten_days_ahead  = dt_from_string->add( days =>  10 );
1186
        my $issue           = AddIssue(
1186
        my $issue           = AddIssue(
1187
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1187
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1188
            undef, { auto_renew => 1 }
1188
            undef, { auto_renew => 1 }
Lines 1332-1338 subtest "CanBookBeRenewed tests" => sub { Link Here
1332
        );
1332
        );
1333
1333
1334
        my $ten_days_before = dt_from_string->add( days => -10 );
1334
        my $ten_days_before = dt_from_string->add( days => -10 );
1335
        my $ten_days_ahead  = dt_from_string->add( days => 10 );
1335
        my $ten_days_ahead  = dt_from_string->add( days =>  10 );
1336
        my $issue           = AddIssue(
1336
        my $issue           = AddIssue(
1337
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1337
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1338
            undef, { auto_renew => 1 }
1338
            undef, { auto_renew => 1 }
Lines 1442-1448 subtest "CanBookBeRenewed tests" => sub { Link Here
1442
        );
1442
        );
1443
1443
1444
        my $ten_days_before = dt_from_string->add( days => -10 );
1444
        my $ten_days_before = dt_from_string->add( days => -10 );
1445
        my $ten_days_ahead  = dt_from_string->add( days => 10 );
1445
        my $ten_days_ahead  = dt_from_string->add( days =>  10 );
1446
1446
1447
        # Patron is expired and BlockExpiredPatronOpacActions=''
1447
        # Patron is expired and BlockExpiredPatronOpacActions=''
1448
        # => auto renew is allowed
1448
        # => auto renew is allowed
Lines 1494-1500 subtest "CanBookBeRenewed tests" => sub { Link Here
1494
        );
1494
        );
1495
1495
1496
        my $ten_days_before = dt_from_string->add( days => -10 );
1496
        my $ten_days_before = dt_from_string->add( days => -10 );
1497
        my $ten_days_ahead  = dt_from_string->add( days => 10 );
1497
        my $ten_days_ahead  = dt_from_string->add( days =>  10 );
1498
        my $issue           = AddIssue(
1498
        my $issue           = AddIssue(
1499
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1499
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1500
            undef, { auto_renew => 1 }
1500
            undef, { auto_renew => 1 }
Lines 1529-1535 subtest "CanBookBeRenewed tests" => sub { Link Here
1529
                }
1529
                }
1530
            }
1530
            }
1531
        );
1531
        );
1532
        $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj,, $issue );
1532
        $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj, $issue );
1533
        is(
1533
        is(
1534
            $latest_auto_renew_date->truncate( to => 'minute' ),
1534
            $latest_auto_renew_date->truncate( to => 'minute' ),
1535
            $five_days_before->truncate( to => 'minute' ),
1535
            $five_days_before->truncate( to => 'minute' ),
Lines 1615-1621 subtest "CanBookBeRenewed tests" => sub { Link Here
1615
        );
1615
        );
1616
1616
1617
        my $ten_days_before = dt_from_string->add( days => -10 );
1617
        my $ten_days_before = dt_from_string->add( days => -10 );
1618
        my $ten_days_ahead  = dt_from_string->add( days => 10 );
1618
        my $ten_days_ahead  = dt_from_string->add( days =>  10 );
1619
        my $issue           = AddIssue(
1619
        my $issue           = AddIssue(
1620
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1620
            $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before,
1621
            undef, { auto_renew => 1 }
1621
            undef, { auto_renew => 1 }
Lines 1965-1971 subtest "GetUpcomingDueIssues" => sub { Link Here
1965
    my $a_borrower                = Koha::Patrons->find($a_borrower_borrowernumber);
1965
    my $a_borrower                = Koha::Patrons->find($a_borrower_borrowernumber);
1966
1966
1967
    my $yesterday      = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 );
1967
    my $yesterday      = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 );
1968
    my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 );
1968
    my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days =>  2 );
1969
    my $today          = DateTime->today( time_zone => C4::Context->tz() );
1969
    my $today          = DateTime->today( time_zone => C4::Context->tz() );
1970
1970
1971
    my $issue    = AddIssue( $a_borrower, $item_1->barcode, $yesterday );
1971
    my $issue    = AddIssue( $a_borrower, $item_1->barcode, $yesterday );
Lines 2842-2847 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2842
    );
2842
    );
2843
};
2843
};
2844
2844
2845
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2846
    plan tests => 6;
2847
2848
    my $homebranch  = $builder->build( { source => 'Branch' } );
2849
    my $otherbranch = $builder->build( { source => 'Branch' } );
2850
    my $patron =
2851
        $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
2852
2853
    my $item = $builder->build_sample_item(
2854
        {
2855
            homebranch    => $homebranch->{branchcode},
2856
            holdingbranch => $homebranch->{branchcode},
2857
        }
2858
    );
2859
2860
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2861
    set_userenv($homebranch);
2862
    my $issue = AddIssue( $patron, $item->barcode );
2863
    my ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch );
2864
    is( 1,     $allowed, 'with AllowReturnToBranch = anywhere and no limits return to other is allowed' );
2865
    is( undef, $message, 'without limits provides no message' );
2866
2867
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits',  '1' );
2868
    t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' );
2869
2870
    # set limit
2871
    my $limit = Koha::Item::Transfer::Limit->new(
2872
        {
2873
            toBranch   => $otherbranch->{branchcode},
2874
            fromBranch => $item->homebranch,
2875
            itemtype   => $item->effective_itemtype,
2876
        }
2877
    )->store();
2878
2879
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch );
2880
    is( 0,                         $allowed, 'With transfer limits cannot return to otherbranch' );
2881
    is( $homebranch->{branchcode}, $message, 'With transfer limits asks return to homebranch' );
2882
2883
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $homebranch );
2884
    is( 1,     $allowed, 'With transfer limits can return to homebranch' );
2885
    is( undef, $message, 'With transfer limits and homebranch provides no message' );
2886
};
2887
2845
subtest 'Statistic patrons "X"' => sub {
2888
subtest 'Statistic patrons "X"' => sub {
2846
    plan tests => 15;
2889
    plan tests => 15;
2847
2890
Lines 3877-3883 subtest 'AddReturn | is_overdue' => sub { Link Here
3877
        is( $line->status,                'RETURNED', "Overdue fine is fixed" );
3920
        is( $line->status,                'RETURNED', "Overdue fine is fixed" );
3878
        $line = $lines->next;
3921
        $line = $lines->next;
3879
        is( $line->amount + 0,            -2, "Original payment amount remains as 2" );
3922
        is( $line->amount + 0,            -2, "Original payment amount remains as 2" );
3880
        is( $line->amountoutstanding + 0, 0,  "Original payment remains applied" );
3923
        is( $line->amountoutstanding + 0,  0, "Original payment remains applied" );
3881
        $line = $lines->next;
3924
        $line = $lines->next;
3882
        is( $line->amount + 0,            -1, "Refund amount correctly set to 1" );
3925
        is( $line->amount + 0,            -1, "Refund amount correctly set to 1" );
3883
        is( $line->amountoutstanding + 0, -1, "Refund amount outstanding unspent" );
3926
        is( $line->amountoutstanding + 0, -1, "Refund amount outstanding unspent" );
Lines 4792-4798 subtest '_FixOverduesOnReturn' => sub { Link Here
4792
    my $credit = $offset->credit;
4835
    my $credit = $offset->credit;
4793
    is( ref $credit,                    "Koha::Account::Line", "Found matching credit for fine forgiveness" );
4836
    is( ref $credit,                    "Koha::Account::Line", "Found matching credit for fine forgiveness" );
4794
    is( $credit->amount + 0,            -99,                   "Credit amount is set correctly" );
4837
    is( $credit->amount + 0,            -99,                   "Credit amount is set correctly" );
4795
    is( $credit->amountoutstanding + 0, 0,                     "Credit amountoutstanding is correctly set to 0" );
4838
    is( $credit->amountoutstanding + 0,  0,                    "Credit amountoutstanding is correctly set to 0" );
4796
4839
4797
    # Bug 25417 - Only forgive fines where there is an amount outstanding to forgive
4840
    # Bug 25417 - Only forgive fines where there is an amount outstanding to forgive
4798
    $accountline->set(
4841
    $accountline->set(
Lines 7325-7331 subtest 'NoRefundOnLostFinesPaidAge' => sub { Link Here
7325
        {
7368
        {
7326
            borrowernumber    => $patron->id,
7369
            borrowernumber    => $patron->id,
7327
            date              => '1970-01-01 14:00:01',
7370
            date              => '1970-01-01 14:00:01',
7328
            amountoutstanding => 0,
7371
            amountoutstanding =>  0,
7329
            amount            => -5,
7372
            amount            => -5,
7330
            interface         => 'commandline',
7373
            interface         => 'commandline',
7331
            credit_type_code  => 'PAYMENT'
7374
            credit_type_code  => 'PAYMENT'
Lines 7381-7387 subtest 'NoRefundOnLostFinesPaidAge' => sub { Link Here
7381
            borrowernumber    => $patron2->id,
7424
            borrowernumber    => $patron2->id,
7382
            date              => '1970-01-01 14:00:01',
7425
            date              => '1970-01-01 14:00:01',
7383
            amount            => -5,
7426
            amount            => -5,
7384
            amountoutstanding => 0,
7427
            amountoutstanding =>  0,
7385
            interface         => 'commandline',
7428
            interface         => 'commandline',
7386
            credit_type_code  => 'PAYMENT'
7429
            credit_type_code  => 'PAYMENT'
7387
        }
7430
        }
7388
- 

Return to bug 7376