From 077a13fc1b8a823bad9993cf90a9976a2c0ccb5a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 26 Apr 2022 15:56:45 +0100 Subject: [PATCH] Bug 30275: Add renewals relation to Koha::Old::Checkout Add the new 'renewals' relation to Koha::Old::Checkout to return a list of Koha::Checkouts::Renewal objects. We also add the same relation to the OldIssue schema inline. Signed-off-by: Owen Leonard Signed-off-by: Tomas Cohen Arazi --- Koha/Old/Checkout.pm | 15 +++++++++++++++ Koha/Schema/Result/OldIssue.pm | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm index e4cd9989f1..ab958985e7 100644 --- a/Koha/Old/Checkout.pm +++ b/Koha/Old/Checkout.pm @@ -90,6 +90,21 @@ sub issuer { return Koha::Patron->_new_from_dbic( $issuer_rs ); } +=head3 renewals + + my $renewals = $checkout->renewals; + +Return a Koha::Checkouts::Renewals set attached to this checkout + +=cut + +sub renewals { + my ( $self ) = @_; + my $renewals_rs = $self->_result->renewals; + return unless $renewals_rs; + return Koha::Checkouts::Renewals->_new_from_dbic( $renewals_rs ); +} + =head3 anonymize $checkout->anonymize(); diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm index c01e207d55..1383033d31 100644 --- a/Koha/Schema/Result/OldIssue.pm +++ b/Koha/Schema/Result/OldIssue.pm @@ -343,6 +343,21 @@ __PACKAGE__->belongs_to( }, ); +=head2 renewals + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "renewals", + "Koha::Schema::Result::CheckoutRenewal", + { "foreign.issue_id" => "self.issue_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 return_claim Type: might_have -- 2.20.1