Bug 39658

Summary: Allow definition of non-hierarchical linked patron accounts
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: PatronsAssignee: Jacob O'Mara <jacob.omara>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: gmcharlt, kyle, lucas, martin.renvoize, phillip.berg
Version: Main   
Hardware: All   
OS: All   
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 39658: DB: Add patron_account_links table and sysprefs
Bug 39658: Add Koha::Patron::AccountLink(s) objects
Bug 39658: Add linked account methods to Koha::Patron
Bug 39658: API: Add REST endpoints for patron account links
Bug 39658: Circulation: Add linked account fee/hold checks
Bug 39658: Circulation: Add linked account hold pickup redirect
Bug 39658: Circulation UI: Add linked account fee/hold messages
Bug 39658: Patron detail: Pass linked accounts to template
Bug 39658: Patron detail UI: Add linked accounts section
Bug 39658: Admin: Add linked account system preferences UI
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink
Bug 39658: Tests: Add API tests for patron account links endpoints
Bug 39658: Add Koha::Exceptions::PatronAccountLink
Bug 39658: Add link_to_patron and linked_account_links methods
Bug 39658: DBIC schema - DO NOT PUSH
Bug 39658: Schema: Add Koha object class mappings
Bug 39658: DB: Add patron_account_links table and sysprefs
Bug 39658: Add Koha::Patron::AccountLink(s) objects
Bug 39658: Add linked account methods to Koha::Patron
Bug 39658: API: Add REST endpoints for patron account links
Bug 39658: Circulation: Add linked account fee/hold checks
Bug 39658: Circulation: Add linked account hold pickup redirect
Bug 39658: Circulation UI: Add linked account fee/hold messages
Bug 39658: Patron detail: Pass linked accounts to template
Bug 39658: Patron detail UI: Add linked accounts section
Bug 39658: Admin: Add linked account system preferences UI
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink
Bug 39658: Tests: Add API tests for patron account links endpoints
Bug 39658: Add Koha::Exceptions::PatronAccountLink
Bug 39658: Add link_to_patron and linked_account_links methods
Bug 39658: DBIC schema - DO NOT PUSH
Bug 39658: Schema: Add Koha object class mappings
Bug 39658: (follow-up) linked hold pickup all types
Bug 39658: (follow-up) block checkout when linked accounts over charge limit
Bug 39658: DB: Add patron_account_links table and sysprefs
Bug 39658: Add Koha::Patron::AccountLink(s) objects
Bug 39658: Add linked account methods to Koha::Patron
Bug 39658: API: Add REST endpoints for patron account links
Bug 39658: Circulation: Add linked account fee/hold checks
Bug 39658: Circulation: Add linked account hold pickup redirect
Bug 39658: Circulation UI: Add linked account fee/hold messages
Bug 39658: Patron detail: Pass linked accounts to template
Bug 39658: Patron detail UI: Add linked accounts section
Bug 39658: Admin: Add linked account system preferences UI
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink
Bug 39658: Tests: Add API tests for patron account links endpoints
Bug 39658: Add Koha::Exceptions::PatronAccountLink
Bug 39658: Add link_to_patron and linked_account_links methods
Bug 39658: DBIC schema - DO NOT PUSH
Bug 39658: Schema: Add Koha object class mappings
Bug 39658: (follow-up) linked hold pickup all types
Bug 39658: (follow-up) block checkout when linked accounts over charge limit
Bug 39658: DB: Add patron_account_links table and sysprefs
Bug 39658: Add Koha::Patron::AccountLink(s) objects
Bug 39658: Add linked account methods to Koha::Patron
Bug 39658: API: Add REST endpoints for patron account links
Bug 39658: Circulation: Add linked account fee/hold checks
Bug 39658: Circulation: Add linked account hold pickup redirect
Bug 39658: Circulation UI: Add linked account fee/hold messages
Bug 39658: Patron detail: Pass linked accounts to template
Bug 39658: Patron detail UI: Add linked accounts section
Bug 39658: Admin: Add linked account system preferences UI
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink
Bug 39658: Tests: Add API tests for patron account links endpoints
Bug 39658: Add Koha::Exceptions::PatronAccountLink
Bug 39658: Add link_to_patron and linked_account_links methods
Bug 39658: DBIC schema - DO NOT PUSH
Bug 39658: Schema: Add Koha object class mappings
Bug 39658: (follow-up) linked hold pickup all types
Bug 39658: (follow-up) block checkout when linked accounts over charge limit

Description Andrew Fuerste-Henry 2025-04-16 17:00:37 UTC
In a Koha system containing multiple functionally-autonomous libraries, one patron may have multiple distinct accounts within the same Koha system. These accounts represent distinct cards from distinct libraries and need their circulation rules enforced as such, so they can't be merged into one account. But no one of these accounts is "primary" and they all represent the same person, so guarantor/guarantee relationships are a poor conceptual fit (and may already be in use for their intended purpose).

These linked/shared accounts would:
- clearly link between each other in the Details of the patron record
- optionally reciprocally enforce restrictions and blocks due to fines & fees (when one account is blocked, all are)
- optionally allow checkout of on-hold items for shared accounts


For that last item, assuming one patron has accounts card1 and card2. They have a hold ready for pickup on their card1 account. If Koha attempts to check the waiting item out to the card2 account, koha should check the item out on the card1 account, mark the hold complete, and give the user a clear on-screen message as to what happened. It should not ask for confirmation.
Comment 1 Phillip Berg 2025-04-21 16:09:14 UTC
Library patrons may qualify for different levels of library service in multiple library services areas. For example, one might live in one town, own a vacation property elsewhere, and work yet somewhere else. Each of those libraries have certain materials/services that they only allow local card-holders to access, thus why some people receive multiple cards.

This is more prevalent in some cooperatives/consortia representing many tax districts, municipalities, and counties via a single instance of the ILS. The guarantee/guarantor function is great for family dynamics, but does not work for individuals who possess two, three, or more total library cards (each at different libraries). Choosing which library card in these situations should be the guarantor is awkward at best and politically charged at worst. We also don't want a situation where a patron tries to game the system by running up huge bills on each account without an auto-block coming into play.

Having the ability to simply connect multiple patron accounts together to better manage that person's library privileges, usage, and restrictions is vital to keeping a harmonious relationship between libraries.

This change would not remove or force any Koha libraries to abandon the guarantee/guarantor functionality. We just need to add another option.
Comment 2 Jacob O'Mara 2026-02-18 14:20:26 UTC
Created attachment 193344 [details] [review]
Bug 39658: DB: Add patron_account_links table and sysprefs

Patron Account Linking: Test Plan

Setup: Enable all 3 sysprefs: EnablePatronAccountLinking = Enable, NoIssuesChargeLinkedAccounts = 10, AllowLinkedAccountHoldPickup = Allow.

Linking:
1. Go to Koha's detail page (moremember.pl). Confirm the "Linked accounts" section appears.
2. Click "Add linked account", search for Henry, link him. Confirm Henry appears in the list.
3. Repeat to link Edna. Confirm both Henry and Edna are listed under Koha.
4. Go to Henry's detail page. Confirm Koha and Edna appear as linked accounts.
5. Test "Leave linked group" on Edna — confirm she is removed from all linked accounts.

Checkout blocking (NoIssuesChargeLinkedAccounts):
6. Re-link Edna to the group.
7. Add fines across Koha, Henry, and Edna so the combined total exceeds 10.
8. Try checking out an item to any of them — confirm the linked account debt warning/block appears.
9. Reduce fines below 10 — confirm checkout proceeds without warning.

Hold pickup (AllowLinkedAccountHoldPickup):
10. Place a hold for Koha on an available item. Check it in so it's waiting.
11. Check out that waiting item to Henry — confirm it succeeds and is issued to Koha automatically.
12. Disable AllowLinkedAccountHoldPickup. Repeat — confirm the redirect does not occur.

Adds table and 3 sysprefs for patron account linking feature.
Comment 3 Jacob O'Mara 2026-02-18 14:20:28 UTC
Created attachment 193345 [details] [review]
Bug 39658: Add Koha::Patron::AccountLink(s) objects

New objects to manage patron account links.
Comment 4 Jacob O'Mara 2026-02-18 14:20:31 UTC
Created attachment 193346 [details] [review]
Bug 39658: Add linked account methods to Koha::Patron

Methods: account_link, linked_accounts, all_linked_borrowernumbers,
linked_accounts_debt. Also adds charge limit checking.
Comment 5 Jacob O'Mara 2026-02-18 14:20:33 UTC
Created attachment 193347 [details] [review]
Bug 39658: API: Add REST endpoints for patron account links

Endpoints: GET/POST/DELETE /patrons/{id}/account_links
Comment 6 Jacob O'Mara 2026-02-18 14:20:35 UTC
Created attachment 193348 [details] [review]
Bug 39658: Circulation: Add linked account fee/hold checks

DEBT_LINKED_ACCOUNTS blocker and LINKED_ACCOUNT_HOLD_PICKUP alert.
Comment 7 Jacob O'Mara 2026-02-18 14:20:37 UTC
Created attachment 193349 [details] [review]
Bug 39658: Circulation: Add linked account hold pickup redirect

Enable linked patrons to pick up each other's holds when allowed.
Comment 8 Jacob O'Mara 2026-02-18 14:20:40 UTC
Created attachment 193350 [details] [review]
Bug 39658: Circulation UI: Add linked account fee/hold messages

Display warnings for combined debt and linked hold pickup.
Comment 9 Jacob O'Mara 2026-02-18 14:20:42 UTC
Created attachment 193351 [details] [review]
Bug 39658: Patron detail: Pass linked accounts to template

Add linked_accounts and link_group data for display.
Comment 10 Jacob O'Mara 2026-02-18 14:20:45 UTC
Created attachment 193352 [details] [review]
Bug 39658: Patron detail UI: Add linked accounts section

Display linked patrons with Add/Leave link group buttons.
Comment 11 Jacob O'Mara 2026-02-18 14:20:47 UTC
Created attachment 193353 [details] [review]
Bug 39658: Admin: Add linked account system preferences UI

Add prefs for EnablePatronAccountLinking and related settings.
Comment 12 Jacob O'Mara 2026-02-18 14:20:49 UTC
Created attachment 193354 [details] [review]
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink

Test linking, group management, and linked_accounts methods.
Comment 13 Jacob O'Mara 2026-02-18 14:20:52 UTC
Created attachment 193355 [details] [review]
Bug 39658: Tests: Add API tests for patron account links endpoints

Test GET/POST/DELETE /api/v1/patrons/{id}/account_links.
Comment 14 Jacob O'Mara 2026-02-18 14:20:54 UTC
Created attachment 193356 [details] [review]
Bug 39658: Add Koha::Exceptions::PatronAccountLink

Add typed exceptions for patron account linking:
- AlreadyLinked: patrons already in same group
- DifferentGroups: patrons in different groups
Comment 15 Jacob O'Mara 2026-02-18 14:20:56 UTC
Created attachment 193357 [details] [review]
Bug 39658: Add link_to_patron and linked_account_links methods

- link_to_patron($other_patron): Links patrons, handles group logic
- linked_account_links(): Returns all links in patron's group
Comment 16 Jacob O'Mara 2026-02-18 14:20:59 UTC
Created attachment 193358 [details] [review]
Bug 39658: DBIC schema - DO NOT PUSH

Auto-generated schema for patron_account_links table.
Comment 17 Jacob O'Mara 2026-02-18 14:21:01 UTC
Created attachment 193359 [details] [review]
Bug 39658: Schema: Add Koha object class mappings

Map PatronAccountLink to Koha::Patron::AccountLink(s).
Comment 18 Jacob O'Mara 2026-02-19 14:34:17 UTC
Created attachment 193462 [details] [review]
Bug 39658: DB: Add patron_account_links table and sysprefs

Adds table and 3 sysprefs for patron account linking feature.

Setup: Enable all 3 sysprefs: EnablePatronAccountLinking = Enable, NoIssuesChargeLinkedAccounts = 10, AllowLinkedAccountHoldPickup = Allow.

Linking:
1. Go to Koha's detail page (moremember.pl). Confirm the "Linked accounts" section appears.
2. Click "Add linked account", search for Henry, link him. Confirm Henry appears in the list.
3. Repeat to link Edna. Confirm both Henry and Edna are listed under Koha.
4. Go to Henry's detail page. Confirm Koha and Edna appear as linked accounts.
5. Test "Leave linked group" on Edna — confirm she is removed from all linked accounts.

Checkout blocking (NoIssuesChargeLinkedAccounts):
6. Re-link Edna to the group.
7. Add fines across Koha, Henry, and Edna so the combined total exceeds 10.
8. Try checking out an item to any of them — confirm the linked account debt warning/block appears.
9. Reduce fines below 10 — confirm checkout proceeds without warning.

Hold pickup (AllowLinkedAccountHoldPickup):
10. Place a hold for Koha on an available item. Check it in so it's waiting.
11. Check out that waiting item to Henry — confirm it succeeds and is issued to Koha automatically.
12. Disable AllowLinkedAccountHoldPickup. Repeat — confirm the redirect does not occur.
Comment 19 Jacob O'Mara 2026-02-19 14:34:19 UTC
Created attachment 193463 [details] [review]
Bug 39658: Add Koha::Patron::AccountLink(s) objects

New objects to manage patron account links.
Comment 20 Jacob O'Mara 2026-02-19 14:34:22 UTC
Created attachment 193464 [details] [review]
Bug 39658: Add linked account methods to Koha::Patron

Methods: account_link, linked_accounts, all_linked_borrowernumbers,
linked_accounts_debt. Also adds charge limit checking.
Comment 21 Jacob O'Mara 2026-02-19 14:34:24 UTC
Created attachment 193465 [details] [review]
Bug 39658: API: Add REST endpoints for patron account links

Endpoints: GET/POST/DELETE /patrons/{id}/account_links
Comment 22 Jacob O'Mara 2026-02-19 14:34:27 UTC
Created attachment 193466 [details] [review]
Bug 39658: Circulation: Add linked account fee/hold checks

DEBT_LINKED_ACCOUNTS blocker and LINKED_ACCOUNT_HOLD_PICKUP alert.
Comment 23 Jacob O'Mara 2026-02-19 14:34:29 UTC
Created attachment 193467 [details] [review]
Bug 39658: Circulation: Add linked account hold pickup redirect

Enable linked patrons to pick up each other's holds when allowed.
Comment 24 Jacob O'Mara 2026-02-19 14:34:31 UTC
Created attachment 193468 [details] [review]
Bug 39658: Circulation UI: Add linked account fee/hold messages

Display warnings for combined debt and linked hold pickup.
Comment 25 Jacob O'Mara 2026-02-19 14:34:34 UTC
Created attachment 193469 [details] [review]
Bug 39658: Patron detail: Pass linked accounts to template

Add linked_accounts and link_group data for display.
Comment 26 Jacob O'Mara 2026-02-19 14:34:36 UTC
Created attachment 193470 [details] [review]
Bug 39658: Patron detail UI: Add linked accounts section

Display linked patrons with Add/Leave link group buttons.
Comment 27 Jacob O'Mara 2026-02-19 14:34:39 UTC
Created attachment 193471 [details] [review]
Bug 39658: Admin: Add linked account system preferences UI

Add prefs for EnablePatronAccountLinking and related settings.
Comment 28 Jacob O'Mara 2026-02-19 14:34:41 UTC
Created attachment 193472 [details] [review]
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink

Test linking, group management, and linked_accounts methods.
Comment 29 Jacob O'Mara 2026-02-19 14:34:44 UTC
Created attachment 193473 [details] [review]
Bug 39658: Tests: Add API tests for patron account links endpoints

Test GET/POST/DELETE /api/v1/patrons/{id}/account_links.
Comment 30 Jacob O'Mara 2026-02-19 14:34:46 UTC
Created attachment 193474 [details] [review]
Bug 39658: Add Koha::Exceptions::PatronAccountLink

Add typed exceptions for patron account linking:
- AlreadyLinked: patrons already in same group
- DifferentGroups: patrons in different groups
Comment 31 Jacob O'Mara 2026-02-19 14:34:48 UTC
Created attachment 193475 [details] [review]
Bug 39658: Add link_to_patron and linked_account_links methods

- link_to_patron($other_patron): Links patrons, handles group logic
- linked_account_links(): Returns all links in patron's group
Comment 32 Jacob O'Mara 2026-02-19 14:34:51 UTC
Created attachment 193476 [details] [review]
Bug 39658: DBIC schema - DO NOT PUSH

Auto-generated schema for patron_account_links table.
Comment 33 Jacob O'Mara 2026-02-19 14:34:53 UTC
Created attachment 193477 [details] [review]
Bug 39658: Schema: Add Koha object class mappings

Map PatronAccountLink to Koha::Patron::AccountLink(s).
Comment 34 Jacob O'Mara 2026-02-19 14:34:56 UTC
Created attachment 193478 [details] [review]
Bug 39658: (follow-up) linked hold pickup all types

Linked account hold pickup check now applies to all hold
statuses (Reserved, Transferred, Processing), not just Waiting.
Comment 35 Jacob O'Mara 2026-02-19 14:34:59 UTC
Created attachment 193479 [details] [review]
Bug 39658: (follow-up) block checkout when linked accounts over charge limit

When AllowFineOverride is disabled and NoIssuesChargeLinkedAccounts
is exceeded, hide the barcode field and show 'Cannot check out'.
Comment 36 Andrew Fuerste-Henry 2026-02-24 17:22:05 UTC
Created attachment 193781 [details] [review]
Bug 39658: DB: Add patron_account_links table and sysprefs

Adds table and 3 sysprefs for patron account linking feature.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 37 Andrew Fuerste-Henry 2026-02-24 17:22:08 UTC
Created attachment 193782 [details] [review]
Bug 39658: Add Koha::Patron::AccountLink(s) objects

New objects to manage patron account links.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 38 Andrew Fuerste-Henry 2026-02-24 17:22:11 UTC
Created attachment 193783 [details] [review]
Bug 39658: Add linked account methods to Koha::Patron

Methods: account_link, linked_accounts, all_linked_borrowernumbers,
linked_accounts_debt. Also adds charge limit checking.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 39 Andrew Fuerste-Henry 2026-02-24 17:22:14 UTC
Created attachment 193784 [details] [review]
Bug 39658: API: Add REST endpoints for patron account links

Endpoints: GET/POST/DELETE /patrons/{id}/account_links

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 40 Andrew Fuerste-Henry 2026-02-24 17:22:17 UTC
Created attachment 193785 [details] [review]
Bug 39658: Circulation: Add linked account fee/hold checks

DEBT_LINKED_ACCOUNTS blocker and LINKED_ACCOUNT_HOLD_PICKUP alert.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 41 Andrew Fuerste-Henry 2026-02-24 17:22:20 UTC
Created attachment 193786 [details] [review]
Bug 39658: Circulation: Add linked account hold pickup redirect

Enable linked patrons to pick up each other's holds when allowed.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 42 Andrew Fuerste-Henry 2026-02-24 17:22:23 UTC
Created attachment 193787 [details] [review]
Bug 39658: Circulation UI: Add linked account fee/hold messages

Display warnings for combined debt and linked hold pickup.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 43 Andrew Fuerste-Henry 2026-02-24 17:22:26 UTC
Created attachment 193788 [details] [review]
Bug 39658: Patron detail: Pass linked accounts to template

Add linked_accounts and link_group data for display.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 44 Andrew Fuerste-Henry 2026-02-24 17:22:29 UTC
Created attachment 193789 [details] [review]
Bug 39658: Patron detail UI: Add linked accounts section

Display linked patrons with Add/Leave link group buttons.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 45 Andrew Fuerste-Henry 2026-02-24 17:22:31 UTC
Created attachment 193790 [details] [review]
Bug 39658: Admin: Add linked account system preferences UI

Add prefs for EnablePatronAccountLinking and related settings.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 46 Andrew Fuerste-Henry 2026-02-24 17:22:34 UTC
Created attachment 193791 [details] [review]
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink

Test linking, group management, and linked_accounts methods.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 47 Andrew Fuerste-Henry 2026-02-24 17:22:37 UTC
Created attachment 193792 [details] [review]
Bug 39658: Tests: Add API tests for patron account links endpoints

Test GET/POST/DELETE /api/v1/patrons/{id}/account_links.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 48 Andrew Fuerste-Henry 2026-02-24 17:22:40 UTC
Created attachment 193793 [details] [review]
Bug 39658: Add Koha::Exceptions::PatronAccountLink

Add typed exceptions for patron account linking:
- AlreadyLinked: patrons already in same group
- DifferentGroups: patrons in different groups

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 49 Andrew Fuerste-Henry 2026-02-24 17:22:43 UTC
Created attachment 193794 [details] [review]
Bug 39658: Add link_to_patron and linked_account_links methods

- link_to_patron($other_patron): Links patrons, handles group logic
- linked_account_links(): Returns all links in patron's group

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 50 Andrew Fuerste-Henry 2026-02-24 17:22:46 UTC
Created attachment 193795 [details] [review]
Bug 39658: DBIC schema - DO NOT PUSH

Auto-generated schema for patron_account_links table.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 51 Andrew Fuerste-Henry 2026-02-24 17:22:49 UTC
Created attachment 193796 [details] [review]
Bug 39658: Schema: Add Koha object class mappings

Map PatronAccountLink to Koha::Patron::AccountLink(s).

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 52 Andrew Fuerste-Henry 2026-02-24 17:22:52 UTC
Created attachment 193797 [details] [review]
Bug 39658: (follow-up) linked hold pickup all types

Linked account hold pickup check now applies to all hold
statuses (Reserved, Transferred, Processing), not just Waiting.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 53 Andrew Fuerste-Henry 2026-02-24 17:22:55 UTC
Created attachment 193798 [details] [review]
Bug 39658: (follow-up) block checkout when linked accounts over charge limit

When AllowFineOverride is disabled and NoIssuesChargeLinkedAccounts
is exceeded, hide the barcode field and show 'Cannot check out'.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Comment 54 Kellie Stephens 2026-02-24 21:13:26 UTC
Created attachment 193800 [details] [review]
Bug 39658: DB: Add patron_account_links table and sysprefs

Adds table and 3 sysprefs for patron account linking feature.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 55 Kellie Stephens 2026-02-24 21:13:29 UTC
Created attachment 193801 [details] [review]
Bug 39658: Add Koha::Patron::AccountLink(s) objects

New objects to manage patron account links.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 56 Kellie Stephens 2026-02-24 21:13:32 UTC
Created attachment 193802 [details] [review]
Bug 39658: Add linked account methods to Koha::Patron

Methods: account_link, linked_accounts, all_linked_borrowernumbers,
linked_accounts_debt. Also adds charge limit checking.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 57 Kellie Stephens 2026-02-24 21:13:35 UTC
Created attachment 193803 [details] [review]
Bug 39658: API: Add REST endpoints for patron account links

Endpoints: GET/POST/DELETE /patrons/{id}/account_links

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 58 Kellie Stephens 2026-02-24 21:13:38 UTC
Created attachment 193804 [details] [review]
Bug 39658: Circulation: Add linked account fee/hold checks

DEBT_LINKED_ACCOUNTS blocker and LINKED_ACCOUNT_HOLD_PICKUP alert.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 59 Kellie Stephens 2026-02-24 21:13:41 UTC
Created attachment 193805 [details] [review]
Bug 39658: Circulation: Add linked account hold pickup redirect

Enable linked patrons to pick up each other's holds when allowed.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 60 Kellie Stephens 2026-02-24 21:13:44 UTC
Created attachment 193806 [details] [review]
Bug 39658: Circulation UI: Add linked account fee/hold messages

Display warnings for combined debt and linked hold pickup.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 61 Kellie Stephens 2026-02-24 21:13:47 UTC
Created attachment 193807 [details] [review]
Bug 39658: Patron detail: Pass linked accounts to template

Add linked_accounts and link_group data for display.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 62 Kellie Stephens 2026-02-24 21:13:50 UTC
Created attachment 193808 [details] [review]
Bug 39658: Patron detail UI: Add linked accounts section

Display linked patrons with Add/Leave link group buttons.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 63 Kellie Stephens 2026-02-24 21:13:53 UTC
Created attachment 193809 [details] [review]
Bug 39658: Admin: Add linked account system preferences UI

Add prefs for EnablePatronAccountLinking and related settings.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 64 Kellie Stephens 2026-02-24 21:13:56 UTC
Created attachment 193810 [details] [review]
Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink

Test linking, group management, and linked_accounts methods.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 65 Kellie Stephens 2026-02-24 21:13:59 UTC
Created attachment 193811 [details] [review]
Bug 39658: Tests: Add API tests for patron account links endpoints

Test GET/POST/DELETE /api/v1/patrons/{id}/account_links.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 66 Kellie Stephens 2026-02-24 21:14:02 UTC
Created attachment 193812 [details] [review]
Bug 39658: Add Koha::Exceptions::PatronAccountLink

Add typed exceptions for patron account linking:
- AlreadyLinked: patrons already in same group
- DifferentGroups: patrons in different groups

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 67 Kellie Stephens 2026-02-24 21:14:05 UTC
Created attachment 193813 [details] [review]
Bug 39658: Add link_to_patron and linked_account_links methods

- link_to_patron($other_patron): Links patrons, handles group logic
- linked_account_links(): Returns all links in patron's group

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 68 Kellie Stephens 2026-02-24 21:14:08 UTC
Created attachment 193814 [details] [review]
Bug 39658: DBIC schema - DO NOT PUSH

Auto-generated schema for patron_account_links table.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 69 Kellie Stephens 2026-02-24 21:14:11 UTC
Created attachment 193815 [details] [review]
Bug 39658: Schema: Add Koha object class mappings

Map PatronAccountLink to Koha::Patron::AccountLink(s).

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 70 Kellie Stephens 2026-02-24 21:14:15 UTC
Created attachment 193816 [details] [review]
Bug 39658: (follow-up) linked hold pickup all types

Linked account hold pickup check now applies to all hold
statuses (Reserved, Transferred, Processing), not just Waiting.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>
Comment 71 Kellie Stephens 2026-02-24 21:14:18 UTC
Created attachment 193817 [details] [review]
Bug 39658: (follow-up) block checkout when linked accounts over charge limit

When AllowFineOverride is disabled and NoIssuesChargeLinkedAccounts
is exceeded, hide the barcode field and show 'Cannot check out'.

Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Kellie Stephens <kellie.stephens@bywatersolutions.com>