From 690fda171931bf3b53b2f4b0f9a5b36afbfffed3 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Fri, 13 Sep 2024 13:56:42 +0200 Subject: [PATCH] Bug 37892: (follow-up) Fix patron creation This patch fixes the 22. of the test plan (22 - Confirm you cannot add a guarantor - "Guarantor cannot be a guarantee" ) --- Koha/Patron.pm | 12 ++++++++++++ members/memberentry.pl | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 9a897ae..7b94aef 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -533,6 +533,18 @@ sub guarantor_relationships { return Koha::Patron::Relationships->search( { guarantee_id => $self->id } ); } +=head3 is_guarantee + +Returns true if the patron has a guarantor. + +=cut + +sub is_guarantee { + my ($self) = @_; + return $self->guarantor_relationships()->count() +} + + =head3 guarantee_relationships Returns Koha::Patron::Relationships object for this patron's guarantors diff --git a/members/memberentry.pl b/members/memberentry.pl index e0950e6..6d18fd0 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -285,7 +285,7 @@ if ( ( $op eq 'cud-save' || $op eq 'cud-insert' ) } foreach my $guarantor (@guarantors) { - if ( ( $op eq 'cud-save' || $op eq 'cud-insert' ) && $guarantor->is_child ) { + if ( ( $op eq 'cud-save' || $op eq 'cud-insert' ) && ($guarantor->is_child ) || $guarantor->is_guarantee) { push @errors, 'ERROR_guarantor_is_guarantee'; } } -- 2.43.0