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

(-)a/C4/SIP/Sip/MsgType.pm (-1 / +8 lines)
Lines 1714-1719 sub patron_status_string { Link Here
1714
1714
1715
    my $patron_status;
1715
    my $patron_status;
1716
1716
1717
    my $too_many_lost = 0;
1718
    if ( my $lost_block_checkout = $server->{account}->{lost_block_checkout} ) {
1719
        my $lost_block_checkout_value = $server->{account}->{lost_block_checkout_value} // 1;
1720
        my $lost_checkouts = Koha::Checkouts->search({ borrowernumber => $patron->borrowernumber, 'itemlost' => { '>=', $lost_block_checkout_value } }, { join => 'item'} )->count;
1721
        $too_many_lost = $lost_checkouts >= $lost_block_checkout;
1722
    }
1723
1717
    siplog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
1724
    siplog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
1718
    $patron_status = sprintf(
1725
    $patron_status = sprintf(
1719
        '%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
1726
        '%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
Lines 1726-1732 sub patron_status_string { Link Here
1726
        $server->{account}->{overdues_block_checkout} ? boolspace( $patron->too_many_overdue ) : q{ },
1733
        $server->{account}->{overdues_block_checkout} ? boolspace( $patron->too_many_overdue ) : q{ },
1727
        boolspace( $patron->too_many_renewal ),
1734
        boolspace( $patron->too_many_renewal ),
1728
        boolspace( $patron->too_many_claim_return ),
1735
        boolspace( $patron->too_many_claim_return ),
1729
        boolspace( $patron->too_many_lost ),
1736
        boolspace( $too_many_lost ),
1730
        boolspace( $patron->excessive_fines ),
1737
        boolspace( $patron->excessive_fines ),
1731
        boolspace( $patron->excessive_fees ),
1738
        boolspace( $patron->excessive_fees ),
1732
        boolspace( $patron->recall_overdue ),
1739
        boolspace( $patron->recall_overdue ),
(-)a/etc/SIPconfig.xml (+4 lines)
Lines 74-82 Link Here
74
             holds_get_captured="1"
74
             holds_get_captured="1"
75
             prevcheckout_block_checkout="0"
75
             prevcheckout_block_checkout="0"
76
             overdues_block_checkout="1"
76
             overdues_block_checkout="1"
77
             lost_block_checkout="2"
78
             lost_block_checkout_value="1"
77
             format_due_date="0"
79
             format_due_date="0"
78
             inhouse_item_types=""
80
             inhouse_item_types=""
79
             inhouse_patron_categories="">
81
             inhouse_patron_categories="">
82
             <!-- lost_block_checkout sets flag if patron has more than the given current checkouts that are lost ( itemlost > 0 by default ) -->
83
             <!-- lost_block_checkout_value determines the minimum lost item value to count ( that is, the value in items.itemlost ) -->
80
          <!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping -->
84
          <!-- Refer to syspref SIP2SortBinMapping for full explanation of sort bin mapping -->
81
          <sort_bin_mapping mapping="CPL:itype:eq:BK:1"/>
85
          <sort_bin_mapping mapping="CPL:itype:eq:BK:1"/>
82
          <sort_bin_mapping mapping="CPL:location:eq:OFFICE:2"/>
86
          <sort_bin_mapping mapping="CPL:location:eq:OFFICE:2"/>
(-)a/t/db_dependent/SIP/Message.t (-3 / +86 lines)
Lines 21-27 Link Here
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
use Test::More tests => 15;
24
use Test::More tests => 16;
25
use Test::Exception;
25
use Test::Exception;
26
use Test::MockObject;
26
use Test::MockObject;
27
use Test::MockModule;
27
use Test::MockModule;
Lines 31-37 use t::lib::Mocks; Link Here
31
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
32
32
33
use C4::Reserves qw( AddReserve );
33
use C4::Reserves qw( AddReserve );
34
use C4::Circulation qw( AddReturn );
34
use C4::Circulation qw( AddIssue AddReturn );
35
use Koha::Database;
35
use Koha::Database;
36
use Koha::AuthUtils qw(hash_password);
36
use Koha::AuthUtils qw(hash_password);
37
use Koha::DateUtils qw( dt_from_string output_pref );
37
use Koha::DateUtils qw( dt_from_string output_pref );
Lines 237-242 subtest 'Lastseen response' => sub { Link Here
237
237
238
};
238
};
239
239
240
subtest "Test patron_status_string" => sub {
241
    my $schema = Koha::Database->new->schema;
242
    $schema->storage->txn_begin;
243
244
    plan tests => 9;
245
246
    my $builder = t::lib::TestBuilder->new();
247
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
248
    my $patron = $builder->build({
249
        source => 'Borrower',
250
        value  => {
251
            branchcode => $branchcode,
252
        },
253
    });
254
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber} );
255
256
    t::lib::Mocks::mock_userenv({ branchcode => $branchcode });
257
258
     my $item1 = $builder->build_sample_item(
259
        {
260
            damaged       => 0,
261
            withdrawn     => 0,
262
            itemlost      => 0,
263
            restricted    => 0,
264
            homebranch    => $branchcode,
265
            holdingbranch => $branchcode,
266
            permanent_location => "PERMANENT_LOCATION"
267
        }
268
    );
269
     AddIssue( $patron, $item1->barcode );
270
271
     my $item2 = $builder->build_sample_item(
272
        {
273
            damaged       => 0,
274
            withdrawn     => 0,
275
            itemlost      => 0,
276
            restricted    => 0,
277
            homebranch    => $branchcode,
278
            holdingbranch => $branchcode,
279
            permanent_location => "PERMANENT_LOCATION"
280
        }
281
    );
282
    AddIssue( $patron, $item2->barcode );
283
284
    is( Koha::Checkouts->search({ borrowernumber => $patron->{borrowernumber} })->count, 2, "Found 2 checkouts for this patron" );
285
286
    $item1->itemlost(1)->store();
287
    $item2->itemlost(2)->store();
288
289
    is( Koha::Checkouts->search({ borrowernumber => $patron->{borrowernumber}, 'itemlost' => { '>', 0 } }, { join => 'item'} )->count, 2, "Found 2 lost checkouts for this patron" );
290
291
    my $server->{account}->{lost_block_checkout} = undef;
292
    my $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
293
    is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 0 does not block checkouts with 2 lost checkouts" );;
294
295
    $server->{account}->{lost_block_checkout} = 0;
296
    $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
297
    is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 0 does not block checkouts with 2 lost checkouts" );;
298
299
    $server->{account}->{lost_block_checkout} = 1;
300
    $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
301
    is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 1 does block checkouts with 2 lost checkouts" );;
302
303
    $server->{account}->{lost_block_checkout} = 2;
304
    $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
305
    is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 2 does block checkouts with 2 lost checkouts" );;
306
307
    $server->{account}->{lost_block_checkout} = 3;
308
    $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
309
    is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 3 does not block checkouts with 2 lost checkouts" );;
310
311
    $server->{account}->{lost_block_checkout} = 2;
312
    $server->{account}->{lost_block_checkout_value} = 2;
313
    $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
314
    is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 2, lost_block_checkout_value = 2 does not block checkouts with 2 lost checkouts where only 1 has itemlost = 2" );
315
316
    $server->{account}->{lost_block_checkout} = 1;
317
    $server->{account}->{lost_block_checkout_value} = 2;
318
    $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server );
319
    is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 2, lost_block_checkout_value = 2 does block checkouts with 2 lost checkouts where only 1 has itemlost = 2" );
320
321
    $schema->storage->txn_rollback;
322
};
323
240
subtest "Test build_additional_item_fields_string" => sub {
324
subtest "Test build_additional_item_fields_string" => sub {
241
    my $schema = Koha::Database->new->schema;
325
    my $schema = Koha::Database->new->schema;
242
    $schema->storage->txn_begin;
326
    $schema->storage->txn_begin;
243
- 

Return to bug 32684