Bug 36552: Update record 'date entered on file' when duplicating a record

The 'date entered on file' (MARC21: 008/0-5, UNIMARC: 100a/0=7) of a record created
by duplication of an existing record should be set to the current date instead of
having the value of the original record.

Test plan
=========
1. Check the 'date entered on file' of an existing biblio / authotiry record
   (MARC21: 008/0-5, UNIMARC: 100a/0=7).
2. Duplicate the record by Edit > Edit as new (duplicate)
3. Control the 'date entered on file' value - it will equal to that of the
   original record.
4. Apply the patch (restart plack).
5. Repeat step 2.
6. Check the date - it should be the current date.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit dd8f9e1266)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Janusz Kaczmarek 2023-04-27 01:04:48 +02:00 committed by Fridolin Somers
parent aabe54000a
commit 0cd9d2f184
2 changed files with 24 additions and 0 deletions

View file

@ -637,6 +637,17 @@ if ($op eq "add") {
} else {
if ( $op eq "duplicate" ) {
$authid = "";
if ( C4::Context->preference('marcflavour') eq 'MARC21' && $record->field('008') ) {
my $s008 = $record->field('008')->data;
my $date = POSIX::strftime( "%y%m%d", localtime );
substr( $s008, 0, 6, $date );
$record->field('008')->update($s008);
} elsif ( C4::Context->preference('marcflavour') eq 'UNIMARC' && $record->subfield( '100', 'a' ) ) {
my $s100a = $record->subfield( '100', 'a' );
my $date = POSIX::strftime( "%Y%m%d", localtime );
substr( $s100a, 0, 8, $date );
$record->field('100')->update( a => $s100a );
}
}
if ( $changed_authtype eq "changed" ) {

View file

@ -602,6 +602,19 @@ if ( $record && $op eq 'duplicate' &&
my @control_num = $record->field('001');
$record->delete_fields(@control_num);
}
if ( $record && $op eq 'duplicate' ) {
if ( C4::Context->preference('marcflavour') eq 'MARC21' && $record->field('008') ) {
my $s008 = $record->field('008')->data;
my $date = POSIX::strftime( "%y%m%d", localtime );
substr( $s008, 0, 6, $date );
$record->field('008')->update($s008);
} elsif ( C4::Context->preference('marcflavour') eq 'UNIMARC' && $record->subfield( '100', 'a' ) ) {
my $s100a = $record->subfield( '100', 'a' );
my $date = POSIX::strftime( "%Y%m%d", localtime );
substr( $s100a, 0, 8, $date );
$record->field('100')->update( a => $s100a );
}
}
#populate hostfield if hostbiblionumber is available
if ($hostbiblionumber) {
my $marcflavour = C4::Context->preference("marcflavour");