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

(-)a/Koha/Patron.pm (-5 / +3 lines)
Lines 1194-1208 sub old_checkouts { Link Here
1194
    return Koha::Old::Checkouts->_new_from_dbic( $old_checkouts );
1194
    return Koha::Old::Checkouts->_new_from_dbic( $old_checkouts );
1195
}
1195
}
1196
1196
1197
=head3 get_overdues
1197
=head3 overdues
1198
1198
1199
my $overdue_items = $patron->get_overdues
1199
my $overdue_items = $patron->overdues
1200
1200
1201
Return the overdue items
1201
Return the overdue items
1202
1202
1203
=cut
1203
=cut
1204
1204
1205
sub get_overdues {
1205
sub overdues {
1206
    my ($self) = @_;
1206
    my ($self) = @_;
1207
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
1207
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
1208
    return $self->checkouts->search(
1208
    return $self->checkouts->search(
Lines 1215-1222 sub get_overdues { Link Here
1215
    );
1215
    );
1216
}
1216
}
1217
1217
1218
sub overdues { my $self = shift; return $self->get_overdues(@_); }
1219
1220
=head3 get_routing_lists
1218
=head3 get_routing_lists
1221
1219
1222
my $routinglists = $patron->get_routing_lists
1220
my $routinglists = $patron->get_routing_lists
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 241-247 if ($patron) { Link Here
241
    $template->param( borrowernumber => $patron->borrowernumber );
241
    $template->param( borrowernumber => $patron->borrowernumber );
242
    output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
242
    output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
243
243
244
    my $overdues = $patron->get_overdues;
244
    my $overdues = $patron->overdues;
245
    my $issues = $patron->checkouts;
245
    my $issues = $patron->checkouts;
246
    $balance = $patron->account->balance;
246
    $balance = $patron->account->balance;
247
247
(-)a/members/print_overdues.pl (-1 / +1 lines)
Lines 49-55 my $patron = Koha::Patrons->find( $borrowernumber ); Link Here
49
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
49
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
50
50
51
my $overdues = [
51
my $overdues = [
52
    map { $_->unblessed_all_relateds } $patron->get_overdues->as_list
52
    map { $_->unblessed_all_relateds } $patron->overdues->as_list
53
];
53
];
54
54
55
my $letter = parse_overdues_letter(
55
my $letter = parse_overdues_letter(
(-)a/t/db_dependent/Koha/Object.t (-1 / +1 lines)
Lines 871-877 subtest 'unblessed_all_relateds' => sub { Link Here
871
    );
871
    );
872
872
873
    my $issue = AddIssue( $patron->unblessed, $item->barcode, DateTime->now->subtract( days => 1 ) );
873
    my $issue = AddIssue( $patron->unblessed, $item->barcode, DateTime->now->subtract( days => 1 ) );
874
    my $overdues = Koha::Patrons->find( $patron->id )->get_overdues; # Koha::Patron->get_overdue prefetches
874
    my $overdues = Koha::Patrons->find( $patron->id )->overdues; # Koha::Patron->overdues prefetches
875
    my $overdue = $overdues->next->unblessed_all_relateds;
875
    my $overdue = $overdues->next->unblessed_all_relateds;
876
    is( $overdue->{issue_id}, $issue->issue_id, 'unblessed_all_relateds has field from the original table (issues)' );
876
    is( $overdue->{issue_id}, $issue->issue_id, 'unblessed_all_relateds has field from the original table (issues)' );
877
    is( $overdue->{title}, $biblio->title, 'unblessed_all_relateds has field from other tables (biblio)' );
877
    is( $overdue->{title}, $biblio->title, 'unblessed_all_relateds has field from other tables (biblio)' );
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +5 lines)
Lines 558-564 subtest 'add_enrolment_fee_if_needed' => sub { Link Here
558
    $patron->delete;
558
    $patron->delete;
559
};
559
};
560
560
561
subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub {
561
subtest 'checkouts + pending_checkouts + overdues + old_checkouts' => sub {
562
    plan tests => 17;
562
    plan tests => 17;
563
563
564
    my $library = $builder->build( { source => 'Branch' } );
564
    my $library = $builder->build( { source => 'Branch' } );
Lines 620-628 subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { Link Here
620
    my $first_checkout = $pending_checkouts->next;
620
    my $first_checkout = $pending_checkouts->next;
621
    is( $first_checkout->unblessed_all_relateds->{biblionumber}, $item_3->biblionumber, 'pending_checkouts should prefetch values from other tables (here biblio)' );
621
    is( $first_checkout->unblessed_all_relateds->{biblionumber}, $item_3->biblionumber, 'pending_checkouts should prefetch values from other tables (here biblio)' );
622
622
623
    my $overdues = $patron->get_overdues;
623
    my $overdues = $patron->overdues;
624
    is( $overdues->count, 2, 'Patron should have 2 overdues');
624
    is( $overdues->count, 2, 'Patron should have 2 overdues');
625
    is( ref($overdues), 'Koha::Checkouts', 'Koha::Patron->get_overdues should return Koha::Checkouts' );
625
    is( ref($overdues), 'Koha::Checkouts', 'Koha::Patron->overdues should return Koha::Checkouts' );
626
    is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' );
626
    is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' );
627
    is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' );
627
    is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' );
628
628
Lines 1419-1425 subtest 'is_child | is_adult' => sub { Link Here
1419
    $patron_other->delete;
1419
    $patron_other->delete;
1420
};
1420
};
1421
1421
1422
subtest 'get_overdues' => sub {
1422
subtest 'overdues' => sub {
1423
    plan tests => 7;
1423
    plan tests => 7;
1424
1424
1425
    my $library = $builder->build( { source => 'Branch' } );
1425
    my $library = $builder->build( { source => 'Branch' } );
Lines 1456-1462 subtest 'get_overdues' => sub { Link Here
1456
    AddIssue( $patron, $item_3->barcode );
1456
    AddIssue( $patron, $item_3->barcode );
1457
1457
1458
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
1458
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
1459
    my $overdues = $patron->get_overdues;
1459
    my $overdues = $patron->overdues;
1460
    is( $overdues->count, 2, 'Patron should have 2 overdues');
1460
    is( $overdues->count, 2, 'Patron should have 2 overdues');
1461
    is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' );
1461
    is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' );
1462
    is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' );
1462
    is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' );
1463
- 

Return to bug 30420