From b80fbb2a9d88b388789f0b6c9f2839df9cba8edf Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 18 Nov 2021 07:43:44 +0000 Subject: [PATCH] [21.05.x] Bug 29495: Update relationship methods This patch updates the relationship methods found in Koha::Checkouts::ReturnClaim so that they are prefetchable and embeddable on the API. Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Tomas Cohen Arazi --- Koha/Checkouts/ReturnClaim.pm | 17 ++++++++++++++--- Koha/Schema/Result/ReturnClaim.pm | 8 ++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Koha/Checkouts/ReturnClaim.pm b/Koha/Checkouts/ReturnClaim.pm index 78341e629a..c95c099a44 100644 --- a/Koha/Checkouts/ReturnClaim.pm +++ b/Koha/Checkouts/ReturnClaim.pm @@ -72,10 +72,21 @@ sub store { sub checkout { my ($self) = @_; - my $checkout = Koha::Checkouts->find( $self->issue_id ) - || Koha::Old::Checkouts->find( $self->issue_id ); + my $checkout_rs = $self->_result->checkout; + return unless $checkout_rs; + return Koha::Checkout->_new_from_dbic($checkout_rs); +} + +=head3 old_checkout + +=cut + +sub old_checkout { + my ($self) = @_; - return $checkout; + my $old_checkout_rs = $self->_result->old_checkout; + return unless $old_checkout_rs; + return Koha::Old::Checkout->_new_from_dbic($old_checkout_rs); } =head3 patron diff --git a/Koha/Schema/Result/ReturnClaim.pm b/Koha/Schema/Result/ReturnClaim.pm index 89c6f3e114..4e2c56c40b 100644 --- a/Koha/Schema/Result/ReturnClaim.pm +++ b/Koha/Schema/Result/ReturnClaim.pm @@ -280,7 +280,7 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-17 10:01:24 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ik93SD3kLNecIyRgsBVKDQ -=head2 issue +=head2 checkout Type: belongs_to @@ -289,7 +289,7 @@ Related object: L =cut __PACKAGE__->belongs_to( - "issue", + "checkout", "Koha::Schema::Result::Issue", { issue_id => "issue_id" }, { @@ -298,7 +298,7 @@ __PACKAGE__->belongs_to( }, ); -=head2 old_issue +=head2 old_checkout Type: belongs_to @@ -307,7 +307,7 @@ Related object: L =cut __PACKAGE__->belongs_to( - "old_issue", + "old_checkout", "Koha::Schema::Result::OldIssue", { issue_id => "issue_id" }, { -- 2.35.1