|
Lines 1574-1589
subtest "Bug 13841 - Do not create new 0 amount fines" => sub {
Link Here
|
| 1574 |
}; |
1574 |
}; |
| 1575 |
|
1575 |
|
| 1576 |
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { |
1576 |
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { |
| 1577 |
$dbh->do('DELETE FROM issues'); |
1577 |
plan tests => 9; |
| 1578 |
$dbh->do('DELETE FROM items'); |
1578 |
my $biblio = $builder->build_sample_biblio(); |
| 1579 |
$dbh->do('DELETE FROM circulation_rules'); |
1579 |
my $item_1 = $builder->build_sample_item( |
|
|
1580 |
{ |
| 1581 |
biblionumber => $biblio->biblionumber, |
| 1582 |
library => $library2->{branchcode}, |
| 1583 |
} |
| 1584 |
); |
| 1585 |
my $item_2= $builder->build_sample_item( |
| 1586 |
{ |
| 1587 |
biblionumber => $biblio->biblionumber, |
| 1588 |
library => $library2->{branchcode}, |
| 1589 |
itype => $item_1->effective_itemtype, |
| 1590 |
} |
| 1591 |
); |
| 1592 |
|
| 1580 |
Koha::CirculationRules->set_rules( |
1593 |
Koha::CirculationRules->set_rules( |
| 1581 |
{ |
1594 |
{ |
| 1582 |
categorycode => undef, |
1595 |
categorycode => undef, |
| 1583 |
itemtype => undef, |
1596 |
itemtype => $item_1->effective_itemtype, |
| 1584 |
branchcode => undef, |
1597 |
branchcode => undef, |
| 1585 |
rules => { |
1598 |
rules => { |
| 1586 |
reservesallowed => 25, |
1599 |
reservesallowed => 25, |
|
|
1600 |
holds_per_record => 25, |
| 1587 |
issuelength => 14, |
1601 |
issuelength => 14, |
| 1588 |
lengthunit => 'days', |
1602 |
lengthunit => 'days', |
| 1589 |
renewalsallowed => 1, |
1603 |
renewalsallowed => 1, |
|
Lines 1596-1618
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1596 |
} |
1610 |
} |
| 1597 |
} |
1611 |
} |
| 1598 |
); |
1612 |
); |
| 1599 |
my $biblio = $builder->build_sample_biblio(); |
|
|
| 1600 |
|
1613 |
|
| 1601 |
my $item_1 = $builder->build_sample_item( |
|
|
| 1602 |
{ |
| 1603 |
biblionumber => $biblio->biblionumber, |
| 1604 |
library => $library2->{branchcode}, |
| 1605 |
itype => $itemtype, |
| 1606 |
} |
| 1607 |
); |
| 1608 |
|
| 1609 |
my $item_2= $builder->build_sample_item( |
| 1610 |
{ |
| 1611 |
biblionumber => $biblio->biblionumber, |
| 1612 |
library => $library2->{branchcode}, |
| 1613 |
itype => $itemtype, |
| 1614 |
} |
| 1615 |
); |
| 1616 |
|
1614 |
|
| 1617 |
my $borrowernumber1 = Koha::Patron->new({ |
1615 |
my $borrowernumber1 = Koha::Patron->new({ |
| 1618 |
firstname => 'Kyle', |
1616 |
firstname => 'Kyle', |
|
Lines 1626-1631
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1626 |
categorycode => $patron_category->{categorycode}, |
1624 |
categorycode => $patron_category->{categorycode}, |
| 1627 |
branchcode => $library2->{branchcode}, |
1625 |
branchcode => $library2->{branchcode}, |
| 1628 |
})->store->borrowernumber; |
1626 |
})->store->borrowernumber; |
|
|
1627 |
my $patron_category_2 = $builder->build( |
| 1628 |
{ |
| 1629 |
source => 'Category', |
| 1630 |
value => { |
| 1631 |
category_type => 'P', |
| 1632 |
enrolmentfee => 0, |
| 1633 |
BlockExpiredPatronOpacActions => -1, # Pick the pref value |
| 1634 |
} |
| 1635 |
} |
| 1636 |
); |
| 1637 |
my $borrowernumber3 = Koha::Patron->new({ |
| 1638 |
firstname => 'Carnegie', |
| 1639 |
surname => 'Hall', |
| 1640 |
categorycode => $patron_category_2->{categorycode}, |
| 1641 |
branchcode => $library2->{branchcode}, |
| 1642 |
})->store->borrowernumber; |
| 1629 |
|
1643 |
|
| 1630 |
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; |
1644 |
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; |
| 1631 |
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; |
1645 |
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; |
|
Lines 1647-1653
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1647 |
Koha::CirculationRules->set_rules( |
1661 |
Koha::CirculationRules->set_rules( |
| 1648 |
{ |
1662 |
{ |
| 1649 |
categorycode => undef, |
1663 |
categorycode => undef, |
| 1650 |
itemtype => undef, |
1664 |
itemtype => $item_1->effective_itemtype, |
| 1651 |
branchcode => undef, |
1665 |
branchcode => undef, |
| 1652 |
rules => { |
1666 |
rules => { |
| 1653 |
onshelfholds => 0, |
1667 |
onshelfholds => 0, |
|
Lines 1658-1673
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1658 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1672 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1659 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
1673 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
| 1660 |
|
1674 |
|
| 1661 |
Koha::CirculationRules->set_rules( |
|
|
| 1662 |
{ |
| 1663 |
categorycode => undef, |
| 1664 |
itemtype => undef, |
| 1665 |
branchcode => undef, |
| 1666 |
rules => { |
| 1667 |
onshelfholds => 0, |
| 1668 |
} |
| 1669 |
} |
| 1670 |
); |
| 1671 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1675 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 1672 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1676 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1673 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
1677 |
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 1675-1681
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1675 |
Koha::CirculationRules->set_rules( |
1679 |
Koha::CirculationRules->set_rules( |
| 1676 |
{ |
1680 |
{ |
| 1677 |
categorycode => undef, |
1681 |
categorycode => undef, |
| 1678 |
itemtype => undef, |
1682 |
itemtype => $item_1->effective_itemtype, |
| 1679 |
branchcode => undef, |
1683 |
branchcode => undef, |
| 1680 |
rules => { |
1684 |
rules => { |
| 1681 |
onshelfholds => 1, |
1685 |
onshelfholds => 1, |
|
Lines 1686-1710
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 1686 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1690 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1687 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
1691 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
| 1688 |
|
1692 |
|
|
|
1693 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 1694 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1695 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
| 1696 |
|
| 1697 |
AddReserve( |
| 1698 |
{ |
| 1699 |
branchcode => $library2->{branchcode}, |
| 1700 |
borrowernumber => $borrowernumber3, |
| 1701 |
biblionumber => $biblio->biblionumber, |
| 1702 |
priority => 1, |
| 1703 |
} |
| 1704 |
); |
| 1705 |
|
| 1706 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1707 |
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' ); |
| 1708 |
|
| 1709 |
my $item_3= $builder->build_sample_item( |
| 1710 |
{ |
| 1711 |
biblionumber => $biblio->biblionumber, |
| 1712 |
library => $library2->{branchcode}, |
| 1713 |
itype => $item_1->effective_itemtype, |
| 1714 |
} |
| 1715 |
); |
| 1716 |
|
| 1717 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1718 |
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' ); |
| 1719 |
|
| 1689 |
Koha::CirculationRules->set_rules( |
1720 |
Koha::CirculationRules->set_rules( |
| 1690 |
{ |
1721 |
{ |
| 1691 |
categorycode => undef, |
1722 |
categorycode => $patron_category_2->{categorycode}, |
| 1692 |
itemtype => undef, |
1723 |
itemtype => $item_1->effective_itemtype, |
| 1693 |
branchcode => undef, |
1724 |
branchcode => undef, |
| 1694 |
rules => { |
1725 |
rules => { |
| 1695 |
onshelfholds => 1, |
1726 |
reservesallowed => 0, |
| 1696 |
} |
1727 |
} |
| 1697 |
} |
1728 |
} |
| 1698 |
); |
1729 |
); |
| 1699 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1730 |
|
| 1700 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1731 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1701 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
1732 |
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' ); |
| 1702 |
|
1733 |
|
| 1703 |
# Setting item not checked out to be not for loan but holdable |
1734 |
# Setting item not checked out to be not for loan but holdable |
| 1704 |
$item_2->notforloan(-1)->store; |
1735 |
$item_2->notforloan(-1)->store; |
| 1705 |
|
1736 |
|
| 1706 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1737 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1707 |
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' ); |
1738 |
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' ); |
|
|
1739 |
|
| 1708 |
}; |
1740 |
}; |
| 1709 |
|
1741 |
|
| 1710 |
{ |
1742 |
{ |
|
Lines 1789-1794
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
| 1789 |
holdingbranch => $holdingbranch->{branchcode}, |
1821 |
holdingbranch => $holdingbranch->{branchcode}, |
| 1790 |
} |
1822 |
} |
| 1791 |
); |
1823 |
); |
|
|
1824 |
Koha::CirculationRules->set_rules( |
| 1825 |
{ |
| 1826 |
categorycode => undef, |
| 1827 |
itemtype => $item->effective_itemtype, |
| 1828 |
branchcode => undef, |
| 1829 |
rules => { |
| 1830 |
reservesallowed => 25, |
| 1831 |
issuelength => 14, |
| 1832 |
lengthunit => 'days', |
| 1833 |
renewalsallowed => 1, |
| 1834 |
renewalperiod => 7, |
| 1835 |
norenewalbefore => undef, |
| 1836 |
auto_renew => 0, |
| 1837 |
fine => .10, |
| 1838 |
chargeperiod => 1, |
| 1839 |
maxissueqty => 20 |
| 1840 |
} |
| 1841 |
} |
| 1842 |
); |
| 1792 |
|
1843 |
|
| 1793 |
set_userenv($holdingbranch); |
1844 |
set_userenv($holdingbranch); |
| 1794 |
|
1845 |
|
|
Lines 1942-1947
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
| 1942 |
library => $library->{branchcode}, |
1993 |
library => $library->{branchcode}, |
| 1943 |
} |
1994 |
} |
| 1944 |
); |
1995 |
); |
|
|
1996 |
Koha::CirculationRules->set_rules( |
| 1997 |
{ |
| 1998 |
categorycode => undef, |
| 1999 |
itemtype => undef, |
| 2000 |
branchcode => $library->{branchcode}, |
| 2001 |
rules => { |
| 2002 |
reservesallowed => 25, |
| 2003 |
issuelength => 14, |
| 2004 |
lengthunit => 'days', |
| 2005 |
renewalsallowed => 1, |
| 2006 |
renewalperiod => 7, |
| 2007 |
norenewalbefore => undef, |
| 2008 |
auto_renew => 0, |
| 2009 |
fine => .10, |
| 2010 |
chargeperiod => 1, |
| 2011 |
maxissueqty => 20 |
| 2012 |
} |
| 2013 |
} |
| 2014 |
); |
| 2015 |
|
| 1945 |
|
2016 |
|
| 1946 |
my ( $error, $question, $alerts ); |
2017 |
my ( $error, $question, $alerts ); |
| 1947 |
|
2018 |
|
|
Lines 2139-2144
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
| 2139 |
} |
2210 |
} |
| 2140 |
); |
2211 |
); |
| 2141 |
|
2212 |
|
|
|
2213 |
Koha::CirculationRules->set_rules( |
| 2214 |
{ |
| 2215 |
categorycode => undef, |
| 2216 |
itemtype => undef, |
| 2217 |
branchcode => $library->{branchcode}, |
| 2218 |
rules => { |
| 2219 |
reservesallowed => 25, |
| 2220 |
issuelength => 14, |
| 2221 |
lengthunit => 'days', |
| 2222 |
renewalsallowed => 1, |
| 2223 |
renewalperiod => 7, |
| 2224 |
norenewalbefore => undef, |
| 2225 |
auto_renew => 0, |
| 2226 |
fine => .10, |
| 2227 |
chargeperiod => 1, |
| 2228 |
maxissueqty => 20 |
| 2229 |
} |
| 2230 |
} |
| 2231 |
); |
| 2232 |
|
| 2142 |
my ( $error, $question, $alerts ); |
2233 |
my ( $error, $question, $alerts ); |
| 2143 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2234 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
| 2144 |
|
2235 |
|
| 2145 |
- |
|
|