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

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

Return to bug 19489