|
Lines 33-39
use C4::Reserves;
Link Here
|
| 33 |
use C4::Overdues qw(UpdateFine CalcFine); |
33 |
use C4::Overdues qw(UpdateFine CalcFine); |
| 34 |
use Koha::DateUtils; |
34 |
use Koha::DateUtils; |
| 35 |
use Koha::Database; |
35 |
use Koha::Database; |
| 36 |
use Koha::IssuingRules; |
|
|
| 37 |
use Koha::Checkouts; |
36 |
use Koha::Checkouts; |
| 38 |
use Koha::Patrons; |
37 |
use Koha::Patrons; |
| 39 |
use Koha::CirculationRules; |
38 |
use Koha::CirculationRules; |
|
Lines 180-206
is(
Link Here
|
| 180 |
); |
179 |
); |
| 181 |
|
180 |
|
| 182 |
# Set a simple circ policy |
181 |
# Set a simple circ policy |
| 183 |
$dbh->do('DELETE FROM issuingrules'); |
182 |
$dbh->do('DELETE FROM circulation_rules'); |
| 184 |
Koha::CirculationRules->search()->delete(); |
183 |
Koha::CirculationRules->set_rules( |
| 185 |
$dbh->do( |
184 |
{ |
| 186 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, |
185 |
categorycode => '*', |
| 187 |
issuelength, lengthunit, |
186 |
branchcode => '*', |
| 188 |
renewalsallowed, renewalperiod, |
187 |
itemtype => '*', |
| 189 |
norenewalbefore, auto_renew, |
188 |
rules => { |
| 190 |
fine, chargeperiod) |
189 |
reservesallowed => 25, |
| 191 |
VALUES (?, ?, ?, ?, |
190 |
issuelength => 14, |
| 192 |
?, ?, |
191 |
lengthunit => 'days', |
| 193 |
?, ?, |
192 |
renewalsallowed => 1, |
| 194 |
?, ?, |
193 |
renewalperiod => 7, |
| 195 |
?, ? |
194 |
norenewalbefore => undef, |
| 196 |
) |
195 |
auto_renew => 0, |
| 197 |
}, |
196 |
fine => .10, |
| 198 |
{}, |
197 |
chargeperiod => 1, |
| 199 |
'*', '*', '*', 25, |
198 |
} |
| 200 |
14, 'days', |
199 |
} |
| 201 |
1, 7, |
|
|
| 202 |
undef, 0, |
| 203 |
.10, 1 |
| 204 |
); |
200 |
); |
| 205 |
|
201 |
|
| 206 |
# Test C4::Circulation::ProcessOfflinePayment |
202 |
# Test C4::Circulation::ProcessOfflinePayment |
|
Lines 345-351
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 345 |
); |
341 |
); |
| 346 |
|
342 |
|
| 347 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
343 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
| 348 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
344 |
Koha::CirculationRules->set_rule( |
|
|
345 |
{ |
| 346 |
categorycode => '*', |
| 347 |
branchcode => '*', |
| 348 |
itemtype => '*', |
| 349 |
rule_name => 'onshelfholds', |
| 350 |
rule_value => '1', |
| 351 |
} |
| 352 |
); |
| 349 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
353 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
| 350 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
354 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
| 351 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
355 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
|
Lines 558-564
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 558 |
|
562 |
|
| 559 |
# Bug 7413 |
563 |
# Bug 7413 |
| 560 |
# Test premature manual renewal |
564 |
# Test premature manual renewal |
| 561 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
565 |
Koha::CirculationRules->set_rule( |
|
|
566 |
{ |
| 567 |
categorycode => '*', |
| 568 |
branchcode => '*', |
| 569 |
itemtype => '*', |
| 570 |
rule_name => 'norenewalbefore', |
| 571 |
rule_value => '7', |
| 572 |
} |
| 573 |
); |
| 562 |
|
574 |
|
| 563 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
575 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
| 564 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
576 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
|
Lines 593-599
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 593 |
|
605 |
|
| 594 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
606 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
| 595 |
# and test automatic renewal again |
607 |
# and test automatic renewal again |
| 596 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 0'); |
608 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); |
| 597 |
( $renewokay, $error ) = |
609 |
( $renewokay, $error ) = |
| 598 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
610 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
| 599 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
611 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
|
Lines 603-609
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 603 |
|
615 |
|
| 604 |
# Change policy so that loans can be renewed 99 days prior to the due date |
616 |
# Change policy so that loans can be renewed 99 days prior to the due date |
| 605 |
# and test automatic renewal again |
617 |
# and test automatic renewal again |
| 606 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 99'); |
618 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); |
| 607 |
( $renewokay, $error ) = |
619 |
( $renewokay, $error ) = |
| 608 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
620 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
| 609 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
621 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
|
Lines 627-669
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 627 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
639 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 628 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
640 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 629 |
|
641 |
|
| 630 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 9'); |
642 |
Koha::CirculationRules->set_rules( |
|
|
643 |
{ |
| 644 |
categorycode => '*', |
| 645 |
branchcode => '*', |
| 646 |
itemtype => '*', |
| 647 |
rules => { |
| 648 |
norenewalbefore => '7', |
| 649 |
no_auto_renewal_after => '9', |
| 650 |
} |
| 651 |
} |
| 652 |
); |
| 631 |
( $renewokay, $error ) = |
653 |
( $renewokay, $error ) = |
| 632 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
654 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 633 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
655 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 634 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
656 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 635 |
|
657 |
|
| 636 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 10'); |
658 |
Koha::CirculationRules->set_rules( |
|
|
659 |
{ |
| 660 |
categorycode => '*', |
| 661 |
branchcode => '*', |
| 662 |
itemtype => '*', |
| 663 |
rules => { |
| 664 |
norenewalbefore => '7', |
| 665 |
no_auto_renewal_after => '10', |
| 666 |
} |
| 667 |
} |
| 668 |
); |
| 637 |
( $renewokay, $error ) = |
669 |
( $renewokay, $error ) = |
| 638 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
670 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 639 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
671 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 640 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
672 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
| 641 |
|
673 |
|
| 642 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 11'); |
674 |
Koha::CirculationRules->set_rules( |
|
|
675 |
{ |
| 676 |
categorycode => '*', |
| 677 |
branchcode => '*', |
| 678 |
itemtype => '*', |
| 679 |
rules => { |
| 680 |
norenewalbefore => '7', |
| 681 |
no_auto_renewal_after => '11', |
| 682 |
} |
| 683 |
} |
| 684 |
); |
| 643 |
( $renewokay, $error ) = |
685 |
( $renewokay, $error ) = |
| 644 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
686 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 645 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
687 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 646 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
688 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
| 647 |
|
689 |
|
| 648 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
690 |
Koha::CirculationRules->set_rules( |
|
|
691 |
{ |
| 692 |
categorycode => '*', |
| 693 |
branchcode => '*', |
| 694 |
itemtype => '*', |
| 695 |
rules => { |
| 696 |
norenewalbefore => '10', |
| 697 |
no_auto_renewal_after => '11', |
| 698 |
} |
| 699 |
} |
| 700 |
); |
| 649 |
( $renewokay, $error ) = |
701 |
( $renewokay, $error ) = |
| 650 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
702 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 651 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
703 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 652 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
704 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 653 |
|
705 |
|
| 654 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = NULL, no_auto_renewal_after_hard_limit = ?', undef, dt_from_string->add( days => -1 ) ); |
706 |
Koha::CirculationRules->set_rules( |
|
|
707 |
{ |
| 708 |
categorycode => '*', |
| 709 |
branchcode => '*', |
| 710 |
itemtype => '*', |
| 711 |
rules => { |
| 712 |
norenewalbefore => '10', |
| 713 |
no_auto_renewal_after => undef, |
| 714 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => -1 ), |
| 715 |
} |
| 716 |
} |
| 717 |
); |
| 655 |
( $renewokay, $error ) = |
718 |
( $renewokay, $error ) = |
| 656 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
719 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 657 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
720 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 658 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
721 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 659 |
|
722 |
|
| 660 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 15, no_auto_renewal_after_hard_limit = ?', undef, dt_from_string->add( days => -1 ) ); |
723 |
Koha::CirculationRules->set_rules( |
|
|
724 |
{ |
| 725 |
categorycode => '*', |
| 726 |
branchcode => '*', |
| 727 |
itemtype => '*', |
| 728 |
rules => { |
| 729 |
norenewalbefore => '7', |
| 730 |
no_auto_renewal_after => '15', |
| 731 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => -1 ), |
| 732 |
} |
| 733 |
} |
| 734 |
); |
| 661 |
( $renewokay, $error ) = |
735 |
( $renewokay, $error ) = |
| 662 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
736 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 663 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
737 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 664 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
738 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 665 |
|
739 |
|
| 666 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = NULL, no_auto_renewal_after_hard_limit = ?', undef, dt_from_string->add( days => 1 ) ); |
740 |
Koha::CirculationRules->set_rules( |
|
|
741 |
{ |
| 742 |
categorycode => '*', |
| 743 |
branchcode => '*', |
| 744 |
itemtype => '*', |
| 745 |
rules => { |
| 746 |
norenewalbefore => '10', |
| 747 |
no_auto_renewal_after => undef, |
| 748 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => 1 ), |
| 749 |
} |
| 750 |
} |
| 751 |
); |
| 667 |
( $renewokay, $error ) = |
752 |
( $renewokay, $error ) = |
| 668 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
753 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 669 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
754 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
|
Lines 685-691
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 685 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
770 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 686 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
771 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 687 |
|
772 |
|
| 688 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
773 |
Koha::CirculationRules->set_rules( |
|
|
774 |
{ |
| 775 |
categorycode => '*', |
| 776 |
branchcode => '*', |
| 777 |
itemtype => '*', |
| 778 |
rules => { |
| 779 |
norenewalbefore => '10', |
| 780 |
no_auto_renewal_after => '11', |
| 781 |
} |
| 782 |
} |
| 783 |
); |
| 689 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
784 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
| 690 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
785 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
| 691 |
my $fines_amount = 5; |
786 |
my $fines_amount = 5; |
|
Lines 777-807
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 777 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
872 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 778 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
873 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 779 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
874 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 780 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = "", no_auto_renewal_after_hard_limit = NULL'); |
875 |
Koha::CirculationRules->set_rules( |
|
|
876 |
{ |
| 877 |
categorycode => '*', |
| 878 |
branchcode => '*', |
| 879 |
itemtype => '*', |
| 880 |
rules => { |
| 881 |
norenewalbefore => '7', |
| 882 |
no_auto_renewal_after => '', |
| 883 |
no_auto_renewal_after_hard_limit => undef, |
| 884 |
} |
| 885 |
} |
| 886 |
); |
| 781 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
887 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 782 |
is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after or no_auto_renewal_after_hard_limit are not defined' ); |
888 |
is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after or no_auto_renewal_after_hard_limit are not defined' ); |
| 783 |
my $five_days_before = dt_from_string->add( days => -5 ); |
889 |
my $five_days_before = dt_from_string->add( days => -5 ); |
| 784 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 5, no_auto_renewal_after_hard_limit = NULL'); |
890 |
Koha::CirculationRules->set_rules( |
|
|
891 |
{ |
| 892 |
categorycode => '*', |
| 893 |
branchcode => '*', |
| 894 |
itemtype => '*', |
| 895 |
rules => { |
| 896 |
norenewalbefore => '10', |
| 897 |
no_auto_renewal_after => '5', |
| 898 |
no_auto_renewal_after_hard_limit => undef, |
| 899 |
} |
| 900 |
} |
| 901 |
); |
| 785 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
902 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 786 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
903 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
| 787 |
$five_days_before->truncate( to => 'minute' ), |
904 |
$five_days_before->truncate( to => 'minute' ), |
| 788 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
905 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
| 789 |
); |
906 |
); |
| 790 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
907 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
| 791 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15, no_auto_renewal_after_hard_limit = NULL'); |
908 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '10' WHERE rule_name = 'norenewalbefore'}); |
|
|
909 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '15' WHERE rule_name = 'no_auto_renewal_after'}); |
| 910 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = NULL WHERE rule_name = 'no_auto_renewal_after_hard_limit'}); |
| 911 |
Koha::CirculationRules->set_rules( |
| 912 |
{ |
| 913 |
categorycode => '*', |
| 914 |
branchcode => '*', |
| 915 |
itemtype => '*', |
| 916 |
rules => { |
| 917 |
norenewalbefore => '10', |
| 918 |
no_auto_renewal_after => '15', |
| 919 |
no_auto_renewal_after_hard_limit => undef, |
| 920 |
} |
| 921 |
} |
| 922 |
); |
| 792 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
923 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 793 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
924 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
| 794 |
$five_days_ahead->truncate( to => 'minute' ), |
925 |
$five_days_ahead->truncate( to => 'minute' ), |
| 795 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
926 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
| 796 |
); |
927 |
); |
| 797 |
my $two_days_ahead = dt_from_string->add( days => 2 ); |
928 |
my $two_days_ahead = dt_from_string->add( days => 2 ); |
| 798 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = "", no_auto_renewal_after_hard_limit = ?', undef, dt_from_string->add( days => 2 ) ); |
929 |
Koha::CirculationRules->set_rules( |
|
|
930 |
{ |
| 931 |
categorycode => '*', |
| 932 |
branchcode => '*', |
| 933 |
itemtype => '*', |
| 934 |
rules => { |
| 935 |
norenewalbefore => '10', |
| 936 |
no_auto_renewal_after => '', |
| 937 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => 2 ), |
| 938 |
} |
| 939 |
} |
| 940 |
); |
| 799 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
941 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 800 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
942 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
| 801 |
$two_days_ahead->truncate( to => 'day' ), |
943 |
$two_days_ahead->truncate( to => 'day' ), |
| 802 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' |
944 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' |
| 803 |
); |
945 |
); |
| 804 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15, no_auto_renewal_after_hard_limit = ?', undef, dt_from_string->add( days => 2 ) ); |
946 |
Koha::CirculationRules->set_rules( |
|
|
947 |
{ |
| 948 |
categorycode => '*', |
| 949 |
branchcode => '*', |
| 950 |
itemtype => '*', |
| 951 |
rules => { |
| 952 |
norenewalbefore => '10', |
| 953 |
no_auto_renewal_after => '15', |
| 954 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => 2 ), |
| 955 |
} |
| 956 |
} |
| 957 |
); |
| 805 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
958 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 806 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
959 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
| 807 |
$two_days_ahead->truncate( to => 'day' ), |
960 |
$two_days_ahead->truncate( to => 'day' ), |
|
Lines 809-819
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 809 |
); |
962 |
); |
| 810 |
|
963 |
|
| 811 |
}; |
964 |
}; |
| 812 |
|
|
|
| 813 |
# Too many renewals |
965 |
# Too many renewals |
| 814 |
|
966 |
|
| 815 |
# set policy to forbid renewals |
967 |
# set policy to forbid renewals |
| 816 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = NULL, renewalsallowed = 0'); |
968 |
Koha::CirculationRules->set_rules( |
|
|
969 |
{ |
| 970 |
categorycode => '*', |
| 971 |
branchcode => '*', |
| 972 |
itemtype => '*', |
| 973 |
rules => { |
| 974 |
norenewalbefore => undef, |
| 975 |
renewalsallowed => 0, |
| 976 |
} |
| 977 |
} |
| 978 |
); |
| 817 |
|
979 |
|
| 818 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
980 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
| 819 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
981 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
|
Lines 1031-1057
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 1031 |
{ |
1193 |
{ |
| 1032 |
$dbh->do('DELETE FROM issues'); |
1194 |
$dbh->do('DELETE FROM issues'); |
| 1033 |
$dbh->do('DELETE FROM items'); |
1195 |
$dbh->do('DELETE FROM items'); |
| 1034 |
$dbh->do('DELETE FROM issuingrules'); |
1196 |
$dbh->do('DELETE FROM circulation_rules'); |
| 1035 |
Koha::CirculationRules->search()->delete(); |
|
|
| 1036 |
$dbh->do( |
| 1037 |
q{ |
| 1038 |
INSERT INTO issuingrules ( categorycode, branchcode, itemtype, reservesallowed, issuelength, lengthunit, renewalsallowed, renewalperiod, |
| 1039 |
norenewalbefore, auto_renew, fine, chargeperiod ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) |
| 1040 |
}, |
| 1041 |
{}, |
| 1042 |
'*', '*', '*', 25, |
| 1043 |
14, 'days', |
| 1044 |
1, 7, |
| 1045 |
undef, 0, |
| 1046 |
.10, 1 |
| 1047 |
); |
| 1048 |
Koha::CirculationRules->set_rules( |
1197 |
Koha::CirculationRules->set_rules( |
| 1049 |
{ |
1198 |
{ |
| 1050 |
categorycode => '*', |
1199 |
categorycode => '*', |
| 1051 |
itemtype => '*', |
1200 |
itemtype => '*', |
| 1052 |
branchcode => '*', |
1201 |
branchcode => '*', |
| 1053 |
rules => { |
1202 |
rules => { |
| 1054 |
maxissueqty => 20 |
1203 |
reservesallowed => 25, |
|
|
1204 |
issuelength => 14, |
| 1205 |
lengthunit => 'days', |
| 1206 |
renewalsallowed => 1, |
| 1207 |
renewalperiod => 7, |
| 1208 |
norenewalbefore => undef, |
| 1209 |
auto_renew => 0, |
| 1210 |
fine => .10, |
| 1211 |
chargeperiod => 1, |
| 1212 |
maxissueqty => 20 |
| 1055 |
} |
1213 |
} |
| 1056 |
} |
1214 |
} |
| 1057 |
); |
1215 |
); |
|
Lines 1105-1126
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 1105 |
undef, undef, undef |
1263 |
undef, undef, undef |
| 1106 |
); |
1264 |
); |
| 1107 |
|
1265 |
|
| 1108 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
1266 |
Koha::CirculationRules->set_rules( |
|
|
1267 |
{ |
| 1268 |
categorycode => '*', |
| 1269 |
itemtype => '*', |
| 1270 |
branchcode => '*', |
| 1271 |
rules => { |
| 1272 |
onshelfholds => 0, |
| 1273 |
} |
| 1274 |
} |
| 1275 |
); |
| 1109 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
1276 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
| 1110 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1277 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1111 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
1278 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
| 1112 |
|
1279 |
|
| 1113 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
1280 |
Koha::CirculationRules->set_rules( |
|
|
1281 |
{ |
| 1282 |
categorycode => '*', |
| 1283 |
itemtype => '*', |
| 1284 |
branchcode => '*', |
| 1285 |
rules => { |
| 1286 |
onshelfholds => 0, |
| 1287 |
} |
| 1288 |
} |
| 1289 |
); |
| 1114 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1290 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 1115 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1291 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1116 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
1292 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
| 1117 |
|
1293 |
|
| 1118 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
1294 |
Koha::CirculationRules->set_rules( |
|
|
1295 |
{ |
| 1296 |
categorycode => '*', |
| 1297 |
itemtype => '*', |
| 1298 |
branchcode => '*', |
| 1299 |
rules => { |
| 1300 |
onshelfholds => 1, |
| 1301 |
} |
| 1302 |
} |
| 1303 |
); |
| 1119 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
1304 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
| 1120 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1305 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1121 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
1306 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
| 1122 |
|
1307 |
|
| 1123 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
1308 |
Koha::CirculationRules->set_rules( |
|
|
1309 |
{ |
| 1310 |
categorycode => '*', |
| 1311 |
itemtype => '*', |
| 1312 |
branchcode => '*', |
| 1313 |
rules => { |
| 1314 |
onshelfholds => 1, |
| 1315 |
} |
| 1316 |
} |
| 1317 |
); |
| 1124 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1318 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 1125 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1319 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1126 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
1320 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
|
Lines 1672-1691
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
| 1672 |
} |
1866 |
} |
| 1673 |
); |
1867 |
); |
| 1674 |
|
1868 |
|
| 1675 |
# And the issuing rule |
1869 |
# And the circulation rule |
| 1676 |
Koha::IssuingRules->search->delete; |
1870 |
Koha::CirculationRules->search->delete; |
| 1677 |
my $rule = Koha::IssuingRule->new( |
1871 |
Koha::CirculationRules->set_rules( |
| 1678 |
{ |
1872 |
{ |
| 1679 |
categorycode => '*', |
1873 |
categorycode => '*', |
| 1680 |
itemtype => '*', |
1874 |
itemtype => '*', |
| 1681 |
branchcode => '*', |
1875 |
branchcode => '*', |
| 1682 |
issuelength => 1, |
1876 |
rules => { |
| 1683 |
firstremind => 1, # 1 day of grace |
1877 |
issuelength => 1, |
| 1684 |
finedays => 2, # 2 days of fine per day of overdue |
1878 |
firstremind => 1, # 1 day of grace |
| 1685 |
lengthunit => 'days', |
1879 |
finedays => 2, # 2 days of fine per day of overdue |
|
|
1880 |
lengthunit => 'days', |
| 1881 |
} |
| 1686 |
} |
1882 |
} |
| 1687 |
); |
1883 |
); |
| 1688 |
$rule->store(); |
|
|
| 1689 |
|
1884 |
|
| 1690 |
# Patron cannot issue item_1, they have overdues |
1885 |
# Patron cannot issue item_1, they have overdues |
| 1691 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
1886 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
|
Lines 1787-1806
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
| 1787 |
} |
1982 |
} |
| 1788 |
); |
1983 |
); |
| 1789 |
|
1984 |
|
| 1790 |
Koha::IssuingRules->search->delete; |
1985 |
Koha::CirculationRules->search->delete; |
| 1791 |
my $rule = Koha::IssuingRule->new( |
1986 |
my $rule = Koha::CirculationRules->set_rules( |
| 1792 |
{ |
1987 |
{ |
| 1793 |
categorycode => '*', |
1988 |
categorycode => '*', |
| 1794 |
itemtype => '*', |
1989 |
itemtype => '*', |
| 1795 |
branchcode => '*', |
1990 |
branchcode => '*', |
| 1796 |
maxissueqty => 99, |
1991 |
rules => { |
| 1797 |
issuelength => 6, |
1992 |
maxissueqty => 99, |
| 1798 |
lengthunit => 'days', |
1993 |
issuelength => 6, |
| 1799 |
fine => 1, # Charge 1 every day of overdue |
1994 |
lengthunit => 'days', |
| 1800 |
chargeperiod => 1, |
1995 |
fine => 1, # Charge 1 every day of overdue |
|
|
1996 |
chargeperiod => 1, |
| 1997 |
} |
| 1801 |
} |
1998 |
} |
| 1802 |
); |
1999 |
); |
| 1803 |
$rule->store(); |
|
|
| 1804 |
|
2000 |
|
| 1805 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
2001 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
| 1806 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
2002 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |