Bug 31296: Add ability to disable demagnetizing items via SIP2 based on itemtypes
Some libraries have certain item types that can only do in house checkouts via SIP self check machines. In these cases, the items should not be demagnetized since the items cannot leave the library.
Test Plan:
1) Apply this patch
2) prove t/db_dependent/SIP/Message.t
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 00f489de6d)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
432fa9415d
commit
853990a52d
|
|
@ -93,6 +93,7 @@ sub new {
|
|||
$self->{object} = $item;
|
||||
|
||||
my $it = $item->effective_itemtype;
|
||||
$self->{itemtype} = $it;
|
||||
my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
|
||||
$self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
|
||||
|
||||
|
|
@ -142,6 +143,7 @@ my %fields = (
|
|||
location => 0,
|
||||
author => 0,
|
||||
title => 0,
|
||||
itemtype => 0,
|
||||
);
|
||||
|
||||
sub next_hold {
|
||||
|
|
|
|||
|
|
@ -556,7 +556,16 @@ sub handle_checkout {
|
|||
}
|
||||
|
||||
# We never return the obsolete 'U' value for 'desensitize'
|
||||
$resp .= sipbool( desensitize( { status => $status, patron => $patron, server => $server } ) );
|
||||
$resp .= sipbool(
|
||||
desensitize(
|
||||
{
|
||||
item => $item,
|
||||
patron => $patron,
|
||||
server => $server,
|
||||
status => $status,
|
||||
}
|
||||
)
|
||||
);
|
||||
$resp .= timestamp;
|
||||
|
||||
# Now for the variable fields
|
||||
|
|
@ -1745,17 +1754,26 @@ sub desensitize {
|
|||
return unless $desensitize;
|
||||
|
||||
my $patron = $params->{patron};
|
||||
my $item = $params->{item};
|
||||
my $server = $params->{server};
|
||||
|
||||
my $patron_categories = $server->{account}->{inhouse_patron_categories};
|
||||
my $patron_categories = $server->{account}->{inhouse_patron_categories} // q{};
|
||||
my $item_types = $server->{account}->{inhouse_item_types} // q{};
|
||||
|
||||
# If no patron categories are set for never desensitize, no need to do anything
|
||||
return $desensitize unless $patron_categories;
|
||||
# If no patron categorie or item typess are set for never desensitize, no need to do anything
|
||||
return $desensitize unless $patron_categories || $item_types;
|
||||
|
||||
my $patron_category = $patron->ptype();
|
||||
my @patron_categories = split( /,/, $patron_categories );
|
||||
my $found_patron_category = grep( /^$patron_category$/, @patron_categories );
|
||||
return 0 if $found_patron_category;
|
||||
|
||||
return !grep( /^$patron_category$/, @patron_categories );
|
||||
my $item_type = $item->itemtype;
|
||||
my @item_types = split( /,/, $item_types );
|
||||
my $found_item_type = grep( /^$item_type$/, @item_types );
|
||||
return 0 if $found_item_type;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
prevcheckout_block_checkout="0"
|
||||
overdues_block_checkout="1"
|
||||
format_due_date="0"
|
||||
inhouse_item_types=""
|
||||
inhouse_patron_categories="">
|
||||
<!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping -->
|
||||
<sort_bin_mapping mapping="CPL:itype:eq:BK:1"/>
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ subtest 'Checkout V2' => sub {
|
|||
subtest 'Test checkout desensitize' => sub {
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
plan tests => 3;
|
||||
plan tests => 6;
|
||||
$C4::SIP::Sip::protocol_version = 2;
|
||||
test_checkout_desensitize();
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
@ -89,7 +89,7 @@ subtest 'Test checkout desensitize' => sub {
|
|||
subtest 'Test renew desensitize' => sub {
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
plan tests => 3;
|
||||
plan tests => 6;
|
||||
$C4::SIP::Sip::protocol_version = 2;
|
||||
test_renew_desensitize();
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
@ -899,6 +899,7 @@ sub test_checkout_desensitize {
|
|||
homebranch => $branchcode,
|
||||
holdingbranch => $branchcode,
|
||||
});
|
||||
my $itemtype = $item_object->effective_itemtype;
|
||||
|
||||
my $mockILS = $mocks->{ils};
|
||||
my $server = { ils => $mockILS, account => {} };
|
||||
|
|
@ -937,6 +938,26 @@ sub test_checkout_desensitize {
|
|||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_patron_categories" );
|
||||
|
||||
$server->{account}->{inhouse_patron_categories} = "";
|
||||
|
||||
undef $response;
|
||||
$server->{account}->{inhouse_item_types} = "A,$itemtype,Z";
|
||||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'N', "Desensitize flag was not set for itemtype in inhouse_item_types" );
|
||||
|
||||
undef $response;
|
||||
$server->{account}->{inhouse_item_types} = "A,B,C";
|
||||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'Y', "Desensitize flag was set for item type not in inhouse_item_types" );
|
||||
|
||||
undef $response;
|
||||
$server->{account}->{inhouse_item_types} = "";
|
||||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" );
|
||||
}
|
||||
|
||||
sub test_renew_desensitize {
|
||||
|
|
@ -964,6 +985,7 @@ sub test_renew_desensitize {
|
|||
homebranch => $branchcode,
|
||||
holdingbranch => $branchcode,
|
||||
});
|
||||
my $itemtype = $item_object->effective_itemtype;
|
||||
|
||||
my $mockILS = $mocks->{ils};
|
||||
my $server = { ils => $mockILS, account => {} };
|
||||
|
|
@ -1003,6 +1025,27 @@ sub test_renew_desensitize {
|
|||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_patron_categories" );
|
||||
|
||||
$server->{account}->{inhouse_patron_categories} = "";
|
||||
|
||||
undef $response;
|
||||
$server->{account}->{inhouse_item_types} = "A,B,C";
|
||||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'Y', "Desensitize flag was set for item type not in inhouse_item_types" );
|
||||
|
||||
undef $response;
|
||||
$server->{account}->{inhouse_item_types} = "";
|
||||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" );
|
||||
|
||||
undef $response;
|
||||
$server->{account}->{inhouse_item_types} = "A,$itemtype,Z";
|
||||
$msg->handle_checkout( $server );
|
||||
$respcode = substr( $response, 5, 1 );
|
||||
is( $respcode, 'N', "Desensitize flag was not set for itemtype in inhouse_item_types" );
|
||||
|
||||
}
|
||||
|
||||
# Helper routines
|
||||
|
|
|
|||
Loading…
Reference in New Issue