Bug 39331: If patron category cant be guarantee do not continue with add_guarantors

To test:
1 - Remove age limits from a Child and Adult category in Administration->Patron categories. Ensure Child category can be guarantor and Adult cannot
2 - The above step is to avoid any age checks and form resubmission which removes the guarantor fields
3 - Find/create a child patron
4 - Add a guarantee from the Adult category to the child
5 - Check the DB:
   SELECT * FROM borrower_relationships WHERE guarantee_id={borrowernumber of child};
6 - Note the id colum
7 - Edit the child patron to Adult category
8 - Repeat 5
9 - Note the relationship still exists and the id is incremented
10 - Oof!
11 - APPLY PATCH, restart_all
12 - Try again steps 3 - 8
13 - The relationship should not be re-added
14 - Try with more than 1 guarantor on the record, confirming all are deleted
15 - Try adding some guarantor to patron types that should be able to, they relationship should work.
16 - Try changing some patrons to categories that do allow guarantors, making sure the relationship does stay.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2025-03-14 22:28:37 +00:00 committed by Katrin Fischer
parent 6e4039b72a
commit 4f170fb94d
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -995,6 +995,10 @@ sub patron_attributes_form {
sub add_guarantors {
my ( $patron, $input ) = @_;
unless ( $patron->category->can_be_guarantee ) {
return;
}
my @new_guarantor_id = $input->multi_param('new_guarantor_id');
my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship');