|
Description
Martin Renvoize (ashimema)
2025-01-19 07:41:18 UTC
Initial proposed specification: https://docs.google.com/document/d/1YbEuWbt2ELNbFv36T0qlMscofhMI2wwyhjhhLYAM2X8/edit?usp=sharing Created attachment 178582 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Created attachment 178583 [details] [review] Bug 38924: DBIC Schema DBIC update 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 Created attachment 178585 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Created attachment 178586 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas 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. 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. Created attachment 178589 [details] [review] Bug 38924: DBIC Schema 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 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. 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 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 Created attachment 178594 [details] [review] Bug 38924: Hook quota check and allocation into checkout 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 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 Created attachment 178597 [details] [review] Bug 38924: Add koha_object_class to Schema files 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 Created attachment 178599 [details] [review] Bug 38924: Add quotas available on circuation screen 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 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 Created attachment 178602 [details] [review] Bug 38924: DBIC Dump Created attachment 178603 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page 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 Created attachment 178605 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Created attachment 178606 [details] [review] Bug 38924: Add quota usage api endpoint Created attachment 178607 [details] [review] Bug 38924: Add quota usage details modal Created attachment 178608 [details] [review] Bug 38924: Add option to enable/disable quotas This was a team effort between Jacob and I Created attachment 185631 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Created attachment 185632 [details] [review] Bug 38924: DBIC Schema DBIC update Created attachment 185633 [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 Created attachment 185634 [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> Created attachment 185635 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Created attachment 185636 [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. Created attachment 185637 [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. Created attachment 185638 [details] [review] Bug 38924: DBIC Schema Created attachment 185639 [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 Created attachment 185640 [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. Created attachment 185641 [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 Created attachment 185642 [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 Created attachment 185643 [details] [review] Bug 38924: Hook quota check and allocation into checkout Created attachment 185644 [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 Created attachment 185645 [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 Created attachment 185646 [details] [review] Bug 38924: Add koha_object_class to Schema files Created attachment 185647 [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 Created attachment 185648 [details] [review] Bug 38924: Add quotas available on circuation screen Created attachment 185649 [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> Created attachment 185650 [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 Created attachment 185651 [details] [review] Bug 38924: DBIC Dump Created attachment 185652 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Created attachment 185653 [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> Created attachment 185654 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Created attachment 185655 [details] [review] Bug 38924: Add quota usage api endpoint Created attachment 185656 [details] [review] Bug 38924: Add quota usage details modal Created attachment 185657 [details] [review] Bug 38924: Add option to enable/disable quotas Created attachment 185675 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Created attachment 185676 [details] [review] Bug 38924: DBIC Schema DBIC update 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 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> Created attachment 185679 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas 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. 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. Created attachment 185682 [details] [review] Bug 38924: DBIC Schema 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 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. 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 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 Created attachment 185687 [details] [review] Bug 38924: Hook quota check and allocation into checkout 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 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 Created attachment 185690 [details] [review] Bug 38924: Add koha_object_class to Schema files 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 Created attachment 185692 [details] [review] Bug 38924: Add quotas available on circuation screen 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> 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 Created attachment 185695 [details] [review] Bug 38924: DBIC Dump Created attachment 185696 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page 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> Created attachment 185698 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Created attachment 185699 [details] [review] Bug 38924: Add quota usage api endpoint Created attachment 185700 [details] [review] Bug 38924: Add quota usage details modal Created attachment 185701 [details] [review] Bug 38924: Add option to enable/disable quotas Created attachment 185702 [details] [review] Bug 38924: Remove duplicate sub It also made the tests fail 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. 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 Created attachment 189266 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Created attachment 189267 [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 Created attachment 189268 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Created attachment 189269 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Created attachment 189270 [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. Created attachment 189271 [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. Created attachment 189272 [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. Created attachment 189273 [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. Created attachment 189274 [details] [review] Bug 38924: Add Usage relations to Quota objects Created attachment 189275 [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 Created attachment 189276 [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 Created attachment 189277 [details] [review] Bug 38924: Hook quota check and allocation into checkout Created attachment 189278 [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 Created attachment 189279 [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 Created attachment 189280 [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 Created attachment 189281 [details] [review] Bug 38924: Add quotas available on circuation screen Created attachment 189282 [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 Created attachment 189283 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Created attachment 189284 [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 Created attachment 189285 [details] [review] Bug 38924: Add quota usage details modal Created attachment 189286 [details] [review] Bug 38924: Add option to enable/disable quotas Created attachment 189287 [details] [review] Bug 38924: DBIC - DO NOT PUSH Created attachment 189288 [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 Created attachment 189289 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Created attachment 189290 [details] [review] Bug 38924: Add koha_object_class to Schema files Created attachment 189291 [details] [review] Bug 38924: Add quota usage api endpoint Created attachment 189292 [details] [review] Bug 38924: (follow-up) Minor QOL quota modal fixes This patch: - Makes sure that the quotas modal displays the error message for why the submit failed, instead of a generic message - Clears the modal data on modal close to remove persistent data - Get dates directly from flatpickr selectedDates for API requests to ensure sync. After comparing the diffs, "Bug 38924: DBIC - DO NOT PUSH" include all changes from the 3 duplicates. The patches weren't marked as obsolete so they would have conflicted. -- The content of "Bug 38924: Remove duplicate sub" seem to have been done inline. So I obsoleted my follow-up that was hanging in the ticket. -- 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. -- New Test failure: kohadev-koha@kohadevbox:koha(testing-SO-QA)$ prove t/Koha/Auth/Permissions.t t/Koha/Auth/Permissions.t .. 1/4 # Failed test 'Expected permissions generated for superlibrarian' # at t/Koha/Auth/Permissions.t line 308. # Structures begin differing at: # $got->{CAN_user_borrowers_manage_borrower_quotas} = Does not exist # $expected->{CAN_user_borrowers_manage_borrower_quotas} = '1' # Looks like you failed 1 test of 1. # Failed test 'superlibrarian tests' # at t/Koha/Auth/Permissions.t line 309. Created attachment 193377 [details] [review] Bug 38924: Add patron_quotas table Setup: 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota in system preferences 2. Create an Institutional patron (ORG) and a second Institutional patron (MEMBER) as guarantee of ORG 3. Create a non-institutional patron (NORELATION) with no relationships Quota management: 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar 5. Open NORELATION's detail page → verify no quota tab 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. Re-enable before continuing 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the table 8. Add a second quota with overlapping dates → verify rejected with clash error 9. Edit the quota → verify modal prefills all fields including end date, save updates correctly 10. Add a future non-overlapping quota with no usage → verify Delete button appears. Delete it. Verify Delete button is absent on quotas that have usage Checkout with single quota: 11. Checkout an item to ORG → verify checkout succeeds, quota used increments, ISSUE usage record visible in details 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → verify confirmation prompt, can override 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt checkout → verify blocked, cannot proceed Checkout with guarantor quotas: 14. Give MEMBER their own active quota (allocation 5). 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own and guarantor quota Renewals and returns: 16. Renew an existing checkout that has quota usage → verify used increments and new RENEW usage record created 17. Return a checked-out item → verify quota used value is unchanged Add the new patron_quotas table for storing circulation quotas Created attachment 193378 [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 Created attachment 193379 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Created attachment 193380 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Created attachment 193381 [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. Created attachment 193382 [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. Created attachment 193383 [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. Created attachment 193384 [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. Created attachment 193385 [details] [review] Bug 38924: Add Usage relations to Quota objects Created attachment 193386 [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 Created attachment 193387 [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 Created attachment 193388 [details] [review] Bug 38924: Hook quota check and allocation into checkout Created attachment 193389 [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 Created attachment 193390 [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 Created attachment 193391 [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 Created attachment 193392 [details] [review] Bug 38924: Add quotas available on circuation screen Created attachment 193393 [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 Created attachment 193394 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Created attachment 193395 [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 Created attachment 193396 [details] [review] Bug 38924: Add quota usage details modal Created attachment 193397 [details] [review] Bug 38924: Add option to enable/disable quotas Created attachment 193398 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Created attachment 193399 [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 Created attachment 193400 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Created attachment 193401 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Created attachment 193402 [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. Created attachment 193403 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Setup: 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota in system preferences 2. Create an Institutional patron (ORG) and a second Institutional patron (MEMBER) as guarantee of ORG 3. Create a non-institutional patron (NORELATION) with no relationships Quota management: 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar 5. Open NORELATION's detail page → verify no quota tab 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. Re-enable before continuing 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the table 8. Add a second quota with overlapping dates → verify rejected with clash error 9. Edit the quota → verify modal prefills all fields including end date, save updates correctly 10. Add a future non-overlapping quota with no usage → verify Delete button appears. Delete it. Verify Delete button is absent on quotas that have usage Checkout with single quota: 11. Checkout an item to ORG → verify checkout succeeds, quota used increments, ISSUE usage record visible in details 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → verify confirmation prompt, can override 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt checkout → verify blocked, cannot proceed Checkout with guarantor quotas: 14. Give MEMBER their own active quota (allocation 5). 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own and guarantor quota Renewals and returns: 16. Renew an existing checkout that has quota usage → verify used increments and new RENEW usage record created 17. Return a checked-out item → verify quota used value is unchanged Created attachment 193404 [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 Created attachment 193405 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Created attachment 193406 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Created attachment 193407 [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. Created attachment 193408 [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. Created attachment 193409 [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. Created attachment 193410 [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. Created attachment 193411 [details] [review] Bug 38924: Add Usage relations to Quota objects Created attachment 193412 [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 Created attachment 193413 [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 Created attachment 193414 [details] [review] Bug 38924: Hook quota check and allocation into checkout Created attachment 193415 [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 Created attachment 193416 [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 Created attachment 193417 [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 Created attachment 193418 [details] [review] Bug 38924: Add quotas available on circuation screen Created attachment 193419 [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 Created attachment 193420 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Created attachment 193421 [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 Created attachment 193422 [details] [review] Bug 38924: Add quota usage details modal Created attachment 193423 [details] [review] Bug 38924: Add option to enable/disable quotas Created attachment 193424 [details] [review] Bug 38924: Add tests for quotas object classes and api endpoints Created attachment 193425 [details] [review] Bug 38924: DBIC - DO NOT PUSH Created attachment 193426 [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 Created attachment 193427 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Created attachment 193428 [details] [review] Bug 38924: Add koha_object_class to Schema files Created attachment 193429 [details] [review] Bug 38924: Add quota usage api endpoint Created attachment 193430 [details] [review] Bug 38924: (follow-up) Minor QOL quota modal fixes - Makes sure that the quotas modal displays the error message for why the submit failed, instead of a generic message - Clears the modal data on modal close to remove persistent data - Get dates directly from flatpickr selectedDates for API requests to ensure sync. Created attachment 193431 [details] [review] Bug 38924: (follow-up) Fix edit modal not autofilling end date The flatpickr setDate calls were passing triggerChange=1 which caused the start picker's hooks to interfere with the end picker before its value could be set. Remove triggerChange to match the pattern used by other Koha date pickers (members.js, datatables.js). Test plan is hidden in the ~200 comments so posting at the bottom as well for easier finding! Setup: 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota in system preferences 2. Create an Institutional patron (ORG) and a second Institutional patron (MEMBER) as guarantee of ORG 3. Create a non-institutional patron (NORELATION) with no relationships Quota management: 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar 5. Open NORELATION's detail page → verify no quota tab 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. Re-enable before continuing 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the table 8. Add a second quota with overlapping dates → verify rejected with clash error 9. Edit the quota → verify modal prefills all fields including end date, save updates correctly 10. Add a future non-overlapping quota with no usage → verify Delete button appears. Delete it. Verify Delete button is absent on quotas that have usage Checkout with single quota: 11. Checkout an item to ORG → verify checkout succeeds, quota used increments, ISSUE usage record visible in details 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → verify confirmation prompt, can override 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt checkout → verify blocked, cannot proceed Checkout with guarantor quotas: 14. Give MEMBER their own active quota (allocation 5). 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own and guarantor quota Renewals and returns: 16. Renew an existing checkout that has quota usage → verify used increments and new RENEW usage record created 17. Return a checked-out item → verify quota used value is unchanged Add the new patron_quotas table for storing circulation quotas Created attachment 193432 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Setup: 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota in system preferences 2. Create an Institutional patron (ORG) and a second Institutional patron (MEMBER) as guarantee of ORG 3. Create a non-institutional patron (NORELATION) with no relationships Quota management: 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar 5. Open NORELATION's detail page → verify no quota tab 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. Re-enable before continuing 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the table 8. Add a second quota with overlapping dates → verify rejected with clash error 9. Edit the quota → verify modal prefills all fields including end date, save updates correctly 10. Add a future non-overlapping quota with no usage → verify Delete button appears. Delete it. Verify Delete button is absent on quotas that have usage Checkout with single quota: 11. Checkout an item to ORG → verify checkout succeeds, quota used increments, ISSUE usage record visible in details 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → verify confirmation prompt, can override 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt checkout → verify blocked, cannot proceed Checkout with guarantor quotas: 14. Give MEMBER their own active quota (allocation 5). 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own and guarantor quota Renewals and returns: 16. Renew an existing checkout that has quota usage → verify used increments and new RENEW usage record created 17. Return a checked-out item → verify quota used value is unchanged Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193433 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193434 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193435 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193436 [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. Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193437 [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. Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193438 [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. Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193439 [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. Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193440 [details] [review] Bug 38924: Add Usage relations to Quota objects Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193441 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193442 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193443 [details] [review] Bug 38924: Hook quota check and allocation into checkout Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193444 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193445 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193446 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193447 [details] [review] Bug 38924: Add quotas available on circuation screen Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193448 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193449 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193450 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193451 [details] [review] Bug 38924: Add quota usage details modal Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193452 [details] [review] Bug 38924: Add option to enable/disable quotas Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193453 [details] [review] Bug 38924: Add tests for quotas object classes and api endpoints Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193454 [details] [review] Bug 38924: DBIC - DO NOT PUSH Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193455 [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 Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193456 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193457 [details] [review] Bug 38924: Add koha_object_class to Schema files Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193458 [details] [review] Bug 38924: Add quota usage api endpoint Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193459 [details] [review] Bug 38924: (follow-up) Minor QOL quota modal fixes - Makes sure that the quotas modal displays the error message for why the submit failed, instead of a generic message - Clears the modal data on modal close to remove persistent data - Get dates directly from flatpickr selectedDates for API requests to ensure sync. Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> Created attachment 193460 [details] [review] Bug 38924: (follow-up) Fix edit modal not autofilling end date The flatpickr setDate calls were passing triggerChange=1 which caused the start picker's hooks to interfere with the end picker before its value could be set. Remove triggerChange to match the pattern used by other Koha date pickers (members.js, datatables.js). Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk> This has been on one of our Customer's sites for around a year at this point with no issues, going to call that an implicit sign off that it works as expected. Added sign-off line and moved to needs QA Here is the test plan as it's once again buried: Setup: 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota in system preferences 2. Create an Institutional patron (ORG) and a second Institutional patron (MEMBER) as guarantee of ORG 3. Create a non-institutional patron (NORELATION) with no relationships Quota management: 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar 5. Open NORELATION's detail page → verify no quota tab 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. Re-enable before continuing 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the table 8. Add a second quota with overlapping dates → verify rejected with clash error 9. Edit the quota → verify modal prefills all fields including end date, save updates correctly 10. Add a future non-overlapping quota with no usage → verify Delete button appears. Delete it. Verify Delete button is absent on quotas that have usage Checkout with single quota: 11. Checkout an item to ORG → verify checkout succeeds, quota used increments, ISSUE usage record visible in details 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → verify confirmation prompt, can override 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt checkout → verify blocked, cannot proceed Checkout with guarantor quotas: 14. Give MEMBER their own active quota (allocation 5). 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own and guarantor quota Renewals and returns: 16. Renew an existing checkout that has quota usage → verify used increments and new RENEW usage record created 17. Return a checked-out item → verify quota used value is unchanged Created attachment 193547 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Setup: 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota in system preferences 2. Create an Institutional patron (ORG) and a second Institutional patron (MEMBER) as guarantee of ORG 3. Create a non-institutional patron (NORELATION) with no relationships Quota management: 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar 5. Open NORELATION's detail page → verify no quota tab 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. Re-enable before continuing 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the table 8. Add a second quota with overlapping dates → verify rejected with clash error 9. Edit the quota → verify modal prefills all fields including end date, save updates correctly 10. Add a future non-overlapping quota with no usage → verify Delete button appears. Delete it. Verify Delete button is absent on quotas that have usage Checkout with single quota: 11. Checkout an item to ORG → verify checkout succeeds, quota used increments, ISSUE usage record visible in details 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → verify confirmation prompt, can override 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt checkout → verify blocked, cannot proceed Checkout with guarantor quotas: 14. Give MEMBER their own active quota (allocation 5). 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own and guarantor quota Renewals and returns: 16. Renew an existing checkout that has quota usage → verify used increments and new RENEW usage record created 17. Return a checked-out item → verify quota used value is unchanged Created attachment 193548 [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 Created attachment 193549 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Created attachment 193550 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Created attachment 193551 [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. Created attachment 193552 [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. Created attachment 193553 [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. Created attachment 193554 [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. Created attachment 193555 [details] [review] Bug 38924: Add Usage relations to Quota objects Created attachment 193556 [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 Created attachment 193557 [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 Created attachment 193558 [details] [review] Bug 38924: Hook quota check and allocation into checkout Created attachment 193559 [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 Created attachment 193560 [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 Created attachment 193561 [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 Created attachment 193562 [details] [review] Bug 38924: Add quotas available on circuation screen Created attachment 193563 [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 Created attachment 193564 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Created attachment 193565 [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 Created attachment 193566 [details] [review] Bug 38924: Add quota usage details modal Created attachment 193567 [details] [review] Bug 38924: Add option to enable/disable quotas Created attachment 193568 [details] [review] Bug 38924: Add tests for quotas object classes and api endpoints Created attachment 193569 [details] [review] Bug 38924: DBIC - DO NOT PUSH Created attachment 193570 [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 Created attachment 193571 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Created attachment 193572 [details] [review] Bug 38924: Add koha_object_class to Schema files Created attachment 193573 [details] [review] Bug 38924: Add quota usage api endpoint Created attachment 193574 [details] [review] Bug 38924: (follow-up) Minor QOL quota modal fixes - Makes sure that the quotas modal displays the error message for why the submit failed, instead of a generic message - Clears the modal data on modal close to remove persistent data - Get dates directly from flatpickr selectedDates for API requests to ensure sync. Created attachment 193575 [details] [review] Bug 38924: (follow-up) Fix edit modal not autofilling end date The flatpickr setDate calls were passing triggerChange=1 which caused the start picker's hooks to interfere with the end picker before its value could be set. Remove triggerChange to match the pattern used by other Koha date pickers (members.js, datatables.js). Created attachment 193576 [details] [review] Bug 38924: (follow-up) Record RENEW usage type for renewals Pass explicit type param to add_usage: ISSUE for checkouts, RENEW for renewals. Default to ISSUE in add_usage for safety. Created attachment 193577 [details] [review] Bug 38924: (follow-up) Exclude QUOTA_SELECT from session remember Prevents quota selection from being stored in or skipped by the session confirmation cookie. Hides the remember checkbox when quota is the only confirmation shown. Created attachment 194119 [details] [review] Bug 38924: Add patron_quotas table Add the new patron_quotas table for storing circulation quotas Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194120 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194121 [details] [review] Bug 38924: Add quotas permissions This patch adds the new quotas permissions to the system Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194122 [details] [review] Bug 38924: Add API endpoints for managing quotas This commit adds the api endpoints for administering circulation quotas Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194123 [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. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194124 [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. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194125 [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. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194126 [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. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194127 [details] [review] Bug 38924: Add Usage relations to Quota objects Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194128 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194129 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194130 [details] [review] Bug 38924: Hook quota check and allocation into checkout Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194131 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194132 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194133 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194134 [details] [review] Bug 38924: Add quotas available on circuation screen Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194135 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194136 [details] [review] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194137 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194138 [details] [review] Bug 38924: Add quota usage details modal Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194139 [details] [review] Bug 38924: Add option to enable/disable quotas Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194140 [details] [review] Bug 38924: Add tests for quotas object classes and api endpoints Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194141 [details] [review] Bug 38924: DBIC - DO NOT PUSH Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194142 [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 Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194143 [details] [review] Bug 38924: Add issue and old_issue relations to Schema Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194144 [details] [review] Bug 38924: Add koha_object_class to Schema files Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194145 [details] [review] Bug 38924: Add quota usage api endpoint Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194146 [details] [review] Bug 38924: (follow-up) Minor QOL quota modal fixes - Makes sure that the quotas modal displays the error message for why the submit failed, instead of a generic message - Clears the modal data on modal close to remove persistent data - Get dates directly from flatpickr selectedDates for API requests to ensure sync. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194147 [details] [review] Bug 38924: (follow-up) Fix edit modal not autofilling end date The flatpickr setDate calls were passing triggerChange=1 which caused the start picker's hooks to interfere with the end picker before its value could be set. Remove triggerChange to match the pattern used by other Koha date pickers (members.js, datatables.js). Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194148 [details] [review] Bug 38924: (follow-up) Record RENEW usage type for renewals Pass explicit type param to add_usage: ISSUE for checkouts, RENEW for renewals. Default to ISSUE in add_usage for safety. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Created attachment 194149 [details] [review] Bug 38924: (follow-up) Exclude QUOTA_SELECT from session remember Prevents quota selection from being stored in or skipped by the session confirmation cookie. Hides the remember checkbox when quota is the only confirmation shown. Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> (In reply to Jacob O'Mara from comment #201) > Created attachment 193547 [details] [review] [review] > Bug 38924: Add patron_quotas table > > Add the new patron_quotas table for storing circulation quotas > > Setup: > 1. Enable EnableCirculationQuotas, AllowQuotaOverride, and UseGuarantorQuota > in system preferences > 2. Create an Institutional patron (ORG) and a second Institutional patron > (MEMBER) as guarantee of ORG > 3. Create a non-institutional patron (NORELATION) with no relationships > > Quota management: > 4. Open ORG's detail page → verify "Circulation quota" tab visible in sidebar > 5. Open NORELATION's detail page → verify no quota tab > 6. Disable EnableCirculationQuotas → open ORG → verify no quota tab. > Re-enable before continuing > 7. Add a quota for ORG: Q1 2026, allocation 10 → verify it appears in the > table > 8. Add a second quota with overlapping dates → verify rejected with clash > error > 9. Edit the quota → verify modal prefills all fields including end date, > save updates correctly > 10. Add a future non-overlapping quota with no usage → verify Delete button > appears. Delete it. Verify Delete button is absent on quotas that have usage > > Checkout with single quota: > 11. Checkout an item to ORG → verify checkout succeeds, quota used > increments, ISSUE usage record visible in details > 12. Exhaust ORG's quota, set AllowQuotaOverride ON → attempt checkout → > verify confirmation prompt, can override > 13. With quota still exhausted, set AllowQuotaOverride OFF → attempt > checkout → verify blocked, cannot proceed > > Checkout with guarantor quotas: > 14. Give MEMBER their own active quota (allocation 5). > 15. Checkout to MEMBER → verify QUOTA_SELECT prompt to choose between own > and guarantor quota > > Renewals and returns: > 16. Renew an existing checkout that has quota usage → verify used increments > and new RENEW usage record created > 17. Return a checked-out item → verify quota used value is unchanged Works as described in this test plan; signed off. |