View | Details | Raw Unified | Return to bug 31296
Collapse All | Expand All

(-)a/C4/SIP/ILS/Item.pm (+2 lines)
Lines 93-98 sub new { Link Here
93
    $self->{object} = $item;
93
    $self->{object} = $item;
94
94
95
    my $it = $item->effective_itemtype;
95
    my $it = $item->effective_itemtype;
96
    $self->{itemtype} = $it;
96
    my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
97
    my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
97
    $self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
98
    $self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
98
99
Lines 142-147 my %fields = ( Link Here
142
    location            => 0,
143
    location            => 0,
143
    author              => 0,
144
    author              => 0,
144
    title               => 0,
145
    title               => 0,
146
    itemtype            => 0,
145
);
147
);
146
148
147
sub next_hold {
149
sub next_hold {
(-)a/C4/SIP/Sip/MsgType.pm (-5 / +23 lines)
Lines 556-562 sub handle_checkout { Link Here
556
        }
556
        }
557
557
558
        # We never return the obsolete 'U' value for 'desensitize'
558
        # We never return the obsolete 'U' value for 'desensitize'
559
        $resp .= sipbool( desensitize( { status => $status, patron => $patron, server => $server } ) );
559
        $resp .= sipbool(
560
            desensitize(
561
                {
562
                    item   => $item,
563
                    patron => $patron,
564
                    server => $server,
565
                    status => $status,
566
                }
567
            )
568
        );
560
        $resp .= timestamp;
569
        $resp .= timestamp;
561
570
562
        # Now for the variable fields
571
        # Now for the variable fields
Lines 1745-1761 sub desensitize { Link Here
1745
    return unless $desensitize;
1754
    return unless $desensitize;
1746
1755
1747
    my $patron = $params->{patron};
1756
    my $patron = $params->{patron};
1757
    my $item   = $params->{item};
1748
    my $server = $params->{server};
1758
    my $server = $params->{server};
1749
1759
1750
    my $patron_categories = $server->{account}->{inhouse_patron_categories};
1760
    my $patron_categories = $server->{account}->{inhouse_patron_categories} // q{};
1761
    my $item_types = $server->{account}->{inhouse_item_types} // q{};
1751
1762
1752
    # If no patron categories are set for never desensitize, no need to do anything
1763
    # If no patron categorie or item typess are set for never desensitize, no need to do anything
1753
    return $desensitize unless $patron_categories;
1764
    return $desensitize unless $patron_categories || $item_types;
1754
1765
1755
    my $patron_category = $patron->ptype();
1766
    my $patron_category = $patron->ptype();
1756
    my @patron_categories = split( /,/, $patron_categories );
1767
    my @patron_categories = split( /,/, $patron_categories );
1768
    my $found_patron_category = grep( /^$patron_category$/, @patron_categories );
1769
    return 0 if $found_patron_category;
1770
1771
    my $item_type = $item->itemtype;
1772
    my @item_types = split( /,/, $item_types );
1773
    my $found_item_type = grep( /^$item_type$/, @item_types );
1774
    return 0 if $found_item_type;
1757
1775
1758
    return !grep( /^$patron_category$/, @patron_categories );
1776
    return 1;
1759
}
1777
}
1760
1778
1761
1;
1779
1;
(-)a/etc/SIPconfig.xml (+1 lines)
Lines 74-79 Link Here
74
             prevcheckout_block_checkout="0"
74
             prevcheckout_block_checkout="0"
75
             overdues_block_checkout="1"
75
             overdues_block_checkout="1"
76
             format_due_date="0"
76
             format_due_date="0"
77
             inhouse_item_types=""
77
             inhouse_patron_categories="">
78
             inhouse_patron_categories="">
78
          <!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping -->
79
          <!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping -->
79
          <sort_bin_mapping mapping="CPL:itype:eq:BK:1"/>
80
          <sort_bin_mapping mapping="CPL:itype:eq:BK:1"/>
(-)a/t/db_dependent/SIP/Message.t (-3 / +45 lines)
Lines 80-86 subtest 'Checkout V2' => sub { Link Here
80
subtest 'Test checkout desensitize' => sub {
80
subtest 'Test checkout desensitize' => sub {
81
    my $schema = Koha::Database->new->schema;
81
    my $schema = Koha::Database->new->schema;
82
    $schema->storage->txn_begin;
82
    $schema->storage->txn_begin;
83
    plan tests => 3;
83
    plan tests => 6;
84
    $C4::SIP::Sip::protocol_version = 2;
84
    $C4::SIP::Sip::protocol_version = 2;
85
    test_checkout_desensitize();
85
    test_checkout_desensitize();
86
    $schema->storage->txn_rollback;
86
    $schema->storage->txn_rollback;
Lines 89-95 subtest 'Test checkout desensitize' => sub { Link Here
89
subtest 'Test renew desensitize' => sub {
89
subtest 'Test renew desensitize' => sub {
90
    my $schema = Koha::Database->new->schema;
90
    my $schema = Koha::Database->new->schema;
91
    $schema->storage->txn_begin;
91
    $schema->storage->txn_begin;
92
    plan tests => 3;
92
    plan tests => 6;
93
    $C4::SIP::Sip::protocol_version = 2;
93
    $C4::SIP::Sip::protocol_version = 2;
94
    test_renew_desensitize();
94
    test_renew_desensitize();
95
    $schema->storage->txn_rollback;
95
    $schema->storage->txn_rollback;
Lines 899-904 sub test_checkout_desensitize { Link Here
899
        homebranch => $branchcode,
899
        homebranch => $branchcode,
900
        holdingbranch => $branchcode,
900
        holdingbranch => $branchcode,
901
    });
901
    });
902
    my $itemtype = $item_object->effective_itemtype;
902
903
903
    my $mockILS = $mocks->{ils};
904
    my $mockILS = $mocks->{ils};
904
    my $server = { ils => $mockILS, account => {} };
905
    my $server = { ils => $mockILS, account => {} };
Lines 937-942 sub test_checkout_desensitize { Link Here
937
    $msg->handle_checkout( $server );
938
    $msg->handle_checkout( $server );
938
    $respcode = substr( $response, 5, 1 );
939
    $respcode = substr( $response, 5, 1 );
939
    is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_patron_categories" );
940
    is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_patron_categories" );
941
942
    $server->{account}->{inhouse_patron_categories} = "";
943
944
    undef $response;
945
    $server->{account}->{inhouse_item_types} = "A,$itemtype,Z";
946
    $msg->handle_checkout( $server );
947
    $respcode = substr( $response, 5, 1 );
948
    is( $respcode, 'N', "Desensitize flag was not set for itemtype in inhouse_item_types" );
949
950
    undef $response;
951
    $server->{account}->{inhouse_item_types} = "A,B,C";
952
    $msg->handle_checkout( $server );
953
    $respcode = substr( $response, 5, 1 );
954
    is( $respcode, 'Y', "Desensitize flag was set for item type not in inhouse_item_types" );
955
956
    undef $response;
957
    $server->{account}->{inhouse_item_types} = "";
958
    $msg->handle_checkout( $server );
959
    $respcode = substr( $response, 5, 1 );
960
    is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" );
940
}
961
}
941
962
942
sub test_renew_desensitize {
963
sub test_renew_desensitize {
Lines 964-969 sub test_renew_desensitize { Link Here
964
        homebranch => $branchcode,
985
        homebranch => $branchcode,
965
        holdingbranch => $branchcode,
986
        holdingbranch => $branchcode,
966
    });
987
    });
988
    my $itemtype = $item_object->effective_itemtype;
967
989
968
    my $mockILS = $mocks->{ils};
990
    my $mockILS = $mocks->{ils};
969
    my $server = { ils => $mockILS, account => {} };
991
    my $server = { ils => $mockILS, account => {} };
Lines 1003-1008 sub test_renew_desensitize { Link Here
1003
    $msg->handle_checkout( $server );
1025
    $msg->handle_checkout( $server );
1004
    $respcode = substr( $response, 5, 1 );
1026
    $respcode = substr( $response, 5, 1 );
1005
    is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_patron_categories" );
1027
    is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_patron_categories" );
1028
1029
    $server->{account}->{inhouse_patron_categories} = "";
1030
1031
    undef $response;
1032
    $server->{account}->{inhouse_item_types} = "A,B,C";
1033
    $msg->handle_checkout( $server );
1034
    $respcode = substr( $response, 5, 1 );
1035
    is( $respcode, 'Y', "Desensitize flag was set for item type not in inhouse_item_types" );
1036
1037
    undef $response;
1038
    $server->{account}->{inhouse_item_types} = "";
1039
    $msg->handle_checkout( $server );
1040
    $respcode = substr( $response, 5, 1 );
1041
    is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" );
1042
1043
    undef $response;
1044
    $server->{account}->{inhouse_item_types} = "A,$itemtype,Z";
1045
    $msg->handle_checkout( $server );
1046
    $respcode = substr( $response, 5, 1 );
1047
    is( $respcode, 'N', "Desensitize flag was not set for itemtype in inhouse_item_types" );
1048
1006
}
1049
}
1007
1050
1008
# Helper routines
1051
# Helper routines
1009
- 

Return to bug 31296