Bug 39819

Summary: Additional performance improvements when loading borrower relationships.
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: PatronsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: dcook, gmcharlt, kyle.m.hall
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 39644    
Bug Blocks:    

Description Lucas Gass (lukeg) 2025-05-02 14:47:59 UTC
From Nick via Bug 39644:

I think there is more cleanup to be done here.

relationships_debt is only called twice in the code base:
once in moremember.pl
once in Koha::Patron->is_patron_inside_charge_limits (which is also called in moremember)

The two calls are:
 - moremember:
   $patron->relationships_debt( { include_guarantors => 0, only_this_guarantor => 1, include_this_patron => 1 } );
 - is_patron_inside_charge_limits:
   $patron->relationships_debt( { include_guarantors => 1, only_this_guarantor => 0, include_this_patron => 1 } );

The difference being that the first returns only the single patrons fine + their guarantees, the latter returns the patron and thier gusarantees and the guarantees other guarantors

The first being a subset of the second, we should be able to return this additional info from "is_patron_inside_charge_limits" and avoid a double call.

Additionally, moremember does checks against "NoIssuesChargeGuarantorsWithGuarantees" and "NoIssuesChargeGuarantees" - both of which are checked inside "is_patron_inside_charge_limits" so we can simply use values we are already calculating and not calculate them again