From bd72f24d04a9843cdb6a86b2ee7a7adff1fc46bb Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Mon, 4 Apr 2022 11:00:09 +0200 Subject: [PATCH] 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 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 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 Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- C4/Serials.pm | 15 ++++++++++ t/db_dependent/Serials/updateClaim.t | 42 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 t/db_dependent/Serials/updateClaim.t diff --git a/C4/Serials.pm b/C4/Serials.pm index 37f1c169a6..31a61c05fa 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -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 diff --git a/t/db_dependent/Serials/updateClaim.t b/t/db_dependent/Serials/updateClaim.t new file mode 100755 index 0000000000..1eed7db318 --- /dev/null +++ b/t/db_dependent/Serials/updateClaim.t @@ -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" ); -- 2.39.5