use Modern::Perl;
-use C4::Circulation;
-use C4::Items;
-use C4::Biblio;
+use C4::Circulation qw( AddIssue AddReturn GetBranchBorrowerCircRule GetBranchItemRule );
+use C4::Items qw( ModItemTransfer );
+use C4::Biblio qw( AddBiblio );
use C4::Context;
use Koha::CirculationRules;
use Koha::Patrons;
-use Test::More tests => 15;
+use Test::More tests => 16;
use t::lib::Mocks;
use t::lib::TestBuilder;
BEGIN {
- use_ok('C4::Circulation');
+ use_ok('C4::Circulation', qw( AddIssue AddReturn GetBranchBorrowerCircRule GetBranchItemRule ));
}
can_ok( 'C4::Circulation', qw(
branchcode => $samplebranch2->{branchcode},
itemtype => undef,
rules => {
- holdallowed => 1,
+ holdallowed => 'from_home_library',
returnbranch => 'holdingbranch',
}
}
branchcode => undef,
itemtype => undef,
rules => {
- holdallowed => 3,
+ holdallowed => 'from_local_hold_group',
returnbranch => 'homebranch',
}
}
branchcode => $samplebranch1->{branchcode},
itemtype => $sampleitemtype1->{itemtype},
rules => {
- holdallowed => 5,
+ holdallowed => 'invalid_value',
returnbranch => 'homebranch',
}
}
branchcode => $samplebranch2->{branchcode},
itemtype => $sampleitemtype1->{itemtype},
rules => {
- holdallowed => 5,
+ holdallowed => 'invalid_value',
returnbranch => 'holdingbranch',
}
}
branchcode => $samplebranch2->{branchcode},
itemtype => $sampleitemtype2->{itemtype},
rules => {
- holdallowed => 5,
+ holdallowed => 'invalid_value',
returnbranch => 'noreturn',
}
}
$samplebranch1->{branchcode},
$sampleitemtype1->{itemtype},
),
- { returnbranch => 'homebranch', holdallowed => 5, @lazy_any },
+ { returnbranch => 'homebranch', holdallowed => 'invalid_value', @lazy_any },
"GetBranchitem returns holdallowed and return branch"
);
is_deeply(
GetBranchItemRule(),
- { returnbranch => 'homebranch', holdallowed => 3, @lazy_any },
+ { returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any },
"Without parameters GetBranchItemRule returns the values in default_circ_rules"
);
is_deeply(
GetBranchItemRule( $samplebranch2->{branchcode} ),
- { returnbranch => 'holdingbranch', holdallowed => 1, @lazy_any },
+ { returnbranch => 'holdingbranch', holdallowed => 'from_home_library', @lazy_any },
"With only a branchcode GetBranchItemRule returns values in default_branch_circ_rules"
);
is_deeply(
GetBranchItemRule( -1, -1 ),
- { returnbranch => 'homebranch', holdallowed => 3, @lazy_any },
+ { returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any },
"With only one parametern GetBranchItemRule returns default values"
);
ModItemTransfer($item_id2, $samplebranch2->{branchcode}, $samplebranch1->{branchcode}, "ReturnToHolding");
# Fulfill it
($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_2',$samplebranch1->{branchcode});
-is( $messages->{NeedsTransfer}, undef, "AddReturn does not generate a new transfer for return policy when resolving an existing transfer" );
+is( $messages->{NeedsTransfer}, undef, "AddReturn does not generate a new transfer for return policy when resolving an existing non-Reserve transfer" );
+
+# Generate a hold caused transfer which doesn't have a hold i.e. is the hold is cancelled
+ModItemTransfer($item_id2, $samplebranch2->{branchcode}, $samplebranch1->{branchcode}, "Reserve");
+# Fulfill it
+($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_2',$samplebranch1->{branchcode});
+is( $messages->{NeedsTransfer}, $samplebranch2->{branchcode}, "AddReturn generates a new transfer for hold transfer if the hold was cancelled" );
# item3 should not trigger transfer - floating collection
$query =