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

(-)a/Koha/Account/Line.pm (-1 / +13 lines)
Lines 144-150 sub apply { Link Here
144
        );
144
        );
145
    }
145
    }
146
146
147
    unless ( !$debit->is_credit ) {
147
    unless ( $debit->is_debit ) {
148
        Koha::Exceptions::Account::IsNotDebit->throw(
148
        Koha::Exceptions::Account::IsNotDebit->throw(
149
            error => 'Account line ' . $debit->id . 'is not a debit'
149
            error => 'Account line ' . $debit->id . 'is not a debit'
150
        );
150
        );
Lines 202-207 sub is_credit { Link Here
202
    return ( $self->amount < 0 );
202
    return ( $self->amount < 0 );
203
}
203
}
204
204
205
=head3 is_debit
206
207
    my $bool = $line->is_debit;
208
209
=cut
210
211
sub is_debit {
212
    my ($self) = @_;
213
214
    return !$self->is_credit;
215
}
216
205
=head2 Internal methods
217
=head2 Internal methods
206
218
207
=cut
219
=cut
(-)a/t/db_dependent/Koha/Account/Lines.t (-4 / +5 lines)
Lines 65-73 subtest 'item() tests' => sub { Link Here
65
    $schema->storage->txn_rollback;
65
    $schema->storage->txn_rollback;
66
};
66
};
67
67
68
subtest 'is_credit() tests' => sub {
68
subtest 'is_credit() and is_debit() tests' => sub {
69
69
70
    plan tests => 2;
70
    plan tests => 4;
71
71
72
    $schema->storage->txn_begin;
72
    $schema->storage->txn_begin;
73
73
Lines 77-82 subtest 'is_credit() tests' => sub { Link Here
77
    my $credit = $account->add_credit({ amount => 100, user_id => $patron->id });
77
    my $credit = $account->add_credit({ amount => 100, user_id => $patron->id });
78
78
79
    ok( $credit->is_credit, 'is_credit detects credits' );
79
    ok( $credit->is_credit, 'is_credit detects credits' );
80
    ok( !$credit->is_debit, 'is_debit detects credits' );
80
81
81
    my $debit = Koha::Account::Line->new(
82
    my $debit = Koha::Account::Line->new(
82
    {
83
    {
Lines 85-91 subtest 'is_credit() tests' => sub { Link Here
85
        amount         => 10,
86
        amount         => 10,
86
    })->store;
87
    })->store;
87
88
88
    ok( !$debit->is_credit, 'is_credit() detects debits' );
89
    ok( !$debit->is_credit, 'is_credit detects debits' );
90
    ok( $debit->is_debit, 'is_debit detects debits');
89
91
90
    $schema->storage->txn_rollback;
92
    $schema->storage->txn_rollback;
91
};
93
};
92
- 

Return to bug 20997