Bug 25081: Fix creation of new item for a received issue
authorJanusz Kaczmarek <januszop@gmail.com>
Tue, 7 Apr 2020 20:23:20 +0000 (22:23 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 8 Apr 2020 10:53:20 +0000 (11:53 +0100)
commitbb527d54f598f91e4373282032fbc1ab9b0515d3
treed1232f349f872bf15a55dfa6bc73ae9d237783a9
parent947b16b322b9fe719a1bef6c25d4172db3d7cc8e
Bug 25081: Fix creation of new item for a received issue

The Bug 23435 introduced the idea of multiple copies added while
receiving a new issue.  Unfortunately, under some circumstances, it
causes no items being added at all.  It occurs stochastically, only
under some conditions.  But it is quite likely to happen while receiving
a supplemental issue.

The reason fot hist is that, in serials-edit.pl, line ca 292 and infra,
@num_copies is treated in the same way as @tags, while it should be
treated similarly to @bibnums.  It will be obvious after examining the
content of parameters tag, subfield, field_value, ..., number_of_copies.
In other words, for every edited issue number_of_copies is a scalar.

Nota bene:
a) beter to initialize $countdistinct with zero;
b) note that in master, now, before applying the patch,
$itemhash{$item}->{'num_copies'} is treated once as a scalar
and in the next line--as an array:

$itemhash{$item}->{'num_copies'} //= 1;

for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'}[$index];){

TEST PLAN
=========
1. Have a subscription with the option "Create an item
record when receiving this serial" active and try to receive a
supplemental issue.  Control that a new item under the biblio record
(usually) will not be created.
2. Apply the patch.
3. Repeat p. 1 -- a new item should be created.

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
serials/serials-edit.pl