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 132-140 subtest 'total_outstanding() tests' => sub { Link Here
132
    $schema->storage->txn_rollback;
132
    $schema->storage->txn_rollback;
133
};
133
};
134
134
135
subtest 'is_credit() tests' => sub {
135
subtest 'is_credit() and is_debit() tests' => sub {
136
136
137
    plan tests => 2;
137
    plan tests => 4;
138
138
139
    $schema->storage->txn_begin;
139
    $schema->storage->txn_begin;
140
140
Lines 144-149 subtest 'is_credit() tests' => sub { Link Here
144
    my $credit = $account->add_credit({ amount => 100, user_id => $patron->id });
144
    my $credit = $account->add_credit({ amount => 100, user_id => $patron->id });
145
145
146
    ok( $credit->is_credit, 'is_credit detects credits' );
146
    ok( $credit->is_credit, 'is_credit detects credits' );
147
    ok( !$credit->is_debit, 'is_debit detects credits' );
147
148
148
    my $debit = Koha::Account::Line->new(
149
    my $debit = Koha::Account::Line->new(
149
    {
150
    {
Lines 152-158 subtest 'is_credit() tests' => sub { Link Here
152
        amount         => 10,
153
        amount         => 10,
153
    })->store;
154
    })->store;
154
155
155
    ok( !$debit->is_credit, 'is_credit() detects debits' );
156
    ok( !$debit->is_credit, 'is_credit detects debits' );
157
    ok( $debit->is_debit, 'is_debit detects debits');
156
158
157
    $schema->storage->txn_rollback;
159
    $schema->storage->txn_rollback;
158
};
160
};
159
- 

Return to bug 20997