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

(-)a/Koha/Old/Checkout.pm (+1 lines)
Lines 54-59 Return the patron for who the checkout has been done Link Here
54
sub patron {
54
sub patron {
55
    my ( $self ) = @_;
55
    my ( $self ) = @_;
56
    my $patron_rs = $self->_result->borrower;
56
    my $patron_rs = $self->_result->borrower;
57
    return unless $patron_rs;
57
    return Koha::Patron->_new_from_dbic( $patron_rs );
58
    return Koha::Patron->_new_from_dbic( $patron_rs );
58
}
59
}
59
60
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt (-1 / +5 lines)
Lines 48-54 Link Here
48
        [% FOREACH checkout IN checkouts %]
48
        [% FOREACH checkout IN checkouts %]
49
            <tr>
49
            <tr>
50
                [% IF show_patron_column %]
50
                [% IF show_patron_column %]
51
                <td>[% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]</td>
51
                    <td>
52
                        [% IF checkout.patron %][%# Not set for deleted patron records %]
53
                            [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]
54
                        [% END %]
55
                    </td>
52
                [% END %]
56
                [% END %]
53
                <td>
57
                <td>
54
                    [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %]
58
                    [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %]
(-)a/t/db_dependent/Koha/Checkouts.t (-5 / +26 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 7;
23
23
24
use C4::Circulation;
24
use Koha::Checkouts;
25
use Koha::Checkouts;
25
use Koha::Database;
26
use Koha::Database;
26
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
Lines 94-103 subtest 'item' => sub { Link Here
94
};
95
};
95
96
96
subtest 'patron' => sub {
97
subtest 'patron' => sub {
97
    plan tests => 2;
98
    plan tests => 3;
98
    my $p = $new_checkout_1->patron;
99
    my $patron = $builder->build_object({class=>'Koha::Patrons', value => {branchcode => $library->{branchcode}}});
99
    is( ref($p), 'Koha::Patron', 'Koha::Checkout->patron should return a Koha::Patron' );
100
100
    is( $p->borrowernumber, $patron->{borrowernumber}, 'Koha::Checkout->patron should return the correct patron' );
101
    my $item = $builder->build_object( { class=> 'Koha::Items' } );
102
    my $checkout = Koha::Checkout->new(
103
        {   borrowernumber => $patron->borrowernumber,
104
            itemnumber     => $item->itemnumber,
105
            branchcode     => $library->{branchcode},
106
        }
107
    )->store;
108
109
    my $p = $checkout->patron;
110
    is( ref($p), 'Koha::Patron',
111
        'Koha::Checkout->patron should return a Koha::Patron' );
112
    is( $p->borrowernumber, $patron->borrowernumber,
113
        'Koha::Checkout->patron should return the correct patron' );
114
115
    # Testing Koha::Old::Checkout->patron now
116
    my $issue_id = $checkout->issue_id;
117
    C4::Circulation::MarkIssueReturned( $p->borrowernumber, $checkout->itemnumber );
118
    $p->delete;
119
    my $old_issue = Koha::Old::Checkouts->find($issue_id);
120
    is( $old_issue->patron, undef,
121
        'Koha::Checkout->patron should return undef if the patron record has been deleted'
122
    );
101
};
123
};
102
124
103
$retrieved_checkout_1->delete;
125
$retrieved_checkout_1->delete;
104
- 

Return to bug 21432