}
# 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
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;
+
+ 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 !grep( /^$patron_category$/, @patron_categories );
+ return 1;
}
1;
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;
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;
homebranch => $branchcode,
holdingbranch => $branchcode,
});
+ my $itemtype = $item_object->effective_itemtype;
my $mockILS = $mocks->{ils};
my $server = { ils => $mockILS, account => {} };
$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 {
homebranch => $branchcode,
holdingbranch => $branchcode,
});
+ my $itemtype = $item_object->effective_itemtype;
my $mockILS = $mocks->{ils};
my $server = { ils => $mockILS, account => {} };
$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