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

(-)a/Koha/Patron/Quota.pm (-4 / +40 lines)
Lines 1-9 Link Here
1
package Koha::Patron::Quota;
1
package Koha::Patron::Quota;
2
2
3
use base qw(Koha::Object);
3
use Modern::Perl;
4
use Modern::Perl;
4
use Koha::DateUtils qw( dt_from_string );
5
use Koha::DateUtils qw( dt_from_string );
6
use Koha::Patron::Quotas;
5
use Koha::Exceptions::Quota;
7
use Koha::Exceptions::Quota;
6
use base qw(Koha::Object);
7
8
8
=head1 NAME
9
=head1 NAME
9
10
Lines 114-121 Returns the Koha::Patron associated with this quota Link Here
114
=cut
115
=cut
115
116
116
sub patron {
117
sub patron {
117
    my ( $self ) = @_;
118
    my ($self) = @_;
118
    return Koha::Patron->_new_from_dbic($self->_result->patron);
119
    return Koha::Patron->_new_from_dbic( $self->_result->patron );
119
}
120
}
120
121
121
=head3 is_active
122
=head3 is_active
Lines 143-148 sub is_active { Link Here
143
    return ( $start <= $today && $end >= $today );
144
    return ( $start <= $today && $end >= $today );
144
}
145
}
145
146
147
=head3 usages
148
149
Returns all usage records for this quota
150
151
=cut
152
153
sub usages {
154
    my ($self) = @_;
155
    my $usages_rs = $self->_result->patron_quota_usages;
156
    return Koha::Patron::Quota::Usages->_new_from_dbic($usages_rs);
157
}
158
159
=head3 add_usage
160
161
Creates a new usage record for this quota with the specified parameters.
162
Returns the new Koha::Patron::Quota::Usage object.
163
164
=cut
165
166
sub add_usage {
167
    my ( $self, $params ) = @_;
168
169
    # Set defaults
170
    $params->{patron_id}       = $self->patron_id;
171
    $params->{patron_quota_id} = $self->id;
172
    $params->{issue_id}        = undef unless exists $params->{issue_id};
173
174
    # Create usage record
175
    my $usage = Koha::Patron::Quota::Usage->new($params)->store;
176
177
    # Update quota used amount
178
    $self->add_to_quota( $params->{amount} );
179
180
    return $usage;
181
}
182
146
=head2 Internal methods
183
=head2 Internal methods
147
184
148
=head3 _type
185
=head3 _type
149
- 

Return to bug 38924