1 package Koha::Checkouts::Renewal;
3 # Copyright PTFS Europe 2022
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use base qw(Koha::Object);
25 use Koha::Exceptions::Checkouts::Renewals;
26 use Koha::Exceptions::Object;
27 use Koha::Old::Checkouts;
32 Koha::Checkouts::Renewal - Koha Renewal object class
42 my $return_claim = Koha::Checkout::Renewal->new($args)->store;
44 Overloaded I<store> method that validates the attributes and raises relevant
52 unless ( $self->in_storage || $self->renewer_id ) {
53 Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw();
56 unless ( ( !$self->checkout_id && $self->in_storage )
57 || Koha::Checkouts->find( $self->checkout_id )
58 || Koha::Old::Checkouts->find( $self->checkout_id ) )
60 Koha::Exceptions::Object::FKConstraint->throw(
61 error => 'Broken FK constraint',
62 broken_fk => 'checkout_id'
66 return $self->SUPER::store;
76 my $checkout_rs = $self->_result->checkout;
77 return unless $checkout_rs;
78 return Koha::Checkout->_new_from_dbic($checkout_rs);
88 my $old_checkout_rs = $self->_result->old_checkout;
89 return unless $old_checkout_rs;
90 return Koha::Old::Checkout->_new_from_dbic($old_checkout_rs);
100 my $renewer = $self->_result->renewer;
101 return Koha::Patron->_new_from_dbic( $renewer ) if $renewer;
104 =head2 Internal methods
111 return 'CheckoutRenewal';
116 Martin Renvoize <martin.renvoize@ptfs-europe.com>