From cefbaca5914f4e8a4366b29376af9a7b98583afd 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.39.5