Bug 23775: Claiming a serial issue doesn't create the next one

Whenever we need to generate manually a new serial we go to page
'serials-edit.pl'. With this patch it is possible to generate a new
serial on page 'serials.pl'.

Test Plan:
-- Previously we need a serial which is in EXPECTED status & the Date
received should not be later than today --
1) On the intra. Make sure to have at least 1 subscription for a
   bibliographic record & 1 vendor linked
2) Then Home > Serials > Claims > Claims for <your_vendor_name>
3) Tick the checkbox of the row where the status is EXPECTED then
4) Click 'Send notification'
5) Notice the status of the row : it is now CLAIMED
6) To verify: Home > Serials > Serial collection information for
   <your_record_name>
7) Here the status is CLAIMED too but nothing happened around
8) Apply patch
9) Repeat from 2) to 6)
10) The status is still CLAIMED & the new serial with status EXPECTED is
    freshly generated

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
jeremy breuillard 2022-04-04 11:00:09 +02:00 committed by Tomas Cohen Arazi
parent b9ffc47100
commit bd72f24d04
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 57 additions and 0 deletions

View File

@ -1892,6 +1892,21 @@ sub updateClaim {
unless ( ref $serialids ) {
$serialids = [ $serialids ];
}
foreach my $serialid(@$serialids) {
my $serial = Koha::Serials->find($serialid);
C4::Serials::ModSerialStatus(
$serialid,
$serial->serialseq,
$serial->planneddate,
$serial->publisheddate,
$serial->publisheddatetext,
C4::Serials->CLAIMED,
$serial->notes
);
}
my $dbh = C4::Context->dbh;
return $dbh->do(q|
UPDATE serial

View File

@ -0,0 +1,42 @@
use Modern::Perl;
use Test::More tests => 3;
use C4::Serials;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM subscription|);
my $branchcode = 'CPL';
my $record = MARC::Record->new();
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, '');
# Create a new subscription
my $subscriptionid_claims = C4::Serials::NewSubscription(
undef, $branchcode, undef, undef, undef, $biblionumber,
'2013-01-01', undef, undef, undef, undef,
undef, undef, undef, undef, undef, undef,
1, "notes",undef, '9999-01-01', undef, undef,
undef, undef, 0, "intnotes", 0,
undef, undef, 0, undef, '2013-12-31', 0
);
# Verify and get the serial ID of the subscription
my ( $totalissues, @serials ) = C4::Serials::GetSerials($subscriptionid_claims, 1);
C4::Serials::updateClaim( $serials[0]->{serialid} ); # Updating the claim
# sort the result to separate the CLAIMED and EXPECTED status
@serials = sort { $a->{serialid} <=> $b->{serialid} } @serials;
# Verify if serial IDs are correctly generated
( $totalissues, @serials ) = C4::Serials::GetSerials($subscriptionid_claims);
is ( scalar(@serials), 2, "le test est terminé" ); # Gives the length of the @serials
is ( ($serials[0]->{status}), C4::Serials::CLAIMED, "test CLAIMED" );
is ( ($serials[1]->{status}), C4::Serials::EXPECTED, "test EXPECTED" );