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

(-)a/Koha/Account/Line.pm (+15 lines)
Lines 54-59 sub item { Link Here
54
    return Koha::Item->_new_from_dbic( $rs );
54
    return Koha::Item->_new_from_dbic( $rs );
55
}
55
}
56
56
57
=head3 issue
58
59
Return the item linked to this account line if exists
60
61
=cut
62
63
sub issue {
64
    my ( $self ) = @_;
65
    return unless $self->issue_id ;
66
67
    my $issue = Koha::Checkouts->find( $self->issue_id );
68
    $issue = Koha::Old::Checkouts->find( $self->issue_id ) unless $issue;
69
    return $issue;
70
}
71
57
=head3 void
72
=head3 void
58
73
59
$payment_accountline->void();
74
$payment_accountline->void();
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +42 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 6;
22
use Test::More tests => 7;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Account;
25
use Koha::Account;
Lines 414-417 subtest 'adjust() tests' => sub { Link Here
414
    $schema->storage->txn_rollback;
414
    $schema->storage->txn_rollback;
415
};
415
};
416
416
417
subtest 'issue() tests' => sub {
418
    plan tests => 6;
419
420
    $schema->storage->txn_begin;
421
422
    my $library = $builder->build( { source => 'Branch' } );
423
    my $patron = $builder->build( { source => 'Borrower' } );
424
    my $item = $builder->build( { source => 'Item' } );
425
426
    my $checkout = Koha::Checkout->new(
427
        {   borrowernumber => $patron->{borrowernumber},
428
            itemnumber     => $item->{itemnumber},
429
            branchcode     => $library->{branchcode},
430
        })->store;
431
432
    my $line = Koha::Account::Line->new(
433
        {
434
            borrowernumber  => $patron->{borrowernumber},
435
            itemnumber      => $item->{itemnumber},
436
            issue_id        => $checkout->issue_id,
437
            accounttype     => "F",
438
            amount          => 10,
439
        })->store;
440
441
    my $line_issue = $line->issue;
442
    is( ref($line_issue), 'Koha::Checkout', 'Result type is correct' );
443
    is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue');
444
445
    my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} );
446
    is( $returned, 1, 'The item should have been returned' );
447
448
    my $old_line_issue = $line->issue;
449
    is( ref($old_line_issue), 'Koha::Old::Checkout', 'Result type is correct' );
450
    is( $old_line_issue->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' );
451
452
    $line->issue_id(undef)->store;
453
    is( $line->issue, undef, 'Koha::Account::Line->issue should return undef if no issue linked' );
454
455
    $schema->storage->txn_rollback;
456
};
457
417
1;
458
1;
418
- 

Return to bug 19489