Lines 83-91
sub test_debarment_on_checkout {
Link Here
|
83 |
); |
83 |
); |
84 |
my @caller = caller; |
84 |
my @caller = caller; |
85 |
my $line_number = $caller[2]; |
85 |
my $line_number = $caller[2]; |
86 |
AddIssue( $patron, $item->{barcode}, $due_date ); |
86 |
AddIssue( $patron, $item->barcode, $due_date ); |
87 |
|
87 |
|
88 |
my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, $return_date ); |
88 |
my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); |
89 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
89 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
90 |
or diag('AddReturn returned message ' . Dumper $message ); |
90 |
or diag('AddReturn returned message ' . Dumper $message ); |
91 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
91 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
Lines 749-767
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
749 |
|
749 |
|
750 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
750 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
751 |
plan tests => 14; |
751 |
plan tests => 14; |
752 |
my $item_to_auto_renew = $builder->build( |
752 |
my $item_to_auto_renew = $builder->build_sample_item( |
753 |
{ source => 'Item', |
753 |
{ |
754 |
value => { |
754 |
biblionumber => $biblio->biblionumber, |
755 |
biblionumber => $biblio->biblionumber, |
755 |
library => $branch, |
756 |
homebranch => $branch, |
|
|
757 |
holdingbranch => $branch, |
758 |
} |
759 |
} |
756 |
} |
760 |
); |
757 |
); |
761 |
|
758 |
|
762 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
759 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
763 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
760 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
764 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
761 |
AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
765 |
|
762 |
|
766 |
Koha::CirculationRules->set_rules( |
763 |
Koha::CirculationRules->set_rules( |
767 |
{ |
764 |
{ |
Lines 775-781
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
775 |
} |
772 |
} |
776 |
); |
773 |
); |
777 |
( $renewokay, $error ) = |
774 |
( $renewokay, $error ) = |
778 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
775 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
779 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
776 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
780 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
777 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
781 |
|
778 |
|
Lines 791-797
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
791 |
} |
788 |
} |
792 |
); |
789 |
); |
793 |
( $renewokay, $error ) = |
790 |
( $renewokay, $error ) = |
794 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
791 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
795 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
792 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
796 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
793 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
797 |
|
794 |
|
Lines 807-813
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
807 |
} |
804 |
} |
808 |
); |
805 |
); |
809 |
( $renewokay, $error ) = |
806 |
( $renewokay, $error ) = |
810 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
807 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
811 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
808 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
812 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
809 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); |
813 |
|
810 |
|
Lines 823-829
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
823 |
} |
820 |
} |
824 |
); |
821 |
); |
825 |
( $renewokay, $error ) = |
822 |
( $renewokay, $error ) = |
826 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
823 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
827 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
824 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
828 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
825 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
829 |
|
826 |
|
Lines 840-846
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
840 |
} |
837 |
} |
841 |
); |
838 |
); |
842 |
( $renewokay, $error ) = |
839 |
( $renewokay, $error ) = |
843 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
840 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
844 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
841 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
845 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
842 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
846 |
|
843 |
|
Lines 857-863
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
857 |
} |
854 |
} |
858 |
); |
855 |
); |
859 |
( $renewokay, $error ) = |
856 |
( $renewokay, $error ) = |
860 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
857 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
861 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
858 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
862 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
859 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
863 |
|
860 |
|
Lines 874-898
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
874 |
} |
871 |
} |
875 |
); |
872 |
); |
876 |
( $renewokay, $error ) = |
873 |
( $renewokay, $error ) = |
877 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
874 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
878 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
875 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
879 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
876 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
880 |
}; |
877 |
}; |
881 |
|
878 |
|
882 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { |
879 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { |
883 |
plan tests => 10; |
880 |
plan tests => 10; |
884 |
my $item_to_auto_renew = $builder->build({ |
881 |
my $item_to_auto_renew = $builder->build_sample_item( |
885 |
source => 'Item', |
882 |
{ |
886 |
value => { |
|
|
887 |
biblionumber => $biblio->biblionumber, |
883 |
biblionumber => $biblio->biblionumber, |
888 |
homebranch => $branch, |
884 |
library => $branch, |
889 |
holdingbranch => $branch, |
|
|
890 |
} |
885 |
} |
891 |
}); |
886 |
); |
892 |
|
887 |
|
893 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
888 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
894 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
889 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
895 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
890 |
AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
896 |
|
891 |
|
897 |
Koha::CirculationRules->set_rules( |
892 |
Koha::CirculationRules->set_rules( |
898 |
{ |
893 |
{ |
Lines 915-926
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
915 |
amount => $fines_amount, |
910 |
amount => $fines_amount, |
916 |
interface => 'test', |
911 |
interface => 'test', |
917 |
type => 'OVERDUE', |
912 |
type => 'OVERDUE', |
918 |
item_id => $item_to_auto_renew->{itemnumber}, |
913 |
item_id => $item_to_auto_renew->itemnumber, |
919 |
description => "Some fines" |
914 |
description => "Some fines" |
920 |
} |
915 |
} |
921 |
)->status('RETURNED')->store; |
916 |
)->status('RETURNED')->store; |
922 |
( $renewokay, $error ) = |
917 |
( $renewokay, $error ) = |
923 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
918 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
924 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
919 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
925 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
920 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
926 |
|
921 |
|
Lines 929-940
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
929 |
amount => $fines_amount, |
924 |
amount => $fines_amount, |
930 |
interface => 'test', |
925 |
interface => 'test', |
931 |
type => 'OVERDUE', |
926 |
type => 'OVERDUE', |
932 |
item_id => $item_to_auto_renew->{itemnumber}, |
927 |
item_id => $item_to_auto_renew->itemnumber, |
933 |
description => "Some fines" |
928 |
description => "Some fines" |
934 |
} |
929 |
} |
935 |
)->status('RETURNED')->store; |
930 |
)->status('RETURNED')->store; |
936 |
( $renewokay, $error ) = |
931 |
( $renewokay, $error ) = |
937 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
932 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
938 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
933 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
939 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
934 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
940 |
|
935 |
|
Lines 943-954
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
943 |
amount => $fines_amount, |
938 |
amount => $fines_amount, |
944 |
interface => 'test', |
939 |
interface => 'test', |
945 |
type => 'OVERDUE', |
940 |
type => 'OVERDUE', |
946 |
item_id => $item_to_auto_renew->{itemnumber}, |
941 |
item_id => $item_to_auto_renew->itemnumber, |
947 |
description => "Some fines" |
942 |
description => "Some fines" |
948 |
} |
943 |
} |
949 |
)->status('RETURNED')->store; |
944 |
)->status('RETURNED')->store; |
950 |
( $renewokay, $error ) = |
945 |
( $renewokay, $error ) = |
951 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
946 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
952 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
947 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
953 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
948 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
954 |
|
949 |
|
Lines 961-973
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
961 |
} |
956 |
} |
962 |
)->store; |
957 |
)->store; |
963 |
( $renewokay, $error ) = |
958 |
( $renewokay, $error ) = |
964 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
959 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
965 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
960 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
966 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
961 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
967 |
|
962 |
|
968 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); |
963 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); |
969 |
( $renewokay, $error ) = |
964 |
( $renewokay, $error ) = |
970 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
965 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
971 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
966 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
972 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
967 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); |
973 |
|
968 |
|
Lines 977-990
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
977 |
|
972 |
|
978 |
subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub { |
973 |
subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub { |
979 |
plan tests => 6; |
974 |
plan tests => 6; |
980 |
my $item_to_auto_renew = $builder->build({ |
975 |
my $item_to_auto_renew = $builder->build_sample_item( |
981 |
source => 'Item', |
976 |
{ |
982 |
value => { |
|
|
983 |
biblionumber => $biblio->biblionumber, |
977 |
biblionumber => $biblio->biblionumber, |
984 |
homebranch => $branch, |
978 |
library => $branch, |
985 |
holdingbranch => $branch, |
|
|
986 |
} |
979 |
} |
987 |
}); |
980 |
); |
988 |
|
981 |
|
989 |
Koha::CirculationRules->set_rules( |
982 |
Koha::CirculationRules->set_rules( |
990 |
{ |
983 |
{ |
Lines 1005-1013
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1005 |
# => auto renew is allowed |
998 |
# => auto renew is allowed |
1006 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
999 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1007 |
my $patron = $expired_borrower; |
1000 |
my $patron = $expired_borrower; |
1008 |
my $checkout = AddIssue( $patron, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1001 |
my $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1009 |
( $renewokay, $error ) = |
1002 |
( $renewokay, $error ) = |
1010 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1003 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); |
1011 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1004 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1012 |
is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); |
1005 |
is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); |
1013 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1006 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
Lines 1017-1025
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1017 |
# => auto renew is not allowed |
1010 |
# => auto renew is not allowed |
1018 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1011 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1019 |
$patron = $expired_borrower; |
1012 |
$patron = $expired_borrower; |
1020 |
$checkout = AddIssue( $patron, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1013 |
$checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1021 |
( $renewokay, $error ) = |
1014 |
( $renewokay, $error ) = |
1022 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1015 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); |
1023 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1016 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1024 |
is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); |
1017 |
is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); |
1025 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1018 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
Lines 1029-1037
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1029 |
# => auto renew is allowed |
1022 |
# => auto renew is allowed |
1030 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1023 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1031 |
$patron = $renewing_borrower; |
1024 |
$patron = $renewing_borrower; |
1032 |
$checkout = AddIssue( $patron, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1025 |
$checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1033 |
( $renewokay, $error ) = |
1026 |
( $renewokay, $error ) = |
1034 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); |
1027 |
CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); |
1035 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1028 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1036 |
is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); |
1029 |
is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); |
1037 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
1030 |
Koha::Checkouts->find( $checkout->issue_id )->delete; |
Lines 1039-1057
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1039 |
|
1032 |
|
1040 |
subtest "GetLatestAutoRenewDate" => sub { |
1033 |
subtest "GetLatestAutoRenewDate" => sub { |
1041 |
plan tests => 5; |
1034 |
plan tests => 5; |
1042 |
my $item_to_auto_renew = $builder->build( |
1035 |
my $item_to_auto_renew = $builder->build_sample_item( |
1043 |
{ source => 'Item', |
1036 |
{ |
1044 |
value => { |
1037 |
biblionumber => $biblio->biblionumber, |
1045 |
biblionumber => $biblio->biblionumber, |
1038 |
library => $branch, |
1046 |
homebranch => $branch, |
|
|
1047 |
holdingbranch => $branch, |
1048 |
} |
1049 |
} |
1039 |
} |
1050 |
); |
1040 |
); |
1051 |
|
1041 |
|
1052 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1042 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1053 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1043 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1054 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1044 |
AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1055 |
Koha::CirculationRules->set_rules( |
1045 |
Koha::CirculationRules->set_rules( |
1056 |
{ |
1046 |
{ |
1057 |
categorycode => undef, |
1047 |
categorycode => undef, |
Lines 1064-1070
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1064 |
} |
1054 |
} |
1065 |
} |
1055 |
} |
1066 |
); |
1056 |
); |
1067 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
1057 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
1068 |
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' ); |
1058 |
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' ); |
1069 |
my $five_days_before = dt_from_string->add( days => -5 ); |
1059 |
my $five_days_before = dt_from_string->add( days => -5 ); |
1070 |
Koha::CirculationRules->set_rules( |
1060 |
Koha::CirculationRules->set_rules( |
Lines 1079-1085
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1079 |
} |
1069 |
} |
1080 |
} |
1070 |
} |
1081 |
); |
1071 |
); |
1082 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
1072 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
1083 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
1073 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
1084 |
$five_days_before->truncate( to => 'minute' ), |
1074 |
$five_days_before->truncate( to => 'minute' ), |
1085 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
1075 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
Lines 1100-1106
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1100 |
} |
1090 |
} |
1101 |
} |
1091 |
} |
1102 |
); |
1092 |
); |
1103 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
1093 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
1104 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
1094 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
1105 |
$five_days_ahead->truncate( to => 'minute' ), |
1095 |
$five_days_ahead->truncate( to => 'minute' ), |
1106 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
1096 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
Lines 1118-1124
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1118 |
} |
1108 |
} |
1119 |
} |
1109 |
} |
1120 |
); |
1110 |
); |
1121 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
1111 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
1122 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
1112 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
1123 |
$two_days_ahead->truncate( to => 'day' ), |
1113 |
$two_days_ahead->truncate( to => 'day' ), |
1124 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' |
1114 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' |
Lines 1135-1141
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1135 |
} |
1125 |
} |
1136 |
} |
1126 |
} |
1137 |
); |
1127 |
); |
1138 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
1128 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); |
1139 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
1129 |
is( $latest_auto_renew_date->truncate( to => 'day' ), |
1140 |
$two_days_ahead->truncate( to => 'day' ), |
1130 |
$two_days_ahead->truncate( to => 'day' ), |
1141 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is < no_auto_renewal_after' |
1131 |
'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is < no_auto_renewal_after' |
Lines 1602-1612
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1602 |
homebranch => $homebranch->{branchcode}, |
1592 |
homebranch => $homebranch->{branchcode}, |
1603 |
holdingbranch => $holdingbranch->{branchcode}, |
1593 |
holdingbranch => $holdingbranch->{branchcode}, |
1604 |
} |
1594 |
} |
1605 |
)->unblessed; |
1595 |
); |
1606 |
|
1596 |
|
1607 |
set_userenv($holdingbranch); |
1597 |
set_userenv($holdingbranch); |
1608 |
|
1598 |
|
1609 |
my $issue = AddIssue( $patron_1->unblessed, $item->{barcode} ); |
1599 |
my $issue = AddIssue( $patron_1->unblessed, $item->barcode ); |
1610 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1600 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1611 |
|
1601 |
|
1612 |
my ( $error, $question, $alerts ); |
1602 |
my ( $error, $question, $alerts ); |
Lines 1619-1634
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1619 |
ok( $error->{UNKNOWN_BARCODE}, '"KohaIsAwesome" is not a valid barcode as expected.' ); |
1609 |
ok( $error->{UNKNOWN_BARCODE}, '"KohaIsAwesome" is not a valid barcode as expected.' ); |
1620 |
## Can be issued from homebranch |
1610 |
## Can be issued from homebranch |
1621 |
set_userenv($homebranch); |
1611 |
set_userenv($homebranch); |
1622 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1612 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1623 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1613 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1624 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1614 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1625 |
## Can be issued from holdingbranch |
1615 |
## Can be issued from holdingbranch |
1626 |
set_userenv($holdingbranch); |
1616 |
set_userenv($holdingbranch); |
1627 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1617 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1628 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1618 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1629 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1619 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1630 |
## Can be issued from another branch |
1620 |
## Can be issued from another branch |
1631 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1621 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1632 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1622 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1633 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1623 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1634 |
|
1624 |
|
Lines 1636-1653
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1636 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1626 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1637 |
## Cannot be issued from homebranch |
1627 |
## Cannot be issued from homebranch |
1638 |
set_userenv($homebranch); |
1628 |
set_userenv($homebranch); |
1639 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1629 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1640 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1630 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1641 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1631 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1642 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matched holdingbranch' ); |
1632 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matched holdingbranch' ); |
1643 |
## Can be issued from holdinbranch |
1633 |
## Can be issued from holdinbranch |
1644 |
set_userenv($holdingbranch); |
1634 |
set_userenv($holdingbranch); |
1645 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1635 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1646 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1636 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1647 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1637 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1648 |
## Cannot be issued from another branch |
1638 |
## Cannot be issued from another branch |
1649 |
set_userenv($otherbranch); |
1639 |
set_userenv($otherbranch); |
1650 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1640 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1651 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1641 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1652 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1642 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1653 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matches holdingbranch' ); |
1643 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matches holdingbranch' ); |
Lines 1656-1673
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1656 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1646 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1657 |
## Can be issued from holdinbranch |
1647 |
## Can be issued from holdinbranch |
1658 |
set_userenv($homebranch); |
1648 |
set_userenv($homebranch); |
1659 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1649 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1660 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1650 |
is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1661 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1651 |
is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); |
1662 |
## Cannot be issued from holdinbranch |
1652 |
## Cannot be issued from holdinbranch |
1663 |
set_userenv($holdingbranch); |
1653 |
set_userenv($holdingbranch); |
1664 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1654 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1665 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1655 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1666 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1656 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1667 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
1657 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
1668 |
## Cannot be issued from holdinbranch |
1658 |
## Cannot be issued from holdinbranch |
1669 |
set_userenv($otherbranch); |
1659 |
set_userenv($otherbranch); |
1670 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1660 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); |
1671 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1661 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1672 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1662 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1673 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
1663 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
Lines 1689-1700
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1689 |
homebranch => $homebranch->{branchcode}, |
1679 |
homebranch => $homebranch->{branchcode}, |
1690 |
holdingbranch => $holdingbranch->{branchcode}, |
1680 |
holdingbranch => $holdingbranch->{branchcode}, |
1691 |
} |
1681 |
} |
1692 |
)->unblessed; |
1682 |
); |
1693 |
|
1683 |
|
1694 |
set_userenv($holdingbranch); |
1684 |
set_userenv($holdingbranch); |
1695 |
|
1685 |
|
1696 |
my $ref_issue = 'Koha::Checkout'; |
1686 |
my $ref_issue = 'Koha::Checkout'; |
1697 |
my $issue = AddIssue( $patron_1, $item->{barcode} ); |
1687 |
my $issue = AddIssue( $patron_1, $item->barcode ); |
1698 |
|
1688 |
|
1699 |
my ( $error, $question, $alerts ); |
1689 |
my ( $error, $question, $alerts ); |
1700 |
|
1690 |
|
Lines 1702-1743
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1702 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1692 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1703 |
## Can be issued from homebranch |
1693 |
## Can be issued from homebranch |
1704 |
set_userenv($homebranch); |
1694 |
set_userenv($homebranch); |
1705 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch'); |
1695 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch'); |
1706 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1696 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue |
1707 |
## Can be issued from holdinbranch |
1697 |
## Can be issued from holdinbranch |
1708 |
set_userenv($holdingbranch); |
1698 |
set_userenv($holdingbranch); |
1709 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch'); |
1699 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch'); |
1710 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1700 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue |
1711 |
## Can be issued from another branch |
1701 |
## Can be issued from another branch |
1712 |
set_userenv($otherbranch); |
1702 |
set_userenv($otherbranch); |
1713 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch'); |
1703 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch'); |
1714 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1704 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue |
1715 |
|
1705 |
|
1716 |
# AllowReturnToBranch == holdinbranch |
1706 |
# AllowReturnToBranch == holdinbranch |
1717 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1707 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1718 |
## Cannot be issued from homebranch |
1708 |
## Cannot be issued from homebranch |
1719 |
set_userenv($homebranch); |
1709 |
set_userenv($homebranch); |
1720 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch'); |
1710 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch'); |
1721 |
## Can be issued from holdingbranch |
1711 |
## Can be issued from holdingbranch |
1722 |
set_userenv($holdingbranch); |
1712 |
set_userenv($holdingbranch); |
1723 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch'); |
1713 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch'); |
1724 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1714 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue |
1725 |
## Cannot be issued from another branch |
1715 |
## Cannot be issued from another branch |
1726 |
set_userenv($otherbranch); |
1716 |
set_userenv($otherbranch); |
1727 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch'); |
1717 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch'); |
1728 |
|
1718 |
|
1729 |
# AllowReturnToBranch == homebranch |
1719 |
# AllowReturnToBranch == homebranch |
1730 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1720 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1731 |
## Can be issued from homebranch |
1721 |
## Can be issued from homebranch |
1732 |
set_userenv($homebranch); |
1722 |
set_userenv($homebranch); |
1733 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' ); |
1723 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' ); |
1734 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1724 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue |
1735 |
## Cannot be issued from holdinbranch |
1725 |
## Cannot be issued from holdinbranch |
1736 |
set_userenv($holdingbranch); |
1726 |
set_userenv($holdingbranch); |
1737 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' ); |
1727 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' ); |
1738 |
## Cannot be issued from another branch |
1728 |
## Cannot be issued from another branch |
1739 |
set_userenv($otherbranch); |
1729 |
set_userenv($otherbranch); |
1740 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' ); |
1730 |
is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' ); |
1741 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1731 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1742 |
}; |
1732 |
}; |
1743 |
|
1733 |
|
Lines 1750-1787
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1750 |
{ |
1740 |
{ |
1751 |
library => $library->{branchcode}, |
1741 |
library => $library->{branchcode}, |
1752 |
} |
1742 |
} |
1753 |
)->unblessed; |
1743 |
); |
1754 |
my $item_2 = $builder->build_sample_item( |
1744 |
my $item_2 = $builder->build_sample_item( |
1755 |
{ |
1745 |
{ |
1756 |
library => $library->{branchcode}, |
1746 |
library => $library->{branchcode}, |
1757 |
} |
1747 |
} |
1758 |
)->unblessed; |
1748 |
); |
1759 |
|
1749 |
|
1760 |
my ( $error, $question, $alerts ); |
1750 |
my ( $error, $question, $alerts ); |
1761 |
|
1751 |
|
1762 |
# Patron cannot issue item_1, they have overdues |
1752 |
# Patron cannot issue item_1, they have overdues |
1763 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
1753 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
1764 |
my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, $yesterday ); # Add an overdue |
1754 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, $yesterday ); # Add an overdue |
1765 |
|
1755 |
|
1766 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
1756 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
1767 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1757 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1768 |
is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert' . str($error, $question, $alerts) ); |
1758 |
is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert' . str($error, $question, $alerts) ); |
1769 |
is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); |
1759 |
is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); |
1770 |
|
1760 |
|
1771 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
1761 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
1772 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1762 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1773 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
1763 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
1774 |
is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); |
1764 |
is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); |
1775 |
|
1765 |
|
1776 |
# Patron cannot issue item_1, they are debarred |
1766 |
# Patron cannot issue item_1, they are debarred |
1777 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
1767 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
1778 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber, expiration => $tomorrow } ); |
1768 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber, expiration => $tomorrow } ); |
1779 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1769 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1780 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
1770 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
1781 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); |
1771 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); |
1782 |
|
1772 |
|
1783 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber } ); |
1773 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber } ); |
1784 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1774 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1785 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
1775 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); |
1786 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); |
1776 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); |
1787 |
}; |
1777 |
}; |
Lines 1812-1820
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
Link Here
|
1812 |
{ |
1802 |
{ |
1813 |
library => $library->{branchcode}, |
1803 |
library => $library->{branchcode}, |
1814 |
} |
1804 |
} |
1815 |
)->unblessed; |
1805 |
); |
1816 |
|
1806 |
|
1817 |
my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} ); |
1807 |
my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->barcode ); |
1818 |
is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' ); |
1808 |
is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' ); |
1819 |
|
1809 |
|
1820 |
# TODO There are other tests to provide here |
1810 |
# TODO There are other tests to provide here |
Lines 1944-1963
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
1944 |
biblionumber => $biblionumber, |
1934 |
biblionumber => $biblionumber, |
1945 |
library => $library->{branchcode}, |
1935 |
library => $library->{branchcode}, |
1946 |
} |
1936 |
} |
1947 |
)->unblessed; |
1937 |
); |
1948 |
|
1938 |
|
1949 |
my $item_2 = $builder->build_sample_item( |
1939 |
my $item_2 = $builder->build_sample_item( |
1950 |
{ |
1940 |
{ |
1951 |
biblionumber => $biblionumber, |
1941 |
biblionumber => $biblionumber, |
1952 |
library => $library->{branchcode}, |
1942 |
library => $library->{branchcode}, |
1953 |
} |
1943 |
} |
1954 |
)->unblessed; |
1944 |
); |
1955 |
|
1945 |
|
1956 |
my ( $error, $question, $alerts ); |
1946 |
my ( $error, $question, $alerts ); |
1957 |
my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); |
1947 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
1958 |
|
1948 |
|
1959 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
1949 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
1960 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1950 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1961 |
cmp_deeply( |
1951 |
cmp_deeply( |
1962 |
{ error => $error, alerts => $alerts }, |
1952 |
{ error => $error, alerts => $alerts }, |
1963 |
{ error => {}, alerts => {} }, |
1953 |
{ error => {}, alerts => {} }, |
Lines 1966-1972
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
1966 |
is( $question->{BIBLIO_ALREADY_ISSUED}, 1, 'BIBLIO_ALREADY_ISSUED question flag should be set if AllowMultipleIssuesOnABiblio=0 and issue already exists' ); |
1956 |
is( $question->{BIBLIO_ALREADY_ISSUED}, 1, 'BIBLIO_ALREADY_ISSUED question flag should be set if AllowMultipleIssuesOnABiblio=0 and issue already exists' ); |
1967 |
|
1957 |
|
1968 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
1958 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
1969 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1959 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1970 |
cmp_deeply( |
1960 |
cmp_deeply( |
1971 |
{ error => $error, question => $question, alerts => $alerts }, |
1961 |
{ error => $error, question => $question, alerts => $alerts }, |
1972 |
{ error => {}, question => {}, alerts => {} }, |
1962 |
{ error => {}, question => {}, alerts => {} }, |
Lines 1977-1983
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
1977 |
Koha::Subscription->new({ biblionumber => $biblionumber })->store; |
1967 |
Koha::Subscription->new({ biblionumber => $biblionumber })->store; |
1978 |
|
1968 |
|
1979 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
1969 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
1980 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1970 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1981 |
cmp_deeply( |
1971 |
cmp_deeply( |
1982 |
{ error => $error, question => $question, alerts => $alerts }, |
1972 |
{ error => $error, question => $question, alerts => $alerts }, |
1983 |
{ error => {}, question => {}, alerts => {} }, |
1973 |
{ error => {}, question => {}, alerts => {} }, |
Lines 1985-1991
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
1985 |
); |
1975 |
); |
1986 |
|
1976 |
|
1987 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
1977 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
1988 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1978 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
1989 |
cmp_deeply( |
1979 |
cmp_deeply( |
1990 |
{ error => $error, question => $question, alerts => $alerts }, |
1980 |
{ error => $error, question => $question, alerts => $alerts }, |
1991 |
{ error => {}, question => {}, alerts => {} }, |
1981 |
{ error => {}, question => {}, alerts => {} }, |
Lines 2010-2022
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2010 |
biblionumber => $biblionumber, |
2000 |
biblionumber => $biblionumber, |
2011 |
library => $library->{branchcode}, |
2001 |
library => $library->{branchcode}, |
2012 |
} |
2002 |
} |
2013 |
)->unblessed; |
2003 |
); |
2014 |
my $item_2 = $builder->build_sample_item( |
2004 |
my $item_2 = $builder->build_sample_item( |
2015 |
{ |
2005 |
{ |
2016 |
biblionumber => $biblionumber, |
2006 |
biblionumber => $biblionumber, |
2017 |
library => $library->{branchcode}, |
2007 |
library => $library->{branchcode}, |
2018 |
} |
2008 |
} |
2019 |
)->unblessed; |
2009 |
); |
2020 |
|
2010 |
|
2021 |
# And the circulation rule |
2011 |
# And the circulation rule |
2022 |
Koha::CirculationRules->search->delete; |
2012 |
Koha::CirculationRules->search->delete; |
Lines 2038-2049
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2038 |
my $now = dt_from_string; |
2028 |
my $now = dt_from_string; |
2039 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2029 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2040 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2030 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2041 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
2031 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2042 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
2032 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2043 |
; # Add another overdue |
2033 |
; # Add another overdue |
2044 |
|
2034 |
|
2045 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2035 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2046 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now ); |
2036 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2047 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
2037 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
2048 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2038 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2049 |
is( scalar(@$debarments), 1 ); |
2039 |
is( scalar(@$debarments), 1 ); |
Lines 2059-2065
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2059 |
); |
2049 |
); |
2060 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
2050 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
2061 |
|
2051 |
|
2062 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, $now ); |
2052 |
AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); |
2063 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2053 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2064 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2054 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2065 |
is( scalar(@$debarments), 1 ); |
2055 |
is( scalar(@$debarments), 1 ); |
Lines 2076-2085
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2076 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2066 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2077 |
|
2067 |
|
2078 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2068 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2079 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
2069 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2080 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
2070 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2081 |
; # Add another overdue |
2071 |
; # Add another overdue |
2082 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now ); |
2072 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2083 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2073 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2084 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2074 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2085 |
is( scalar(@$debarments), 1 ); |
2075 |
is( scalar(@$debarments), 1 ); |
Lines 2092-2098
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2092 |
); |
2082 |
); |
2093 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
2083 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
2094 |
|
2084 |
|
2095 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, $now ); |
2085 |
AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); |
2096 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2086 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2097 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2087 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2098 |
is( scalar(@$debarments), 1 ); |
2088 |
is( scalar(@$debarments), 1 ); |
Lines 2122-2128
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2122 |
biblionumber => $biblionumber, |
2112 |
biblionumber => $biblionumber, |
2123 |
library => $library->{branchcode}, |
2113 |
library => $library->{branchcode}, |
2124 |
} |
2114 |
} |
2125 |
)->unblessed; |
2115 |
); |
2126 |
|
2116 |
|
2127 |
# And the issuing rule |
2117 |
# And the issuing rule |
2128 |
Koha::CirculationRules->search->delete; |
2118 |
Koha::CirculationRules->search->delete; |
Lines 2336-2352
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
2336 |
{ |
2326 |
{ |
2337 |
library => $library->branchcode, |
2327 |
library => $library->branchcode, |
2338 |
} |
2328 |
} |
2339 |
)->unblessed; |
2329 |
); |
2340 |
|
2330 |
|
2341 |
my ( $error, $question, $alerts ); |
2331 |
my ( $error, $question, $alerts ); |
2342 |
my $issue = AddIssue( $patron1->unblessed, $item->{barcode} ); |
2332 |
my $issue = AddIssue( $patron1->unblessed, $item->barcode ); |
2343 |
|
2333 |
|
2344 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2334 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2345 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); |
2335 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
2346 |
is( $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER question flag should be set if AutoReturnCheckedOutItems is disabled and item is checked out to another' ); |
2336 |
is( $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER question flag should be set if AutoReturnCheckedOutItems is disabled and item is checked out to another' ); |
2347 |
|
2337 |
|
2348 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 1); |
2338 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 1); |
2349 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); |
2339 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
2350 |
is( $alerts->{RETURNED_FROM_ANOTHER}->{patron}->borrowernumber, $patron1->borrowernumber, 'RETURNED_FROM_ANOTHER alert flag should be set if AutoReturnCheckedOutItems is enabled and item is checked out to another' ); |
2340 |
is( $alerts->{RETURNED_FROM_ANOTHER}->{patron}->borrowernumber, $patron1->borrowernumber, 'RETURNED_FROM_ANOTHER alert flag should be set if AutoReturnCheckedOutItems is enabled and item is checked out to another' ); |
2351 |
|
2341 |
|
2352 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2342 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
Lines 2371-2377
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2371 |
library => $library->{branchcode}, |
2361 |
library => $library->{branchcode}, |
2372 |
replacementprice => 7 |
2362 |
replacementprice => 7 |
2373 |
} |
2363 |
} |
2374 |
)->unblessed; |
2364 |
); |
2375 |
|
2365 |
|
2376 |
Koha::CirculationRules->search->delete; |
2366 |
Koha::CirculationRules->search->delete; |
2377 |
Koha::CirculationRules->set_rules( |
2367 |
Koha::CirculationRules->set_rules( |
Lines 2396-2421
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2396 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
2386 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
2397 |
|
2387 |
|
2398 |
# No return date specified, today will be used => 10 days overdue charged |
2388 |
# No return date specified, today will be used => 10 days overdue charged |
2399 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
2389 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2400 |
AddReturn( $item->{barcode}, $library->{branchcode} ); |
2390 |
AddReturn( $item->barcode, $library->{branchcode} ); |
2401 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
2391 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
2402 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2392 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2403 |
|
2393 |
|
2404 |
# specify return date 5 days before => no overdue charged |
2394 |
# specify return date 5 days before => no overdue charged |
2405 |
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago |
2395 |
AddIssue( $patron->unblessed, $item->barcode, $five_days_ago ); # date due was 5d ago |
2406 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, $ten_days_ago ); |
2396 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
2407 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2397 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2408 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2398 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2409 |
|
2399 |
|
2410 |
# specify return date 5 days later => 5 days overdue charged |
2400 |
# specify return date 5 days later => 5 days overdue charged |
2411 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
2401 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2412 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, $five_days_ago ); |
2402 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
2413 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
2403 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
2414 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2404 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2415 |
|
2405 |
|
2416 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
2406 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
2417 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
2407 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2418 |
AddReturn( $item->{barcode}, $library->{branchcode}, 1, $five_days_ago ); |
2408 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
2419 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2409 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2420 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2410 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2421 |
|
2411 |
|
Lines 2423-2429
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2423 |
|
2413 |
|
2424 |
plan tests => 3; |
2414 |
plan tests => 3; |
2425 |
|
2415 |
|
2426 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
2416 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2427 |
|
2417 |
|
2428 |
# Fake fines cronjob on this checkout |
2418 |
# Fake fines cronjob on this checkout |
2429 |
my ($fine) = |
2419 |
my ($fine) = |
Lines 2432-2438
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2432 |
UpdateFine( |
2422 |
UpdateFine( |
2433 |
{ |
2423 |
{ |
2434 |
issue_id => $issue->issue_id, |
2424 |
issue_id => $issue->issue_id, |
2435 |
itemnumber => $item->{itemnumber}, |
2425 |
itemnumber => $item->itemnumber, |
2436 |
borrowernumber => $patron->borrowernumber, |
2426 |
borrowernumber => $patron->borrowernumber, |
2437 |
amount => $fine, |
2427 |
amount => $fine, |
2438 |
due => output_pref($ten_days_ago) |
2428 |
due => output_pref($ten_days_ago) |
Lines 2442-2453
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2442 |
10, "Overdue fine of 10 days overdue" ); |
2432 |
10, "Overdue fine of 10 days overdue" ); |
2443 |
|
2433 |
|
2444 |
# Fake longoverdue with charge and not marking returned |
2434 |
# Fake longoverdue with charge and not marking returned |
2445 |
LostItem( $item->{itemnumber}, 'cronjob', 0 ); |
2435 |
LostItem( $item->itemnumber, 'cronjob', 0 ); |
2446 |
is( int( $patron->account->balance() ), |
2436 |
is( int( $patron->account->balance() ), |
2447 |
17, "Lost fine of 7 plus 10 days overdue" ); |
2437 |
17, "Lost fine of 7 plus 10 days overdue" ); |
2448 |
|
2438 |
|
2449 |
# Now we return it today |
2439 |
# Now we return it today |
2450 |
AddReturn( $item->{barcode}, $library->{branchcode} ); |
2440 |
AddReturn( $item->barcode, $library->{branchcode} ); |
2451 |
is( int( $patron->account->balance() ), |
2441 |
is( int( $patron->account->balance() ), |
2452 |
17, "Should have a single 10 days overdue fine and lost charge" ); |
2442 |
17, "Should have a single 10 days overdue fine and lost charge" ); |
2453 |
|
2443 |
|
Lines 2461-2467
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2461 |
|
2451 |
|
2462 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
2452 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
2463 |
|
2453 |
|
2464 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $one_day_ago ); # date due was 1d ago |
2454 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
2465 |
|
2455 |
|
2466 |
# Fake fines cronjob on this checkout |
2456 |
# Fake fines cronjob on this checkout |
2467 |
my ($fine) = |
2457 |
my ($fine) = |
Lines 2470-2476
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2470 |
UpdateFine( |
2460 |
UpdateFine( |
2471 |
{ |
2461 |
{ |
2472 |
issue_id => $issue->issue_id, |
2462 |
issue_id => $issue->issue_id, |
2473 |
itemnumber => $item->{itemnumber}, |
2463 |
itemnumber => $item->itemnumber, |
2474 |
borrowernumber => $patron->borrowernumber, |
2464 |
borrowernumber => $patron->borrowernumber, |
2475 |
amount => $fine, |
2465 |
amount => $fine, |
2476 |
due => output_pref($one_day_ago) |
2466 |
due => output_pref($one_day_ago) |
Lines 2480-2492
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2480 |
1, "Overdue fine of 1 day overdue" ); |
2470 |
1, "Overdue fine of 1 day overdue" ); |
2481 |
|
2471 |
|
2482 |
# Backdated return (dropbox mode example - charge should be removed) |
2472 |
# Backdated return (dropbox mode example - charge should be removed) |
2483 |
AddReturn( $item->{barcode}, $library->{branchcode}, 1, $one_day_ago ); |
2473 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $one_day_ago ); |
2484 |
is( int( $patron->account->balance() ), |
2474 |
is( int( $patron->account->balance() ), |
2485 |
0, "Overdue fine should be annulled" ); |
2475 |
0, "Overdue fine should be annulled" ); |
2486 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
2476 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
2487 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
2477 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
2488 |
|
2478 |
|
2489 |
$issue = AddIssue( $patron->unblessed, $item->{barcode}, $two_days_ago ); # date due was 2d ago |
2479 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $two_days_ago ); # date due was 2d ago |
2490 |
|
2480 |
|
2491 |
# Fake fines cronjob on this checkout |
2481 |
# Fake fines cronjob on this checkout |
2492 |
($fine) = |
2482 |
($fine) = |
Lines 2495-2501
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2495 |
UpdateFine( |
2485 |
UpdateFine( |
2496 |
{ |
2486 |
{ |
2497 |
issue_id => $issue->issue_id, |
2487 |
issue_id => $issue->issue_id, |
2498 |
itemnumber => $item->{itemnumber}, |
2488 |
itemnumber => $item->itemnumber, |
2499 |
borrowernumber => $patron->borrowernumber, |
2489 |
borrowernumber => $patron->borrowernumber, |
2500 |
amount => $fine, |
2490 |
amount => $fine, |
2501 |
due => output_pref($one_day_ago) |
2491 |
due => output_pref($one_day_ago) |
Lines 2526-2532
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2526 |
is( $line->amountoutstanding+0, 0, "Overdue fine amountoutstanding reduced to 0"); |
2516 |
is( $line->amountoutstanding+0, 0, "Overdue fine amountoutstanding reduced to 0"); |
2527 |
|
2517 |
|
2528 |
# Backdated return (dropbox mode example - charge should be removed) |
2518 |
# Backdated return (dropbox mode example - charge should be removed) |
2529 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, $one_day_ago ); |
2519 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $one_day_ago ); |
2530 |
is( int( $patron->account->balance() ), |
2520 |
is( int( $patron->account->balance() ), |
2531 |
-1, "Refund credit has been applied" ); |
2521 |
-1, "Refund credit has been applied" ); |
2532 |
$lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }, { order_by => { '-asc' => 'accountlines_id' }}); |
2522 |
$lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }, { order_by => { '-asc' => 'accountlines_id' }}); |
Lines 2553-2559
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2553 |
|
2543 |
|
2554 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
2544 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
2555 |
|
2545 |
|
2556 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $one_day_ago ); # date due was 1d ago |
2546 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
2557 |
|
2547 |
|
2558 |
# Fake fines cronjob on this checkout |
2548 |
# Fake fines cronjob on this checkout |
2559 |
my ($fine) = |
2549 |
my ($fine) = |
Lines 2562-2568
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2562 |
UpdateFine( |
2552 |
UpdateFine( |
2563 |
{ |
2553 |
{ |
2564 |
issue_id => $issue->issue_id, |
2554 |
issue_id => $issue->issue_id, |
2565 |
itemnumber => $item->{itemnumber}, |
2555 |
itemnumber => $item->itemnumber, |
2566 |
borrowernumber => $patron->borrowernumber, |
2556 |
borrowernumber => $patron->borrowernumber, |
2567 |
amount => $fine, |
2557 |
amount => $fine, |
2568 |
due => output_pref($one_day_ago) |
2558 |
due => output_pref($one_day_ago) |
Lines 2572-2578
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2572 |
1, "Overdue fine of 1 day overdue" ); |
2562 |
1, "Overdue fine of 1 day overdue" ); |
2573 |
|
2563 |
|
2574 |
# Backdated return (dropbox mode example - charge should no longer exist) |
2564 |
# Backdated return (dropbox mode example - charge should no longer exist) |
2575 |
AddReturn( $item->{barcode}, $library->{branchcode}, 1, $one_day_ago ); |
2565 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $one_day_ago ); |
2576 |
is( int( $patron->account->balance() ), |
2566 |
is( int( $patron->account->balance() ), |
2577 |
0, "Overdue fine should be annulled" ); |
2567 |
0, "Overdue fine should be annulled" ); |
2578 |
|
2568 |
|
Lines 2586-2598
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2586 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
2576 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
2587 |
|
2577 |
|
2588 |
my $due_date = dt_from_string; |
2578 |
my $due_date = dt_from_string; |
2589 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $due_date ); |
2579 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
2590 |
|
2580 |
|
2591 |
# Add fine |
2581 |
# Add fine |
2592 |
UpdateFine( |
2582 |
UpdateFine( |
2593 |
{ |
2583 |
{ |
2594 |
issue_id => $issue->issue_id, |
2584 |
issue_id => $issue->issue_id, |
2595 |
itemnumber => $item->{itemnumber}, |
2585 |
itemnumber => $item->itemnumber, |
2596 |
borrowernumber => $patron->borrowernumber, |
2586 |
borrowernumber => $patron->borrowernumber, |
2597 |
amount => 0.25, |
2587 |
amount => 0.25, |
2598 |
due => output_pref($due_date) |
2588 |
due => output_pref($due_date) |
Lines 2603-2609
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2603 |
|
2593 |
|
2604 |
# Backdate return to exact due date and time |
2594 |
# Backdate return to exact due date and time |
2605 |
my ( undef, $message ) = |
2595 |
my ( undef, $message ) = |
2606 |
AddReturn( $item->{barcode}, $library->{branchcode}, |
2596 |
AddReturn( $item->barcode, $library->{branchcode}, |
2607 |
undef, $due_date ); |
2597 |
undef, $due_date ); |
2608 |
|
2598 |
|
2609 |
my $accountline = |
2599 |
my $accountline = |
Lines 2611-2623
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2611 |
ok( !$accountline, 'accountline removed as expected' ); |
2601 |
ok( !$accountline, 'accountline removed as expected' ); |
2612 |
|
2602 |
|
2613 |
# Re-issue |
2603 |
# Re-issue |
2614 |
$issue = AddIssue( $patron->unblessed, $item->{barcode}, $due_date ); |
2604 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
2615 |
|
2605 |
|
2616 |
# Add fine |
2606 |
# Add fine |
2617 |
UpdateFine( |
2607 |
UpdateFine( |
2618 |
{ |
2608 |
{ |
2619 |
issue_id => $issue->issue_id, |
2609 |
issue_id => $issue->issue_id, |
2620 |
itemnumber => $item->{itemnumber}, |
2610 |
itemnumber => $item->itemnumber, |
2621 |
borrowernumber => $patron->borrowernumber, |
2611 |
borrowernumber => $patron->borrowernumber, |
2622 |
amount => .25, |
2612 |
amount => .25, |
2623 |
due => output_pref($due_date) |
2613 |
due => output_pref($due_date) |
Lines 2647-2653
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2647 |
|
2637 |
|
2648 |
# Backdate return to exact due date and time |
2638 |
# Backdate return to exact due date and time |
2649 |
( undef, $message ) = |
2639 |
( undef, $message ) = |
2650 |
AddReturn( $item->{barcode}, $library->{branchcode}, |
2640 |
AddReturn( $item->barcode, $library->{branchcode}, |
2651 |
undef, $due_date ); |
2641 |
undef, $due_date ); |
2652 |
|
2642 |
|
2653 |
$lines = Koha::Account::Lines->search( |
2643 |
$lines = Koha::Account::Lines->search( |
Lines 3199-3244
subtest 'Set waiting flag' => sub {
Link Here
|
3199 |
{ |
3189 |
{ |
3200 |
library => $library_1->{branchcode}, |
3190 |
library => $library_1->{branchcode}, |
3201 |
} |
3191 |
} |
3202 |
)->unblessed; |
3192 |
); |
3203 |
|
3193 |
|
3204 |
set_userenv( $library_2 ); |
3194 |
set_userenv( $library_2 ); |
3205 |
my $reserve_id = AddReserve( |
3195 |
my $reserve_id = AddReserve( |
3206 |
{ |
3196 |
{ |
3207 |
branchcode => $library_2->{branchcode}, |
3197 |
branchcode => $library_2->{branchcode}, |
3208 |
borrowernumber => $patron_2->{borrowernumber}, |
3198 |
borrowernumber => $patron_2->{borrowernumber}, |
3209 |
biblionumber => $item->{biblionumber}, |
3199 |
biblionumber => $item->biblionumber, |
3210 |
priority => 1, |
3200 |
priority => 1, |
3211 |
itemnumber => $item->{itemnumber}, |
3201 |
itemnumber => $item->itemnumber, |
3212 |
} |
3202 |
} |
3213 |
); |
3203 |
); |
3214 |
|
3204 |
|
3215 |
set_userenv( $library_1 ); |
3205 |
set_userenv( $library_1 ); |
3216 |
my $do_transfer = 1; |
3206 |
my $do_transfer = 1; |
3217 |
my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} ); |
3207 |
my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); |
3218 |
ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); |
3208 |
ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); |
3219 |
my $hold = Koha::Holds->find( $reserve_id ); |
3209 |
my $hold = Koha::Holds->find( $reserve_id ); |
3220 |
is( $hold->found, 'T', 'Hold is in transit' ); |
3210 |
is( $hold->found, 'T', 'Hold is in transit' ); |
3221 |
|
3211 |
|
3222 |
my ( $status ) = CheckReserves($item->{itemnumber}); |
3212 |
my ( $status ) = CheckReserves($item->itemnumber); |
3223 |
is( $status, 'Reserved', 'Hold is not waiting yet'); |
3213 |
is( $status, 'Reserved', 'Hold is not waiting yet'); |
3224 |
|
3214 |
|
3225 |
set_userenv( $library_2 ); |
3215 |
set_userenv( $library_2 ); |
3226 |
$do_transfer = 0; |
3216 |
$do_transfer = 0; |
3227 |
AddReturn( $item->{barcode}, $library_2->{branchcode} ); |
3217 |
AddReturn( $item->barcode, $library_2->{branchcode} ); |
3228 |
ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); |
3218 |
ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); |
3229 |
$hold = Koha::Holds->find( $reserve_id ); |
3219 |
$hold = Koha::Holds->find( $reserve_id ); |
3230 |
is( $hold->found, 'W', 'Hold is waiting' ); |
3220 |
is( $hold->found, 'W', 'Hold is waiting' ); |
3231 |
( $status ) = CheckReserves($item->{itemnumber}); |
3221 |
( $status ) = CheckReserves($item->itemnumber); |
3232 |
is( $status, 'Waiting', 'Now the hold is waiting'); |
3222 |
is( $status, 'Waiting', 'Now the hold is waiting'); |
3233 |
|
3223 |
|
3234 |
#Bug 21944 - Waiting transfer checked in at branch other than pickup location |
3224 |
#Bug 21944 - Waiting transfer checked in at branch other than pickup location |
3235 |
set_userenv( $library_1 ); |
3225 |
set_userenv( $library_1 ); |
3236 |
(undef, my $messages, undef, undef ) = AddReturn ( $item->{barcode}, $library_1->{branchcode} ); |
3226 |
(undef, my $messages, undef, undef ) = AddReturn ( $item->barcode, $library_1->{branchcode} ); |
3237 |
$hold = Koha::Holds->find( $reserve_id ); |
3227 |
$hold = Koha::Holds->find( $reserve_id ); |
3238 |
is( $hold->found, undef, 'Hold is no longer marked waiting' ); |
3228 |
is( $hold->found, undef, 'Hold is no longer marked waiting' ); |
3239 |
is( $hold->priority, 1, "Hold is now priority one again"); |
3229 |
is( $hold->priority, 1, "Hold is now priority one again"); |
3240 |
is( $hold->waitingdate, undef, "Hold no longer has a waiting date"); |
3230 |
is( $hold->waitingdate, undef, "Hold no longer has a waiting date"); |
3241 |
is( $hold->itemnumber, $item->{itemnumber}, "Hold has retained its' itemnumber"); |
3231 |
is( $hold->itemnumber, $item->itemnumber, "Hold has retained its' itemnumber"); |
3242 |
is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned"); |
3232 |
is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned"); |
3243 |
is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message"); |
3233 |
is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message"); |
3244 |
is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message"); |
3234 |
is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message"); |
Lines 3331-3342
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
3331 |
{ |
3321 |
{ |
3332 |
library => $library->{branchcode}, |
3322 |
library => $library->{branchcode}, |
3333 |
} |
3323 |
} |
3334 |
)->unblessed; |
3324 |
); |
3335 |
|
3325 |
|
3336 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago |
3326 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago |
3337 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
3327 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
3338 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), $five_days_go, "First issue works"); |
3328 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), $five_days_go, "First issue works"); |
3339 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->{barcode},$ten_days_go, undef, undef, undef); |
3329 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef); |
3340 |
is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal"); |
3330 |
is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal"); |
3341 |
is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal"); |
3331 |
is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal"); |
3342 |
}; |
3332 |
}; |
Lines 3957-3976
subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub {
Link Here
|
3957 |
} |
3947 |
} |
3958 |
); |
3948 |
); |
3959 |
|
3949 |
|
3960 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
3950 |
my $item = $builder->build_sample_item( |
3961 |
my $item = $builder->build_object( |
|
|
3962 |
{ |
3951 |
{ |
3963 |
class => 'Koha::Items', |
3952 |
library => $library->id, |
3964 |
value => { |
3953 |
notforloan => 0, |
3965 |
homebranch => $library->id, |
3954 |
itemlost => 0, |
3966 |
holdingbranch => $library->id, |
3955 |
withdrawn => 0, |
3967 |
notforloan => 0, |
3956 |
itype => $itemtype->id, |
3968 |
itemlost => 0, |
|
|
3969 |
withdrawn => 0, |
3970 |
itype => $itemtype->id, |
3971 |
biblionumber => $biblioitem->{biblionumber}, |
3972 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
3973 |
} |
3974 |
} |
3957 |
} |
3975 |
)->store; |
3958 |
)->store; |
3976 |
|
3959 |
|