Lines 1556-1571
subtest "Bug 13841 - Do not create new 0 amount fines" => sub {
Link Here
|
1556 |
}; |
1556 |
}; |
1557 |
|
1557 |
|
1558 |
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { |
1558 |
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { |
1559 |
$dbh->do('DELETE FROM issues'); |
1559 |
plan tests => 9; |
1560 |
$dbh->do('DELETE FROM items'); |
1560 |
my $biblio = $builder->build_sample_biblio(); |
1561 |
$dbh->do('DELETE FROM circulation_rules'); |
1561 |
my $item_1 = $builder->build_sample_item( |
|
|
1562 |
{ |
1563 |
biblionumber => $biblio->biblionumber, |
1564 |
library => $library2->{branchcode}, |
1565 |
} |
1566 |
); |
1567 |
my $item_2= $builder->build_sample_item( |
1568 |
{ |
1569 |
biblionumber => $biblio->biblionumber, |
1570 |
library => $library2->{branchcode}, |
1571 |
itype => $item_1->effective_itemtype, |
1572 |
} |
1573 |
); |
1574 |
|
1562 |
Koha::CirculationRules->set_rules( |
1575 |
Koha::CirculationRules->set_rules( |
1563 |
{ |
1576 |
{ |
1564 |
categorycode => undef, |
1577 |
categorycode => undef, |
1565 |
itemtype => undef, |
1578 |
itemtype => $item_1->effective_itemtype, |
1566 |
branchcode => undef, |
1579 |
branchcode => undef, |
1567 |
rules => { |
1580 |
rules => { |
1568 |
reservesallowed => 25, |
1581 |
reservesallowed => 25, |
|
|
1582 |
holds_per_record => 25, |
1569 |
issuelength => 14, |
1583 |
issuelength => 14, |
1570 |
lengthunit => 'days', |
1584 |
lengthunit => 'days', |
1571 |
renewalsallowed => 1, |
1585 |
renewalsallowed => 1, |
Lines 1578-1600
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1578 |
} |
1592 |
} |
1579 |
} |
1593 |
} |
1580 |
); |
1594 |
); |
1581 |
my $biblio = $builder->build_sample_biblio(); |
|
|
1582 |
|
1595 |
|
1583 |
my $item_1 = $builder->build_sample_item( |
|
|
1584 |
{ |
1585 |
biblionumber => $biblio->biblionumber, |
1586 |
library => $library2->{branchcode}, |
1587 |
itype => $itemtype, |
1588 |
} |
1589 |
); |
1590 |
|
1591 |
my $item_2= $builder->build_sample_item( |
1592 |
{ |
1593 |
biblionumber => $biblio->biblionumber, |
1594 |
library => $library2->{branchcode}, |
1595 |
itype => $itemtype, |
1596 |
} |
1597 |
); |
1598 |
|
1596 |
|
1599 |
my $borrowernumber1 = Koha::Patron->new({ |
1597 |
my $borrowernumber1 = Koha::Patron->new({ |
1600 |
firstname => 'Kyle', |
1598 |
firstname => 'Kyle', |
Lines 1608-1613
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1608 |
categorycode => $patron_category->{categorycode}, |
1606 |
categorycode => $patron_category->{categorycode}, |
1609 |
branchcode => $library2->{branchcode}, |
1607 |
branchcode => $library2->{branchcode}, |
1610 |
})->store->borrowernumber; |
1608 |
})->store->borrowernumber; |
|
|
1609 |
my $patron_category_2 = $builder->build( |
1610 |
{ |
1611 |
source => 'Category', |
1612 |
value => { |
1613 |
category_type => 'P', |
1614 |
enrolmentfee => 0, |
1615 |
BlockExpiredPatronOpacActions => -1, # Pick the pref value |
1616 |
} |
1617 |
} |
1618 |
); |
1619 |
my $borrowernumber3 = Koha::Patron->new({ |
1620 |
firstname => 'Carnegie', |
1621 |
surname => 'Hall', |
1622 |
categorycode => $patron_category_2->{categorycode}, |
1623 |
branchcode => $library2->{branchcode}, |
1624 |
})->store->borrowernumber; |
1611 |
|
1625 |
|
1612 |
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; |
1626 |
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; |
1613 |
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; |
1627 |
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; |
Lines 1629-1635
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1629 |
Koha::CirculationRules->set_rules( |
1643 |
Koha::CirculationRules->set_rules( |
1630 |
{ |
1644 |
{ |
1631 |
categorycode => undef, |
1645 |
categorycode => undef, |
1632 |
itemtype => undef, |
1646 |
itemtype => $item_1->effective_itemtype, |
1633 |
branchcode => undef, |
1647 |
branchcode => undef, |
1634 |
rules => { |
1648 |
rules => { |
1635 |
onshelfholds => 0, |
1649 |
onshelfholds => 0, |
Lines 1640-1655
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1640 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1654 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1641 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
1655 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
1642 |
|
1656 |
|
1643 |
Koha::CirculationRules->set_rules( |
|
|
1644 |
{ |
1645 |
categorycode => undef, |
1646 |
itemtype => undef, |
1647 |
branchcode => undef, |
1648 |
rules => { |
1649 |
onshelfholds => 0, |
1650 |
} |
1651 |
} |
1652 |
); |
1653 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1657 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1654 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1658 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1655 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
1659 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
Lines 1657-1663
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1657 |
Koha::CirculationRules->set_rules( |
1661 |
Koha::CirculationRules->set_rules( |
1658 |
{ |
1662 |
{ |
1659 |
categorycode => undef, |
1663 |
categorycode => undef, |
1660 |
itemtype => undef, |
1664 |
itemtype => $item_1->effective_itemtype, |
1661 |
branchcode => undef, |
1665 |
branchcode => undef, |
1662 |
rules => { |
1666 |
rules => { |
1663 |
onshelfholds => 1, |
1667 |
onshelfholds => 1, |
Lines 1668-1692
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1668 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1672 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1669 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
1673 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
1670 |
|
1674 |
|
|
|
1675 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1676 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1677 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
1678 |
|
1679 |
AddReserve( |
1680 |
{ |
1681 |
branchcode => $library2->{branchcode}, |
1682 |
borrowernumber => $borrowernumber3, |
1683 |
biblionumber => $biblio->biblionumber, |
1684 |
priority => 1, |
1685 |
} |
1686 |
); |
1687 |
|
1688 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1689 |
is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and one other item on record' ); |
1690 |
|
1691 |
my $item_3= $builder->build_sample_item( |
1692 |
{ |
1693 |
biblionumber => $biblio->biblionumber, |
1694 |
library => $library2->{branchcode}, |
1695 |
itype => $item_1->effective_itemtype, |
1696 |
} |
1697 |
); |
1698 |
|
1699 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1700 |
is( $renewokay, 1, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' ); |
1701 |
|
1671 |
Koha::CirculationRules->set_rules( |
1702 |
Koha::CirculationRules->set_rules( |
1672 |
{ |
1703 |
{ |
1673 |
categorycode => undef, |
1704 |
categorycode => $patron_category_2->{categorycode}, |
1674 |
itemtype => undef, |
1705 |
itemtype => $item_1->effective_itemtype, |
1675 |
branchcode => undef, |
1706 |
branchcode => undef, |
1676 |
rules => { |
1707 |
rules => { |
1677 |
onshelfholds => 1, |
1708 |
reservesallowed => 0, |
1678 |
} |
1709 |
} |
1679 |
} |
1710 |
} |
1680 |
); |
1711 |
); |
1681 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1712 |
|
1682 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1713 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1683 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
1714 |
is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record, but only one of those holds can be filled when AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' ); |
1684 |
|
1715 |
|
1685 |
# Setting item not checked out to be not for loan but holdable |
1716 |
# Setting item not checked out to be not for loan but holdable |
1686 |
$item_2->notforloan(-1)->store; |
1717 |
$item_2->notforloan(-1)->store; |
1687 |
|
1718 |
|
1688 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1719 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1689 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
1720 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
|
|
1721 |
|
1690 |
}; |
1722 |
}; |
1691 |
|
1723 |
|
1692 |
{ |
1724 |
{ |
Lines 1771-1776
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1771 |
holdingbranch => $holdingbranch->{branchcode}, |
1803 |
holdingbranch => $holdingbranch->{branchcode}, |
1772 |
} |
1804 |
} |
1773 |
); |
1805 |
); |
|
|
1806 |
Koha::CirculationRules->set_rules( |
1807 |
{ |
1808 |
categorycode => undef, |
1809 |
itemtype => $item->effective_itemtype, |
1810 |
branchcode => undef, |
1811 |
rules => { |
1812 |
reservesallowed => 25, |
1813 |
issuelength => 14, |
1814 |
lengthunit => 'days', |
1815 |
renewalsallowed => 1, |
1816 |
renewalperiod => 7, |
1817 |
norenewalbefore => undef, |
1818 |
auto_renew => 0, |
1819 |
fine => .10, |
1820 |
chargeperiod => 1, |
1821 |
maxissueqty => 20 |
1822 |
} |
1823 |
} |
1824 |
); |
1774 |
|
1825 |
|
1775 |
set_userenv($holdingbranch); |
1826 |
set_userenv($holdingbranch); |
1776 |
|
1827 |
|
Lines 1924-1929
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1924 |
library => $library->{branchcode}, |
1975 |
library => $library->{branchcode}, |
1925 |
} |
1976 |
} |
1926 |
); |
1977 |
); |
|
|
1978 |
Koha::CirculationRules->set_rules( |
1979 |
{ |
1980 |
categorycode => undef, |
1981 |
itemtype => undef, |
1982 |
branchcode => $library->{branchcode}, |
1983 |
rules => { |
1984 |
reservesallowed => 25, |
1985 |
issuelength => 14, |
1986 |
lengthunit => 'days', |
1987 |
renewalsallowed => 1, |
1988 |
renewalperiod => 7, |
1989 |
norenewalbefore => undef, |
1990 |
auto_renew => 0, |
1991 |
fine => .10, |
1992 |
chargeperiod => 1, |
1993 |
maxissueqty => 20 |
1994 |
} |
1995 |
} |
1996 |
); |
1997 |
|
1927 |
|
1998 |
|
1928 |
my ( $error, $question, $alerts ); |
1999 |
my ( $error, $question, $alerts ); |
1929 |
|
2000 |
|
Lines 2121-2126
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
2121 |
} |
2192 |
} |
2122 |
); |
2193 |
); |
2123 |
|
2194 |
|
|
|
2195 |
Koha::CirculationRules->set_rules( |
2196 |
{ |
2197 |
categorycode => undef, |
2198 |
itemtype => undef, |
2199 |
branchcode => $library->{branchcode}, |
2200 |
rules => { |
2201 |
reservesallowed => 25, |
2202 |
issuelength => 14, |
2203 |
lengthunit => 'days', |
2204 |
renewalsallowed => 1, |
2205 |
renewalperiod => 7, |
2206 |
norenewalbefore => undef, |
2207 |
auto_renew => 0, |
2208 |
fine => .10, |
2209 |
chargeperiod => 1, |
2210 |
maxissueqty => 20 |
2211 |
} |
2212 |
} |
2213 |
); |
2214 |
|
2124 |
my ( $error, $question, $alerts ); |
2215 |
my ( $error, $question, $alerts ); |
2125 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2216 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2126 |
|
2217 |
|
2127 |
- |
|
|