|
Line 0
Link Here
|
|
|
1 |
package Koha::Patron::Quota::Usage; |
| 2 |
|
| 3 |
use base qw(Koha::Object); |
| 4 |
use Modern::Perl; |
| 5 |
use Koha::Patron::Quota; |
| 6 |
use Koha::Patron::Quota::Usages; |
| 7 |
|
| 8 |
=head1 NAME |
| 9 |
|
| 10 |
Koha::Patron::Quota::Usage - Koha Patron Quota Usage Object class |
| 11 |
|
| 12 |
=head1 API |
| 13 |
|
| 14 |
=head2 Class methods |
| 15 |
|
| 16 |
=cut |
| 17 |
|
| 18 |
=head3 patron |
| 19 |
|
| 20 |
Returns the patron this quota usage belongs to |
| 21 |
|
| 22 |
=cut |
| 23 |
|
| 24 |
sub patron { |
| 25 |
my ($self) = @_; |
| 26 |
my $rs = $self->_result->patron; |
| 27 |
return Koha::Patron->_new_from_dbic($rs); |
| 28 |
} |
| 29 |
|
| 30 |
=head3 quota |
| 31 |
|
| 32 |
Returns the quota this usage belongs to |
| 33 |
|
| 34 |
=cut |
| 35 |
|
| 36 |
sub quota { |
| 37 |
my ($self) = @_; |
| 38 |
my $rs = $self->_result->patron_quota; |
| 39 |
return Koha::Patron::Quota->_new_from_dbic($rs); |
| 40 |
} |
| 41 |
|
| 42 |
=head3 store |
| 43 |
|
| 44 |
Overloaded I<store> method to set implement issue_id foreign key in code |
| 45 |
|
| 46 |
=cut |
| 47 |
|
| 48 |
sub store { |
| 49 |
my ($self) = @_; |
| 50 |
|
| 51 |
# Check that we have a valid issue_id |
| 52 |
unless ( !$self->issue_id |
| 53 |
|| Koha::Checkouts->find( $self->issue_id ) |
| 54 |
|| Koha::Old::Checkouts->find( $self->issue_id ) ) |
| 55 |
{ |
| 56 |
Koha::Exceptions::Object::FKConstraint->throw( |
| 57 |
error => 'Broken FK Contraint', |
| 58 |
broken_fk => 'issue_id' |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
return $self->SUPER::store(); |
| 63 |
} |
| 64 |
|
| 65 |
=head2 Internal methods |
| 66 |
|
| 67 |
=head3 _type |
| 68 |
|
| 69 |
=cut |
| 70 |
|
| 71 |
sub _type { |
| 72 |
return 'PatronQuotaUsage'; |
| 73 |
} |
| 74 |
|
| 75 |
1; |