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

(-)a/C4/SIP/ILS.pm (-1 / +26 lines)
Lines 139-145 sub checkout { Link Here
139
        } elsif ($patron->expired) {
139
        } elsif ($patron->expired) {
140
            $circ->screen_msg("Patron expired");
140
            $circ->screen_msg("Patron expired");
141
        } elsif ($patron->fine_blocked) {
141
        } elsif ($patron->fine_blocked) {
142
            $circ->screen_msg("Patron has fines");
142
            my $message = "Patron has fines";
143
            if ($account->{show_outstanding_amount}) {
144
                my $patron_account = Koha::Account->new( { patron_id => $patron->{borrowernumber} });
145
                my $balance = $patron_account->balance;
146
                if ($balance) {
147
                    $message .= (" - You owe " . Koha::Number::Price->new( $balance )->format({ with_symbol => 1}) . ".");
148
                }
149
            }
150
            $circ->screen_msg($message);
143
        } else {
151
        } else {
144
            $circ->screen_msg("Patron blocked");
152
            $circ->screen_msg("Patron blocked");
145
        }
153
        }
Lines 246-251 sub checkin { Link Here
246
        delete $item->{borrowernumber};
254
        delete $item->{borrowernumber};
247
        delete $item->{due_date};
255
        delete $item->{due_date};
248
        $patron->{items} = [ grep { $_ ne $item_id } @{ $patron->{items} } ];
256
        $patron->{items} = [ grep { $_ ne $item_id } @{ $patron->{items} } ];
257
        # Check for overdue fines to display
258
        if ($account->{show_outstanding_amount}) {
259
            my $kohaitem = Koha::Items->find( { barcode => $item_id } );
260
            if ($kohaitem) {
261
                my $charges = Koha::Account::Lines->search(
262
                    {
263
                        borrowernumber    => $patron->{borrowernumber},
264
                        amountoutstanding => { '>' => 0 },
265
                        debit_type_code   => [ 'OVERDUE' ],
266
                        itemnumber        => $kohaitem->itemnumber
267
                    },
268
                );
269
                if ($charges) {
270
                    $circ->screen_msg("You owe " . Koha::Number::Price->new( $charges->total_outstanding )->format({ with_symbol => 1}) . " for this item.");
271
                }
272
            }
273
        }
249
    } else {
274
    } else {
250
        # Checkin failed: Wrongbranch or withdrawn?
275
        # Checkin failed: Wrongbranch or withdrawn?
251
        # Bug 10748 with pref BlockReturnOfLostItems adds another case to come
276
        # Bug 10748 with pref BlockReturnOfLostItems adds another case to come
(-)a/etc/SIPconfig.xml (+1 lines)
Lines 74-79 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
             show_outstanding_amount="1"
77
             format_due_date="0"
78
             format_due_date="0"
78
             inhouse_item_types=""
79
             inhouse_item_types=""
79
             inhouse_patron_categories="">
80
             inhouse_patron_categories="">
(-)a/t/db_dependent/SIP/Transaction.t (-4 / +90 lines)
Lines 334-341 subtest "Placing holds via SIP check CanItemBeReserved" => sub { Link Here
334
};
334
};
335
335
336
subtest do_checkin => sub {
336
subtest do_checkin => sub {
337
    plan tests => 12;
337
    plan tests => 13;
338
338
339
    my $mockILS = Test::MockObject->new;
340
    my $server = { ils => $mockILS };
339
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
341
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
340
    my $library2 = $builder->build_object( { class => 'Koha::Libraries' } );
342
    my $library2 = $builder->build_object( { class => 'Koha::Libraries' } );
341
    my $patron = $builder->build_object(
343
    my $patron = $builder->build_object(
Lines 437-447 subtest do_checkin => sub { Link Here
437
        is( $hold->itemnumber, $item->itemnumber, );
439
        is( $hold->itemnumber, $item->itemnumber, );
438
        is( Koha::Checkouts->search({itemnumber => $item->itemnumber})->count, 0, );
440
        is( Koha::Checkouts->search({itemnumber => $item->itemnumber})->count, 0, );
439
    };
441
    };
442
443
    subtest 'Checkin with fines' => sub {
444
        plan tests => 2;
445
446
        my $mockILS = Test::MockObject->new;
447
        my $server = { ils => $mockILS };
448
        my $library = $builder->build_object( { class => 'Koha::Libraries' } );
449
        my $institution = {
450
            id             => $library->id,
451
            implementation => "ILS",
452
            policy         => {
453
                checkin  => "true",
454
                renewal  => "true",
455
                checkout => "true",
456
                timeout  => 100,
457
                retries  => 5,
458
            }
459
        };
460
        my $ils = C4::SIP::ILS->new($institution);
461
        my $item = $builder->build_sample_item(
462
            {
463
                library => $library->branchcode,
464
            }
465
        );
466
467
        # show_outstanding_amount disabled
468
        my $patron = $builder->build_object(
469
            {
470
                class => 'Koha::Patrons',
471
                value => {
472
                    branchcode => $library->branchcode,
473
                }
474
            }
475
        );
476
        my $circ = $ils->checkout($patron->cardnumber, $item->barcode, undef, undef, $server->{account});
477
        my $fee1 = $builder->build(
478
            {
479
                source => 'Accountline',
480
                value  => {
481
                    borrowernumber => $patron->borrowernumber,
482
                    amountoutstanding => 12,
483
                    debit_type_code   => 'OVERDUE',
484
                    itemnumber        => $item->itemnumber
485
                }
486
            }
487
        );
488
        $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode, undef, undef, $server->{account} );
489
        is( $circ->{screen_msg}, '', "The fine is not displayed on checkin when show_outstanding_amount is disabled" );
490
491
        # show_outstanding_amount enabled
492
        $patron = $builder->build_object(
493
            {
494
                class => 'Koha::Patrons',
495
                value => {
496
                    branchcode => $library->branchcode,
497
                }
498
            }
499
        );
500
        $circ = $ils->checkout($patron->cardnumber, $item->barcode, undef, undef, $server->{account});
501
502
        $fee1 = $builder->build(
503
            {
504
                source => 'Accountline',
505
                value  => {
506
                    borrowernumber => $patron->borrowernumber,
507
                    amountoutstanding => 12,
508
                    debit_type_code   => 'OVERDUE',
509
                    itemnumber        => $item->itemnumber
510
                }
511
            }
512
        );
513
514
        $server->{account}->{show_outstanding_amount} = 1;
515
        $circ = $ils->checkout($patron->cardnumber, $item->barcode, undef, undef, $server->{account});
516
517
        $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode, undef, undef, $server->{account} );
518
        is( $circ->{screen_msg}, 'You owe $12.00 for this item.', "The fine is displayed on checkin when show_outstanding_amount is enabled" );
519
520
    };
440
};
521
};
441
522
442
subtest do_checkout_with_patron_blocked => sub {
523
subtest do_checkout_with_patron_blocked => sub {
443
    plan tests => 4;
524
    plan tests => 5;
444
525
526
    my $mockILS = Test::MockObject->new;
527
    my $server = { ils => $mockILS };
445
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
528
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
446
    my $institution = {
529
    my $institution = {
447
        id             => $library->id,
530
        id             => $library->id,
Lines 492-500 subtest do_checkout_with_patron_blocked => sub { Link Here
492
    );
575
    );
493
576
494
    my $fines_sip_patron  = C4::SIP::ILS::Patron->new( $fines_patron->cardnumber );
577
    my $fines_sip_patron  = C4::SIP::ILS::Patron->new( $fines_patron->cardnumber );
495
    $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode);
578
579
    $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account});
496
    is( $circ->{screen_msg}, 'Patron has fines', "Got correct fines screen message" );
580
    is( $circ->{screen_msg}, 'Patron has fines', "Got correct fines screen message" );
497
581
582
    $server->{account}->{show_outstanding_amount} = 1;
583
    $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account});
584
    is( $circ->{screen_msg}, 'Patron has fines - You owe $10.00.', "Got correct fines with amount screen message" );
498
    my $debarred_patron = $builder->build_object(
585
    my $debarred_patron = $builder->build_object(
499
        {
586
        {
500
            class => 'Koha::Patrons',
587
            class => 'Koha::Patrons',
501
- 

Return to bug 25812