Bug 24134 - Add placeholder for 2 digit years to allow autogeneration of dates in 008
Summary: Add placeholder for 2 digit years to allow autogeneration of dates in 008
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Owen Leonard
QA Contact: Tomás Cohen Arazi
URL:
Keywords: Academy
Depends on: 25599
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-29 04:55 UTC by Philip Bertling
Modified: 2020-11-30 21:51 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:
20.11.00


Attachments
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008 (5.63 KB, patch)
2019-12-09 16:56 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008 (5.68 KB, patch)
2019-12-09 18:37 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008 (5.73 KB, patch)
2020-05-28 23:08 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008 (5.78 KB, patch)
2020-08-11 14:39 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Bertling 2019-11-29 04:55:47 UTC
When creating a framework for a form type other than book, it does not seem possible to autogenerate the date correctly. The 00-05 ‘date entered on file’ in the 008 field, can almost be auto-filled by using the code <<YYYY>><<MM>><<DD>>. However it doesn’t quite work because the 008 field expects a 6 digit date [YYMMDD] – this code inserts an 8 digit date [YYYYMMDD].

e.g. <<YY>><<MM>><<DD>> b        at |||p  |||||00|   eng d 
= entered on the date <<29>><<11>><<25>>

This creates the following data in a record:
<<YY>>1125 b        at |||p  |||||00|   eng d

Is it possible to make this date code work to insert a date comprising 6 digits?
Comment 1 Katrin Fischer 2019-11-29 06:42:57 UTC
See bug 7045 for the other placeholders already available. At the moment we support:

<<DD>> - 2 digit day of month
<<MM>> - 2 digit number of month
<<YYYY>> - 4 digit year
<<USER>> - user adding the record
Comment 2 Owen Leonard 2019-12-09 16:56:48 UTC Comment hidden (obsolete)
Comment 3 Lucas Gass 2019-12-09 18:37:33 UTC
Created attachment 96113 [details] [review]
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008

This patch modifies the code for parsing MARC framework configurations
so that the placeholder "<<YY>>" translates to a two-year date.

To test, apply the patch and modify a framework to include placeholders.
For example, in MARC21:

 - Administration -> MARC structure -> 952 -> Edit subfields -> d
 - Expand "Advanced constraints" and add a default value:
   <<YYYY>> <<YY>> <<MM>> <<DD>> <<USER>>
 - Save your configuration and go to Cataloging.
 - Go to the add/edit items page for a record which uses the framework
   you edited.
 - In the "Add item" form, in the "Date aquired" field, you should see
   the correct values. For example: '2019 19 12 03 Leonard'

Perform the same test when adding an item during the Acquisitions
process (depending on your AcqCreateItem setting).

Note that acqui/neworderempty.pl has been modified because the
placeholder-replacement code is repeated there, but I couldn't discover
how to test it (if it is used at all?)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Katrin Fischer 2019-12-22 19:58:58 UTC
This works great int he cataloguing editor, but the replacement doesn't work in the ACQ framework.

To test:
- Activate UseACQFrameworkForBiblioRecords 
- Add 008 with a default using placeholders to the ACQ framework
- Add a basket
- Add a new po line to the basket using 'new record'
- Verify that the default is printed as is

And we have a log full of those - but before the patch too:
Use of uninitialized value $value in substitution (s///) at /home/vagrant/kohaclone/acqui/neworderempty.pl line 236.
Use of uninitialized value $value in substitution (s///) at /home/vagrant/kohaclone/acqui/neworderempty.pl line 237.
Use of uninitialized value $value in substitution (s///) at /home/vagrant/kohaclone/acqui/neworderempty.pl line 238.
Use of uninitialized value $value in substitution (s///) at /home/vagrant/kohaclone/acqui/neworderempty.pl line 239.
Use of uninitialized value $value in substitution (s///) at /home/vagrant/kohaclone/acqui/neworderempty.pl line 246.

It would be great if it could be fixed, but also contemplating if we should move this into another bug? 

Adding Tomas for the connection to UseACQFrameworkForBiblioRecords.
Comment 5 Katrin Fischer 2020-01-02 22:47:10 UTC
I'd really like to see this one moving. 

Jonathan fixes the default value behaviour on controlfields in bug 24294, but the placeholders are not replaced. Maybe we could treat this as a preexisting bug - meaning, we let this move in, but file a new bug for fixing the placeholder behaviour in acquisitions?
Comment 6 Katrin Fischer 2020-05-25 23:57:01 UTC
I've filed bug 25599 for the issue with the ACQ framework.
Comment 7 Katrin Fischer 2020-05-28 23:08:13 UTC
Created attachment 105430 [details] [review]
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008

This patch modifies the code for parsing MARC framework configurations
so that the placeholder "<<YY>>" translates to a two-year date.

To test, apply the patch and modify a framework to include placeholders.
For example, in MARC21:

 - Administration -> MARC structure -> 952 -> Edit subfields -> d
 - Expand "Advanced constraints" and add a default value:
   <<YYYY>> <<YY>> <<MM>> <<DD>> <<USER>>
 - Save your configuration and go to Cataloging.
 - Go to the add/edit items page for a record which uses the framework
   you edited.
 - In the "Add item" form, in the "Date aquired" field, you should see
   the correct values. For example: '2019 19 12 03 Leonard'

Perform the same test when adding an item during the Acquisitions
process (depending on your AcqCreateItem setting).

Note that acqui/neworderempty.pl has been modified because the
placeholder-replacement code is repeated there, but I couldn't discover
how to test it (if it is used at all?)

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Katrin Fischer 2020-05-28 23:09:35 UTC
Ok, so with bug 25599 fixing neworderempty, we can now move this one on as well. It applies cleanly on top and I have verified it works. Moving to blocked until the dependency moves to PQA.
Comment 9 Katrin Fischer 2020-06-29 13:11:29 UTC
Unblocking as dependency is in now.
Comment 10 Nick Clemens 2020-07-31 16:29:46 UTC
(In reply to Katrin Fischer from comment #9)
> Unblocking as dependency is in now.

With Lucas SO and your SO, should it be PQA?
Comment 11 Tomás Cohen Arazi 2020-08-11 14:39:18 UTC
Created attachment 108072 [details] [review]
Bug 24134: Add placeholder for 2 digit years to allow autogeneration of dates in 008

This patch modifies the code for parsing MARC framework configurations
so that the placeholder "<<YY>>" translates to a two-year date.

To test, apply the patch and modify a framework to include placeholders.
For example, in MARC21:

 - Administration -> MARC structure -> 952 -> Edit subfields -> d
 - Expand "Advanced constraints" and add a default value:
   <<YYYY>> <<YY>> <<MM>> <<DD>> <<USER>>
 - Save your configuration and go to Cataloging.
 - Go to the add/edit items page for a record which uses the framework
   you edited.
 - In the "Add item" form, in the "Date aquired" field, you should see
   the correct values. For example: '2019 19 12 03 Leonard'

Perform the same test when adding an item during the Acquisitions
process (depending on your AcqCreateItem setting).

Note that acqui/neworderempty.pl has been modified because the
placeholder-replacement code is repeated there, but I couldn't discover
how to test it (if it is used at all?)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 12 Jonathan Druart 2020-08-13 05:57:07 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 13 Lucas Gass 2020-08-17 15:29:03 UTC
not backporting enhancement to 20.05.x