From 26d8368820dc91d317bd1241f457f25aac1b5389 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Fri, 13 Sep 2024 17:41:02 +0000
Subject: [PATCH] Bug 37796: Pass correct publication date when generating the
 next serial form the serial collection page

This patch changes the call to GetNextSeq from serial-collection.pl to ensure the new issue publication date is used to
generate the numbers

To test:
1 - On the serial used in previous patch go to 'Serial collection'
2 - Generate next issue
3 - Confirm the numbering is correctly generated after this patch
---
 serials/serials-collection.pl | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl
index 025bde2179e..e3a6aceae14 100755
--- a/serials/serials-collection.pl
+++ b/serials/serials-collection.pl
@@ -78,13 +78,15 @@ if($op eq 'cud-gennext' && @subscriptionid){
             my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
             my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
             my $expected = GetNextExpected($subscriptionid);
+
+            ## We generate the next publication date
+            my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
+
             my (
                  $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
                  $newinnerloop1, $newinnerloop2, $newinnerloop3
-            ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}, $count_forward);
+            ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}, $nextpublisheddate, $count_forward);
 
-             ## We generate the next publication date
-             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
              my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
              ## Creating the new issue
              NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
-- 
2.39.2