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 => 5;
22
use Test::More tests => 6;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Account;
25
use Koha::Account;
Lines 298-300 subtest 'Keep account info when a patron is deleted' => sub { Link Here
298
298
299
    $schema->storage->txn_rollback;
299
    $schema->storage->txn_rollback;
300
};
300
};
301
- 
301
302
subtest 'issue() tests' => sub {
303
304
    plan tests => 5;
305
306
    $schema->storage->txn_begin;
307
308
    my $library = $builder->build( { source => 'Branch' } );
309
    my $patron = $builder->build( { source => 'Borrower' } );
310
    my $item = $builder->build( { source => 'Item' } );
311
312
    my $checkout = Koha::Checkout->new(
313
        {   borrowernumber => $patron->{borrowernumber},
314
            itemnumber     => $item->{itemnumber},
315
            branchcode     => $library->{branchcode},
316
        })->store;
317
318
    my $line = Koha::Account::Line->new(
319
        {
320
            borrowernumber  => $patron->{borrowernumber},
321
            itemnumber      => $item->{itemnumber},
322
            issue_id        => $checkout->issue_id,
323
            accounttype     => "F",
324
            amount          => 10,
325
        })->store;
326
327
    my $line_issue = $line->issue;
328
    is( ref($line_issue), 'Koha::Checkout', 'Result type is correct' );
329
    is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue');
330
331
    my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} );
332
    is( $returned, 1, 'The item should have been returned' );
333
334
    my $old_line_issue = $line->issue;
335
    is( ref($old_line_issue), 'Koha::Old::Checkout', 'Result type is correct' );
336
    is( $old_line_issue->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' );
337
338
    $schema->storage->txn_rollback;
339
};

Return to bug 19489