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::Object;
26 use Koha::Old::Checkouts;
31 Koha::Checkouts::Renewal - Koha Renewal object class
41 my $renewal = Koha::Checkout::Renewal->new($args)->store;
43 Overloaded I<store> method that validates the attributes and raises relevant
51 unless ( ( !$self->checkout_id && $self->in_storage )
52 || Koha::Checkouts->find( $self->checkout_id )
53 || Koha::Old::Checkouts->find( $self->checkout_id ) )
55 Koha::Exceptions::Object::FKConstraint->throw(
56 error => 'Broken FK constraint',
57 broken_fk => 'checkout_id'
61 return $self->SUPER::store;
71 my $checkout_rs = $self->_result->checkout;
72 return unless $checkout_rs;
73 return Koha::Checkout->_new_from_dbic($checkout_rs);
83 my $old_checkout_rs = $self->_result->old_checkout;
84 return unless $old_checkout_rs;
85 return Koha::Old::Checkout->_new_from_dbic($old_checkout_rs);
95 my $renewer = $self->_result->renewer;
96 return Koha::Patron->_new_from_dbic( $renewer ) if $renewer;
99 =head2 Internal methods
106 return 'CheckoutRenewal';
111 Martin Renvoize <martin.renvoize@ptfs-europe.com>