Koha-clms/Koha/Acquisition
Tomás Cohen Arazi 713c5c3343
Bug 41950: (follow-up) Add DBIC relationship aliases for +count embeds
Adds DBIC relationship aliases so that +count embeds advertised in
the API specs are backed by actual database relationships, making
them sortable via the SQL COUNT subquery infrastructure.

New aliases:
- Borrower: checkouts (issues)
- Aqbookseller: baskets (aqbaskets), invoices (aqinvoices)
- Ticket: updates (ticket_updates)
- ErmEholdingsPackage: resources (erm_eholdings_resources)
- Biblio: holds (reserves)

Koha methods are updated to use the new relationship names directly,
following the one-liner style: Koha::Foo->_new_from_dbic( scalar ... )

Note: checkouts on Borrower and subscriptions on Aqbookseller already
had matching DBIC relationships. comments on Illrequest, requests on
IllBatch, and items on Biblio also already existed.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
   k$ prove t/Koha/REST/Plugin/Query.t \
       t/db_dependent/api/v1/patrons.t \
       t/db_dependent/api/v1/acquisitions_vendors.t \
       t/db_dependent/Koha/REST/Plugin/Objects.t \
       t/db_dependent/Koha/Biblio.t
=> SUCCESS: All tests pass
3. Verify sorting works:
   GET /api/v1/patrons
   x-koha-embed: checkouts+count
   _order_by: -me.checkouts_count
=> SUCCESS: Patrons sorted by checkout count
4. Sign off :-D

Assisted-by: Sonnet 4.6 (Anthropic)
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-06-29 16:19:49 +00:00
..
Bookseller Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Invoice Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Order Bug 39830: Add order claim object definition 2025-09-29 14:02:21 -06:00
Basket.pm Bug 29668: Add API route to add a basket 2026-01-21 15:28:09 -07:00
BasketGroup.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
BasketGroups.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Baskets.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Bookseller.pm Bug 41950: (follow-up) Add DBIC relationship aliases for +count embeds 2026-06-29 16:19:49 +00:00
Booksellers.pm Bug 38262: Enable additional fields support for acquisition vendors 2026-01-12 10:53:35 -07:00
Budget.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Budgets.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Currencies.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Currency.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Fund.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Funds.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Invoice.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Invoices.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Order.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Orders.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00