[Bug 22707] New: Allow manual definition of AutoMemberNum range
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Bug ID: 22707 Summary: Allow manual definition of AutoMemberNum range Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: andrew@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com Target Milestone: --- It'd be great to have a way to tell Koha where to start when assigning card numbers via AutoMemberNum and to see what the next number will be. Bug 19263 introduced a feature that uses an authorized value to set up ranges of auto-incremented control numbers in bib records. Could something similar be used for card numbers? Ideally, this could also allow the definition of separate card number ranges for different branches. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Andrew <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Kelly McElligott <kelly@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kelly@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #1 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Our current flood of libraries trying to set up online self-reg is highlighting the problems with AutoMemberNum as it exists now. Giving this a bump. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=19958 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Jessie Zairo <jzairo@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jzairo@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #2 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- A couple suggestions from a librarian: 1. Able to specify a card number length, and a starting number (or a range). 2. Able to randomize a bit when incrementing, for example, NewCardNumber = CurrentLargestNumber += RandomNumberBetween(0~10) -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Sally <sally.healey@cheshiresharedservices.gov.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sally.healey@cheshireshared | |services.gov.uk --- Comment #3 from Sally <sally.healey@cheshiresharedservices.gov.uk> --- Being able to specify a starting number or range would be great. It would also be useful to have on/off settings for the OPAC and staff client. For instance, to only generate a card number when a staff member creates an account via the staff client, but not when someone joins online. Or the opposite, to only generate a card number when a patron joins online, but not when a member of staff creates an account via the staff client. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Kris <kbecker@jcls.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kbecker@jcls.org --- Comment #4 from Kris <kbecker@jcls.org> --- This would be a big help to us. Every other month staff accidentally make a patron card that's larger than the highest in Koha and then there's any number of self reg patrons that need to be corrected because the numbering system got thrown off. Thanks! -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Chris Rowlands <chris.rowlands6@nhs.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chris.rowlands6@nhs.net -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Patch complexity|--- |Medium patch Sponsorship status|--- |Unsponsored Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199826 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199826&action=edit Bug 22707: Add Koha::AutoNumber generic strategy framework Introduces a context-aware strategy framework for generating unique sequential identifiers, applicable to any domain (patron cardnumbers, item barcodes, or others) without per-domain code in the strategies. Context is injected at construction time: format_pref — syspref that selects the active strategy counter_pref — syspref holding the monotonic counter db_source — DBIx::Class result source name (e.g. 'Borrower') db_column — column within that source Strategies only override two hooks: _next_from($prev) — pure generation arithmetic (check digits, padding) db_max($schema) — narrowed query when the format needs it (EAN-13) Both next_value() (locking, consuming) and peek() (non-locking, advisory) call _next_from(), keeping format logic in exactly one place. Two strategies are provided: Sequential — increments the highest value by 1; uses DBIx::Class with a CAST literal for correct numeric ordering of variable- length values. EAN13 — generates valid 13-digit EAN-13 barcodes using Algorithm::CheckDigits; uses a fully idiomatic DBIC get_column->max query (no CAST needed since all EAN-13 values share the same 13-digit length). Strategy subclasses are lazy-loaded inside new() to avoid a circular compile-time dependency (the subclasses declare 'use parent Koha::AutoNumber'). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199827 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199827&action=edit Bug 22707: Add Koha::Patron::AutoNumber as a domain adapter for patron cardnumbers Adds a thin adapter class that instantiates Koha::AutoNumber with the patron-specific context: format_pref => autoMemberNumFormat counter_pref => autoMemberNumValue db_source => Borrower db_column => cardnumber Callers use Koha::Patron::AutoNumber->new->next_value($schema) without needing to know about the generic framework. A future Koha::Item::AutoNumber can follow the identical pattern for item barcodes. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199828 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199828&action=edit Bug 22707: Delegate fixup_cardnumber to Koha::Patron::AutoNumber Replaces the inline generation logic in fixup_cardnumber with a one-line call to the active AutoNumber strategy. The strategy is responsible for locking autoMemberNumValue FOR UPDATE, computing the next value, and applying any formatting — keeping Patron.pm free of generation details. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199829 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199829&action=edit Bug 22707: Add system preferences for cardnumber generation strategy autoMemberNumFormat — 'sequential' (default) or 'ean13' The EAN-13 option appears in the Patrons section of System Preferences immediately below the existing autoMemberNum toggle, with a note directing staff to seed autoMemberNumValue with their institutional prefix barcode. Test plan: 1. Apply patch and run the database update. 2. Confirm the sequential strategy is unchanged: a. Ensure autoMemberNum is enabled and autoMemberNumFormat is 'sequential' (the default). b. Create a new patron without entering a card number. c. Confirm the card number is auto-assigned as the next integer after the current maximum. 3. Test the EAN-13 strategy: a. Go to Administration > System preferences > Patrons. b. Set autoMemberNumFormat to 'EAN-13'. c. Set autoMemberNumValue to a valid 13-digit EAN-13 barcode that represents the start of your institutional range, for example a GS1-prefixed number with a zero sequential part and the correct check digit (e.g. use an online EAN-13 check-digit calculator to construct a starting value). d. Create a new patron without entering a card number. e. Confirm the assigned card number is 13 digits and passes EAN-13 check-digit validation. f. Create a second patron. Confirm the card number is the next valid EAN-13 in sequence. 4. Verify that legacy short card numbers do not inflate the EAN-13 sequence: a. Manually assign a short numeric card number (e.g. '12345') to a patron while autoMemberNumFormat is 'ean13'. b. Create another patron without a card number. c. Confirm the auto-assigned value is still a valid 13-digit EAN-13, not a number derived from '12345'. 5. Switch autoMemberNumFormat back to 'sequential' and confirm that sequential generation resumes correctly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199830 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199830&action=edit Bug 22707: Add tests for Koha::AutoNumber strategy framework Unit tests (t/Koha/Patron/AutoNumber.t): - Factory: correct strategy returned for each format_pref value; Koha::Patron::AutoNumber delegates to Koha::AutoNumber - Sequential::effective_floor uses base-class default - EAN13::_next_from produces valid 13-digit EAN-13 values - EAN13 format_value and effective_floor use base-class defaults DB-dependent tests (t/db_dependent/Koha/Patron/AutoNumber.t): - Tests use patron context config (db_source/db_column) directly, demonstrating that the generic strategies work with any injected result source and column - Sequential: db_max, next_value, counter updated in autoMemberNumValue - EAN13: db_max excludes short and non-numeric values; next_value produces valid EAN-13; short-cardnumber patrons do not inflate the sequence - peek: advisory preview, counter unchanged, idempotent -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- *** Bug 19958 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=42734 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- OK, bug 42734 covers the basic case where you want to override the 'start' point of the simple incrementing numbers. I thought I'd re-purpose this bug for adding a framework around building out more configurable automated number incrementalism.. It ships with 'Sequential' and 'EAN13' as initial options for Patron barcodes -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |42752 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42752 [Bug 42752] Add additional patron cardnumber generation strategies to Koha::AutoNumber -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199834 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199834&action=edit Bug 22707: Show next auto-generated card number as a hint on the patron form When autoMemberNum is enabled and the card number field is not mandatory, memberentry.pl now calls Koha::Patron::AutoNumber->peek() and passes the result to the template. The patron form shows: "Leave blank for auto calc during registration — next available: XXXXX" Because peek() is advisory (no lock taken), the displayed value is the likely next number but may differ from the one actually assigned at save time if another patron is saved concurrently. Test plan: 1. Enable autoMemberNum in System Preferences. 2. Go to Patrons > New patron. 3. Navigate to the Library management tab (step 3). 4. Confirm the card number hint reads "Leave blank for auto calc during registration — next available: XXXXX" with the expected next value. 5. With autoMemberNumFormat set to 'ean13', confirm the hint shows a valid 13-digit EAN-13 barcode. 6. Save the patron and confirm the assigned card number matches (or is close to) the hinted value. 7. Confirm the hint is absent when card number is listed in BorrowerMandatoryField (the existing error message should appear instead). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Allow manual definition of |Add format options for |AutoMemberNum range |AutoMemberNum -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org