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

(-)a/Koha/Patron.pm (-3 / +13 lines)
Lines 449-454 sub add_enrolment_fee_if_needed { Link Here
449
    return $enrolment_fee || 0;
449
    return $enrolment_fee || 0;
450
}
450
}
451
451
452
=head3 get_issues
453
454
my $issues = $patron->get_issues
455
456
=cut
457
458
sub get_issues {
459
    my ($self) = @_;
460
    my $issues = $self->_result->issues;
461
    return Koha::Issues->_new_from_dbic( $issues );
462
}
463
452
=head3 get_overdues
464
=head3 get_overdues
453
465
454
my $overdue_items = $patron->get_overdues
466
my $overdue_items = $patron->get_overdues
Lines 460-475 Return the overdued items Link Here
460
sub get_overdues {
472
sub get_overdues {
461
    my ($self) = @_;
473
    my ($self) = @_;
462
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
474
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
463
    my $issues = Koha::Issues->search(
475
    return $self->get_issues->search(
464
        {
476
        {
465
            'me.borrowernumber' => $self->borrowernumber,
466
            'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) },
477
            'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) },
467
        },
478
        },
468
        {
479
        {
469
            prefetch => { item => { biblio => 'biblioitems' } },
480
            prefetch => { item => { biblio => 'biblioitems' } },
470
        }
481
        }
471
    );
482
    );
472
    return $issues;
473
}
483
}
474
484
475
=head3 type
485
=head3 type
(-)a/t/db_dependent/Koha/Patrons.t (-4 / +12 lines)
Lines 516-523 subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { Link Here
516
    Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete;
516
    Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete;
517
};
517
};
518
518
519
subtest 'get_overdues' => sub {
519
subtest 'get_issues + get_overdues' => sub {
520
    plan tests => 4;
520
    plan tests => 8;
521
521
522
    my $library = $builder->build( { source => 'Branch' } );
522
    my $library = $builder->build( { source => 'Branch' } );
523
    my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
523
    my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
Lines 559-566 subtest 'get_overdues' => sub { Link Here
559
        }
559
        }
560
    );
560
    );
561
561
562
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
563
    my $issues = $patron->get_issues;
564
    is( $issues->count, 0, 'get_issues should not return any issues for that patron' );
565
    is( ref($issues), 'Koha::Issues', 'get_issues should return a Koha::Issues object' );
566
562
    # Not sure how this is useful, but AddIssue pass this variable to different other subroutines
567
    # Not sure how this is useful, but AddIssue pass this variable to different other subroutines
563
    $patron = GetMember( borrowernumber => $patron->{borrowernumber} );
568
    $patron = GetMember( borrowernumber => $patron->borrowernumber );
564
569
565
    my $module = new Test::MockModule('C4::Context');
570
    my $module = new Test::MockModule('C4::Context');
566
    $module->mock( 'userenv', sub { { branch => $library->{branchcode} } } );
571
    $module->mock( 'userenv', sub { { branch => $library->{branchcode} } } );
Lines 570-575 subtest 'get_overdues' => sub { Link Here
570
    AddIssue( $patron, $item_3->{barcode} );
575
    AddIssue( $patron, $item_3->{barcode} );
571
576
572
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
577
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
578
    $issues = $patron->get_issues;
579
    is( $issues->count, 3, 'get_issues should return 3 issues for that patron' );
580
    is( ref($issues), 'Koha::Issues', 'get_issues should return a Koha::Issues object' );
581
573
    my $overdues = $patron->get_overdues;
582
    my $overdues = $patron->get_overdues;
574
    is( $overdues->count, 2, 'Patron should have 2 overdues');
583
    is( $overdues->count, 2, 'Patron should have 2 overdues');
575
    is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' );
584
    is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' );
576
- 

Return to bug 17584