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

(-)a/Koha/Patron.pm (-4 / +4 lines)
Lines 501-513 sub add_enrolment_fee_if_needed { Link Here
501
    return $enrolment_fee || 0;
501
    return $enrolment_fee || 0;
502
}
502
}
503
503
504
=head3 get_checkouts
504
=head3 checkouts
505
505
506
my $issues = $patron->get_checkouts
506
my $issues = $patron->checkouts
507
507
508
=cut
508
=cut
509
509
510
sub get_checkouts {
510
sub checkouts {
511
    my ($self) = @_;
511
    my ($self) = @_;
512
    my $issues = $self->_result->issues;
512
    my $issues = $self->_result->issues;
513
    return Koha::Checkouts->_new_from_dbic( $issues );
513
    return Koha::Checkouts->_new_from_dbic( $issues );
Lines 524-530 Return the overdued items Link Here
524
sub get_overdues {
524
sub get_overdues {
525
    my ($self) = @_;
525
    my ($self) = @_;
526
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
526
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
527
    return $self->get_checkouts->search(
527
    return $self->checkouts->search(
528
        {
528
        {
529
            'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) },
529
            'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) },
530
        },
530
        },
(-)a/t/db_dependent/Koha/Patrons.t (-8 / +7 lines)
Lines 412-418 subtest 'add_enrolment_fee_if_needed' => sub { Link Here
412
    $patron->delete;
412
    $patron->delete;
413
};
413
};
414
414
415
subtest 'get_checkouts + get_overdues' => sub {
415
subtest 'checkouts + get_overdues' => sub {
416
    plan tests => 8;
416
    plan tests => 8;
417
417
418
    my $library = $builder->build( { source => 'Branch' } );
418
    my $library = $builder->build( { source => 'Branch' } );
Lines 456-464 subtest 'get_checkouts + get_overdues' => sub { Link Here
456
    );
456
    );
457
457
458
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
458
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
459
    my $checkouts = $patron->get_checkouts;
459
    my $checkouts = $patron->checkouts;
460
    is( $checkouts->count, 0, 'get_checkouts should not return any issues for that patron' );
460
    is( $checkouts->count, 0, 'checkouts should not return any issues for that patron' );
461
    is( ref($checkouts), 'Koha::Checkouts', 'get_checkouts should return a Koha::Checkouts object' );
461
    is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' );
462
462
463
    # Not sure how this is useful, but AddIssue pass this variable to different other subroutines
463
    # Not sure how this is useful, but AddIssue pass this variable to different other subroutines
464
    $patron = GetMember( borrowernumber => $patron->borrowernumber );
464
    $patron = GetMember( borrowernumber => $patron->borrowernumber );
Lines 471-479 subtest 'get_checkouts + get_overdues' => sub { Link Here
471
    AddIssue( $patron, $item_3->{barcode} );
471
    AddIssue( $patron, $item_3->{barcode} );
472
472
473
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
473
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
474
    $checkouts = $patron->get_checkouts;
474
    $checkouts = $patron->checkouts;
475
    is( $checkouts->count, 3, 'get_checkouts should return 3 issues for that patron' );
475
    is( $checkouts->count, 3, 'checkouts should return 3 issues for that patron' );
476
    is( ref($checkouts), 'Koha::Checkouts', 'get_checkouts should return a Koha::Checkouts object' );
476
    is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' );
477
477
478
    my $overdues = $patron->get_overdues;
478
    my $overdues = $patron->get_overdues;
479
    is( $overdues->count, 2, 'Patron should have 2 overdues');
479
    is( $overdues->count, 2, 'Patron should have 2 overdues');
480
- 

Return to bug 17584