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

(-)a/t/db_dependent/Circulation.t (-2 / +66 lines)
Lines 2103-2109 subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { Link Here
2103
};
2103
};
2104
2104
2105
subtest 'AddReturn + suspension_chargeperiod' => sub {
2105
subtest 'AddReturn + suspension_chargeperiod' => sub {
2106
    plan tests => 27;
2106
    plan tests => 29;
2107
2107
2108
    my $library = $builder->build( { source => 'Branch' } );
2108
    my $library = $builder->build( { source => 'Branch' } );
2109
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
2109
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
Lines 2142-2147 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2142
    # We want to charge 2 days every day, without grace
2142
    # We want to charge 2 days every day, without grace
2143
    # With 5 days of overdue: 5 * Z
2143
    # With 5 days of overdue: 5 * Z
2144
    my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 );
2144
    my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 );
2145
    Koha::Patron::Debarments::AddUniqueDebarment( {
2146
        borrowernumber => $patron->{borrowernumber},
2147
        type => 'SUSPENSION',
2148
        expiration => $expected_expiration } );
2145
    test_debarment_on_checkout(
2149
    test_debarment_on_checkout(
2146
        {
2150
        {
2147
            item            => $item_1,
2151
            item            => $item_1,
Lines 2174-2179 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2174
    # We want to charge 2 days every day, without grace
2178
    # We want to charge 2 days every day, without grace
2175
    # With 5 days of overdue: 5 * Z
2179
    # With 5 days of overdue: 5 * Z
2176
    my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 );
2180
    my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 );
2181
    Koha::Patron::Debarments::AddUniqueDebarment( {
2182
        borrowernumber => $patron->{borrowernumber},
2183
        type => 'SUSPENSION',
2184
        expiration => $expected_expiration } );
2177
    test_debarment_on_checkout(
2185
    test_debarment_on_checkout(
2178
        {
2186
        {
2179
            item            => $item_1,
2187
            item            => $item_1,
Lines 2197-2202 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2197
    );
2205
    );
2198
2206
2199
    $expected_expiration = $now->clone->add( days => floor( 5 * 2 ) / 2 );
2207
    $expected_expiration = $now->clone->add( days => floor( 5 * 2 ) / 2 );
2208
    Koha::Patron::Debarments::AddUniqueDebarment( {
2209
        borrowernumber => $patron->{borrowernumber},
2210
        type => 'SUSPENSION',
2211
        expiration => $expected_expiration } );
2200
    test_debarment_on_checkout(
2212
    test_debarment_on_checkout(
2201
        {
2213
        {
2202
            item            => $item_1,
2214
            item            => $item_1,
Lines 2221-2226 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2221
        }
2233
        }
2222
    );
2234
    );
2223
    $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) );
2235
    $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) );
2236
    Koha::Patron::Debarments::AddUniqueDebarment( {
2237
        borrowernumber => $patron->{borrowernumber},
2238
        type => 'SUSPENSION',
2239
        expiration => $expected_expiration } );
2224
    test_debarment_on_checkout(
2240
    test_debarment_on_checkout(
2225
        {
2241
        {
2226
            item            => $item_1,
2242
            item            => $item_1,
Lines 2260-2265 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2260
    );
2276
    );
2261
    # With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday)
2277
    # With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday)
2262
    $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) );
2278
    $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) );
2279
    Koha::Patron::Debarments::AddUniqueDebarment( {
2280
        borrowernumber => $patron->{borrowernumber},
2281
        type => 'SUSPENSION',
2282
        expiration => $expected_expiration } );
2263
    test_debarment_on_checkout(
2283
    test_debarment_on_checkout(
2264
        {
2284
        {
2265
            item            => $item_1,
2285
            item            => $item_1,
Lines 2282-2287 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2282
2302
2283
    # Same as above, but we should skip D+2
2303
    # Same as above, but we should skip D+2
2284
    $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 );
2304
    $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 );
2305
    Koha::Patron::Debarments::AddUniqueDebarment( {
2306
        borrowernumber => $patron->{borrowernumber},
2307
        type => 'SUSPENSION',
2308
        expiration => $expected_expiration } );
2285
    test_debarment_on_checkout(
2309
    test_debarment_on_checkout(
2286
        {
2310
        {
2287
            item            => $item_1,
2311
            item            => $item_1,
Lines 2302-2307 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2302
        description     => 'holidayDesc on expiration date'
2326
        description     => 'holidayDesc on expiration date'
2303
    );
2327
    );
2304
    # Expiration date will be the day after
2328
    # Expiration date will be the day after
2329
    Koha::Patron::Debarments::AddUniqueDebarment( {
2330
        borrowernumber => $patron->{borrowernumber},
2331
        type => 'SUSPENSION',
2332
        expiration => $expected_expiration->clone->add( days => 1 ) } );
2305
    test_debarment_on_checkout(
2333
    test_debarment_on_checkout(
2306
        {
2334
        {
2307
            item            => $item_1,
2335
            item            => $item_1,
Lines 2312-2317 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2312
        }
2340
        }
2313
    );
2341
    );
2314
2342
2343
    Koha::Patron::Debarments::AddUniqueDebarment( {
2344
        borrowernumber => $patron->{borrowernumber},
2345
        type => 'SUSPENSION',
2346
        expiration => $now->clone->add(days => 5 + (5 * 2 - 1) ) } );
2315
    test_debarment_on_checkout(
2347
    test_debarment_on_checkout(
2316
        {
2348
        {
2317
            item            => $item_1,
2349
            item            => $item_1,
Lines 2322-2327 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2322
        }
2354
        }
2323
    );
2355
    );
2324
2356
2357
    Koha::Patron::Debarments::AddUniqueDebarment( {
2358
        borrowernumber => $patron->{borrowernumber},
2359
        type => 'SUSPENSION',
2360
        expiration => $now->clone->add(days => 5 + (4 * 2 - 1) ) } );
2325
    test_debarment_on_checkout(
2361
    test_debarment_on_checkout(
2326
        {
2362
        {
2327
            item            => $item_1,
2363
            item            => $item_1,
Lines 2333-2338 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2333
        }
2369
        }
2334
    );
2370
    );
2335
2371
2372
    # Debarred message when finesdays = 0
2373
2374
    Koha::CirculationRules->set_rules(
2375
        {
2376
            categorycode => undef,
2377
            branchcode   => undef,
2378
            itemtype     => undef,
2379
            rules        => {
2380
                finedays                => 0,
2381
                suspension_chargeperiod => 1,
2382
            }
2383
        }
2384
    );
2385
2386
    Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, type => 'MANUAL', expiration => $now->clone->add(days => 10) } );
2387
2388
    AddIssue( $patron, $item_1->barcode, $now->clone->add(days => 1) );
2389
2390
    my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now->clone->subtract(days => 1) );
2391
    is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for AddReturn when not overdue' );
2392
2393
    AddIssue( $patron, $item_1->barcode, $now->clone->add(days => 1) );
2394
2395
    ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now->clone->add(days => 5) );
2396
    is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for AddReturn when overdue' );
2397
2398
    Koha::Patron::Debarments::DelUniqueDebarment(
2399
        { borrowernumber => $patron->{borrowernumber}, type => 'MANUAL' } );
2400
2336
};
2401
};
2337
2402
2338
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
2403
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
2339
- 

Return to bug 14784