Koha-clms/Koha/Acquisition
Andrii Nugged d64d02761d
Bug 43344: Use the current source alias in filter_by_active
Bug 36018 qualified the quantity column with the default "me" alias to
avoid ambiguity when joined tables also have a quantity column.

DBIx::Class does not always use "me" for related resultsets. The
many-to-many item_orders relationship uses "ordernumber", so evaluating
item.orders.filter_by_active from the OPAC refers to a non-existent
me.quantity column.

Use current_source_alias to qualify quantity with the alias of the actual
resultset. Add regression coverage for filtering active orders through the
item relationship.

Test plan:
Before applying the patch:
1. Set OPACAcquisitionDetails to Show.
2. Set AcqCreateItem to create an item when placing an order.
3. Create a basket and add an order for a bibliographic record, including an
   item.
4. Close the basket so the order is active and outstanding.
5. Open the bibliographic record in the OPAC.
6. Confirm the item is not shown as On order and the log contains an Unknown
   column 'me.quantity' error.

Apply the patch.

After applying the patch:
1. Open the same bibliographic record in the OPAC again.
2. Confirm the item is shown as On order and the SQL error is gone.

Co-Authored-By: Loontik <loontik@nugged.team>
Signed-off-by: Olivia Reynolds <olivia.reynolds@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-09 15:49:59 +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 30144: (QA follow-up) Exclude servicing_instruction from order API representation 2026-08-28 16:36:28 +00:00
Orders.pm Bug 43344: Use the current source alias in filter_by_active 2026-09-09 15:49:59 +00:00