Bug 18936: (follow-up) Fix tests, replace old get_onshelfholds_policy method
Signed-off-by: Minna Kivinen <minna.kivinen@hamk.fi> Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
5712ec566f
commit
1c43a26525
|
|
@ -342,7 +342,28 @@ sub delete {
|
|||
while ( my $rule = $self->next ){
|
||||
$rule->delete;
|
||||
}
|
||||
}
|
||||
|
||||
=head3 get_onshelfholds_policy
|
||||
|
||||
my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy({ item => $item, patron => $patron });
|
||||
|
||||
=cut
|
||||
|
||||
sub get_onshelfholds_policy {
|
||||
my ( $class, $params ) = @_;
|
||||
my $item = $params->{item};
|
||||
my $itemtype = $item->effective_itemtype;
|
||||
my $patron = $params->{patron};
|
||||
my $rule = Koha::CirculationRules->get_effective_rule(
|
||||
{
|
||||
categorycode => ( $patron ? $patron->categorycode : undef ),
|
||||
itemtype => $itemtype,
|
||||
branchcode => $item->holdingbranch,
|
||||
rule_name => 'onshelfholds',
|
||||
}
|
||||
);
|
||||
return $rule ? $rule->rule_value : undef;
|
||||
}
|
||||
|
||||
=head3 type
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ use Koha::DateUtils;
|
|||
use Koha::Patrons;
|
||||
use Koha::Patron::Categories;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::IssuingRules;
|
||||
|
||||
#Setting variables
|
||||
my $input = new CGI;
|
||||
|
|
@ -251,15 +250,16 @@ if ( $step == 5 ) {
|
|||
branchcode => $branchcode,
|
||||
categorycode => $categorycode,
|
||||
itemtype => $itemtype,
|
||||
renewalsallowed => $renewalsallowed,
|
||||
renewalperiod => $renewalperiod,
|
||||
issuelength => $issuelength,
|
||||
lengthunit => $lengthunit,
|
||||
onshelfholds => $onshelfholds,
|
||||
rules => {
|
||||
renewalsallowed => $renewalsallowed,
|
||||
renewalperiod => $renewalperiod,
|
||||
issuelength => $issuelength,
|
||||
lengthunit => $lengthunit,
|
||||
onshelfholds => $onshelfholds,
|
||||
}
|
||||
};
|
||||
|
||||
my $issuingrule = Koha::IssuingRule->new($params);
|
||||
eval { $issuingrule->store; };
|
||||
eval { Koha::CirculationRules->set_rules( $params ) };
|
||||
|
||||
if ($@) {
|
||||
push @messages, { code => 'error_on_insert_circ_rule' };
|
||||
|
|
@ -287,7 +287,7 @@ if ( $step == 5 ) {
|
|||
}
|
||||
}
|
||||
|
||||
$step++ if Koha::IssuingRules->count;
|
||||
$step++ if Koha::CirculationRules->count;
|
||||
}
|
||||
|
||||
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ use C4::Reserves;
|
|||
use C4::Acquisition;
|
||||
use C4::Serials; # uses getsubscriptionfrom biblionumber
|
||||
use C4::Koha;
|
||||
use Koha::IssuingRules;
|
||||
use Koha::CirculationRules;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Patrons;
|
||||
use Koha::RecordProcessor;
|
||||
|
|
@ -178,7 +178,7 @@ while ( my $item = $items->next ) {
|
|||
&& !Koha::ItemTypes->find($item->effective_itemtype)->notforloan
|
||||
&& $item->itemnumber;
|
||||
|
||||
$allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
|
||||
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
|
||||
unless $allow_onshelf_holds;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ use C4::Acquisition;
|
|||
use C4::Koha;
|
||||
use List::MoreUtils qw( any uniq );
|
||||
use Koha::Biblios;
|
||||
use Koha::IssuingRules;
|
||||
use Koha::CirculationRules;
|
||||
use Koha::Items;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Patrons;
|
||||
|
|
@ -138,7 +138,7 @@ $template->param(
|
|||
my $allow_onshelf_holds;
|
||||
for my $itm (@all_items) {
|
||||
my $item = Koha::Items->find( $itm->{itemnumber} );
|
||||
$allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
|
||||
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
|
||||
last if $allow_onshelf_holds;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ use C4::CourseReserves qw(GetItemCourseReservesInfo);
|
|||
use Koha::Biblios;
|
||||
use Koha::RecordProcessor;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::IssuingRules;
|
||||
use Koha::CirculationRules;
|
||||
use Koha::Items;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Acquisition::Orders;
|
||||
|
|
@ -689,7 +689,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
|
|||
&& !$itemtypes->{$itm->{'itype'}}->{notforloan}
|
||||
&& $itm->{'itemnumber'};
|
||||
|
||||
$allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
|
||||
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
|
||||
unless $allow_onshelf_holds;
|
||||
|
||||
# get collection code description, too
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use C4::Debug;
|
|||
use Koha::AuthorisedValues;
|
||||
use Koha::Biblios;
|
||||
use Koha::DateUtils;
|
||||
use Koha::IssuingRules;
|
||||
use Koha::CirculationRules;
|
||||
use Koha::Items;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Checkouts;
|
||||
|
|
@ -548,7 +548,7 @@ foreach my $biblioNum (@biblionumbers) {
|
|||
CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
|
||||
|
||||
if ($policy_holdallowed) {
|
||||
my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
|
||||
my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
|
||||
if ( $opac_hold_policy ne 'N' ) { # If Y or F
|
||||
$itemLoopIter->{available} = 1;
|
||||
$numCopiesOPACAvailable++;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use C4::XSLT;
|
|||
|
||||
use Koha::Biblios;
|
||||
use Koha::Biblioitems;
|
||||
use Koha::IssuingRules;
|
||||
use Koha::CirculationRules;
|
||||
use Koha::Items;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Patrons;
|
||||
|
|
@ -337,7 +337,7 @@ if ( $op eq 'view' ) {
|
|||
|
||||
my $items = $biblio->items;
|
||||
while ( my $item = $items->next ) {
|
||||
$this_item->{allow_onshelf_holds} = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
|
||||
$this_item->{allow_onshelf_holds} = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
|
||||
last if $this_item->{allow_onshelf_holds};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ use Koha::Biblios;
|
|||
use Koha::DateUtils;
|
||||
use Koha::Checkouts;
|
||||
use Koha::Holds;
|
||||
use Koha::IssuingRules;
|
||||
use Koha::CirculationRules;
|
||||
use Koha::Items;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Libraries;
|
||||
|
|
@ -551,7 +551,7 @@ foreach my $biblionumber (@biblionumbers) {
|
|||
my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
|
||||
$item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
|
||||
|
||||
$item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
|
||||
$item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
|
||||
|
||||
if (
|
||||
!$item->{cantreserve}
|
||||
|
|
|
|||
|
|
@ -216,17 +216,17 @@ my $hold = $builder->build({
|
|||
}
|
||||
});
|
||||
|
||||
Koha::IssuingRule->new(
|
||||
Koha::CirculationRules->set_rules(
|
||||
{
|
||||
categorycode => '*',
|
||||
categorycode => undef,
|
||||
itemtype => $itemtype2,
|
||||
branchcode => '*',
|
||||
issuelength => 7,
|
||||
lengthunit => 8,
|
||||
reservesallowed => 99,
|
||||
onshelfholds => 0,
|
||||
branchcode => undef,
|
||||
rules => {
|
||||
maxissueqty => 99,
|
||||
onshelfholds => 2,
|
||||
}
|
||||
}
|
||||
)->store();
|
||||
);
|
||||
|
||||
$is = IsAvailableForItemLevelRequest( $item3, $patron1);
|
||||
is( $is, 1, "Item can be held, items in transit are not available" );
|
||||
|
|
|
|||
|
|
@ -563,19 +563,6 @@ Koha::CirculationRules->set_rules(
|
|||
}
|
||||
);
|
||||
|
||||
ok( C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() allowed" );
|
||||
Koha::CirculationRules->set_rules(
|
||||
{
|
||||
categorycode => $categorycode,
|
||||
itemtype => $itype,
|
||||
branchcode => $holdingbranch,
|
||||
rules => {
|
||||
onshelfholds => 0,
|
||||
}
|
||||
}
|
||||
);
|
||||
ok( !C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() disallowed" );
|
||||
|
||||
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
|
||||
# hold from A pos 1, today, no fut holds: MoveReserve should fill it
|
||||
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
|
||||
|
|
|
|||
Loading…
Reference in New Issue