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

(-)a/t/db_dependent/Circulation.t (-178 / +82 lines)
Lines 1183-1198 subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { Link Here
1183
    my $patron_1      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1183
    my $patron_1      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1184
    my $patron_2      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1184
    my $patron_2      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1185
1185
1186
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1186
    my $item = $builder->build_sample_item(
1187
    my $item = $builder->build(
1187
        {
1188
        {   source => 'Item',
1188
            homebranch    => $homebranch->{branchcode},
1189
            value  => {
1189
            holdingbranch => $holdingbranch->{branchcode},
1190
                homebranch    => $homebranch->{branchcode},
1191
                holdingbranch => $holdingbranch->{branchcode},
1192
                biblionumber  => $biblioitem->{biblionumber}
1193
            }
1194
        }
1190
        }
1195
    );
1191
    )->unblessed;
1196
1192
1197
    set_userenv($holdingbranch);
1193
    set_userenv($holdingbranch);
1198
1194
Lines 1274-1292 subtest 'AddIssue & AllowReturnToBranch' => sub { Link Here
1274
    my $patron_1      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1270
    my $patron_1      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1275
    my $patron_2      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1271
    my $patron_2      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1276
1272
1277
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1273
    my $item = $builder->build_sample_item(
1278
    my $item = $builder->build(
1274
        {
1279
        {   source => 'Item',
1275
            homebranch    => $homebranch->{branchcode},
1280
            value  => {
1276
            holdingbranch => $holdingbranch->{branchcode},
1281
                homebranch    => $homebranch->{branchcode},
1282
                holdingbranch => $holdingbranch->{branchcode},
1283
                notforloan    => 0,
1284
                itemlost      => 0,
1285
                withdrawn     => 0,
1286
                biblionumber  => $biblioitem->{biblionumber}
1287
            }
1288
        }
1277
        }
1289
    );
1278
    )->unblessed;
1290
1279
1291
    set_userenv($holdingbranch);
1280
    set_userenv($holdingbranch);
1292
1281
Lines 1343-1369 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
1343
1332
1344
    my $library = $builder->build( { source => 'Branch' } );
1333
    my $library = $builder->build( { source => 'Branch' } );
1345
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1334
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1346
1335
    my $item_1 = $builder->build_sample_item(
1347
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1336
        {
1348
    my $item_1 = $builder->build(
1337
            library => $library->{branchcode},
1349
        {   source => 'Item',
1350
            value  => {
1351
                homebranch    => $library->{branchcode},
1352
                holdingbranch => $library->{branchcode},
1353
                biblionumber  => $biblioitem_1->{biblionumber}
1354
            }
1355
        }
1338
        }
1356
    );
1339
    )->unblessed;
1357
    my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } );
1340
    my $item_2 = $builder->build_sample_item(
1358
    my $item_2 = $builder->build(
1341
        {
1359
        {   source => 'Item',
1342
            library => $library->{branchcode},
1360
            value  => {
1361
                homebranch    => $library->{branchcode},
1362
                holdingbranch => $library->{branchcode},
1363
                biblionumber  => $biblioitem_2->{biblionumber}
1364
            }
1365
        }
1343
        }
1366
    );
1344
    )->unblessed;
1367
1345
1368
    my ( $error, $question, $alerts );
1346
    my ( $error, $question, $alerts );
1369
1347
Lines 1416-1432 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
1416
            }
1394
            }
1417
        }
1395
        }
1418
    );
1396
    );
1419
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1397
    my $item_1 = $builder->build_sample_item(
1420
    my $item_1 = $builder->build(
1421
        {
1398
        {
1422
            source => 'Item',
1399
            library => $library->{branchcode},
1423
            value  => {
1424
                homebranch    => $library->branchcode,
1425
                holdingbranch => $library->branchcode,
1426
                biblionumber  => $biblioitem_1->{biblionumber}
1427
            }
1428
        }
1400
        }
1429
    );
1401
    )->unblessed;
1430
1402
1431
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} );
1403
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} );
1432
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
1404
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
Lines 1532-1557 subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { Link Here
1532
    my $library = $builder->build( { source => 'Branch' } );
1504
    my $library = $builder->build( { source => 'Branch' } );
1533
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1505
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1534
1506
1535
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1507
    my $biblionumber = $builder->build_sample_biblio(
1536
    my $biblionumber = $biblioitem->{biblionumber};
1508
        {
1537
    my $item_1 = $builder->build(
1509
            branchcode => $library->{branchcode},
1538
        {   source => 'Item',
1539
            value  => {
1540
                homebranch    => $library->{branchcode},
1541
                holdingbranch => $library->{branchcode},
1542
                biblionumber  => $biblionumber,
1543
            }
1544
        }
1510
        }
1545
    );
1511
    )->biblionumber;
1546
    my $item_2 = $builder->build(
1512
    my $item_1 = $builder->build_sample_item(
1547
        {   source => 'Item',
1513
        {
1548
            value  => {
1514
            biblionumber => $biblionumber,
1549
                homebranch    => $library->{branchcode},
1515
            library      => $library->{branchcode},
1550
                holdingbranch => $library->{branchcode},
1551
                biblionumber  => $biblionumber,
1552
            }
1553
        }
1516
        }
1554
    );
1517
    )->unblessed;
1518
1519
    my $item_2 = $builder->build_sample_item(
1520
        {
1521
            biblionumber => $biblionumber,
1522
            library      => $library->{branchcode},
1523
        }
1524
    )->unblessed;
1555
1525
1556
    my ( $error, $question, $alerts );
1526
    my ( $error, $question, $alerts );
1557
    my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) );
1527
    my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) );
Lines 1584-1617 subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { Link Here
1584
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1554
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1585
1555
1586
    # Add 2 items
1556
    # Add 2 items
1587
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1557
    my $biblionumber = $builder->build_sample_biblio(
1588
    my $item_1 = $builder->build(
1589
        {
1558
        {
1590
            source => 'Item',
1559
            branchcode => $library->{branchcode},
1591
            value  => {
1592
                homebranch    => $library->{branchcode},
1593
                holdingbranch => $library->{branchcode},
1594
                notforloan    => 0,
1595
                itemlost      => 0,
1596
                withdrawn     => 0,
1597
                biblionumber  => $biblioitem_1->{biblionumber}
1598
            }
1599
        }
1560
        }
1600
    );
1561
    )->biblionumber;
1601
    my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } );
1562
    my $item_1 = $builder->build_sample_item(
1602
    my $item_2 = $builder->build(
1603
        {
1563
        {
1604
            source => 'Item',
1564
            biblionumber => $biblionumber,
1605
            value  => {
1565
            library      => $library->{branchcode},
1606
                homebranch    => $library->{branchcode},
1607
                holdingbranch => $library->{branchcode},
1608
                notforloan    => 0,
1609
                itemlost      => 0,
1610
                withdrawn     => 0,
1611
                biblionumber  => $biblioitem_2->{biblionumber}
1612
            }
1613
        }
1566
        }
1614
    );
1567
    )->unblessed;
1568
    my $item_2 = $builder->build_sample_item(
1569
        {
1570
            biblionumber => $biblionumber,
1571
            library      => $library->{branchcode},
1572
        }
1573
    )->unblessed;
1615
1574
1616
    # And the issuing rule
1575
    # And the issuing rule
1617
    Koha::IssuingRules->search->delete;
1576
    Koha::IssuingRules->search->delete;
Lines 1710-1730 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
1710
    my $library = $builder->build( { source => 'Branch' } );
1669
    my $library = $builder->build( { source => 'Branch' } );
1711
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1670
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1712
1671
1713
    # Add 2 items
1672
    my $biblionumber = $builder->build_sample_biblio(
1714
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1715
    my $item_1 = $builder->build(
1716
        {
1673
        {
1717
            source => 'Item',
1674
            branchcode => $library->{branchcode},
1718
            value  => {
1719
                homebranch    => $library->{branchcode},
1720
                holdingbranch => $library->{branchcode},
1721
                notforloan    => 0,
1722
                itemlost      => 0,
1723
                withdrawn     => 0,
1724
                biblionumber  => $biblioitem_1->{biblionumber}
1725
            }
1726
        }
1675
        }
1727
    );
1676
    )->biblionumber;
1677
    my $item_1 = $builder->build_sample_item(
1678
        {
1679
            biblionumber => $biblionumber,
1680
            library      => $library->{branchcode},
1681
        }
1682
    )->unblessed;
1728
1683
1729
    # And the issuing rule
1684
    # And the issuing rule
1730
    Koha::IssuingRules->search->delete;
1685
    Koha::IssuingRules->search->delete;
Lines 1878-1897 subtest 'AddReturn | is_overdue' => sub { Link Here
1878
    my $library = $builder->build( { source => 'Branch' } );
1833
    my $library = $builder->build( { source => 'Branch' } );
1879
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1834
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1880
1835
1881
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1836
    my $item = $builder->build_sample_item(
1882
    my $item = $builder->build(
1883
        {
1837
        {
1884
            source => 'Item',
1838
            library      => $library->{branchcode},
1885
            value  => {
1886
                homebranch    => $library->{branchcode},
1887
                holdingbranch => $library->{branchcode},
1888
                notforloan    => 0,
1889
                itemlost      => 0,
1890
                withdrawn     => 0,
1891
                biblionumber  => $biblioitem->{biblionumber},
1892
            }
1893
        }
1839
        }
1894
    );
1840
    )->unblessed;
1895
1841
1896
    Koha::IssuingRules->search->delete;
1842
    Koha::IssuingRules->search->delete;
1897
    my $rule = Koha::IssuingRule->new(
1843
    my $rule = Koha::IssuingRule->new(
Lines 2325-2350 subtest 'Set waiting flag' => sub { Link Here
2325
    my $library_2 = $builder->build( { source => 'Branch' } );
2271
    my $library_2 = $builder->build( { source => 'Branch' } );
2326
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2272
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2327
2273
2328
    my $biblio = $builder->build( { source => 'Biblio' } );
2274
    my $item = $builder->build_sample_item(
2329
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
2330
2331
    my $item = $builder->build(
2332
        {
2275
        {
2333
            source => 'Item',
2276
            library      => $library_1->{branchcode},
2334
            value  => {
2335
                homebranch    => $library_1->{branchcode},
2336
                holdingbranch => $library_1->{branchcode},
2337
                notforloan    => 0,
2338
                itemlost      => 0,
2339
                withdrawn     => 0,
2340
                biblionumber  => $biblioitem->{biblionumber},
2341
            }
2342
        }
2277
        }
2343
    );
2278
    )->unblessed;
2344
2279
2345
    set_userenv( $library_2 );
2280
    set_userenv( $library_2 );
2346
    my $reserve_id = AddReserve(
2281
    my $reserve_id = AddReserve(
2347
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber},
2282
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $item->{biblionumber},
2348
        '', 1, undef, undef, '', undef, $item->{itemnumber},
2283
        '', 1, undef, undef, '', undef, $item->{itemnumber},
2349
    );
2284
    );
2350
2285
Lines 2399-2418 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
2399
    my $library = $builder->build( { source => 'Branch' } );
2334
    my $library = $builder->build( { source => 'Branch' } );
2400
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
2335
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
2401
2336
2402
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
2337
    my $item = $builder->build_sample_item(
2403
    my $item = $builder->build(
2404
        {
2338
        {
2405
            source => 'Item',
2339
            library      => $library->{branchcode},
2406
            value  => {
2407
                homebranch    => $library->{branchcode},
2408
                holdingbranch => $library->{branchcode},
2409
                notforloan    => 0,
2410
                itemlost      => 0,
2411
                withdrawn     => 0,
2412
                biblionumber  => $biblioitem->{biblionumber},
2413
            }
2414
        }
2340
        }
2415
    );
2341
    )->unblessed;
2416
2342
2417
    my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago
2343
    my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago
2418
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
2344
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
Lines 2557-2585 subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub { Link Here
2557
    my $library = $builder->build( { source => 'Branch' } );
2483
    my $library = $builder->build( { source => 'Branch' } );
2558
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store;
2484
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store;
2559
2485
2560
    my $itemtype = $builder->build(
2486
    my $item = $builder->build_sample_item(
2561
        {
2487
        {
2562
            source => 'Itemtype',
2488
            library      => $library->{branchcode},
2563
            value  => { notforloan => undef, }
2564
        }
2489
        }
2565
    );
2490
    );
2566
2491
2567
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { itemtype => $itemtype->{itemtype} } } );
2568
    my $item = $builder->build_object(
2569
        {
2570
            class => 'Koha::Items',
2571
            value  => {
2572
                homebranch    => $library->{branchcode},
2573
                holdingbranch => $library->{branchcode},
2574
                notforloan    => 0,
2575
                itemlost      => 0,
2576
                withdrawn     => 0,
2577
                biblionumber  => $biblioitem->{biblionumber},
2578
                biblioitemnumber => $biblioitem->{biblioitemnumber},
2579
            }
2580
        }
2581
    )->store;
2582
2583
    my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef );
2492
    my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef );
2584
    is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' );
2493
    is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' );
2585
    is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' );
2494
    is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' );
Lines 2599-2621 subtest 'CanBookBeIssued | notforloan' => sub { Link Here
2599
            value  => { notforloan => undef, }
2508
            value  => { notforloan => undef, }
2600
        }
2509
        }
2601
    );
2510
    );
2602
2511
    my $item = $builder->build_sample_item(
2603
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
2604
    my $item = $builder->build_object(
2605
        {
2512
        {
2606
            class => 'Koha::Items',
2513
            library  => $library->{branchcode},
2607
            value  => {
2514
            itype    => $itemtype->{itemtype},
2608
                homebranch    => $library->{branchcode},
2609
                holdingbranch => $library->{branchcode},
2610
                notforloan    => 0,
2611
                itemlost      => 0,
2612
                withdrawn     => 0,
2613
                itype         => $itemtype->{itemtype},
2614
                biblionumber  => $biblioitem->{biblionumber},
2615
                biblioitemnumber => $biblioitem->{biblioitemnumber},
2616
            }
2617
        }
2515
        }
2618
    )->store;
2516
    );
2517
    $item->biblioitem->itemtype($itemtype->{itemtype})->store;
2619
2518
2620
    my ( $issuingimpossible, $needsconfirmation );
2519
    my ( $issuingimpossible, $needsconfirmation );
2621
2520
Lines 2700-2706 subtest 'AddReturn should clear items.onloan for unissued items' => sub { Link Here
2700
    plan tests => 1;
2599
    plan tests => 1;
2701
2600
2702
    t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' );
2601
    t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' );
2703
    my $item = $builder->build_object({ class => 'Koha::Items', value  => { onloan => '2018-01-01' }});
2602
    my $item = $builder->build_sample_item(
2603
        {
2604
            onloan => '2018-01-01',
2605
        }
2606
    );
2607
2704
    AddReturn( $item->barcode, $item->homebranch );
2608
    AddReturn( $item->barcode, $item->homebranch );
2705
    $item->discard_changes; # refresh
2609
    $item->discard_changes; # refresh
2706
    is( $item->onloan, undef, 'AddReturn did clear items.onloan' );
2610
    is( $item->onloan, undef, 'AddReturn did clear items.onloan' );
(-)a/t/lib/TestBuilder.pm (-1 / +1 lines)
Lines 548-553 sub _gen_default_values { Link Here
548
            rentalcharge => 0,
548
            rentalcharge => 0,
549
            defaultreplacecost => 0,
549
            defaultreplacecost => 0,
550
            processfee => 0,
550
            processfee => 0,
551
            notforloan => 0,
551
        },
552
        },
552
        Aqbookseller => {
553
        Aqbookseller => {
553
            tax_rate => 0,
554
            tax_rate => 0,
554
- 

Return to bug 21985