Bug 35646 - Allow using the publication date parts for serial numbering
Summary: Allow using the publication date parts for serial numbering
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Serials (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Nick Clemens (kidclamp)
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 37001
  Show dependency treegraph
 
Reported: 2023-12-22 18:20 UTC by Nick Clemens (kidclamp)
Modified: 2024-11-15 21:30 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/995
Text to go in the release notes:
This adds some new placeholders to be used within the numbering pattern of a subscription: {Year}, {Day}, {DayName}, {Month}, {MonthName}. They will be automatically replaced with the corresponding value derived from the publication date of the issue when its received.
Version(s) released in:
24.05.00
Circulation function:


Attachments
Bgg 35646: Allow use of publication date fields in serial numbering pattern (3.57 KB, patch)
2023-12-22 18:27 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35646: Allow use of publication date fields in serial numbering pattern (3.50 KB, patch)
2023-12-22 18:56 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35646: Unit tests (2.98 KB, patch)
2023-12-22 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35646: Allow use of publication date fields in serial numbering pattern (3.55 KB, patch)
2023-12-26 15:41 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 35646: Unit tests (3.03 KB, patch)
2023-12-26 15:41 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 35646: Allow use of publication date fields in serial numbering pattern (3.55 KB, patch)
2024-04-18 13:12 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35646: Unit tests (3.00 KB, patch)
2024-04-18 13:12 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35646: (follow-up) Correct firstaquidate type (2.12 KB, patch)
2024-04-18 13:12 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35646: Allow use of publication date fields in serial numbering pattern (3.65 KB, patch)
2024-04-18 13:22 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 35646: Unit tests (3.10 KB, patch)
2024-04-18 13:22 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 35646: (follow-up) Correct firstaquidate type (2.21 KB, patch)
2024-04-18 13:22 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2023-12-22 18:20:53 UTC
Sometimes libraries want date fields based on publication date included in the numbering, say for a weekly serial
Comment 1 Nick Clemens (kidclamp) 2023-12-22 18:27:02 UTC Comment hidden (obsolete)
Comment 2 Nick Clemens (kidclamp) 2023-12-22 18:56:59 UTC
Created attachment 160276 [details] [review]
Bug 35646: Allow use of publication date fields in serial numbering pattern

This patch extends the numbering pattern field to accept subsitituations for:
{Year} {Day} {DayName} {Month} {MonthName}

These fields are based on the publication date for the serial issue.

To test:
0 - Apply patch
1 - Setup a enw numbering pattern
    Serials->Manage numbering patterns + New numbering pattern
2 - In the numbering formula enter: {X} {Y} {Z} {Year} {Month} {Day} {MonthName} {DayName}
3 - Populate X/Y/Z in the table as you wish, these should be unaffected by patch
4 - Set a Frequency /  First issue plublication date / Subscription length
5 - Click 'Test pattern'
6 - Confirm the dates in the Number match the publication date values
7 - Try with different frequencies to confirm they match
8 - Save the pattern
9 - Create a new subscription and use the new pattern
10 - Confirm it works as expected
Comment 3 Nick Clemens (kidclamp) 2023-12-22 18:57:01 UTC
Created attachment 160277 [details] [review]
Bug 35646: Unit tests
Comment 4 Lucas Gass (lukeg) 2023-12-26 15:41:48 UTC
Created attachment 160297 [details] [review]
Bug 35646: Allow use of publication date fields in serial numbering pattern

This patch extends the numbering pattern field to accept subsitituations for:
{Year} {Day} {DayName} {Month} {MonthName}

These fields are based on the publication date for the serial issue.

To test:
0 - Apply patch
1 - Setup a enw numbering pattern
    Serials->Manage numbering patterns + New numbering pattern
2 - In the numbering formula enter: {X} {Y} {Z} {Year} {Month} {Day} {MonthName} {DayName}
3 - Populate X/Y/Z in the table as you wish, these should be unaffected by patch
4 - Set a Frequency /  First issue plublication date / Subscription length
5 - Click 'Test pattern'
6 - Confirm the dates in the Number match the publication date values
7 - Try with different frequencies to confirm they match
8 - Save the pattern
9 - Create a new subscription and use the new pattern
10 - Confirm it works as expected

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 5 Lucas Gass (lukeg) 2023-12-26 15:41:50 UTC
Created attachment 160298 [details] [review]
Bug 35646: Unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 6 Marcel de Rooy 2024-04-18 12:43:32 UTC
subsitituations ?
Are these events related to using substitutions? Like when I was in a subsitituation the other day ;)

+    my $dt = dt_from_string( $subscription->{firstaquidate} );
Could be me, but looks like a typo.

+        firstaquidate  => '1970-11-01',
Comment 7 Nick Clemens (kidclamp) 2024-04-18 13:12:47 UTC
Created attachment 165088 [details] [review]
Bug 35646: Allow use of publication date fields in serial numbering pattern

This patch extends the numbering pattern field to accept subsititutions for:
{Year} {Day} {DayName} {Month} {MonthName}

These fields are based on the publication date for the serial issue.

To test:
0 - Apply patch
1 - Setup a enw numbering pattern
    Serials->Manage numbering patterns + New numbering pattern
2 - In the numbering formula enter: {X} {Y} {Z} {Year} {Month} {Day} {MonthName} {DayName}
3 - Populate X/Y/Z in the table as you wish, these should be unaffected by patch
4 - Set a Frequency /  First issue plublication date / Subscription length
5 - Click 'Test pattern'
6 - Confirm the dates in the Number match the publication date values
7 - Try with different frequencies to confirm they match
8 - Save the pattern
9 - Create a new subscription and use the new pattern
10 - Confirm it works as expected

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Nick Clemens (kidclamp) 2024-04-18 13:12:50 UTC
Created attachment 165089 [details] [review]
Bug 35646: Unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 9 Nick Clemens (kidclamp) 2024-04-18 13:12:52 UTC
Created attachment 165090 [details] [review]
Bug 35646: (follow-up) Correct firstaquidate type
Comment 10 Marcel de Rooy 2024-04-18 13:22:14 UTC
Created attachment 165093 [details] [review]
Bug 35646: Allow use of publication date fields in serial numbering pattern

This patch extends the numbering pattern field to accept subsititutions for:
{Year} {Day} {DayName} {Month} {MonthName}

These fields are based on the publication date for the serial issue.

To test:
0 - Apply patch
1 - Setup a enw numbering pattern
    Serials->Manage numbering patterns + New numbering pattern
2 - In the numbering formula enter: {X} {Y} {Z} {Year} {Month} {Day} {MonthName} {DayName}
3 - Populate X/Y/Z in the table as you wish, these should be unaffected by patch
4 - Set a Frequency /  First issue plublication date / Subscription length
5 - Click 'Test pattern'
6 - Confirm the dates in the Number match the publication date values
7 - Try with different frequencies to confirm they match
8 - Save the pattern
9 - Create a new subscription and use the new pattern
10 - Confirm it works as expected

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 11 Marcel de Rooy 2024-04-18 13:22:16 UTC
Created attachment 165094 [details] [review]
Bug 35646: Unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 12 Marcel de Rooy 2024-04-18 13:22:19 UTC
Created attachment 165095 [details] [review]
Bug 35646: (follow-up) Correct firstaquidate type

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 13 Katrin Fischer 2024-04-29 07:16:49 UTC
I do like {Year} {Month} {Day}.

I struggle with: {MonthName} {DayName} 
These don't seem to take the Locale set into account - so maybe English only or will use the interface language? Ideally it should follow the locale setting.
Comment 14 Katrin Fischer 2024-04-29 07:38:14 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 15 Fridolin Somers 2024-05-24 09:47:14 UTC
Not backported to 23.11.x
Comment 16 Katrin Fischer 2024-05-26 19:36:55 UTC
(In reply to Katrin Fischer from comment #13)
> I do like {Year} {Month} {Day}.
> 
> I struggle with: {MonthName} {DayName} 
> These don't seem to take the Locale set into account - so maybe English only
> or will use the interface language? Ideally it should follow the locale
> setting.

NICK! *tries to get attention*
Comment 17 Nick Clemens (kidclamp) 2024-05-29 17:41:07 UTC
(In reply to Katrin Fischer from comment #16)
> (In reply to Katrin Fischer from comment #13)
> > I do like {Year} {Month} {Day}.
> > 
> > I struggle with: {MonthName} {DayName} 
> > These don't seem to take the Locale set into account - so maybe English only
> > or will use the interface language? Ideally it should follow the locale
> > setting.
> 
> NICK! *tries to get attention*

I think it doesn't work because we don't set Locale for the DateTime objects we create in Koha::DateUtils:
https://metacpan.org/pod/DateTime#Locales


We could easily pass through the 'locale' from the Serial (subscription table) however, I spot tested and got an error for 'Ethiopic'/'gez' though it is listed here:
https://metacpan.org/pod/DateTime::Locale::Catalog
Our list comes from here:
https://www.loc.gov/standards/iso639-2/php/code_list.php

Maybe our datetime modules need an update?

Here is a full list of ones that throw an error:
Invalid locale code or name: akk
Invalid locale code or name: tut
Invalid locale code or name: grc
Invalid locale code or name: ave
Invalid locale code or name: bnt
Invalid locale code or name: bra
Invalid locale code or name: cel
Invalid locale code or name: chp
Invalid locale code or name: cho
Invalid locale code or name: chu
Invalid locale code or name: syc
Invalid locale code or name: cop
Invalid locale code or name: cre
Invalid locale code or name: prs
Invalid locale code or name: dgr
Invalid locale code or name: egy
Invalid locale code or name: gez
Invalid locale code or name: gem
Invalid locale code or name: got
Invalid locale code or name: gwi
Invalid locale code or name: her
Invalid locale code or name: hit
Invalid locale code or name: inc
Invalid locale code or name: iku
Invalid locale code or name: ipk
Invalid locale code or name: ira
Invalid locale code or name: jrb
Invalid locale code or name: csb
Invalid locale code or name: lad
Invalid locale code or name: lat
Invalid locale code or name: myn
Invalid locale code or name: dum
Invalid locale code or name: enm
Invalid locale code or name: frm
Invalid locale code or name: gmh
Invalid locale code or name: mga
Invalid locale code or name: mul
Invalid locale code or name: nah
Invalid locale code or name: zxx
Invalid locale code or name: nya
Invalid locale code or name: arc
Invalid locale code or name: ang
Invalid locale code or name: fro
Invalid locale code or name: goh
Invalid locale code or name: peo
Invalid locale code or name: pro
Invalid locale code or name: ota
Invalid locale code or name: pal
Invalid locale code or name: pli
Invalid locale code or name: pbr
Invalid locale code or name: pra
Invalid locale code or name: roa
Invalid locale code or name: rom
Invalid locale code or name: sam
Invalid locale code or name: sem
Invalid locale code or name: den
Invalid locale code or name: sla
Invalid locale code or name: wen
Invalid locale code or name: sux
Invalid locale code or name: syr
Invalid locale code or name: tgl
Invalid locale code or name: tet
Invalid locale code or name: uga
Invalid locale code or name: mis
Comment 18 Nick Clemens (kidclamp) 2024-05-31 10:36:41 UTC
Filed a new bug for this issue - can we remove addition_work from this one?
Comment 19 Katrin Fischer 2024-05-31 11:04:09 UTC
(In reply to Nick Clemens (kidclamp) from comment #18)
> Filed a new bug for this issue - can we remove addition_work from this one?

Yep, I used it so we would not forget about this loose end.
Comment 20 Phil Ringnalda 2024-11-15 00:17:59 UTC
(In reply to Fridolin Somers from comment #15)
> Not backported to 23.11.x