Bug 37528

Summary: Using borrowerRelationship while guarantor relationship is unchecked from BorrowerMandatoryField results in error
Product: Koha Reporter: Katariina Pohto <katariina.pohto>
Component: PatronsAssignee: Johanna Räisä <johanna.raisa>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, johanna.raisa, kyle.m.hall, ovezina
Version: 24.05   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 37528: check if selected relationship is valid
Bug 37528: check if selected relationship is valid

Description Katariina Pohto 2024-07-30 13:57:03 UTC
Before 24.05 having values in borrowerRelationship made the guarantor relationship field required in patron page. Now one needs to check the relationship option from BorrowerMandatoryField settings. If borrower relationships are used but the relationship is not set up as required field, it is possible to save a patron with the empty option from gurantor relationship drop down selector. This will result in an internal service error. Despite the error, the new patron will be saved, but the guarantor information is lost in the process, as it wasn't valid.


To replicate:

Have at least one option in borrowerRelationship
Have the relationship field unchecked from BorrowerMandatoryFields

1. Create or select an existing patron in category that can be a guarantee.
2. Select a guarantor but leave the relationship blank
3. Fill in the other required information if not present yet.
4. Try to save the patron.
5. Notice an error page.
6. Check the patron and note that the new patron or changes to existing one were saved without the new guarantor information.


Also, I'd like to add that when adding a new guarantee for an existing patron, the hint text for required field doesn't show correctly with the mandatory field setting. It will show 'required field' when it's UNchecked from mandatory fields, and doesn't show it when it's checked. When creating a new patron from scratch or editing an existing guarantee patron, the 'required field' text works correctly.
Comment 1 Johanna Räisä 2024-08-01 06:16:49 UTC
Created attachment 169925 [details] [review]
Bug 37528: check if selected relationship is valid

This patch checks if the selected relationship is valid before trying to save the patron record.
It takes the list of valid relationships from borrowerRelationships syspref and checks if the selected relationship is in the list.

Also this patch fixes relationship field required message when BorrowerMandatoryField is not set.
The required message is shown when adding the guarantee from guarantor's detail page.

Test plan:
1) Add at least one option to borrowerRelationships syspref.
2) Leave the relationship unchecked from BorrowerMandatoryField syspref.
3) Create a new guarantee patron.
4) Add a guarantor to the guarantee patron.
5) Leave the relationship field empty and try to save the patron record.
6) Notice the 500 error page.
7) Apply the patch.
8) Repeat steps 3-5.
9) Notice the error message "Guarantor relationship is invalid".

Sponsored-by: Koha-Suomi Oy
Comment 2 Olivier V 2024-09-10 16:51:47 UTC
Created attachment 171277 [details] [review]
Bug 37528: check if selected relationship is valid

This patch checks if the selected relationship is valid before trying to save the patron record.
It takes the list of valid relationships from borrowerRelationships syspref and checks if the selected relationship is in the list.

Also this patch fixes relationship field required message when BorrowerMandatoryField is not set.
The required message is shown when adding the guarantee from guarantor's detail page.

Test plan:
1) Add at least one option to borrowerRelationships syspref.
2) Leave the relationship unchecked from BorrowerMandatoryField syspref.
3) Create a new guarantee patron.
4) Add a guarantor to the guarantee patron.
5) Leave the relationship field empty and try to save the patron record.
6) Notice the 500 error page.
7) Apply the patch.
8) Repeat steps 3-5.
9) Notice the error message "Guarantor relationship is invalid".

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Olivier V <olivier.vezina@inLibro.com>