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 |
|
1740 |
$schema->storage->txn_rollback; |
1741 |
die "barf"; |
1708 |
}; |
1742 |
}; |
1709 |
|
1743 |
|
1710 |
{ |
1744 |
{ |
Lines 1789-1794
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1789 |
holdingbranch => $holdingbranch->{branchcode}, |
1823 |
holdingbranch => $holdingbranch->{branchcode}, |
1790 |
} |
1824 |
} |
1791 |
); |
1825 |
); |
|
|
1826 |
Koha::CirculationRules->set_rules( |
1827 |
{ |
1828 |
categorycode => undef, |
1829 |
itemtype => $item->effective_itemtype, |
1830 |
branchcode => undef, |
1831 |
rules => { |
1832 |
reservesallowed => 25, |
1833 |
issuelength => 14, |
1834 |
lengthunit => 'days', |
1835 |
renewalsallowed => 1, |
1836 |
renewalperiod => 7, |
1837 |
norenewalbefore => undef, |
1838 |
auto_renew => 0, |
1839 |
fine => .10, |
1840 |
chargeperiod => 1, |
1841 |
maxissueqty => 20 |
1842 |
} |
1843 |
} |
1844 |
); |
1792 |
|
1845 |
|
1793 |
set_userenv($holdingbranch); |
1846 |
set_userenv($holdingbranch); |
1794 |
|
1847 |
|
Lines 1942-1947
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1942 |
library => $library->{branchcode}, |
1995 |
library => $library->{branchcode}, |
1943 |
} |
1996 |
} |
1944 |
); |
1997 |
); |
|
|
1998 |
Koha::CirculationRules->set_rules( |
1999 |
{ |
2000 |
categorycode => undef, |
2001 |
itemtype => undef, |
2002 |
branchcode => $library->{branchcode}, |
2003 |
rules => { |
2004 |
reservesallowed => 25, |
2005 |
issuelength => 14, |
2006 |
lengthunit => 'days', |
2007 |
renewalsallowed => 1, |
2008 |
renewalperiod => 7, |
2009 |
norenewalbefore => undef, |
2010 |
auto_renew => 0, |
2011 |
fine => .10, |
2012 |
chargeperiod => 1, |
2013 |
maxissueqty => 20 |
2014 |
} |
2015 |
} |
2016 |
); |
2017 |
|
1945 |
|
2018 |
|
1946 |
my ( $error, $question, $alerts ); |
2019 |
my ( $error, $question, $alerts ); |
1947 |
|
2020 |
|
Lines 2139-2144
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
2139 |
} |
2212 |
} |
2140 |
); |
2213 |
); |
2141 |
|
2214 |
|
|
|
2215 |
Koha::CirculationRules->set_rules( |
2216 |
{ |
2217 |
categorycode => undef, |
2218 |
itemtype => undef, |
2219 |
branchcode => $library->{branchcode}, |
2220 |
rules => { |
2221 |
reservesallowed => 25, |
2222 |
issuelength => 14, |
2223 |
lengthunit => 'days', |
2224 |
renewalsallowed => 1, |
2225 |
renewalperiod => 7, |
2226 |
norenewalbefore => undef, |
2227 |
auto_renew => 0, |
2228 |
fine => .10, |
2229 |
chargeperiod => 1, |
2230 |
maxissueqty => 20 |
2231 |
} |
2232 |
} |
2233 |
); |
2234 |
|
2142 |
my ( $error, $question, $alerts ); |
2235 |
my ( $error, $question, $alerts ); |
2143 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2236 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2144 |
|
2237 |
|
2145 |
- |
|
|