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

(-)a/Koha/Account/Line.pm (-5 / +7 lines)
Lines 61-72 Return the checkout linked to this account line if exists Link Here
61
=cut
61
=cut
62
62
63
sub checkout {
63
sub checkout {
64
    my ( $self ) = @_;
64
    my ($self) = @_;
65
    return unless $self->issue_id ;
65
    return unless ( $self->issue_id || $self->old_issue_id );
66
67
    my $issue_rs = $self->_result->issue;
68
    return Koha::Checkout->_new_from_dbic($issue_rs) if $issue_rs;
66
69
67
    $self->{_checkout} ||= Koha::Checkouts->find( $self->issue_id );
70
    my $old_issue_rs = $self->_result->old_issue;
68
    $self->{_checkout} ||= Koha::Old::Checkouts->find( $self->issue_id );
71
    return Koha::Old::Checkout->_new_from_dbic($old_issue_rs) if $old_issue_rs;
69
    return $self->{_checkout};
70
}
72
}
71
73
72
=head3 void
74
=head3 void
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +2 lines)
Lines 495-501 subtest 'checkout() tests' => sub { Link Here
495
    is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' );
495
    is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' );
496
    is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' );
496
    is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' );
497
497
498
    $line->issue_id(undef)->store;
498
    $old_line_checkout->delete;
499
    $line->discard_changes; #NOTE: discard_changes refreshes the whole resultset, get_from_storage only refreshes the unjoined row
499
    is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
500
    is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
500
501
501
    $schema->storage->txn_rollback;
502
    $schema->storage->txn_rollback;
502
- 

Return to bug 22421