Bug 38924 - Introduce an organization level loan 'Quota' system for Koha
Summary: Introduce an organization level loan 'Quota' system for Koha
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jacob O'Mara
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-19 07:41 UTC by Martin Renvoize (ashimema)
Modified: 2025-08-22 02:19 UTC (History)
4 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 38924: Add patron_quotas table (4.17 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: DBIC Schema (4.23 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add Koha::Patron::Quota(s) classes (5.71 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add quotas permissions (4.81 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add API endpoints for managing quotas (12.95 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add patron quota management page (20.83 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add patron_quota_usage table (4.34 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: DBIC Schema (5.62 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add Koha::Patron::Quota::Usage(s) classes (4.63 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Overload delete method in Koha::Old::Checkout (1.36 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add AllowQuotaOverride and UseGuarantorQuota preferences (4.58 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add get_patron_quotas method (4.06 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Hook quota check and allocation into checkout (3.77 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Hook quota check and allocation into renewals (1.52 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add quota picker to checkout confirmation (13.39 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add koha_object_class to Schema files (2.26 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Move from get_patron_quota to Koha::Patron relations (11.53 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add quotas available on circuation screen (3.72 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add relations after the hash in DBIC (1.17 KB, patch)
2025-02-24 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add type and timestamp to usage table (3.79 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: DBIC Dump (1.84 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page (1.70 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Display quota used at checkout (2.26 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add issue and old_issue relations to Schema (2.10 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add quota usage api endpoint (10.92 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add quota usage details modal (22.69 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add option to enable/disable quotas (14.10 KB, patch)
2025-02-24 16:30 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38924: Add patron_quotas table (4.17 KB, patch)
2025-08-21 17:24 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: DBIC Schema (4.22 KB, patch)
2025-08-21 17:24 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add Koha::Patron::Quota(s) classes (5.70 KB, patch)
2025-08-21 17:24 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quotas permissions (4.84 KB, patch)
2025-08-21 17:24 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add API endpoints for managing quotas (12.93 KB, patch)
2025-08-21 17:24 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add patron quota management page (20.82 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add patron_quota_usage table (4.33 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: DBIC Schema (5.00 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add Koha::Patron::Quota::Usage(s) classes (4.62 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Overload delete method in Koha::Old::Checkout (1.36 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add AllowQuotaOverride and UseGuarantorQuota preferences (4.57 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add get_patron_quotas method (4.05 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Hook quota check and allocation into checkout (3.76 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Hook quota check and allocation into renewals (1.52 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota picker to checkout confirmation (13.17 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add koha_object_class to Schema files (1.81 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Move from get_patron_quota to Koha::Patron relations (11.49 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quotas available on circuation screen (3.72 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add relations after the hash in DBIC (1.24 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add type and timestamp to usage table (3.31 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: DBIC Dump (1.84 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page (1.70 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Display quota used at checkout (2.35 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add issue and old_issue relations to Schema (1.75 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota usage api endpoint (10.69 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota usage details modal (22.69 KB, patch)
2025-08-21 17:25 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add option to enable/disable quotas (13.94 KB, patch)
2025-08-21 17:26 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add patron_quotas table (4.17 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: DBIC Schema (4.22 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add Koha::Patron::Quota(s) classes (5.70 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quotas permissions (4.84 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add API endpoints for managing quotas (12.93 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add patron quota management page (20.82 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add patron_quota_usage table (4.33 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: DBIC Schema (5.00 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add Koha::Patron::Quota::Usage(s) classes (4.62 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Overload delete method in Koha::Old::Checkout (1.36 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add AllowQuotaOverride and UseGuarantorQuota preferences (4.57 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add get_patron_quotas method (4.05 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Hook quota check and allocation into checkout (3.76 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Hook quota check and allocation into renewals (1.52 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota picker to checkout confirmation (13.17 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add koha_object_class to Schema files (1.81 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Move from get_patron_quota to Koha::Patron relations (11.49 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quotas available on circuation screen (3.72 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add relations after the hash in DBIC (1.24 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add type and timestamp to usage table (3.31 KB, patch)
2025-08-21 22:53 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: DBIC Dump (1.84 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page (1.70 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Display quota used at checkout (2.35 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add issue and old_issue relations to Schema (2.02 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota usage api endpoint (10.69 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add quota usage details modal (22.69 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Add option to enable/disable quotas (13.94 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38924: Remove duplicate sub (2.14 KB, patch)
2025-08-21 22:54 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2025-01-19 07:41:18 UTC
Some libraries work based on the number of allowed issues in a time period as opposed to the number of simultaneous issues.

This enhancement intends to add a per-user, including guarantee/guarantor relations, quota option for setting a fixed number of issues a user is allowed within a specified period.
Comment 1 Martin Renvoize (ashimema) 2025-01-19 07:42:18 UTC
Initial proposed specification: https://docs.google.com/document/d/1YbEuWbt2ELNbFv36T0qlMscofhMI2wwyhjhhLYAM2X8/edit?usp=sharing
Comment 2 Martin Renvoize (ashimema) 2025-02-24 16:29:14 UTC
Created attachment 178582 [details] [review]
Bug 38924: Add patron_quotas table

Add the new patron_quotas table for storing circulation quotas
Comment 3 Martin Renvoize (ashimema) 2025-02-24 16:29:17 UTC
Created attachment 178583 [details] [review]
Bug 38924: DBIC Schema

DBIC update
Comment 4 Martin Renvoize (ashimema) 2025-02-24 16:29:19 UTC
Created attachment 178584 [details] [review]
Bug 38924: Add Koha::Patron::Quota(s) classes

Add initial Koha::Patron::Quota(s) classes for working with circulation
quotas, including an overloaded store method to prevent overlapping
quota periods. Additionally added a definition for the custom exception
for if you are trying to store a quota whos active period overlaps with
another for this patron
Comment 5 Martin Renvoize (ashimema) 2025-02-24 16:29:21 UTC
Created attachment 178585 [details] [review]
Bug 38924: Add quotas permissions

This patch adds the new quotas permissions to the system
Comment 6 Martin Renvoize (ashimema) 2025-02-24 16:29:24 UTC
Created attachment 178586 [details] [review]
Bug 38924: Add API endpoints for managing quotas

This commit adds the api endpoints for administering circulation quotas
Comment 7 Martin Renvoize (ashimema) 2025-02-24 16:29:26 UTC
Created attachment 178587 [details] [review]
Bug 38924: Add patron quota management page

Add a new patron quota management tab under the members area for patrons
of the organization category type.

FIXME: Tie into permissions for 'add', 'edit'

Depending on permissions, we will need display only options including
guarantor and guarantee usage against quotas and also the options to add
and edit quota.
Comment 8 Martin Renvoize (ashimema) 2025-02-24 16:29:29 UTC
Created attachment 178588 [details] [review]
Bug 38924: Add patron_quota_usage table

Add the new patron_quota_usage table for recording usage of quota
allocations against user issues.
Comment 9 Martin Renvoize (ashimema) 2025-02-24 16:29:31 UTC
Created attachment 178589 [details] [review]
Bug 38924: DBIC Schema
Comment 10 Martin Renvoize (ashimema) 2025-02-24 16:29:34 UTC
Created attachment 178590 [details] [review]
Bug 38924: Add Koha::Patron::Quota::Usage(s) classes

Add ::Usage(s) classes for working with quota allocation usage.

We overload store to ensure data consistency for the checkout_id field
which is linked to either the issue or old_issue table appropriatly.

We include a checkout relationship that handles the lack of foreign key
due to issues/old_issues.

We also add the Usage relations to Quota objects
Comment 11 Martin Renvoize (ashimema) 2025-02-24 16:29:37 UTC
Created attachment 178591 [details] [review]
Bug 38924: Overload delete method in Koha::Old::Checkout

This overloads the delete method for old::checkouts to ensure that the
issue_id for quotas usage is nulled in the event that an old_checkout is
deleted.
Would like to make this the standard for all the tables we have had to
handle issue/old_issues for but is currently just hard-coded for quotas
as many of the other tables with issue_id columns are not nullable.
Comment 12 Martin Renvoize (ashimema) 2025-02-24 16:29:39 UTC
Created attachment 178592 [details] [review]
Bug 38924: Add AllowQuotaOverride and UseGuarantorQuota preferences

Add a system preferences to allow/dissallow quota overflow at checkout
and enable/disable the use of guarantor quotas against guarantees
Comment 13 Martin Renvoize (ashimema) 2025-02-24 16:29:41 UTC
Created attachment 178593 [details] [review]
Bug 38924: Add get_patron_quotas method

This commit adds the ability to return the guarantor's quota when
searching for a patron's quota at checkout. This will only occur if the
related syspref is enabled "UseGuaratorQuota" and will return in this
order or priority:
guarantor's quota with availability
patrons's quota with availability
guarantor's quota with no availability
patron's quota with no availibility
null
Comment 14 Martin Renvoize (ashimema) 2025-02-24 16:29:44 UTC
Created attachment 178594 [details] [review]
Bug 38924: Hook quota check and allocation into checkout
Comment 15 Martin Renvoize (ashimema) 2025-02-24 16:29:46 UTC
Created attachment 178595 [details] [review]
Bug 38924: Hook quota check and allocation into renewals

This adds the checks for quotas and allocates a usage for a renewal of a
book, should a quota exist for this patron
Comment 16 Martin Renvoize (ashimema) 2025-02-24 16:29:49 UTC
Created attachment 178596 [details] [review]
Bug 38924: Add quota picker to checkout confirmation

This patch adds the quota selector to the checkout confirmation for if
multiple eligable quotas are available

Bug 38924: Return all eligable quotas so that the staff user can pick

This patch adds the logic to return multiple eligable quotas if there
are more than 1, allowing the staff user to pick which to assign an item
to.

Bug 38924: Add searcher method for currently active quota for patron

Bug 38924: amend circ logic to handle multiple eligable quotas

This amends the circulations logic to handle the fact that we can return
multiple eligable quotas now. This ensures that the same quotas as was
used for the checkout will be used for the renewal (both check and
assignment) and that we use the selected quota from our confirmation
dropdown for checkout of new item

Bug 38924: add better name display for quota select at checkout
Comment 17 Martin Renvoize (ashimema) 2025-02-24 16:29:52 UTC
Created attachment 178597 [details] [review]
Bug 38924: Add koha_object_class to Schema files
Comment 18 Martin Renvoize (ashimema) 2025-02-24 16:29:54 UTC
Created attachment 178598 [details] [review]
Bug 38924: Move from get_patron_quota to Koha::Patron relations

Bug 38924: Deal with multiple quota options in QUOTA_EXCEEDED handling

Bug 38924: Deal with using the same quota for renewals
Comment 19 Martin Renvoize (ashimema) 2025-02-24 16:29:57 UTC
Created attachment 178599 [details] [review]
Bug 38924: Add quotas available on circuation screen
Comment 20 Martin Renvoize (ashimema) 2025-02-24 16:29:59 UTC
Created attachment 178600 [details] [review]
Bug 38924: Add relations after the hash in DBIC

This adds additional relations to our DBIC classes to allow relation
traversal in our Koha::Objects
Comment 21 Martin Renvoize (ashimema) 2025-02-24 16:30:02 UTC
Created attachment 178601 [details] [review]
Bug 38924: Add type and timestamp to usage table

This allows us to more easily audit what actions incremented the usage
and when.

We will use this later in display
Comment 22 Martin Renvoize (ashimema) 2025-02-24 16:30:04 UTC
Created attachment 178602 [details] [review]
Bug 38924: DBIC Dump
Comment 23 Martin Renvoize (ashimema) 2025-02-24 16:30:07 UTC
Created attachment 178603 [details] [review]
Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page
Comment 24 Martin Renvoize (ashimema) 2025-02-24 16:30:09 UTC
Created attachment 178604 [details] [review]
Bug 38924: Display quota used at checkout

Use the quota relation added to Koha::Checkout to display an info alert
message that quota allocation has been used by the checkout that just
took place
Comment 25 Martin Renvoize (ashimema) 2025-02-24 16:30:12 UTC
Created attachment 178605 [details] [review]
Bug 38924: Add issue and old_issue relations to Schema
Comment 26 Martin Renvoize (ashimema) 2025-02-24 16:30:15 UTC
Created attachment 178606 [details] [review]
Bug 38924: Add quota usage api endpoint
Comment 27 Martin Renvoize (ashimema) 2025-02-24 16:30:17 UTC
Created attachment 178607 [details] [review]
Bug 38924: Add quota usage details modal
Comment 28 Martin Renvoize (ashimema) 2025-02-24 16:30:20 UTC
Created attachment 178608 [details] [review]
Bug 38924: Add option to enable/disable quotas
Comment 29 Martin Renvoize (ashimema) 2025-02-24 16:31:31 UTC
This was a team effort between Jacob and I
Comment 30 Victor Grousset/tuxayo 2025-08-21 17:24:49 UTC Comment hidden (obsolete)
Comment 31 Victor Grousset/tuxayo 2025-08-21 17:24:51 UTC Comment hidden (obsolete)
Comment 32 Victor Grousset/tuxayo 2025-08-21 17:24:54 UTC Comment hidden (obsolete)
Comment 33 Victor Grousset/tuxayo 2025-08-21 17:24:57 UTC Comment hidden (obsolete)
Comment 34 Victor Grousset/tuxayo 2025-08-21 17:24:59 UTC Comment hidden (obsolete)
Comment 35 Victor Grousset/tuxayo 2025-08-21 17:25:02 UTC Comment hidden (obsolete)
Comment 36 Victor Grousset/tuxayo 2025-08-21 17:25:05 UTC Comment hidden (obsolete)
Comment 37 Victor Grousset/tuxayo 2025-08-21 17:25:08 UTC Comment hidden (obsolete)
Comment 38 Victor Grousset/tuxayo 2025-08-21 17:25:11 UTC Comment hidden (obsolete)
Comment 39 Victor Grousset/tuxayo 2025-08-21 17:25:14 UTC Comment hidden (obsolete)
Comment 40 Victor Grousset/tuxayo 2025-08-21 17:25:17 UTC Comment hidden (obsolete)
Comment 41 Victor Grousset/tuxayo 2025-08-21 17:25:20 UTC Comment hidden (obsolete)
Comment 42 Victor Grousset/tuxayo 2025-08-21 17:25:22 UTC Comment hidden (obsolete)
Comment 43 Victor Grousset/tuxayo 2025-08-21 17:25:25 UTC Comment hidden (obsolete)
Comment 44 Victor Grousset/tuxayo 2025-08-21 17:25:28 UTC Comment hidden (obsolete)
Comment 45 Victor Grousset/tuxayo 2025-08-21 17:25:31 UTC Comment hidden (obsolete)
Comment 46 Victor Grousset/tuxayo 2025-08-21 17:25:34 UTC Comment hidden (obsolete)
Comment 47 Victor Grousset/tuxayo 2025-08-21 17:25:37 UTC Comment hidden (obsolete)
Comment 48 Victor Grousset/tuxayo 2025-08-21 17:25:40 UTC Comment hidden (obsolete)
Comment 49 Victor Grousset/tuxayo 2025-08-21 17:25:43 UTC Comment hidden (obsolete)
Comment 50 Victor Grousset/tuxayo 2025-08-21 17:25:45 UTC Comment hidden (obsolete)
Comment 51 Victor Grousset/tuxayo 2025-08-21 17:25:48 UTC Comment hidden (obsolete)
Comment 52 Victor Grousset/tuxayo 2025-08-21 17:25:51 UTC Comment hidden (obsolete)
Comment 53 Victor Grousset/tuxayo 2025-08-21 17:25:54 UTC Comment hidden (obsolete)
Comment 54 Victor Grousset/tuxayo 2025-08-21 17:25:56 UTC Comment hidden (obsolete)
Comment 55 Victor Grousset/tuxayo 2025-08-21 17:25:59 UTC Comment hidden (obsolete)
Comment 56 Victor Grousset/tuxayo 2025-08-21 17:26:02 UTC Comment hidden (obsolete)
Comment 57 Victor Grousset/tuxayo 2025-08-21 22:53:01 UTC
Created attachment 185675 [details] [review]
Bug 38924: Add patron_quotas table

Add the new patron_quotas table for storing circulation quotas
Comment 58 Victor Grousset/tuxayo 2025-08-21 22:53:04 UTC
Created attachment 185676 [details] [review]
Bug 38924: DBIC Schema

DBIC update
Comment 59 Victor Grousset/tuxayo 2025-08-21 22:53:07 UTC
Created attachment 185677 [details] [review]
Bug 38924: Add Koha::Patron::Quota(s) classes

Add initial Koha::Patron::Quota(s) classes for working with circulation
quotas, including an overloaded store method to prevent overlapping
quota periods. Additionally added a definition for the custom exception
for if you are trying to store a quota whos active period overlaps with
another for this patron
Comment 60 Victor Grousset/tuxayo 2025-08-21 22:53:10 UTC
Created attachment 185678 [details] [review]
Bug 38924: Add quotas permissions

This patch adds the new quotas permissions to the system

Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 61 Victor Grousset/tuxayo 2025-08-21 22:53:13 UTC
Created attachment 185679 [details] [review]
Bug 38924: Add API endpoints for managing quotas

This commit adds the api endpoints for administering circulation quotas
Comment 62 Victor Grousset/tuxayo 2025-08-21 22:53:16 UTC
Created attachment 185680 [details] [review]
Bug 38924: Add patron quota management page

Add a new patron quota management tab under the members area for patrons
of the organization category type.

FIXME: Tie into permissions for 'add', 'edit'

Depending on permissions, we will need display only options including
guarantor and guarantee usage against quotas and also the options to add
and edit quota.
Comment 63 Victor Grousset/tuxayo 2025-08-21 22:53:18 UTC
Created attachment 185681 [details] [review]
Bug 38924: Add patron_quota_usage table

Add the new patron_quota_usage table for recording usage of quota
allocations against user issues.
Comment 64 Victor Grousset/tuxayo 2025-08-21 22:53:21 UTC
Created attachment 185682 [details] [review]
Bug 38924: DBIC Schema
Comment 65 Victor Grousset/tuxayo 2025-08-21 22:53:24 UTC
Created attachment 185683 [details] [review]
Bug 38924: Add Koha::Patron::Quota::Usage(s) classes

Add ::Usage(s) classes for working with quota allocation usage.

We overload store to ensure data consistency for the checkout_id field
which is linked to either the issue or old_issue table appropriatly.

We include a checkout relationship that handles the lack of foreign key
due to issues/old_issues.

We also add the Usage relations to Quota objects
Comment 66 Victor Grousset/tuxayo 2025-08-21 22:53:27 UTC
Created attachment 185684 [details] [review]
Bug 38924: Overload delete method in Koha::Old::Checkout

This overloads the delete method for old::checkouts to ensure that the
issue_id for quotas usage is nulled in the event that an old_checkout is
deleted.
Would like to make this the standard for all the tables we have had to
handle issue/old_issues for but is currently just hard-coded for quotas
as many of the other tables with issue_id columns are not nullable.
Comment 67 Victor Grousset/tuxayo 2025-08-21 22:53:30 UTC
Created attachment 185685 [details] [review]
Bug 38924: Add AllowQuotaOverride and UseGuarantorQuota preferences

Add a system preferences to allow/dissallow quota overflow at checkout
and enable/disable the use of guarantor quotas against guarantees
Comment 68 Victor Grousset/tuxayo 2025-08-21 22:53:33 UTC
Created attachment 185686 [details] [review]
Bug 38924: Add get_patron_quotas method

This commit adds the ability to return the guarantor's quota when
searching for a patron's quota at checkout. This will only occur if the
related syspref is enabled "UseGuaratorQuota" and will return in this
order or priority:
guarantor's quota with availability
patrons's quota with availability
guarantor's quota with no availability
patron's quota with no availibility
null
Comment 69 Victor Grousset/tuxayo 2025-08-21 22:53:36 UTC
Created attachment 185687 [details] [review]
Bug 38924: Hook quota check and allocation into checkout
Comment 70 Victor Grousset/tuxayo 2025-08-21 22:53:39 UTC
Created attachment 185688 [details] [review]
Bug 38924: Hook quota check and allocation into renewals

This adds the checks for quotas and allocates a usage for a renewal of a
book, should a quota exist for this patron
Comment 71 Victor Grousset/tuxayo 2025-08-21 22:53:42 UTC
Created attachment 185689 [details] [review]
Bug 38924: Add quota picker to checkout confirmation

This patch adds the quota selector to the checkout confirmation for if
multiple eligable quotas are available

Bug 38924: Return all eligable quotas so that the staff user can pick

This patch adds the logic to return multiple eligable quotas if there
are more than 1, allowing the staff user to pick which to assign an item
to.

Bug 38924: Add searcher method for currently active quota for patron

Bug 38924: amend circ logic to handle multiple eligable quotas

This amends the circulations logic to handle the fact that we can return
multiple eligable quotas now. This ensures that the same quotas as was
used for the checkout will be used for the renewal (both check and
assignment) and that we use the selected quota from our confirmation
dropdown for checkout of new item

Bug 38924: add better name display for quota select at checkout
Comment 72 Victor Grousset/tuxayo 2025-08-21 22:53:45 UTC
Created attachment 185690 [details] [review]
Bug 38924: Add koha_object_class to Schema files
Comment 73 Victor Grousset/tuxayo 2025-08-21 22:53:48 UTC
Created attachment 185691 [details] [review]
Bug 38924: Move from get_patron_quota to Koha::Patron relations

Bug 38924: Deal with multiple quota options in QUOTA_EXCEEDED handling

Bug 38924: Deal with using the same quota for renewals
Comment 74 Victor Grousset/tuxayo 2025-08-21 22:53:51 UTC
Created attachment 185692 [details] [review]
Bug 38924: Add quotas available on circuation screen
Comment 75 Victor Grousset/tuxayo 2025-08-21 22:53:54 UTC
Created attachment 185693 [details] [review]
Bug 38924: Add relations after the hash in DBIC

This adds additional relations to our DBIC classes to allow relation
traversal in our Koha::Objects

Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 76 Victor Grousset/tuxayo 2025-08-21 22:53:57 UTC
Created attachment 185694 [details] [review]
Bug 38924: Add type and timestamp to usage table

This allows us to more easily audit what actions incremented the usage
and when.

We will use this later in display
Comment 77 Victor Grousset/tuxayo 2025-08-21 22:54:00 UTC
Created attachment 185695 [details] [review]
Bug 38924: DBIC Dump
Comment 78 Victor Grousset/tuxayo 2025-08-21 22:54:03 UTC
Created attachment 185696 [details] [review]
Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page
Comment 79 Victor Grousset/tuxayo 2025-08-21 22:54:06 UTC
Created attachment 185697 [details] [review]
Bug 38924: Display quota used at checkout

Use the quota relation added to Koha::Checkout to display an info alert
message that quota allocation has been used by the checkout that just
took place

Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 80 Victor Grousset/tuxayo 2025-08-21 22:54:09 UTC
Created attachment 185698 [details] [review]
Bug 38924: Add issue and old_issue relations to Schema
Comment 81 Victor Grousset/tuxayo 2025-08-21 22:54:12 UTC
Created attachment 185699 [details] [review]
Bug 38924: Add quota usage api endpoint
Comment 82 Victor Grousset/tuxayo 2025-08-21 22:54:15 UTC
Created attachment 185700 [details] [review]
Bug 38924: Add quota usage details modal
Comment 83 Victor Grousset/tuxayo 2025-08-21 22:54:18 UTC
Created attachment 185701 [details] [review]
Bug 38924: Add option to enable/disable quotas
Comment 84 Victor Grousset/tuxayo 2025-08-21 22:54:21 UTC
Created attachment 185702 [details] [review]
Bug 38924: Remove duplicate sub

It also made the tests fail
Comment 85 Victor Grousset/tuxayo 2025-08-22 02:12:09 UTC
Rebased. Compared old patches to new patches to ensure no unintended introduced changes.

There are some differences. But it seems it's not from solving conflicts but more the other changes in Koha somehow causing a change generated schema code to move from one commit to another. Anyway, same final state.
https://gitlab.com/tuxayo/Koha/-/commit/a8314615be7286edde4f00338f91d3143606cbca#31b1f86aafa41bf560774c2daa7af732818260e1_47_47
https://gitlab.com/tuxayo/Koha/-/commit/17092c96432275b77e8297a9e388e8a76e2f28f7#47

https://gitlab.com/tuxayo/Koha/-/commit/acedb3f90e07d6ed2b26ab0427ad8dadc86e3183#31b1f86aafa41bf560774c2daa7af732818260e1_0_47
https://gitlab.com/tuxayo/Koha/-/commit/49afbbcb06d0b19e35dc8c0df543c3594f9b4121#31b1f86aafa41bf560774c2daa7af732818260e1_0_47


Tests pass. Anything else to run than t/Koha/Auth/Permissions.t ?
Doesn't mean everything works as on 2025-02-24.
In case it's needed later, relevant branch: https://gitlab.com/tuxayo/Koha/-/commits/bug_38924-old-2025-02-24

Any test plan besides following the high level user stories of the document in comment 1?
If it's that, at least that should be mentioned in a commit message in a test plan section. Or copy the user story there.
Comment 86 Victor Grousset/tuxayo 2025-08-22 02:19:33 UTC
There are 3 DBIC generation commits (which generate 3 times conflicts VS having one).
And they don't have DO NOT PUSH in the name. https://wiki.koha-community.org/wiki/Database_updates#Files_to_change

--

Since February, bug 39367 landed, providing that test:

kohadev-koha@kohadevbox:koha(bug_38924-rebase-wip)$ time prove xt/author/pod_coverage.t
xt/author/pod_coverage.t .. 864/1249
#   Failed test 'POD coverage for Koha/Schema/Result/PatronQuota.pm'
#   at xt/author/pod_coverage.t line 35.
#          got: '1'
#     expected: '0'
# koha_objects_class

#   Failed test 'POD coverage for Koha/Schema/Result/PatronQuotaUsage.pm'
#   at xt/author/pod_coverage.t line 35.
#          got: '2'
#     expected: '0'
# koha_objects_class, koha_object_class
xt/author/pod_coverage.t .. 1241/1249 # Looks like you failed 2 tests of 1249.
xt/author/pod_coverage.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/1249 subtests

Test Summary Report
-------------------
xt/author/pod_coverage.t (Wstat: 512 (exited 2) Tests: 1249 Failed: 2)
  Failed tests:  1015-1016
  Non-zero exit status: 2
Files=1, Tests=1249,  8 wallclock secs ( 0.23 usr  0.02 sys +  6.43 cusr  0.63 csys =  7.31 CPU)
Result: FAIL