|
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 168-194
is(
Link Here
|
| 168 |
); |
167 |
); |
| 169 |
|
168 |
|
| 170 |
# Set a simple circ policy |
169 |
# Set a simple circ policy |
| 171 |
$dbh->do('DELETE FROM issuingrules'); |
170 |
$dbh->do('DELETE FROM circulation_rules'); |
| 172 |
Koha::CirculationRules->search()->delete(); |
171 |
Koha::CirculationRules->set_rules( |
| 173 |
$dbh->do( |
172 |
{ |
| 174 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, |
173 |
categorycode => '*', |
| 175 |
issuelength, lengthunit, |
174 |
branchcode => '*', |
| 176 |
renewalsallowed, renewalperiod, |
175 |
itemtype => '*', |
| 177 |
norenewalbefore, auto_renew, |
176 |
rules => { |
| 178 |
fine, chargeperiod) |
177 |
reservesallowed => 25, |
| 179 |
VALUES (?, ?, ?, ?, |
178 |
issuelength => 14, |
| 180 |
?, ?, |
179 |
lengthunit => 'days', |
| 181 |
?, ?, |
180 |
renewalsallowed => 1, |
| 182 |
?, ?, |
181 |
renewalperiod => 7, |
| 183 |
?, ? |
182 |
norenewalbefore => undef, |
| 184 |
) |
183 |
auto_renew => 0, |
| 185 |
}, |
184 |
fine => .10, |
| 186 |
{}, |
185 |
chargeperiod => 1, |
| 187 |
'*', '*', '*', 25, |
186 |
} |
| 188 |
14, 'days', |
187 |
} |
| 189 |
1, 7, |
|
|
| 190 |
undef, 0, |
| 191 |
.10, 1 |
| 192 |
); |
188 |
); |
| 193 |
|
189 |
|
| 194 |
# Test C4::Circulation::ProcessOfflinePayment |
190 |
# Test C4::Circulation::ProcessOfflinePayment |
|
Lines 332-338
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 332 |
); |
328 |
); |
| 333 |
|
329 |
|
| 334 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
330 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
| 335 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
331 |
Koha::CirculationRules->set_rule( |
|
|
332 |
{ |
| 333 |
categorycode => '*', |
| 334 |
branchcode => '*', |
| 335 |
itemtype => '*', |
| 336 |
rule_name => 'onshelfholds', |
| 337 |
rule_value => '1', |
| 338 |
} |
| 339 |
); |
| 336 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
340 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
| 337 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
341 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
| 338 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
342 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
|
Lines 530-536
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 530 |
|
534 |
|
| 531 |
# Bug 7413 |
535 |
# Bug 7413 |
| 532 |
# Test premature manual renewal |
536 |
# Test premature manual renewal |
| 533 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
537 |
Koha::CirculationRules->set_rule( |
|
|
538 |
{ |
| 539 |
categorycode => '*', |
| 540 |
branchcode => '*', |
| 541 |
itemtype => '*', |
| 542 |
rule_name => 'norenewalbefore', |
| 543 |
rule_value => '7', |
| 544 |
} |
| 545 |
); |
| 534 |
|
546 |
|
| 535 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
547 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
| 536 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
548 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
|
Lines 565-571
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 565 |
|
577 |
|
| 566 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
578 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
| 567 |
# and test automatic renewal again |
579 |
# and test automatic renewal again |
| 568 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 0'); |
580 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); |
| 569 |
( $renewokay, $error ) = |
581 |
( $renewokay, $error ) = |
| 570 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
582 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
| 571 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
583 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
|
Lines 575-581
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 575 |
|
587 |
|
| 576 |
# Change policy so that loans can be renewed 99 days prior to the due date |
588 |
# Change policy so that loans can be renewed 99 days prior to the due date |
| 577 |
# and test automatic renewal again |
589 |
# and test automatic renewal again |
| 578 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 99'); |
590 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); |
| 579 |
( $renewokay, $error ) = |
591 |
( $renewokay, $error ) = |
| 580 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
592 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
| 581 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
593 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
|
Lines 599-641
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 599 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
611 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 600 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
612 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 601 |
|
613 |
|
| 602 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 9'); |
614 |
Koha::CirculationRules->set_rules( |
|
|
615 |
{ |
| 616 |
categorycode => '*', |
| 617 |
branchcode => '*', |
| 618 |
itemtype => '*', |
| 619 |
rules => { |
| 620 |
norenewalbefore => '7', |
| 621 |
no_auto_renewal_after => '9', |
| 622 |
} |
| 623 |
} |
| 624 |
); |
| 603 |
( $renewokay, $error ) = |
625 |
( $renewokay, $error ) = |
| 604 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
626 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 605 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
627 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 606 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
628 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 607 |
|
629 |
|
| 608 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 10'); |
630 |
Koha::CirculationRules->set_rules( |
|
|
631 |
{ |
| 632 |
categorycode => '*', |
| 633 |
branchcode => '*', |
| 634 |
itemtype => '*', |
| 635 |
rules => { |
| 636 |
norenewalbefore => '7', |
| 637 |
no_auto_renewal_after => '10', |
| 638 |
} |
| 639 |
} |
| 640 |
); |
| 609 |
( $renewokay, $error ) = |
641 |
( $renewokay, $error ) = |
| 610 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
642 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 611 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
643 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 612 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
644 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
| 613 |
|
645 |
|
| 614 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 11'); |
646 |
Koha::CirculationRules->set_rules( |
|
|
647 |
{ |
| 648 |
categorycode => '*', |
| 649 |
branchcode => '*', |
| 650 |
itemtype => '*', |
| 651 |
rules => { |
| 652 |
norenewalbefore => '7', |
| 653 |
no_auto_renewal_after => '11', |
| 654 |
} |
| 655 |
} |
| 656 |
); |
| 615 |
( $renewokay, $error ) = |
657 |
( $renewokay, $error ) = |
| 616 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
658 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 617 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
659 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 618 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
660 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
| 619 |
|
661 |
|
| 620 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
662 |
Koha::CirculationRules->set_rules( |
|
|
663 |
{ |
| 664 |
categorycode => '*', |
| 665 |
branchcode => '*', |
| 666 |
itemtype => '*', |
| 667 |
rules => { |
| 668 |
norenewalbefore => '10', |
| 669 |
no_auto_renewal_after => '11', |
| 670 |
} |
| 671 |
} |
| 672 |
); |
| 621 |
( $renewokay, $error ) = |
673 |
( $renewokay, $error ) = |
| 622 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
674 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 623 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
675 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 624 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
676 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 625 |
|
677 |
|
| 626 |
$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 ) ); |
678 |
Koha::CirculationRules->set_rules( |
|
|
679 |
{ |
| 680 |
categorycode => '*', |
| 681 |
branchcode => '*', |
| 682 |
itemtype => '*', |
| 683 |
rules => { |
| 684 |
norenewalbefore => '10', |
| 685 |
no_auto_renewal_after => undef, |
| 686 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => -1 ), |
| 687 |
} |
| 688 |
} |
| 689 |
); |
| 627 |
( $renewokay, $error ) = |
690 |
( $renewokay, $error ) = |
| 628 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
691 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 629 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
692 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 630 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
693 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 631 |
|
694 |
|
| 632 |
$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 ) ); |
695 |
Koha::CirculationRules->set_rules( |
|
|
696 |
{ |
| 697 |
categorycode => '*', |
| 698 |
branchcode => '*', |
| 699 |
itemtype => '*', |
| 700 |
rules => { |
| 701 |
norenewalbefore => '7', |
| 702 |
no_auto_renewal_after => '15', |
| 703 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => -1 ), |
| 704 |
} |
| 705 |
} |
| 706 |
); |
| 633 |
( $renewokay, $error ) = |
707 |
( $renewokay, $error ) = |
| 634 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
708 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 635 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
709 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 636 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
710 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 637 |
|
711 |
|
| 638 |
$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 ) ); |
712 |
Koha::CirculationRules->set_rules( |
|
|
713 |
{ |
| 714 |
categorycode => '*', |
| 715 |
branchcode => '*', |
| 716 |
itemtype => '*', |
| 717 |
rules => { |
| 718 |
norenewalbefore => '10', |
| 719 |
no_auto_renewal_after => undef, |
| 720 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => 1 ), |
| 721 |
} |
| 722 |
} |
| 723 |
); |
| 639 |
( $renewokay, $error ) = |
724 |
( $renewokay, $error ) = |
| 640 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
725 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 641 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
726 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
|
Lines 657-663
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 657 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
742 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 658 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
743 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 659 |
|
744 |
|
| 660 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
745 |
Koha::CirculationRules->set_rules( |
|
|
746 |
{ |
| 747 |
categorycode => '*', |
| 748 |
branchcode => '*', |
| 749 |
itemtype => '*', |
| 750 |
rules => { |
| 751 |
norenewalbefore => '10', |
| 752 |
no_auto_renewal_after => '11', |
| 753 |
} |
| 754 |
} |
| 755 |
); |
| 661 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
756 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
| 662 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
757 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
| 663 |
my $fines_amount = 5; |
758 |
my $fines_amount = 5; |
|
Lines 697-727
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 697 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
792 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 698 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
793 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 699 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
794 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 700 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = "", no_auto_renewal_after_hard_limit = NULL'); |
795 |
Koha::CirculationRules->set_rules( |
|
|
796 |
{ |
| 797 |
categorycode => '*', |
| 798 |
branchcode => '*', |
| 799 |
itemtype => '*', |
| 800 |
rules => { |
| 801 |
norenewalbefore => '7', |
| 802 |
no_auto_renewal_after => '', |
| 803 |
no_auto_renewal_after_hard_limit => undef, |
| 804 |
} |
| 805 |
} |
| 806 |
); |
| 701 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
807 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 702 |
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' ); |
808 |
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' ); |
| 703 |
my $five_days_before = dt_from_string->add( days => -5 ); |
809 |
my $five_days_before = dt_from_string->add( days => -5 ); |
| 704 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 5, no_auto_renewal_after_hard_limit = NULL'); |
810 |
Koha::CirculationRules->set_rules( |
|
|
811 |
{ |
| 812 |
categorycode => '*', |
| 813 |
branchcode => '*', |
| 814 |
itemtype => '*', |
| 815 |
rules => { |
| 816 |
norenewalbefore => '10', |
| 817 |
no_auto_renewal_after => '5', |
| 818 |
no_auto_renewal_after_hard_limit => undef, |
| 819 |
} |
| 820 |
} |
| 821 |
); |
| 705 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
822 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 706 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
823 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
| 707 |
$five_days_before->truncate( to => 'minute' ), |
824 |
$five_days_before->truncate( to => 'minute' ), |
| 708 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
825 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
| 709 |
); |
826 |
); |
| 710 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
827 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
| 711 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15, no_auto_renewal_after_hard_limit = NULL'); |
828 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '10' WHERE rule_name = 'norenewalbefore'}); |
|
|
829 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = '15' WHERE rule_name = 'no_auto_renewal_after'}); |
| 830 |
$dbh->do(q{UPDATE circulation_rules SET rule_value = NULL WHERE rule_name = 'no_auto_renewal_after_hard_limit'}); |
| 831 |
Koha::CirculationRules->set_rules( |
| 832 |
{ |
| 833 |
categorycode => '*', |
| 834 |
branchcode => '*', |
| 835 |
itemtype => '*', |
| 836 |
rules => { |
| 837 |
norenewalbefore => '10', |
| 838 |
no_auto_renewal_after => '15', |
| 839 |
no_auto_renewal_after_hard_limit => undef, |
| 840 |
} |
| 841 |
} |
| 842 |
); |
| 712 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
843 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 713 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
844 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
| 714 |
$five_days_ahead->truncate( to => 'minute' ), |
845 |
$five_days_ahead->truncate( to => 'minute' ), |
| 715 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
846 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
| 716 |
); |
847 |
); |
| 717 |
my $two_days_ahead = dt_from_string->add( days => 2 ); |
848 |
my $two_days_ahead = dt_from_string->add( days => 2 ); |
| 718 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = "", no_auto_renewal_after_hard_limit = ?', undef, dt_from_string->add( days => 2 ) ); |
849 |
Koha::CirculationRules->set_rules( |
|
|
850 |
{ |
| 851 |
categorycode => '*', |
| 852 |
branchcode => '*', |
| 853 |
itemtype => '*', |
| 854 |
rules => { |
| 855 |
norenewalbefore => '10', |
| 856 |
no_auto_renewal_after => '', |
| 857 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => 2 ), |
| 858 |
} |
| 859 |
} |
| 860 |
); |
| 719 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
861 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 720 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
862 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
| 721 |
$two_days_ahead->truncate( to => 'day' ), |
863 |
$two_days_ahead->truncate( to => 'day' ), |
| 722 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' |
864 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' |
| 723 |
); |
865 |
); |
| 724 |
$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 ) ); |
866 |
Koha::CirculationRules->set_rules( |
|
|
867 |
{ |
| 868 |
categorycode => '*', |
| 869 |
branchcode => '*', |
| 870 |
itemtype => '*', |
| 871 |
rules => { |
| 872 |
norenewalbefore => '10', |
| 873 |
no_auto_renewal_after => '15', |
| 874 |
no_auto_renewal_after_hard_limit => dt_from_string->add( days => 2 ), |
| 875 |
} |
| 876 |
} |
| 877 |
); |
| 725 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
878 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 726 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
879 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
| 727 |
$two_days_ahead->truncate( to => 'day' ), |
880 |
$two_days_ahead->truncate( to => 'day' ), |
|
Lines 729-739
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 729 |
); |
882 |
); |
| 730 |
|
883 |
|
| 731 |
}; |
884 |
}; |
| 732 |
|
|
|
| 733 |
# Too many renewals |
885 |
# Too many renewals |
| 734 |
|
886 |
|
| 735 |
# set policy to forbid renewals |
887 |
# set policy to forbid renewals |
| 736 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = NULL, renewalsallowed = 0'); |
888 |
Koha::CirculationRules->set_rules( |
|
|
889 |
{ |
| 890 |
categorycode => '*', |
| 891 |
branchcode => '*', |
| 892 |
itemtype => '*', |
| 893 |
rules => { |
| 894 |
norenewalbefore => undef, |
| 895 |
renewalsallowed => 0, |
| 896 |
} |
| 897 |
} |
| 898 |
); |
| 737 |
|
899 |
|
| 738 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
900 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
| 739 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
901 |
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed'); |
|
Lines 946-975
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 946 |
{ |
1108 |
{ |
| 947 |
$dbh->do('DELETE FROM issues'); |
1109 |
$dbh->do('DELETE FROM issues'); |
| 948 |
$dbh->do('DELETE FROM items'); |
1110 |
$dbh->do('DELETE FROM items'); |
| 949 |
$dbh->do('DELETE FROM issuingrules'); |
1111 |
$dbh->do('DELETE FROM circulation_rules'); |
| 950 |
Koha::CirculationRules->search()->delete(); |
1112 |
Koha::CirculationRules->set_rules( |
| 951 |
$dbh->do( |
1113 |
{ |
| 952 |
q{ |
1114 |
categorycode => '*', |
| 953 |
INSERT INTO issuingrules ( categorycode, branchcode, itemtype, reservesallowed, issuelength, lengthunit, renewalsallowed, renewalperiod, |
1115 |
itemtype => '*', |
| 954 |
norenewalbefore, auto_renew, fine, chargeperiod ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) |
1116 |
branchcode => '*', |
| 955 |
}, |
1117 |
rules => { |
| 956 |
{}, |
1118 |
reservesallowed => 25, |
| 957 |
'*', '*', '*', 25, |
1119 |
issuelength => 14, |
| 958 |
14, 'days', |
1120 |
lengthunit => 'days', |
| 959 |
1, 7, |
1121 |
renewalsallowed => 1, |
| 960 |
undef, 0, |
1122 |
renewalperiod => 7, |
| 961 |
.10, 1 |
1123 |
norenewalbefore => undef, |
| 962 |
); |
1124 |
auto_renew => 0, |
| 963 |
Koha::CirculationRules->set_rules( |
1125 |
fine => .10, |
| 964 |
{ |
1126 |
chargeperiod => 1, |
| 965 |
categorycode => '*', |
1127 |
maxissueqty => 20 |
| 966 |
itemtype => '*', |
1128 |
} |
| 967 |
branchcode => '*', |
1129 |
} |
| 968 |
rules => { |
1130 |
); |
| 969 |
maxissueqty => 20 |
|
|
| 970 |
} |
| 971 |
} |
| 972 |
); |
| 973 |
my $biblio = MARC::Record->new(); |
1131 |
my $biblio = MARC::Record->new(); |
| 974 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
1132 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
| 975 |
|
1133 |
|
|
Lines 1021-1042
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 1021 |
undef, undef, undef |
1179 |
undef, undef, undef |
| 1022 |
); |
1180 |
); |
| 1023 |
|
1181 |
|
| 1024 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
1182 |
Koha::CirculationRules->set_rules( |
|
|
1183 |
{ |
| 1184 |
categorycode => '*', |
| 1185 |
itemtype => '*', |
| 1186 |
branchcode => '*', |
| 1187 |
rules => { |
| 1188 |
onshelfholds => 0, |
| 1189 |
} |
| 1190 |
} |
| 1191 |
); |
| 1025 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
1192 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
| 1026 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1193 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1027 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
1194 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
| 1028 |
|
1195 |
|
| 1029 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
1196 |
Koha::CirculationRules->set_rules( |
|
|
1197 |
{ |
| 1198 |
categorycode => '*', |
| 1199 |
itemtype => '*', |
| 1200 |
branchcode => '*', |
| 1201 |
rules => { |
| 1202 |
onshelfholds => 0, |
| 1203 |
} |
| 1204 |
} |
| 1205 |
); |
| 1030 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1206 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 1031 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1207 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1032 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
1208 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
| 1033 |
|
1209 |
|
| 1034 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
1210 |
Koha::CirculationRules->set_rules( |
|
|
1211 |
{ |
| 1212 |
categorycode => '*', |
| 1213 |
itemtype => '*', |
| 1214 |
branchcode => '*', |
| 1215 |
rules => { |
| 1216 |
onshelfholds => 1, |
| 1217 |
} |
| 1218 |
} |
| 1219 |
); |
| 1035 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
1220 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
| 1036 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1221 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1037 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
1222 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
| 1038 |
|
1223 |
|
| 1039 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
1224 |
Koha::CirculationRules->set_rules( |
|
|
1225 |
{ |
| 1226 |
categorycode => '*', |
| 1227 |
itemtype => '*', |
| 1228 |
branchcode => '*', |
| 1229 |
rules => { |
| 1230 |
onshelfholds => 1, |
| 1231 |
} |
| 1232 |
} |
| 1233 |
); |
| 1040 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1234 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 1041 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
1235 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
| 1042 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
1236 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
|
Lines 1557-1576
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
| 1557 |
} |
1751 |
} |
| 1558 |
); |
1752 |
); |
| 1559 |
|
1753 |
|
| 1560 |
# And the issuing rule |
1754 |
# And the circulation rule |
| 1561 |
Koha::IssuingRules->search->delete; |
1755 |
Koha::CirculationRules->search->delete; |
| 1562 |
my $rule = Koha::IssuingRule->new( |
1756 |
Koha::CirculationRules->set_rules( |
| 1563 |
{ |
1757 |
{ |
| 1564 |
categorycode => '*', |
1758 |
categorycode => '*', |
| 1565 |
itemtype => '*', |
1759 |
itemtype => '*', |
| 1566 |
branchcode => '*', |
1760 |
branchcode => '*', |
| 1567 |
issuelength => 1, |
1761 |
rules => { |
| 1568 |
firstremind => 1, # 1 day of grace |
1762 |
issuelength => 1, |
| 1569 |
finedays => 2, # 2 days of fine per day of overdue |
1763 |
firstremind => 1, # 1 day of grace |
| 1570 |
lengthunit => 'days', |
1764 |
finedays => 2, # 2 days of fine per day of overdue |
|
|
1765 |
lengthunit => 'days', |
| 1766 |
} |
| 1571 |
} |
1767 |
} |
| 1572 |
); |
1768 |
); |
| 1573 |
$rule->store(); |
|
|
| 1574 |
|
1769 |
|
| 1575 |
# Patron cannot issue item_1, they have overdues |
1770 |
# Patron cannot issue item_1, they have overdues |
| 1576 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
1771 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
|
Lines 1672-1691
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
| 1672 |
} |
1867 |
} |
| 1673 |
); |
1868 |
); |
| 1674 |
|
1869 |
|
| 1675 |
Koha::IssuingRules->search->delete; |
1870 |
Koha::CirculationRules->search->delete; |
| 1676 |
my $rule = Koha::IssuingRule->new( |
1871 |
my $rule = Koha::CirculationRules->set_rules( |
| 1677 |
{ |
1872 |
{ |
| 1678 |
categorycode => '*', |
1873 |
categorycode => '*', |
| 1679 |
itemtype => '*', |
1874 |
itemtype => '*', |
| 1680 |
branchcode => '*', |
1875 |
branchcode => '*', |
| 1681 |
maxissueqty => 99, |
1876 |
rules => { |
| 1682 |
issuelength => 6, |
1877 |
maxissueqty => 99, |
| 1683 |
lengthunit => 'days', |
1878 |
issuelength => 6, |
| 1684 |
fine => 1, # Charge 1 every day of overdue |
1879 |
lengthunit => 'days', |
| 1685 |
chargeperiod => 1, |
1880 |
fine => 1, # Charge 1 every day of overdue |
|
|
1881 |
chargeperiod => 1, |
| 1882 |
} |
| 1686 |
} |
1883 |
} |
| 1687 |
); |
1884 |
); |
| 1688 |
$rule->store(); |
|
|
| 1689 |
|
1885 |
|
| 1690 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
1886 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
| 1691 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
1887 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |