https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22707
--- Comment #5 from Martin Renvoize (ashimema) <[email protected]> --- 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. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
