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

(-)a/Koha/Account/Line.pm (+16 lines)
Lines 52-57 sub item { Link Here
52
    return Koha::Item->_new_from_dbic( $rs );
52
    return Koha::Item->_new_from_dbic( $rs );
53
}
53
}
54
54
55
=head3 issue
56
57
Return the issue linked to this account line if exists
58
59
=cut
60
61
sub issue {
62
    my ( $self ) = @_;
63
64
    return unless $self->issue_id ;
65
66
    my $issue = Koha::Checkouts->find( $self->issue_id );
67
    $issue = Koha::Old::Checkouts->find( $self->issue_id ) unless $issue;
68
    return $issue;
69
}
70
55
=head3 void
71
=head3 void
56
72
57
$payment_accountline->void();
73
$payment_accountline->void();
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +40 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Account;
25
use Koha::Account;
Lines 271-273 subtest 'apply() tests' => sub { Link Here
271
271
272
    $schema->storage->txn_rollback;
272
    $schema->storage->txn_rollback;
273
};
273
};
274
- 
274
275
subtest 'issue() tests' => sub {
276
277
    plan tests => 5;
278
279
    $schema->storage->txn_begin;
280
281
    my $library = $builder->build( { source => 'Branch' } );
282
    my $patron = $builder->build( { source => 'Borrower' } );
283
    my $item = $builder->build( { source => 'Item' } );
284
285
    my $checkout = Koha::Checkout->new(
286
        {   borrowernumber => $patron->{borrowernumber},
287
            itemnumber     => $item->{itemnumber},
288
            branchcode     => $library->{branchcode},
289
        })->store;
290
291
    my $line = Koha::Account::Line->new(
292
        {
293
            borrowernumber  => $patron->{borrowernumber},
294
            itemnumber      => $item->{itemnumber},
295
            issue_id        => $checkout->issue_id,
296
            accounttype     => "F",
297
            amount          => 10,
298
        })->store;
299
300
    my $line_issue = $line->issue;
301
    is( ref($line_issue), 'Koha::Checkout', 'Result type is correct' );
302
    is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue');
303
304
    my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} );
305
    is( $returned, 1, 'The item should have been returned' );
306
307
    my $old_line_issue = $line->issue;
308
    is( ref($old_line_issue), 'Koha::Old::Checkout', 'Result type is correct' );
309
    is( $old_line_issue->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' );
310
311
    $schema->storage->txn_rollback;
312
};

Return to bug 19489