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

(-)a/Koha/Account/Line.pm (-1 / +1 lines)
Lines 700-706 sub apply { Link Here
700
        }
700
        }
701
    });
701
    });
702
702
703
    Koha::Patron::Debarments::del_restrictions_after_payment({ borrowernumber => $self->borrowernumber });
703
    Koha::Patron::Debarments::del_restrictions_after_payment( { borrowernumber => $self->borrowernumber } );
704
704
705
    return $self;
705
    return $self;
706
}
706
}
(-)a/Koha/Patron/Debarments.pm (-5 / +4 lines)
Lines 274-282 sub UpdateBorrowerDebarmentFlags { Link Here
274
274
275
=head2 del_restrictions_after_payment
275
=head2 del_restrictions_after_payment
276
276
277
my $success = del_restrictions_after_payment({
277
    my $success = del_restrictions_after_payment({
278
    borrowernumber => $borrowernumber,
278
        borrowernumber => $borrowernumber,
279
});
279
    });
280
280
281
Deletes any restrictions from patron by following the rules
281
Deletes any restrictions from patron by following the rules
282
defined in "Patron restrictions".
282
defined in "Patron restrictions".
Lines 295-302 sub del_restrictions_after_payment { Link Here
295
    my $restrictions = $patron->restrictions;
295
    my $restrictions = $patron->restrictions;
296
    return unless ( $restrictions->count );
296
    return unless ( $restrictions->count );
297
297
298
    my $lines =
298
    my $lines     = Koha::Account::Lines->search( { borrowernumber => $borrowernumber } );
299
      Koha::Account::Lines->search( { borrowernumber => $borrowernumber } );
300
    my $total_due = $lines->total_outstanding;
299
    my $total_due = $lines->total_outstanding;
301
300
302
    while ( my $restriction = $restrictions->next ) {
301
    while ( my $restriction = $restrictions->next ) {
(-)a/admin/restrictions.pl (-9 / +11 lines)
Lines 53-62 if ( $op eq 'add_form') { Link Here
53
    }
53
    }
54
} elsif ( $op eq 'add_validate' ) {
54
} elsif ( $op eq 'add_validate' ) {
55
55
56
    my $display_text = $input->param('display_text');
56
    my $display_text       = $input->param('display_text');
57
    my $lift_after_payment = $input->param('lift_after_payment');
57
    my $lift_after_payment = $input->param('lift_after_payment');
58
    my $fee_limit = $input->param('fee_limit');
58
    my $fee_limit          = $input->param('fee_limit');
59
    my $is_a_modif = $input->param("is_a_modif");
59
    my $is_a_modif         = $input->param("is_a_modif");
60
60
61
    if ($is_a_modif) {
61
    if ($is_a_modif) {
62
        # Check whether another restriction already has this display text
62
        # Check whether another restriction already has this display text
Lines 86-97 if ( $op eq 'add_form') { Link Here
86
                type => 'error', code => 'duplicate_code'
86
                type => 'error', code => 'duplicate_code'
87
            };
87
            };
88
        } else {
88
        } else {
89
            my $restriction = Koha::Patron::Restriction::Type->new({
89
            my $restriction = Koha::Patron::Restriction::Type->new(
90
                code => $code,
90
                {
91
                display_text => $display_text,
91
                    code               => $code,
92
                lift_after_payment => $lift_after_payment,
92
                    display_text       => $display_text,
93
                fee_limit => $fee_limit
93
                    lift_after_payment => $lift_after_payment,
94
            });
94
                    fee_limit          => $fee_limit
95
                }
96
            );
95
            $restriction->store;
97
            $restriction->store;
96
            push @messages, { type => 'message', code => 'add_success' };
98
            push @messages, { type => 'message', code => 'add_success' };
97
        }
99
        }
(-)a/t/db_dependent/Patron/Borrower_Debarments.t (-5 / +4 lines)
Lines 262-268 my $patron4 = Koha::Patron->new( Link Here
262
)->store;
262
)->store;
263
263
264
my $account = $patron4->account;
264
my $account = $patron4->account;
265
my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' });
265
my $line1   = $account->add_debit( { type => 'ACCOUNT', amount => 10, interface => 'commandline' } );
266
266
267
Koha::Patron::Debarments::AddDebarment(
267
Koha::Patron::Debarments::AddDebarment(
268
    {
268
    {
Lines 286-296 $restrictions = $patron4->restrictions; Link Here
286
286
287
is( $restrictions->count, 2, "->restrictions returns 2 restrictions before payment" );
287
is( $restrictions->count, 2, "->restrictions returns 2 restrictions before payment" );
288
288
289
$account->pay({amount => 5});
289
$account->pay( { amount => 5 } );
290
$restrictions = $patron4->restrictions;
290
$restrictions = $patron4->restrictions;
291
is( $restrictions->count, 1, "->restrictions returns 1 restriction after paying half of the fee" );
291
is( $restrictions->count,            1,       "->restrictions returns 1 restriction after paying half of the fee" );
292
is( $restrictions->next->type->code, "TEST2", "Restriction left has type value 'TEST2'" );
292
is( $restrictions->next->type->code, "TEST2", "Restriction left has type value 'TEST2'" );
293
293
294
$account->pay({amount => 5});
294
$account->pay( { amount => 5 } );
295
$restrictions = $patron4->restrictions;
295
$restrictions = $patron4->restrictions;
296
is( $restrictions->count, 0, "->restrictions returns 0 restrictions after paying all fees" );
296
is( $restrictions->count, 0, "->restrictions returns 0 restrictions after paying all fees" );
297
- 

Return to bug 16223