Bug 40961 - LocalUse Circulation Statistics offering empty results
Summary: LocalUse Circulation Statistics offering empty results
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: 25.05
Hardware: All All
: P5 - low normal
Assignee: Andrew Fuerste-Henry
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-06 17:20 UTC by Todd Goatley
Modified: 2025-11-21 17:41 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40961: Fix query for localuse (2.03 KB, patch)
2025-10-06 18:19 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 40961: Default item and patron library values to blank (2.62 KB, patch)
2025-11-19 17:09 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 40961: Default item and patron library values to blank (2.67 KB, patch)
2025-11-21 17:41 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Todd Goatley 2025-10-06 17:20:17 UTC
Libraries are reporting that the LocalUse Circulation Statistics offer empty results once setup and then ran. The other selections return results.
Comment 1 Lucas Gass (lukeg) 2025-10-06 17:28:29 UTC
To recreate:

1. Set RecordLocalUseOnReturn to 'Record'
2. Record some local uses by checking in items 
3. You can double check the DB that local uses are getting record with: select localuse from items where itemnumber = ITEMNUMBER;
4. Go to reports > Statistics wizards -> Circulation 
5. Adjust "Type:" to "Local use"
6. Notice there are 0 results
Comment 2 Lucas Gass (lukeg) 2025-10-06 18:19:58 UTC
Created attachment 187489 [details] [review]
Bug 40961: Fix query for localuse
Comment 3 Lucas Gass (lukeg) 2025-10-06 18:21:23 UTC
Very unsure about this patch. It skips looking for items.homebranch or borrowers.branchcode if local use is selected, because those values can be NULL.
Comment 4 Andrew Fuerste-Henry 2025-10-06 18:39:00 UTC
This is sort of a weird issue. 
If one records local use via checkin with the RecordLocalUseOnReturn syspref, those localuse entries will always lack a borrowernumber and therefor have a NULL for patron's home library. That means they won't come up in any query made via the wizard that selects a value for patron's home library.
But if one records local use via a statistical patron, then there will be an associated borrowernumber and therefore a patron home library and folks may want to filter their results based on that value.

Prior to Bug 20601, the patron library dropdown in the wizard didn't work and therefore didn't impact these queries.
Comment 5 Andrew Fuerste-Henry 2025-10-06 18:40:30 UTC
Expanding on that comment: the current behavior is technically correct but confusing to the user.
Comment 6 Andrew Fuerste-Henry 2025-11-19 17:01:38 UTC
I don't think Lucas's original fix here is the way to go. He told the query to ignore both the associated borrower's branch and the associated item's homebranch. If a library is using statistical patrons, the borrower's branch will have a value that libraries may want to use for differentiating local use counts. The item's homebranch should always have an item, even if the item has been deleted.

In the circulation statistics wizard the various library values correspond to:
Issuing library - the value record in statistics.branch when the transaction took place
Home library - the current home library of the item in question
Holding library - the current holding library of the item in question
Patron library - the current library of the associated patron used (if any - for local use there is only a patron if statistical patrons are used)

So if the user lands on the circulation statistics page, changes Type to "Local use" and runs the query with the default values they get all local uses that happened at the logged-in branch, involving items with home and holding values matching the logged-in branch, and to patrons from the logged-in branch. That's a very specific query and seems unlikely to match what folks want.

I suggest we make the page load with home library, holding library, and patron library all set to blank. That would make the default search simply all transactions of the given type that happened at the logged-in branch. Broad but clear.
Comment 7 Andrew Fuerste-Henry 2025-11-19 17:09:18 UTC
Created attachment 189715 [details] [review]
Bug 40961: Default item and patron library values to blank

To test:
1 - load the Circulation Statistics wizard
2 - confirm Home library, Holding library, and Patron library default to selecting the logged-in branch
3 - apply patch, restart_all, reload page
4 - confirm Home library, Holding library, and Patron library default to a blank selection
5 - confirm queries with those blank selections are not limited by items.homebranch, items.holdingbranch, or borrowers.branchcode
Comment 8 Andrew Fuerste-Henry 2025-11-21 17:41:28 UTC
Created attachment 189869 [details] [review]
Bug 40961: Default item and patron library values to blank

To test:
1 - load the Circulation Statistics wizard
2 - confirm Home library, Holding library, and Patron library default to selecting the logged-in branch
3 - apply patch, restart_all, reload page
4 - confirm Home library, Holding library, and Patron library default to a blank selection
5 - confirm queries with those blank selections are not limited by items.homebranch, items.holdingbranch, or borrowers.branchcode

Signed-off-by: Katherine Wolf <wolf@sarsf.org>