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

(-)a/C4/SIP/ILS/Patron.pm (+1 lines)
Lines 241-246 sub new { Link Here
241
my %fields = (
241
my %fields = (
242
    id                    => 0,
242
    id                    => 0,
243
    borrowernumber        => 0,
243
    borrowernumber        => 0,
244
    branchcode            => 0,
244
    name                  => 0,
245
    name                  => 0,
245
    address               => 0,
246
    address               => 0,
246
    email_addr            => 0,
247
    email_addr            => 0,
(-)a/C4/SIP/Sip/MsgType.pm (-2 / +7 lines)
Lines 516-521 sub build_patron_status { Link Here
516
        $resp .= $patron->build_custom_field_string($server);
516
        $resp .= $patron->build_custom_field_string($server);
517
        $resp .= $patron->build_patron_attributes_string($server);
517
        $resp .= $patron->build_patron_attributes_string($server);
518
518
519
        my $branchcode =
520
            $server->{account}->{patron_branchcode_in_ao} ? $patron->branchcode : $fields->{ (FID_INST_ID) };
521
        $resp .= add_field( FID_INST_ID, $branchcode, $server );
519
    } else {
522
    } else {
520
523
521
        # Invalid patron (cardnumber)
524
        # Invalid patron (cardnumber)
Lines 533-541 sub build_patron_status { Link Here
533
            and $resp .= add_field( FID_VALID_PATRON, 'N', $server );
536
            and $resp .= add_field( FID_VALID_PATRON, 'N', $server );
534
537
535
        $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server );
538
        $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server );
539
540
        $resp .= add_field( FID_INST_ID, $fields->{ (FID_INST_ID) }, $server );
536
    }
541
    }
537
542
538
    $resp .= add_field( FID_INST_ID, $fields->{ (FID_INST_ID) }, $server );
539
    return $resp;
543
    return $resp;
540
}
544
}
541
545
Lines 1090-1096 sub handle_patron_info { Link Here
1090
        $resp .= add_count( 'patron_info/recall_items',  scalar @{ $patron->recall_items } );
1094
        $resp .= add_count( 'patron_info/recall_items',  scalar @{ $patron->recall_items } );
1091
        $resp .= add_count( 'patron_info/unavail_holds', scalar @{ $patron->unavail_holds } );
1095
        $resp .= add_count( 'patron_info/unavail_holds', scalar @{ $patron->unavail_holds } );
1092
1096
1093
        $resp .= add_field( FID_INST_ID, ( $ils->institution_id || 'SIP2' ), $server );
1097
        my $branchcode = $server->{account}->{patron_branchcode_in_ao} ? $patron->branchcode : $ils->institution_id;
1098
        $resp .= add_field( FID_INST_ID, ( $branchcode || 'SIP2' ), $server );
1094
1099
1095
        # while the patron ID we got from the SC is valid, let's
1100
        # while the patron ID we got from the SC is valid, let's
1096
        # use the one returned from the ILS, just in case...
1101
        # use the one returned from the ILS, just in case...
(-)a/api/v1/swagger/definitions/sip2_account.yaml (+5 lines)
Lines 58-63 properties: Link Here
58
    type:
58
    type:
59
    - boolean
59
    - boolean
60
    - 'null'
60
    - 'null'
61
  patron_branchcode_in_ao:
62
    description: patron branchcode in ao
63
    type:
64
    - boolean
65
    - 'null'
61
  cv_send_00_on_success:
66
  cv_send_00_on_success:
62
    description: cv send 00 on success
67
    description: cv send 00 on success
63
    type:
68
    type:
(-)a/installer/data/mysql/atomicupdate/bug_41311.pl (+19 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "41311",
6
    description => "Add patron_branchcode_in_ao to sip_accounts table",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        $dbh->do(
12
            q{
13
            ALTER TABLE sip_accounts ADD COLUMN `patron_branchcode_in_ao` tinyint(1) AFTER `send_patron_home_library_in_af`;
14
        }
15
        );
16
17
        say_success( $out, "Added column 'sip_accounts.patron_branchcode_in_ao'" );
18
    },
19
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 6190-6195 CREATE TABLE `sip_accounts` ( Link Here
6190
  `sip_account_id` int(11) NOT NULL AUTO_INCREMENT,
6190
  `sip_account_id` int(11) NOT NULL AUTO_INCREMENT,
6191
  `sip_institution_id` int(11) NOT NULL COMMENT 'Foreign key to sip_institutions.sip_institution_id',
6191
  `sip_institution_id` int(11) NOT NULL COMMENT 'Foreign key to sip_institutions.sip_institution_id',
6192
  `ae_field_template` varchar(255) DEFAULT NULL,
6192
  `ae_field_template` varchar(255) DEFAULT NULL,
6193
  `patron_branchcode_in_ao` tinyint(1) DEFAULT 0,
6193
  `allow_additional_materials_checkout` tinyint(1) DEFAULT NULL,
6194
  `allow_additional_materials_checkout` tinyint(1) DEFAULT NULL,
6194
  `allow_empty_passwords` tinyint(1) DEFAULT NULL,
6195
  `allow_empty_passwords` tinyint(1) DEFAULT NULL,
6195
  `allow_fields` varchar(255) DEFAULT NULL,
6196
  `allow_fields` varchar(255) DEFAULT NULL,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2AccountResource.vue (+10 lines)
Lines 449-454 export default { Link Here
449
                hideIn: ["List"],
449
                hideIn: ["List"],
450
                group: "Details",
450
                group: "Details",
451
            },
451
            },
452
            {
453
                name: "patron_branchcode_in_ao",
454
                type: "boolean",
455
                label: __("Send patron home library in AO"),
456
                hideIn: ["List"],
457
                group: "Details",
458
                toolTip: __(
459
                    "Send patron branchcode in AO field for patron status and patron information responses"
460
                ),
461
            },
452
            {
462
            {
453
                name: "show_checkin_message",
463
                name: "show_checkin_message",
454
                type: "boolean",
464
                type: "boolean",
(-)a/t/cypress/integration/SIP2/Accounts.ts (+1 lines)
Lines 12-17 function get_account() { Link Here
12
        convert_nonprinting_characters: "",
12
        convert_nonprinting_characters: "",
13
        cr_item_field: "collection_code",
13
        cr_item_field: "collection_code",
14
        ct_always_send: false,
14
        ct_always_send: false,
15
        patron_branchcode_in_ao: false,
15
        cv_send_00_on_success: false,
16
        cv_send_00_on_success: false,
16
        cv_triggers_alert: false,
17
        cv_triggers_alert: false,
17
        custom_item_fields: [],
18
        custom_item_fields: [],
(-)a/t/db_dependent/SIP/Message.t (-5 / +20 lines)
Lines 64-70 subtest 'Testing Patron Status Request V2' => sub { Link Here
64
subtest 'Testing Patron Info Request V2' => sub {
64
subtest 'Testing Patron Info Request V2' => sub {
65
    my $schema = Koha::Database->new->schema;
65
    my $schema = Koha::Database->new->schema;
66
    $schema->storage->txn_begin;
66
    $schema->storage->txn_begin;
67
    plan tests => 32;
67
    plan tests => 35;
68
    $C4::SIP::Sip::protocol_version = 2;
68
    $C4::SIP::Sip::protocol_version = 2;
69
    test_request_patron_info_v2();
69
    test_request_patron_info_v2();
70
    $schema->storage->txn_rollback;
70
    $schema->storage->txn_rollback;
Lines 1070-1077 sub test_request_patron_status_v2 { Link Here
1070
}
1070
}
1071
1071
1072
sub test_request_patron_info_v2 {
1072
sub test_request_patron_info_v2 {
1073
    my $builder    = t::lib::TestBuilder->new();
1073
    my $builder     = t::lib::TestBuilder->new();
1074
    my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
1074
    my $branchcode  = $builder->build( { source => 'Branch' } )->{branchcode};
1075
    my $branchcode2 = $builder->build( { source => 'Branch' } )->{branchcode};
1075
    my ( $response, $findpatron );
1076
    my ( $response, $findpatron );
1076
    my $mocks = create_mocks( \$response, \$findpatron, \$branchcode );
1077
    my $mocks = create_mocks( \$response, \$findpatron, \$branchcode );
1077
1078
Lines 1079-1091 sub test_request_patron_info_v2 { Link Here
1079
        {
1080
        {
1080
            source => 'Borrower',
1081
            source => 'Borrower',
1081
            value  => {
1082
            value  => {
1082
                password => hash_password(PATRON_PW),
1083
                password   => hash_password(PATRON_PW),
1084
                branchcode => $branchcode2,
1083
            },
1085
            },
1084
        }
1086
        }
1085
    );
1087
    );
1086
    my $card        = $patron2->{cardnumber};
1088
    my $card        = $patron2->{cardnumber};
1087
    my $sip_patron2 = C4::SIP::ILS::Patron->new($card);
1089
    my $sip_patron2 = C4::SIP::ILS::Patron->new($card);
1088
    $findpatron = $sip_patron2;
1090
    $findpatron = $sip_patron2;
1091
1089
    my $siprequest =
1092
    my $siprequest =
1090
          PATRON_INFO
1093
          PATRON_INFO
1091
        . 'engYYYYMMDDZZZZHHMMSS'
1094
        . 'engYYYYMMDDZZZZHHMMSS'
Lines 1130-1135 sub test_request_patron_info_v2 { Link Here
1130
        'Check customized patron name'
1133
        'Check customized patron name'
1131
    );
1134
    );
1132
1135
1136
    # Test patron_branchcode_in_ao
1137
    $server->{account}->{patron_branchcode_in_ao} = "1";
1138
    $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
1139
    undef $response;
1140
    is( $patron2->{branchcode},   $branchcode2, "Patron created with correct home library" );
1141
    is( $sip_patron2->branchcode, $branchcode2, "SIP Patron created with correct home library" );
1142
    $msg->handle_patron_info($server);
1143
    $respcode = substr( $response, 0, 2 );
1144
    check_field(
1145
        $respcode, $response, FID_INST_ID, $patron2->{branchcode},
1146
        "Patron home library is in the AO field( patron = $patron2->{branchcode}, INST = $branchcode"
1147
    );
1148
1133
    # Test hide_fields
1149
    # Test hide_fields
1134
    undef $response;
1150
    undef $response;
1135
    $server->{account}->{hide_fields} = join( ",", FID_HOME_ADDR, FID_EMAIL, FID_HOME_PHONE, FID_PATRON_BIRTHDATE );
1151
    $server->{account}->{hide_fields} = join( ",", FID_HOME_ADDR, FID_EMAIL, FID_HOME_PHONE, FID_PATRON_BIRTHDATE );
1136
- 

Return to bug 41311