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

(-)a/t/db_dependent/Circulation.t (-191 / +82 lines)
Lines 1296-1311 subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { Link Here
1296
    my $patron_1      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1296
    my $patron_1      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1297
    my $patron_2      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1297
    my $patron_2      = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1298
1298
1299
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1299
    my $item = $builder->build_sample_item(
1300
    my $item = $builder->build(
1300
        {
1301
        {   source => 'Item',
1301
            homebranch    => $homebranch->{branchcode},
1302
            value  => {
1302
            holdingbranch => $holdingbranch->{branchcode},
1303
                homebranch    => $homebranch->{branchcode},
1304
                holdingbranch => $holdingbranch->{branchcode},
1305
                biblionumber  => $biblioitem->{biblionumber}
1306
            }
1307
        }
1303
        }
1308
    );
1304
    )->unblessed;
1309
1305
1310
    set_userenv($holdingbranch);
1306
    set_userenv($holdingbranch);
1311
1307
Lines 1387-1405 subtest 'AddIssue & AllowReturnToBranch' => sub { Link Here
1387
    my $patron_1      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1383
    my $patron_1      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1388
    my $patron_2      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1384
    my $patron_2      = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1389
1385
1390
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1386
    my $item = $builder->build_sample_item(
1391
    my $item = $builder->build(
1387
        {
1392
        {   source => 'Item',
1388
            homebranch    => $homebranch->{branchcode},
1393
            value  => {
1389
            holdingbranch => $holdingbranch->{branchcode},
1394
                homebranch    => $homebranch->{branchcode},
1395
                holdingbranch => $holdingbranch->{branchcode},
1396
                notforloan    => 0,
1397
                itemlost      => 0,
1398
                withdrawn     => 0,
1399
                biblionumber  => $biblioitem->{biblionumber}
1400
            }
1401
        }
1390
        }
1402
    );
1391
    )->unblessed;
1403
1392
1404
    set_userenv($holdingbranch);
1393
    set_userenv($holdingbranch);
1405
1394
Lines 1456-1482 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
1456
1445
1457
    my $library = $builder->build( { source => 'Branch' } );
1446
    my $library = $builder->build( { source => 'Branch' } );
1458
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1447
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1459
1448
    my $item_1 = $builder->build_sample_item(
1460
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1449
        {
1461
    my $item_1 = $builder->build(
1450
            library => $library->{branchcode},
1462
        {   source => 'Item',
1463
            value  => {
1464
                homebranch    => $library->{branchcode},
1465
                holdingbranch => $library->{branchcode},
1466
                biblionumber  => $biblioitem_1->{biblionumber}
1467
            }
1468
        }
1451
        }
1469
    );
1452
    )->unblessed;
1470
    my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } );
1453
    my $item_2 = $builder->build_sample_item(
1471
    my $item_2 = $builder->build(
1454
        {
1472
        {   source => 'Item',
1455
            library => $library->{branchcode},
1473
            value  => {
1474
                homebranch    => $library->{branchcode},
1475
                holdingbranch => $library->{branchcode},
1476
                biblionumber  => $biblioitem_2->{biblionumber}
1477
            }
1478
        }
1456
        }
1479
    );
1457
    )->unblessed;
1480
1458
1481
    my ( $error, $question, $alerts );
1459
    my ( $error, $question, $alerts );
1482
1460
Lines 1529-1545 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
1529
            }
1507
            }
1530
        }
1508
        }
1531
    );
1509
    );
1532
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1510
    my $item_1 = $builder->build_sample_item(
1533
    my $item_1 = $builder->build(
1534
        {
1511
        {
1535
            source => 'Item',
1512
            library => $library->{branchcode},
1536
            value  => {
1537
                homebranch    => $library->branchcode,
1538
                holdingbranch => $library->branchcode,
1539
                biblionumber  => $biblioitem_1->{biblionumber}
1540
            }
1541
        }
1513
        }
1542
    );
1514
    )->unblessed;
1543
1515
1544
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} );
1516
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} );
1545
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
1517
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
Lines 1645-1670 subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { Link Here
1645
    my $library = $builder->build( { source => 'Branch' } );
1617
    my $library = $builder->build( { source => 'Branch' } );
1646
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1618
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
1647
1619
1648
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1620
    my $biblionumber = $builder->build_sample_biblio(
1649
    my $biblionumber = $biblioitem->{biblionumber};
1621
        {
1650
    my $item_1 = $builder->build(
1622
            branchcode => $library->{branchcode},
1651
        {   source => 'Item',
1652
            value  => {
1653
                homebranch    => $library->{branchcode},
1654
                holdingbranch => $library->{branchcode},
1655
                biblionumber  => $biblionumber,
1656
            }
1657
        }
1623
        }
1658
    );
1624
    )->biblionumber;
1659
    my $item_2 = $builder->build(
1625
    my $item_1 = $builder->build_sample_item(
1660
        {   source => 'Item',
1626
        {
1661
            value  => {
1627
            biblionumber => $biblionumber,
1662
                homebranch    => $library->{branchcode},
1628
            library      => $library->{branchcode},
1663
                holdingbranch => $library->{branchcode},
1664
                biblionumber  => $biblionumber,
1665
            }
1666
        }
1629
        }
1667
    );
1630
    )->unblessed;
1631
1632
    my $item_2 = $builder->build_sample_item(
1633
        {
1634
            biblionumber => $biblionumber,
1635
            library      => $library->{branchcode},
1636
        }
1637
    )->unblessed;
1668
1638
1669
    my ( $error, $question, $alerts );
1639
    my ( $error, $question, $alerts );
1670
    my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) );
1640
    my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) );
Lines 1697-1730 subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { Link Here
1697
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1667
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1698
1668
1699
    # Add 2 items
1669
    # Add 2 items
1700
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1670
    my $biblionumber = $builder->build_sample_biblio(
1701
    my $item_1 = $builder->build(
1702
        {
1671
        {
1703
            source => 'Item',
1672
            branchcode => $library->{branchcode},
1704
            value  => {
1705
                homebranch    => $library->{branchcode},
1706
                holdingbranch => $library->{branchcode},
1707
                notforloan    => 0,
1708
                itemlost      => 0,
1709
                withdrawn     => 0,
1710
                biblionumber  => $biblioitem_1->{biblionumber}
1711
            }
1712
        }
1673
        }
1713
    );
1674
    )->biblionumber;
1714
    my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } );
1675
    my $item_1 = $builder->build_sample_item(
1715
    my $item_2 = $builder->build(
1716
        {
1676
        {
1717
            source => 'Item',
1677
            biblionumber => $biblionumber,
1718
            value  => {
1678
            library      => $library->{branchcode},
1719
                homebranch    => $library->{branchcode},
1720
                holdingbranch => $library->{branchcode},
1721
                notforloan    => 0,
1722
                itemlost      => 0,
1723
                withdrawn     => 0,
1724
                biblionumber  => $biblioitem_2->{biblionumber}
1725
            }
1726
        }
1679
        }
1727
    );
1680
    )->unblessed;
1681
    my $item_2 = $builder->build_sample_item(
1682
        {
1683
            biblionumber => $biblionumber,
1684
            library      => $library->{branchcode},
1685
        }
1686
    )->unblessed;
1728
1687
1729
    # And the issuing rule
1688
    # And the issuing rule
1730
    Koha::IssuingRules->search->delete;
1689
    Koha::IssuingRules->search->delete;
Lines 1818-1838 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
1818
    my $library = $builder->build( { source => 'Branch' } );
1777
    my $library = $builder->build( { source => 'Branch' } );
1819
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1778
    my $patron  = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
1820
1779
1821
    # Add 2 items
1780
    my $biblionumber = $builder->build_sample_biblio(
1822
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1823
    my $item_1 = $builder->build(
1824
        {
1781
        {
1825
            source => 'Item',
1782
            branchcode => $library->{branchcode},
1826
            value  => {
1827
                homebranch    => $library->{branchcode},
1828
                holdingbranch => $library->{branchcode},
1829
                notforloan    => 0,
1830
                itemlost      => 0,
1831
                withdrawn     => 0,
1832
                biblionumber  => $biblioitem_1->{biblionumber}
1833
            }
1834
        }
1783
        }
1835
    );
1784
    )->biblionumber;
1785
    my $item_1 = $builder->build_sample_item(
1786
        {
1787
            biblionumber => $biblionumber,
1788
            library      => $library->{branchcode},
1789
        }
1790
    )->unblessed;
1836
1791
1837
    # And the issuing rule
1792
    # And the issuing rule
1838
    Koha::IssuingRules->search->delete;
1793
    Koha::IssuingRules->search->delete;
Lines 2045-2077 subtest 'AddReturn | is_overdue' => sub { Link Here
2045
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2000
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2046
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2001
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2047
2002
2048
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
2003
    my $item = $builder->build_sample_item(
2049
    my $item_type          = $builder->build_object(
2050
        {   class => 'Koha::ItemTypes',
2051
            value => {
2052
                notforloan         => undef,
2053
                rentalcharge       => 0,
2054
                defaultreplacecost => undef,
2055
                processfee         => 0,
2056
                rentalcharge_daily => 0,
2057
            }
2058
        }
2059
    );
2060
    my $item = $builder->build(
2061
        {
2004
        {
2062
            source => 'Item',
2005
            library      => $library->{branchcode},
2063
            value  => {
2064
                homebranch    => $library->{branchcode},
2065
                holdingbranch => $library->{branchcode},
2066
                notforloan    => 0,
2067
                itemlost      => 0,
2068
                withdrawn     => 0,
2069
                biblionumber  => $biblioitem->{biblionumber},
2070
                replacementprice => 7,
2071
                itype         => $item_type->itemtype
2072
            }
2073
        }
2006
        }
2074
    );
2007
    )->unblessed;
2075
2008
2076
    Koha::IssuingRules->search->delete;
2009
    Koha::IssuingRules->search->delete;
2077
    my $rule = Koha::IssuingRule->new(
2010
    my $rule = Koha::IssuingRule->new(
Lines 2658-2683 subtest 'Set waiting flag' => sub { Link Here
2658
    my $library_2 = $builder->build( { source => 'Branch' } );
2591
    my $library_2 = $builder->build( { source => 'Branch' } );
2659
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2592
    my $patron_2  = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } );
2660
2593
2661
    my $biblio = $builder->build( { source => 'Biblio' } );
2594
    my $item = $builder->build_sample_item(
2662
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
2663
2664
    my $item = $builder->build(
2665
        {
2595
        {
2666
            source => 'Item',
2596
            library      => $library_1->{branchcode},
2667
            value  => {
2668
                homebranch    => $library_1->{branchcode},
2669
                holdingbranch => $library_1->{branchcode},
2670
                notforloan    => 0,
2671
                itemlost      => 0,
2672
                withdrawn     => 0,
2673
                biblionumber  => $biblioitem->{biblionumber},
2674
            }
2675
        }
2597
        }
2676
    );
2598
    )->unblessed;
2677
2599
2678
    set_userenv( $library_2 );
2600
    set_userenv( $library_2 );
2679
    my $reserve_id = AddReserve(
2601
    my $reserve_id = AddReserve(
2680
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber},
2602
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $item->{biblionumber},
2681
        '', 1, undef, undef, '', undef, $item->{itemnumber},
2603
        '', 1, undef, undef, '', undef, $item->{itemnumber},
2682
    );
2604
    );
2683
2605
Lines 2783-2802 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
2783
    my $library = $builder->build( { source => 'Branch' } );
2705
    my $library = $builder->build( { source => 'Branch' } );
2784
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
2706
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
2785
2707
2786
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
2708
    my $item = $builder->build_sample_item(
2787
    my $item = $builder->build(
2788
        {
2709
        {
2789
            source => 'Item',
2710
            library      => $library->{branchcode},
2790
            value  => {
2791
                homebranch    => $library->{branchcode},
2792
                holdingbranch => $library->{branchcode},
2793
                notforloan    => 0,
2794
                itemlost      => 0,
2795
                withdrawn     => 0,
2796
                biblionumber  => $biblioitem->{biblionumber},
2797
            }
2798
        }
2711
        }
2799
    );
2712
    )->unblessed;
2800
2713
2801
    my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago
2714
    my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago
2802
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
2715
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
Lines 2941-2969 subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub { Link Here
2941
    my $library = $builder->build( { source => 'Branch' } );
2854
    my $library = $builder->build( { source => 'Branch' } );
2942
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store;
2855
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store;
2943
2856
2944
    my $itemtype = $builder->build(
2857
    my $item = $builder->build_sample_item(
2945
        {
2858
        {
2946
            source => 'Itemtype',
2859
            library      => $library->{branchcode},
2947
            value  => { notforloan => undef, }
2948
        }
2860
        }
2949
    );
2861
    );
2950
2862
2951
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { itemtype => $itemtype->{itemtype} } } );
2952
    my $item = $builder->build_object(
2953
        {
2954
            class => 'Koha::Items',
2955
            value  => {
2956
                homebranch    => $library->{branchcode},
2957
                holdingbranch => $library->{branchcode},
2958
                notforloan    => 0,
2959
                itemlost      => 0,
2960
                withdrawn     => 0,
2961
                biblionumber  => $biblioitem->{biblionumber},
2962
                biblioitemnumber => $biblioitem->{biblioitemnumber},
2963
            }
2964
        }
2965
    )->store;
2966
2967
    my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef );
2863
    my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef );
2968
    is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' );
2864
    is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' );
2969
    is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' );
2865
    is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' );
Lines 2983-3005 subtest 'CanBookBeIssued | notforloan' => sub { Link Here
2983
            value  => { notforloan => undef, }
2879
            value  => { notforloan => undef, }
2984
        }
2880
        }
2985
    );
2881
    );
2986
2882
    my $item = $builder->build_sample_item(
2987
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
2988
    my $item = $builder->build_object(
2989
        {
2883
        {
2990
            class => 'Koha::Items',
2884
            library  => $library->{branchcode},
2991
            value  => {
2885
            itype    => $itemtype->{itemtype},
2992
                homebranch    => $library->{branchcode},
2993
                holdingbranch => $library->{branchcode},
2994
                notforloan    => 0,
2995
                itemlost      => 0,
2996
                withdrawn     => 0,
2997
                itype         => $itemtype->{itemtype},
2998
                biblionumber  => $biblioitem->{biblionumber},
2999
                biblioitemnumber => $biblioitem->{biblioitemnumber},
3000
            }
3001
        }
2886
        }
3002
    )->store;
2887
    );
2888
    $item->biblioitem->itemtype($itemtype->{itemtype})->store;
3003
2889
3004
    my ( $issuingimpossible, $needsconfirmation );
2890
    my ( $issuingimpossible, $needsconfirmation );
3005
2891
Lines 3084-3090 subtest 'AddReturn should clear items.onloan for unissued items' => sub { Link Here
3084
    plan tests => 1;
2970
    plan tests => 1;
3085
2971
3086
    t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' );
2972
    t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' );
3087
    my $item = $builder->build_object({ class => 'Koha::Items', value  => { onloan => '2018-01-01' }});
2973
    my $item = $builder->build_sample_item(
2974
        {
2975
            onloan => '2018-01-01',
2976
        }
2977
    );
2978
3088
    AddReturn( $item->barcode, $item->homebranch );
2979
    AddReturn( $item->barcode, $item->homebranch );
3089
    $item->discard_changes; # refresh
2980
    $item->discard_changes; # refresh
3090
    is( $item->onloan, undef, 'AddReturn did clear items.onloan' );
2981
    is( $item->onloan, undef, 'AddReturn did clear items.onloan' );
(-)a/t/lib/TestBuilder.pm (-1 / +1 lines)
Lines 557-562 sub _gen_default_values { Link Here
557
            rentalcharge_hourly => 0,
557
            rentalcharge_hourly => 0,
558
            defaultreplacecost => 0,
558
            defaultreplacecost => 0,
559
            processfee => 0,
559
            processfee => 0,
560
            notforloan => 0,
560
        },
561
        },
561
        Aqbookseller => {
562
        Aqbookseller => {
562
            tax_rate => 0,
563
            tax_rate => 0,
563
- 

Return to bug 21985