From e52d1f521681ed20f3bfd54c2ab30c41b99f91ba Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Fri, 13 Sep 2024 16:53:20 +0200 Subject: [PATCH] Bug 37892: (follow-up) Fix patron creation TEST PLAN: 1 - Do the 22 parts of the test plan 2 - Add a guarantor to one patron not selected before (let's say A is the guarantee, B the guarantor) 3 - Try and add a guarantor to B -> you will success 4 - Remove B's guarantor 5 - Apply this patch 6 - Repeat 3 -> you will not be able to --- Koha/Patron.pm | 13 +++++++++++++ members/memberentry.pl | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 7b94aef..be24ae4 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -569,6 +569,19 @@ sub guarantee_relationships { ); } + +=head3 is_guarantor + +Returns true if the patron is a guarantor. + +=cut + +sub is_guarantor { + my ($self) = @_; + return $self->guarantee_relationships()->count() +} + + =head3 relationships_debt Returns the amount owed by the patron's guarantors *and* the other guarantees of those guarantors diff --git a/members/memberentry.pl b/members/memberentry.pl index 6d18fd0..0af42b2 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 ) || $guarantor->is_guarantee) { + if ( ( $op eq 'cud-save' || $op eq 'cud-insert' ) && ($guarantor->is_child ) || $guarantor->is_guarantee || $patron->is_guarantor) { push @errors, 'ERROR_guarantor_is_guarantee'; } } -- 2.43.0