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

(-)a/C4/SIP/ILS/Patron.pm (-4 / +11 lines)
Lines 78-93 sub new { Link Here
78
78
79
    # Get fines and add fines for guarantees (depends on preference NoIssuesChargeGuarantees)
79
    # Get fines and add fines for guarantees (depends on preference NoIssuesChargeGuarantees)
80
    my $fines_amount = ($patron->account->balance > 0) ? $patron->account->non_issues_charges : 0;
80
    my $fines_amount = ($patron->account->balance > 0) ? $patron->account->non_issues_charges : 0;
81
    my $personal_fines_amount = $fines_amount;
81
    my $fee_limit = _fee_limit();
82
    my $fee_limit = _fee_limit();
82
    my $fine_blocked = $fines_amount > $fee_limit;
83
    my $noissueschargeguarantorswithguarantees = C4::Context->preference('NoIssuesChargeGuarantorsWithGuarantees');
83
    my $noissueschargeguarantorswithguarantees = C4::Context->preference('NoIssuesChargeGuarantorsWithGuarantees');
84
    my $fines_msg = "";
85
    my $fine_blocked = 0;
84
    my $noissueschargeguarantees = C4::Context->preference('NoIssuesChargeGuarantees');
86
    my $noissueschargeguarantees = C4::Context->preference('NoIssuesChargeGuarantees');
85
    if ( $noissueschargeguarantorswithguarantees ) {
87
    if( $fines_amount > $fee_limit ){
88
        $fine_blocked = 1;
89
        $fines_msg .= " -- " . "Patron blocked by fines" if $fine_blocked;
90
    } elsif ( $noissueschargeguarantorswithguarantees ) {
86
        $fines_amount += $patron->relationships_debt({ include_guarantors => 1, only_this_guarantor => 0, include_this_patron => 0 });
91
        $fines_amount += $patron->relationships_debt({ include_guarantors => 1, only_this_guarantor => 0, include_this_patron => 0 });
87
        $fine_blocked ||= $fines_amount > $noissueschargeguarantorswithguarantees;
92
        $fine_blocked ||= $fines_amount > $noissueschargeguarantorswithguarantees;
93
        $fines_msg .= " -- " . "Patron blocked by fines ($fines_amount) on related accounts";
88
    } elsif ( $noissueschargeguarantees ) {
94
    } elsif ( $noissueschargeguarantees ) {
89
        $fines_amount += $patron->relationships_debt({ include_guarantors => 0, only_this_guarantor => 0, include_this_patron => 0 });
95
        $fines_amount += $patron->relationships_debt({ include_guarantors => 0, only_this_guarantor => 0, include_this_patron => 0 });
90
        $fine_blocked ||= $fines_amount > $noissueschargeguarantees;
96
        $fine_blocked ||= $fines_amount > $noissueschargeguarantees;
97
        $fines_msg .= " -- " . "Patron blocked by fines ($fines_amount) on guaranteed accounts";
91
    }
98
    }
92
99
93
    my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" &&  defined $flags->{ODUES}->{itemlist} ) ? 1 : 0;
100
    my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" &&  defined $flags->{ODUES}->{itemlist} ) ? 1 : 0;
Lines 114-124 sub new { Link Here
114
        hold_ok         => ( !$debarred && !$expired && !$fine_blocked),
121
        hold_ok         => ( !$debarred && !$expired && !$fine_blocked),
115
        card_lost       => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ),
122
        card_lost       => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ),
116
        claims_returned => 0,
123
        claims_returned => 0,
117
        fines           => $fines_amount,
124
        fines           => $personal_fines_amount,
118
        fees            => 0,             # currently not distinct from fines
125
        fees            => 0,             # currently not distinct from fines
119
        recall_overdue  => 0,
126
        recall_overdue  => 0,
120
        items_billed    => 0,
127
        items_billed    => 0,
121
        screen_msg      => 'Greetings from Koha. ' . $kp->{opacnote},
128
        screen_msg      => 'Greetings from Koha. ' . $kp->{opacnote} . $fines_msg,
122
        print_line      => '',
129
        print_line      => '',
123
        items           => [],
130
        items           => [],
124
        hold_items      => $flags->{WAITING}->{itemlist},
131
        hold_items      => $flags->{WAITING}->{itemlist},
(-)a/t/db_dependent/SIP/Patron.t (-8 / +12 lines)
Lines 276-282 $schema->storage->txn_rollback; Link Here
276
276
277
subtest "NoIssuesChargeGuarantees tests" => sub {
277
subtest "NoIssuesChargeGuarantees tests" => sub {
278
278
279
    plan tests => 4;
279
    plan tests => 5;
280
280
281
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' );
281
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' );
282
282
Lines 286-292 subtest "NoIssuesChargeGuarantees tests" => sub { Link Here
286
    my $child  = $builder->build_object({ class => 'Koha::Patrons' });
286
    my $child  = $builder->build_object({ class => 'Koha::Patrons' });
287
    $child->add_guarantor({ guarantor_id => $patron->borrowernumber, relationship => 'parent' });
287
    $child->add_guarantor({ guarantor_id => $patron->borrowernumber, relationship => 'parent' });
288
288
289
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantees', 1);
289
    t::lib::Mocks::mock_preference('noissuescharge', 50);
290
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantees', 11.01);
290
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantorsWithGuarantees', undef);
291
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantorsWithGuarantees', undef);
291
292
292
    my $fee1 = $builder->build_object(
293
    my $fee1 = $builder->build_object(
Lines 311-318 subtest "NoIssuesChargeGuarantees tests" => sub { Link Here
311
312
312
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
313
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
313
314
314
    is( $sip_patron->fines_amount, 11.11,"Guarantor fines correctly included");
315
    is( $sip_patron->fines_amount, 11, "Only patron's fines are reported in total");
315
    ok( !$sip_patron->charge_ok, "Guarantor blocked");
316
    ok( !$sip_patron->charge_ok, "Guarantor blocked");
317
    like( $sip_patron->screen_msg, qr/Patron blocked by fines \(11\.11\) on guaranteed accounts/,"Screen message includes related fines total");
316
318
317
    $sip_patron = C4::SIP::ILS::Patron->new( $child->cardnumber );
319
    $sip_patron = C4::SIP::ILS::Patron->new( $child->cardnumber );
318
320
Lines 324-330 subtest "NoIssuesChargeGuarantees tests" => sub { Link Here
324
326
325
subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub {
327
subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub {
326
328
327
    plan tests => 4;
329
    plan tests => 6;
328
330
329
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' );
331
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' );
330
332
Lines 334-340 subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub { Link Here
334
    my $child  = $builder->build_object({ class => 'Koha::Patrons' });
336
    my $child  = $builder->build_object({ class => 'Koha::Patrons' });
335
    $child->add_guarantor({ guarantor_id => $patron->borrowernumber, relationship => 'parent' });
337
    $child->add_guarantor({ guarantor_id => $patron->borrowernumber, relationship => 'parent' });
336
338
337
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantorsWithGuarantees', 1);
339
    t::lib::Mocks::mock_preference('noissuescharge', 50);
340
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantorsWithGuarantees', 11.01);
338
341
339
    my $fee1 = $builder->build_object(
342
    my $fee1 = $builder->build_object(
340
        {
343
        {
Lines 358-370 subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub { Link Here
358
361
359
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
362
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
360
363
361
    is( $sip_patron->fines_amount, 11.11,"Guarantee fines correctly included");
364
    is( $sip_patron->fines_amount, 11, "Guarantee fines correctly included");
362
    ok( !$sip_patron->charge_ok, "Guarantor blocked");
365
    ok( !$sip_patron->charge_ok, "Guarantor blocked");
366
    like( $sip_patron->screen_msg, qr/Patron blocked by fines \(11\.11\) on related accounts/,"Screen message includes related fines total");
363
367
364
    $sip_patron = C4::SIP::ILS::Patron->new( $child->cardnumber );
368
    $sip_patron = C4::SIP::ILS::Patron->new( $child->cardnumber );
365
369
366
    is( $sip_patron->fines_amount, 11.11,"Guarantor fines correctly included");
370
    is( $sip_patron->fines_amount, 0.11, "Guarantor fines correctly included");
367
    ok( !$sip_patron->charge_ok, "Guarantee blocked");
371
    ok( !$sip_patron->charge_ok, "Guarantee blocked");
372
    like( $sip_patron->screen_msg, qr/Patron blocked by fines \(11\.11\) on related accounts/,"Screen message includes related fines total");
368
373
369
    $schema->storage->txn_rollback;
374
    $schema->storage->txn_rollback;
370
};
375
};
371
- 

Return to bug 32624