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

(-)a/C4/SIP/ILS/Transaction/Checkin.pm (-9 / +8 lines)
Lines 204-210 value that should be returned for an item checked in via SIP2. Link Here
204
204
205
The mapping should be:
205
The mapping should be:
206
206
207
 <branchcode>:<item field>:<comparitor>:<item field value>:<sort bin number>
207
 <branchcode>:<item field>:<comparator>:<item field value>:<sort bin number>
208
208
209
For example:
209
For example:
210
210
Lines 242-251 sub _get_sort_bin { Link Here
242
    # Iterate over the mapping. The first hit wins.
242
    # Iterate over the mapping. The first hit wins.
243
    my $rule = 0;
243
    my $rule = 0;
244
    foreach my $line (@lines) {
244
    foreach my $line (@lines) {
245
        warn "Rule: " . $rule++ . " - " . $line . "\n";
246
245
247
        # Split the line into fields
246
        # Split the line into fields
248
        my ( $branchcode, $item_property, $comparitor, $value, $sort_bin ) =
247
        my ( $branchcode, $item_property, $comparator, $value, $sort_bin ) =
249
          split /:/, $line;
248
          split /:/, $line;
250
        if ( $value =~ s/^\$// ) {
249
        if ( $value =~ s/^\$// ) {
251
            $value = $item->$value;
250
            $value = $item->$value;
Lines 253-274 sub _get_sort_bin { Link Here
253
        # Check the fields against values in the item
252
        # Check the fields against values in the item
254
        if ( $branch eq $branchcode ) {
253
        if ( $branch eq $branchcode ) {
255
            my $property = $item->$item_property;
254
            my $property = $item->$item_property;
256
            if ( ( $comparitor eq 'eq' || $comparitor eq '=' ) && ( $property eq $value ) ) {
255
            if ( ( $comparator eq 'eq' || $comparator eq '=' ) && ( $property eq $value ) ) {
257
                return $sort_bin;
256
                return $sort_bin;
258
            }
257
            }
259
            if ( ( $comparitor eq 'ne' || $comparitor eq '!=' ) && ( $property ne $value ) ) {
258
            if ( ( $comparator eq 'ne' || $comparator eq '!=' ) && ( $property ne $value ) ) {
260
                return $sort_bin;
259
                return $sort_bin;
261
            }
260
            }
262
            if ( ( $comparitor eq '<' ) && ( $property < $value ) ) {
261
            if ( ( $comparator eq '<' ) && ( $property < $value ) ) {
263
                return $sort_bin;
262
                return $sort_bin;
264
            }
263
            }
265
            if ( ( $comparitor eq '>' ) && ( $property > $value ) ) {
264
            if ( ( $comparator eq '>' ) && ( $property > $value ) ) {
266
                return $sort_bin;
265
                return $sort_bin;
267
            }
266
            }
268
            if ( ( $comparitor eq '<=' ) && ( $property <= $value ) ) {
267
            if ( ( $comparator eq '<=' ) && ( $property <= $value ) ) {
269
                return $sort_bin;
268
                return $sort_bin;
270
            }
269
            }
271
            if ( ( $comparitor eq '>=' ) && ( $property >= $value ) ) {
270
            if ( ( $comparator eq '>=' ) && ( $property >= $value ) ) {
272
                return $sort_bin;
271
                return $sort_bin;
273
            }
272
            }
274
        }
273
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +13 lines)
Lines 1287-1293 Circulation: Link Here
1287
1287
1288
    SIP2:
1288
    SIP2:
1289
        -
1289
        -
1290
            - "Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form 'branchcode:item field:item field value:sort bin number', with one mapping per line."
1290
            - "Use the following mappings to determine the sort_bin of a returned item.<br/>"
1291
            - "The mapping should be of the form 'branchcode:item field:comparator:item field value:sort bin number', with one mapping per line.<br/>"
1292
            - "- 'branchcode' is the location where the checkin is being performed (i.e. branch assigned to SIP user)<br/>"
1293
            - "- 'item field' is a database column in the items table<br/>"
1294
            - "- 'comparator' is the type of comparison, possible values are: eq,<,<=,>,>=,ne<br/>"
1295
            - "- 'item field value' is the value to compare against the value in the specified 'item field'<br/>"
1296
            - "- 'sort bin number' is the expected return value in the CL field of the SIP response for an item matching a rule<br/><br/>"
1297
            - "NOTE: Specifying 'item_field_value' with a leading '\\$' and an item field name will use the value of that field in the item for comparison:<br/>"
1298
            - "i.e. \\$holdingbranch<br/></br>"
1299
            - "Examples:<br/>"
1300
            - "CPL:itype:eq:BOOK:1 - Will return sort bin 1 for an item of itemtype 'BOOK' returned to CPL.<br/>"
1301
            - "CPL:itemcallnumber:<:339.6:3 - Will return sort bin 3 for an item with a callnumber less than 339.6 returned to CPL .<br/>"
1302
            - "CPL:homebranch:ne:\\$holdingbranch:X - Wil return sort bin 'X' for an item returned to CPL where the holdingbranch is not equal to the homebranch (i.e. any item belonging to a different branch than CPL).<br/><br/>"
1291
            - pref: SIP2SortBinMapping
1303
            - pref: SIP2SortBinMapping
1292
              type: textarea
1304
              type: textarea
1293
              class: long
1305
              class: long
(-)a/t/db_dependent/SIP/Transaction.t (-5 / +5 lines)
Lines 564-579 RULES Link Here
564
    # Set holdingbranch as though item returned to library other than homebranch (As AddReturn would)
564
    # Set holdingbranch as though item returned to library other than homebranch (As AddReturn would)
565
    $item_cd->holdingbranch($library2->branchcode)->store();
565
    $item_cd->holdingbranch($library2->branchcode)->store();
566
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_cd, $library2->branchcode );
566
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_cd, $library2->branchcode );
567
    is($bin, 'X', "Item parameter on RHS of comparison works (ne comparitor)");
567
    is($bin, 'X', "Item parameter on RHS of comparison works (ne comparator)");
568
568
569
    # Reset holdingbranch as though item returned to home library
569
    # Reset holdingbranch as though item returned to home library
570
    $item_cd->holdingbranch($library->branchcode)->store();
570
    $item_cd->holdingbranch($library->branchcode)->store();
571
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_cd, $library->branchcode );
571
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_cd, $library->branchcode );
572
    is($bin, '0', "Fixed value on RHS of comparison works (eq comparitor)");
572
    is($bin, '0', "Fixed value on RHS of comparison works (eq comparator)");
573
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_book, $library->branchcode );
573
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_book, $library->branchcode );
574
    is($bin, '1', "Rules applied in order (< comparitor)");
574
    is($bin, '1', "Rules applied in order (< comparator)");
575
    $item_book->itemcallnumber('350.20')->store();
575
    $item_book->itemcallnumber('350.20')->store();
576
    is($bin, '2', "Rules applied in order (< comparitor)");
576
    $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_book, $library->branchcode );
577
    is($bin, '2', "Rules applied in order (< comparator)");
577
};
578
};
578
579
579
subtest item_circulation_status => sub {
580
subtest item_circulation_status => sub {
580
- 

Return to bug 20517