Bug 38373 - Mandatory non-patron guarantor relationship required where no guarantor surname or first name
Summary: Mandatory non-patron guarantor relationship required where no guarantor surna...
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Johanna Räisä
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-06 09:14 UTC by Johanna Räisä
Modified: 2025-05-23 22:00 UTC (History)
7 users (show)

See Also:
GIT URL:
Change sponsored?: Sponsored
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes adding a non-patron guarantor for a patron - the relationship field is only marked as mandatory if a guarantor surname or first name is entered (where the relationship field is marked as mandatory in the BorrowerMandatoryField system preference). Previously, the relationship field was marked as mandatory even if no guarantor surname or first name was entered.
Version(s) released in:
Circulation function:


Attachments
Bug 38373: check if mandatory relationship is needed for non-patron guarantor (2.29 KB, patch)
2024-11-07 07:14 UTC, Johanna Räisä
Details | Diff | Splinter Review
Bug 38373: check if mandatory relationship is needed for non-patron guarantor (2.51 KB, patch)
2024-11-07 11:47 UTC, Johanna Räisä
Details | Diff | Splinter Review
Bug 38373: check if mandatory relationship is needed for non-patron guarantor (2.73 KB, patch)
2025-04-16 07:59 UTC, Johanna Räisä
Details | Diff | Splinter Review
Bug 38373: Check if mandatory relationship is needed for non-patron guarantor (2.99 KB, patch)
2025-05-23 21:50 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Johanna Räisä 2024-11-06 09:14:40 UTC
When relationship is a mandatory the field has to be selected twice, for non-patron guarantor and patron guarantor.

There should be a some kind of check which input fields are filled and the relationship requirement is based on that.
Comment 1 Johanna Räisä 2024-11-07 07:14:54 UTC
Created attachment 174102 [details] [review]
Bug 38373: check if mandatory relationship is needed for non-patron guarantor

This patch checks if non-patron guarantor is added to the patron and changes the relationship to mandatory if needed.

Test plan:
1) Add relationship as mandatory field
2) Add a child patron
3) See that the non-patron guarantor relationship is mandatory
4) Apply the patch
5) Add a child patron
6) See that the non-patron guarantor relationship is not mandatory
7) Fill a surname for the non-patron guarantor
8) See that the non-patron guarantor relationship turns mandatory

Sponsored-by: Koha-Suomi Oy
Comment 2 Jonathan Druart 2024-11-07 08:56:44 UTC
Why not applying the same trigger for #contactfirstname?

I'd say if at least one of them (#contactname or #contactfirstname) is not empty then the relationship must be required.
Comment 3 Johanna Räisä 2024-11-07 09:20:12 UTC
(In reply to Jonathan Druart from comment #2)
> Why not applying the same trigger for #contactfirstname?
> 
> I'd say if at least one of them (#contactname or #contactfirstname) is not
> empty then the relationship must be required.

Yes, should be check that also. I fill fix that and add a patch
Comment 4 Johanna Räisä 2024-11-07 11:47:49 UTC
Created attachment 174118 [details] [review]
Bug 38373: check if mandatory relationship is needed for non-patron guarantor

This patch checks if non-patron guarantor is added to the patron and changes the relationship to mandatory if needed.

Test plan:
1) Add relationship as mandatory field
2) Add a child patron
3) See that the non-patron guarantor relationship is mandatory
4) Apply the patch
5) Add a child patron
6) See that the non-patron guarantor relationship is not mandatory
7) Fill surname or first name for the non-patron guarantor
8) See that the non-patron guarantor relationship turns mandatory

Sponsored-by: Koha-Suomi Oy
Comment 5 Jesse Maseto 2025-04-02 09:22:56 UTC
Patch does not apply. Merge conflicts.
Comment 6 Johanna Räisä 2025-04-16 07:59:41 UTC
Created attachment 181000 [details] [review]
Bug 38373: check if mandatory relationship is needed for  non-patron guarantor

This patch checks if non-patron guarantor is added to the patron and changes the relationship to mandatory if needed.

Test plan:
1) Add relationship as mandatory field
2) Add a child patron
3) See that the non-patron guarantor relationship is mandatory
4) Apply the patch
5) Add a child patron
6) See that the non-patron guarantor relationship is not mandatory
7) Fill surname or first name for the non-patron guarantor
8) See that the non-patron guarantor relationship turns mandatory

Sponsored-by: Koha-Suomi Oy
Comment 7 Lin Wei 2025-05-12 13:37:38 UTC
# Results before Applying Patch

- Added "Relationship" to "BorrowerMandatoryField" in "Koha administration." 
- When trying to Add patron (kid), Non-patron guarantor > Relationship is "Required."

# Results after Applying Patch

- When trying to Add patron (kid), Non-patron guarantor > Relationship remains "Required."
Comment 8 Johanna Räisä 2025-05-23 06:46:31 UTC
(In reply to Lin Wei from comment #7)
> # Results before Applying Patch
> 
> - Added "Relationship" to "BorrowerMandatoryField" in "Koha administration." 
> - When trying to Add patron (kid), Non-patron guarantor > Relationship is
> "Required."
> 
> # Results after Applying Patch
> 
> - When trying to Add patron (kid), Non-patron guarantor > Relationship
> remains "Required."

I tested this again with current main and to me it seems to be working as in test plan. The relationship field on non-patron guarantor should change to required when you fill surname or first name for non-patron guarantor, steps 7 and 8.

You probably need to load the page with ctrl+f5, so the browser cache resets. Can you test again, please?
Comment 9 David Nind 2025-05-23 21:50:53 UTC
Created attachment 182779 [details] [review]
Bug 38373: Check if mandatory relationship is needed for non-patron guarantor

This patch makes the non-guarantor relationship field mandatory only if
a guarantor surname or first name is entered.

Currently, if the relationship field is mandatory, you need to select a value
even if there is no guarantor surname or first name.

Test plan:
1) Add relationship as mandatory field
2) Add a child patron
3) See that the non-patron guarantor relationship is mandatory
   (note that it is mandtaory, even if there is no guarantor
    surname or first name)
4) Apply the patch
5) Add a child patron
6) See that the non-patron guarantor relationship is not mandatory
7) Fill surname or first name for the non-patron guarantor
8) See that the non-patron guarantor relationship turns mandatory

Sponsored-by: Koha-Suomi Oy
Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2025-05-23 21:59:48 UTC
I've changed the bug title, as I didn't understand this part of the description of the issue, and I found this confusing when trying to work out what the problem was:  "...has to be selected twice".

I think how it works after the patch is better, and is consistent with the patron guarantor.

Testing notes (using KTD):

1. Before the patch, what I did (thanks Lin Wei):
   1.1 For the BorrowerMandatoryField system preference, I added "Relationship" as a mandatory field.
   1.2 When adding a Kid patron, under non-patron guarantor, the relationship field is marked as "Required" in red.
   1.3 This works as expected for me:
       - don't add a patron guarantor surname or first name
       - if a value is not selected, the new patron isn't saved and the relationship has "This field is required." beside it
       OR
       - select a value from the dropdown list 
      (note that the field is requieed even if you don't have a guarantor
       surname or first name)

2. After the patch, under non-patron guarantor, the relationship field is NOT marked as "Required" in red until a guarantor surname or first name is added. (This is now similar to the patron guarantor - until you select a patron as a guarantor, have the relationship field completed is not mandatory.