From f3f318978786820bd5451feee5acd7cbadaaad7c 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 --- C4/Serials.pm | 21 +++++++++- .../prog/en/modules/serials/claims.tt | 2 - .../en/modules/serials/serials-collection.tt | 1 + .../prog/en/modules/serials/serials-edit.tt | 2 + serials/claims.pl | 4 +- serials/serials-collection.pl | 1 - t/db_dependent/Serials/Claims.t | 3 +- t/db_dependent/Serials/updateClaim.t | 42 +++++++++++++++++++ 8 files changed, 70 insertions(+), 6 deletions(-) create mode 100755 t/db_dependent/Serials/updateClaim.t diff --git a/C4/Serials.pm b/C4/Serials.pm index ad772fecac..d896800701 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1150,7 +1150,6 @@ sub ModSerialStatus { my $subscription = GetSubscription($subscriptionid); my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); - # next issue number my ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, @@ -1931,6 +1930,26 @@ sub updateClaim { unless ( ref $serialids ) { $serialids = [ $serialids ]; } + foreach my $serialid(@$serialids) { + + my $serial = Koha::Serials->find($serialid); + my $serialseq = $serial->serialseq; + my $publisheddate = $serial->publisheddate; + my $publisheddatetext = $serial->publisheddatetext; + my $planneddate = $serial->planneddate; + my $status = C4::Serials->CLAIMED; + my $notes = $serial->notes; + + C4::Serials::ModSerialStatus( + $serialid, + $serialseq, + $planneddate, + $publisheddate, + $publisheddatetext, + $status, + $notes + ); + } my $dbh = C4::Context->dbh; return $dbh->do(q| UPDATE serial diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt index 9c9278a7f2..eb748a97f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt @@ -45,7 +45,6 @@

Claims [% IF ( suppliername ) %] for [% suppliername | html %] [% END %]

- [% IF error_claim %] [% IF error_claim == 'no_vendor_email' %]
This vendor has no email defined for late issues.
@@ -212,7 +211,6 @@ [% END %] -
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt index 69575baacc..5779aa44ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt @@ -196,6 +196,7 @@ + [% FOREACH serial IN year.serials %] [% IF ( CAN_user_serials_receive_serials ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt index 642dd2cc5e..ad819bd240 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt @@ -131,6 +131,7 @@ $(document).ready(function() { Status Notes + [% FOREACH serialslis IN serialslist %] @@ -293,6 +294,7 @@ $(document).ready(function() { [% END %] [% END %] [% END %] + [% FOREACH newserialloo IN newserialloop %] [% UNLESS ( newserialloo.subscriptionexpired ) %] diff --git a/serials/claims.pl b/serials/claims.pl index a16d840efe..446ceaf14b 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -25,11 +25,12 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Context; use C4::Letters qw( GetLetters SendAlerts ); + use Koha::AdditionalFields; use Koha::CsvProfiles; +use Koha::Serial; my $input = CGI->new; - my $serialid = $input->param('serialid'); my $op = $input->param('op'); my $claimletter = $input->param('claimletter'); @@ -64,6 +65,7 @@ if (@serialnums) { # i.e. they have been flagged to generate claims C4::Serials::updateClaim( \@serialnums ); } }; + if ( $@ ) { $template->param(error_claim => $@); } elsif ( ref $err and exists $err->{error} ) { diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index 2179b83069..0df95bfb9a 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -28,7 +28,6 @@ use C4::Context; use Koha::Serial::Items; use Koha::DateUtils qw( dt_from_string ); - use List::MoreUtils qw( uniq ); diff --git a/t/db_dependent/Serials/Claims.t b/t/db_dependent/Serials/Claims.t index afc3a18e66..b2651ebc4a 100755 --- a/t/db_dependent/Serials/Claims.t +++ b/t/db_dependent/Serials/Claims.t @@ -76,7 +76,9 @@ my $sample_supplier2 = { }; my $supplier1 = Koha::Acquisition::Bookseller->new($sample_supplier1)->store; + my $supplier2 = Koha::Acquisition::Bookseller->new($sample_supplier2)->store; + my $supplier_id1 = $supplier1->id; my $supplier_id2 = $supplier2->id; @@ -130,7 +132,6 @@ is( GetLateOrMissingIssues(), undef, 'GetLateOrMissingIssues should return undef my @late_or_missing_issues = GetLateOrMissingIssues( $supplier_id1 ); is( scalar(@late_or_missing_issues), 1, 'supplier 1 should have 1 issue in late' ); - @late_or_missing_issues = GetLateOrMissingIssues( $supplier_id2); is( scalar(@late_or_missing_issues), 2, 'supplier 2 should have 2 issues in late' ); 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.17.1