https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27184 --- Comment #9 from David Nind <david@davidnind.com> --- Created attachment 212468 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212468&action=edit Bug 27184: Allow listing a patron's old checkouts through the API This patch adds a `checked_in` query parameter to the GET /patrons/{patron_id}/checkouts route, so the circulation history can be fetched paginated instead of loaded in full by readingrec.pl. The patron is now the pivot: it is looked up through Koha::Patrons->search_limited, like GET /patrons/{patron_id} does, so patrons the requesting user is not allowed to see (library groups 'Hide patron info', IndependentBranches) return 404. This applies to both current and old checkouts. Listing old checkouts also requires the view_checkout_history capability of the CheckoutHistory module policy (intranetreadinghistory enabled and borrowers: view_checkout_history). Otherwise a 403 with the `checkout_history_not_allowed` error_code is returned, carrying the current policy so the client can refresh its view of it. It also adds the `issuer.library` embed. The issuer is a Koha::Patron, so its information is redacted when the user cannot see it, but `library_id` is kept. Embedding the library allows the UI to display 'A patron from <library>' instead of leaking the staff member's name. The first subtest was also missing its txn_rollback, fixed. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ yarn api:bundle k$ restart_all k$ prove t/db_dependent/api/v1/patrons_checkouts.t \ t/db_dependent/api/v1/checkouts.t \ xt/api.t => SUCCESS: Tests pass! 3. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.