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

(-)a/Koha/Checkout.pm (-29 / +30 lines)
Lines 59-67 sub is_overdue { Link Here
59
    $dt ||= dt_from_string();
59
    $dt ||= dt_from_string();
60
60
61
    my $is_overdue =
61
    my $is_overdue =
62
      DateTime->compare( dt_from_string( $self->date_due, 'sql' ), $dt ) == -1
62
        DateTime->compare( dt_from_string( $self->date_due, 'sql' ), $dt ) == -1
63
      ? 1
63
        ? 1
64
      : 0;
64
        : 0;
65
    return $is_overdue;
65
    return $is_overdue;
66
}
66
}
67
67
Lines 74-82 Return the checked out item Link Here
74
=cut
74
=cut
75
75
76
sub item {
76
sub item {
77
    my ( $self ) = @_;
77
    my ($self) = @_;
78
    my $item_rs = $self->_result->item;
78
    my $item_rs = $self->_result->item;
79
    return Koha::Item->_new_from_dbic( $item_rs );
79
    return Koha::Item->_new_from_dbic($item_rs);
80
}
80
}
81
81
82
=head3 account_lines
82
=head3 account_lines
Lines 88-96 Return the checked out account_lines Link Here
88
=cut
88
=cut
89
89
90
sub account_lines {
90
sub account_lines {
91
    my ( $self ) = @_;
91
    my ($self) = @_;
92
    my $account_lines_rs = $self->_result->account_lines;
92
    my $account_lines_rs = $self->_result->account_lines;
93
    return Koha::Account::Lines->_new_from_dbic( $account_lines_rs );
93
    return Koha::Account::Lines->_new_from_dbic($account_lines_rs);
94
}
94
}
95
95
96
=head3 overdue_fines
96
=head3 overdue_fines
Lines 102-110 Return the account lines for just the overdue fines Link Here
102
=cut
102
=cut
103
103
104
sub overdue_fines {
104
sub overdue_fines {
105
    my ( $self ) = @_;
105
    my ($self) = @_;
106
    my $account_lines_rs = $self->_result->account_lines->search( { debit_type_code => 'OVERDUE' } );
106
    my $account_lines_rs = $self->_result->account_lines->search( { debit_type_code => 'OVERDUE' } );
107
    return Koha::Account::Lines->_new_from_dbic( $account_lines_rs );
107
    return Koha::Account::Lines->_new_from_dbic($account_lines_rs);
108
}
108
}
109
109
110
=head3 library
110
=head3 library
Lines 116-124 Return the library in which the transaction took place Link Here
116
=cut
116
=cut
117
117
118
sub library {
118
sub library {
119
    my ( $self ) = @_;
119
    my ($self) = @_;
120
    my $library_rs = $self->_result->library;
120
    my $library_rs = $self->_result->library;
121
    return Koha::Library->_new_from_dbic( $library_rs );
121
    return Koha::Library->_new_from_dbic($library_rs);
122
}
122
}
123
123
124
=head3 patron
124
=head3 patron
Lines 130-138 Return the patron for who the checkout has been done Link Here
130
=cut
130
=cut
131
131
132
sub patron {
132
sub patron {
133
    my ( $self ) = @_;
133
    my ($self) = @_;
134
    my $patron_rs = $self->_result->patron;
134
    my $patron_rs = $self->_result->patron;
135
    return Koha::Patron->_new_from_dbic( $patron_rs );
135
    return Koha::Patron->_new_from_dbic($patron_rs);
136
}
136
}
137
137
138
=head3 issuer
138
=head3 issuer
Lines 144-153 Return the patron by whom the checkout was done Link Here
144
=cut
144
=cut
145
145
146
sub issuer {
146
sub issuer {
147
    my ( $self ) = @_;
147
    my ($self) = @_;
148
    my $issuer_rs = $self->_result->issuer;
148
    my $issuer_rs = $self->_result->issuer;
149
    return unless $issuer_rs;
149
    return unless $issuer_rs;
150
    return Koha::Patron->_new_from_dbic( $issuer_rs );
150
    return Koha::Patron->_new_from_dbic($issuer_rs);
151
}
151
}
152
152
153
=head3 renewals
153
=head3 renewals
Lines 159-168 Return a Koha::Checkouts::Renewals set attached to this checkout Link Here
159
=cut
159
=cut
160
160
161
sub renewals {
161
sub renewals {
162
    my ( $self ) = @_;
162
    my ($self) = @_;
163
    my $renewals_rs = $self->_result->renewals;
163
    my $renewals_rs = $self->_result->renewals;
164
    return unless $renewals_rs;
164
    return unless $renewals_rs;
165
    return Koha::Checkouts::Renewals->_new_from_dbic( $renewals_rs );
165
    return Koha::Checkouts::Renewals->_new_from_dbic($renewals_rs);
166
}
166
}
167
167
168
=head3 attempt_auto_renew
168
=head3 attempt_auto_renew
Lines 276-303 sub claim_returned { Link Here
276
276
277
                my $ClaimReturnedChargeFee = C4::Context->preference('ClaimReturnedChargeFee');
277
                my $ClaimReturnedChargeFee = C4::Context->preference('ClaimReturnedChargeFee');
278
                $charge_lost_fee =
278
                $charge_lost_fee =
279
                    $ClaimReturnedChargeFee eq 'charge'    ? 1
279
                      $ClaimReturnedChargeFee eq 'charge'    ? 1
280
                : $ClaimReturnedChargeFee eq 'no_charge' ? 0
280
                    : $ClaimReturnedChargeFee eq 'no_charge' ? 0
281
                :   $charge_lost_fee;    # $ClaimReturnedChargeFee eq 'ask'
281
                    :                                          $charge_lost_fee;    # $ClaimReturnedChargeFee eq 'ask'
282
282
283
                if ( $charge_lost_fee ) {
283
                if ($charge_lost_fee) {
284
                    C4::Circulation::LostItem( $self->itemnumber, 'claim_returned' );
284
                    C4::Circulation::LostItem( $self->itemnumber, 'claim_returned' );
285
                }
285
                } elsif ( C4::Context->preference('MarkLostItemsAsReturned') =~ m/claim_returned/ ) {
286
                elsif ( C4::Context->preference( 'MarkLostItemsAsReturned' ) =~ m/claim_returned/ ) {
286
                    C4::Circulation::MarkIssueReturned(
287
                    C4::Circulation::MarkIssueReturned( $self->borrowernumber, $self->itemnumber, undef, $self->patron->privacy );
287
                        $self->borrowernumber, $self->itemnumber, undef,
288
                        $self->patron->privacy
289
                    );
288
                }
290
                }
289
291
290
                return $claim;
292
                return $claim;
291
            }
293
            }
292
        );
294
        );
293
    }
295
    } catch {
294
    catch {
295
        if ( $_->isa('Koha::Exception') ) {
296
        if ( $_->isa('Koha::Exception') ) {
296
            $_->rethrow();
297
            $_->rethrow();
297
        }
298
        } else {
298
        else {
299
299
            # ?
300
            # ?
300
            Koha::Exception->throw( "Unhandled exception" );
301
            Koha::Exception->throw("Unhandled exception");
301
        }
302
        }
302
    };
303
    };
303
}
304
}
(-)a/t/db_dependent/Koha/Checkout.t (-18 / +15 lines)
Lines 67-79 subtest 'overdue_fines' => sub { Link Here
67
    )->store();
67
    )->store();
68
68
69
    my $overdue_fines = $checkout->overdue_fines;
69
    my $overdue_fines = $checkout->overdue_fines;
70
    is( ref($overdue_fines), 'Koha::Account::Lines',
70
    is(
71
        'Koha::Checkout->overdue_fines should return a Koha::Account::Lines' );
71
        ref($overdue_fines), 'Koha::Account::Lines',
72
    is( $overdue_fines->count, 1, "Koha::Checkout->overdue_fines returns only overdue fines");
72
        'Koha::Checkout->overdue_fines should return a Koha::Account::Lines'
73
    );
74
    is( $overdue_fines->count, 1, "Koha::Checkout->overdue_fines returns only overdue fines" );
73
75
74
    my $overdue = $overdue_fines->next;
76
    my $overdue = $overdue_fines->next;
75
    is( ref($overdue), 'Koha::Account::Line',
77
    is(
76
        'next returns a Koha::Account::Line' );
78
        ref($overdue), 'Koha::Account::Line',
79
        'next returns a Koha::Account::Line'
80
    );
77
81
78
    is(
82
    is(
79
        $overdueline->id,
83
        $overdueline->id,
Lines 88-104 subtest 'library() tests' => sub { Link Here
88
92
89
    $schema->storage->txn_begin;
93
    $schema->storage->txn_begin;
90
94
91
    my $library  = $builder->build_object({ class => 'Koha::Libraries' });
95
    my $library  = $builder->build_object( { class => 'Koha::Libraries' } );
92
    my $checkout = $builder->build_object(
96
    my $checkout = $builder->build_object(
93
        {
97
        {
94
            class => 'Koha::Checkouts',
98
            class => 'Koha::Checkouts',
95
            value => {
99
            value => { branchcode => $library->branchcode }
96
                branchcode => $library->branchcode
97
            }
98
        }
100
        }
99
    );
101
    );
100
102
101
    is( ref($checkout->library), 'Koha::Library', 'Object type is correct' );
103
    is( ref( $checkout->library ),      'Koha::Library',      'Object type is correct' );
102
    is( $checkout->library->branchcode, $library->branchcode, 'Right library linked' );
104
    is( $checkout->library->branchcode, $library->branchcode, 'Right library linked' );
103
105
104
    $schema->storage->txn_rollback;
106
    $schema->storage->txn_rollback;
Lines 109-119 subtest 'renewals() tests' => sub { Link Here
109
    plan tests => 2;
111
    plan tests => 2;
110
    $schema->storage->txn_begin;
112
    $schema->storage->txn_begin;
111
113
112
    my $checkout = $builder->build_object(
114
    my $checkout = $builder->build_object( { class => 'Koha::Checkouts' } );
113
        {
114
            class => 'Koha::Checkouts'
115
        }
116
    );
117
    my $renewal1 = $builder->build_object(
115
    my $renewal1 = $builder->build_object(
118
        {
116
        {
119
            class => 'Koha::Checkouts::Renewals',
117
            class => 'Koha::Checkouts::Renewals',
Lines 127-134 subtest 'renewals() tests' => sub { Link Here
127
        }
125
        }
128
    );
126
    );
129
127
130
    is( ref($checkout->renewals), 'Koha::Checkouts::Renewals', 'Object set type is correct' );
128
    is( ref( $checkout->renewals ), 'Koha::Checkouts::Renewals', 'Object set type is correct' );
131
    is( $checkout->renewals->count, 2, "Count of renewals is correct" );
129
    is( $checkout->renewals->count, 2,                           "Count of renewals is correct" );
132
130
133
    $schema->storage->txn_rollback;
131
    $schema->storage->txn_rollback;
134
};
132
};
135
- 

Return to bug 17976