Bug 37796: Pass correct publication date when generating the next serial form the serial collection page
Before this patch, we pass the previous issue date to generate the next seq - this works for the pattern as we are incrementing. When the patter is translated ot words, we need to do this from the date of the next issue, so we must pass in the next published date 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: 0 - Follow the plan to recreate from the initial bug description and recreate 1 - Apply patch 2 - On the serial used in previous patch go to 'Serial collection' 3 - Generate next issue 4 - Confirm the numbering is correctly generated after this patch Signed-off-by: Wesley Owen <wesleyowen@churchofjesuschrist.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
7abf1aeef9
commit
f2f30ad9b9
|
|
@ -810,7 +810,7 @@ sub GetPreviousSerialid {
|
|||
my (
|
||||
$nextseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
|
||||
$newinnerloop1, $newinnerloop2, $newinnerloop3
|
||||
) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $count_forward );
|
||||
) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $nextpublisheddate, $count_forward );
|
||||
|
||||
$subscription is a hashref containing all the attributes of the table
|
||||
'subscription'.
|
||||
|
|
@ -818,13 +818,14 @@ $pattern is a hashref containing all the attributes of the table
|
|||
'subscription_numberpatterns'.
|
||||
$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
|
||||
$planneddate is a date string in iso format.
|
||||
$nextpublishedddate is a date string in iso format.
|
||||
$count_forward is the number of issues to count forward, defaults to 1 if omitted
|
||||
This function get the next issue for the subscription given on input arg
|
||||
|
||||
=cut
|
||||
|
||||
sub GetNextSeq {
|
||||
my ( $subscription, $pattern, $frequency, $planneddate, $count_forward ) = @_;
|
||||
my ( $subscription, $pattern, $frequency, $planneddate, $nextpublisheddate, $count_forward ) = @_;
|
||||
|
||||
return unless ( $subscription and $pattern );
|
||||
|
||||
|
|
@ -915,7 +916,7 @@ sub GetNextSeq {
|
|||
$calculated =~ s/\{Z\}/$newlastvalue3string/g;
|
||||
}
|
||||
|
||||
my $dt = dt_from_string($planneddate);
|
||||
my $dt = dt_from_string($nextpublisheddate);
|
||||
$calculated =~ s/\{Month\}/$dt->month/eg;
|
||||
$calculated =~ s/\{MonthName\}/$dt->month_name/eg;
|
||||
$calculated =~ s/\{Year\}/$dt->year/eg;
|
||||
|
|
@ -1167,15 +1168,16 @@ sub ModSerialStatus {
|
|||
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
|
||||
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
|
||||
|
||||
# next date (calculated from actual date & frequency parameters)
|
||||
my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $frequency, 1 );
|
||||
my $nextpubdate = $nextpublisheddate;
|
||||
|
||||
# next issue number
|
||||
my (
|
||||
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
|
||||
$newinnerloop1, $newinnerloop2, $newinnerloop3
|
||||
) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $count );
|
||||
) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $nextpublisheddate, $count );
|
||||
|
||||
# next date (calculated from actual date & frequency parameters)
|
||||
my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $frequency, 1 );
|
||||
my $nextpubdate = $nextpublisheddate;
|
||||
$query =
|
||||
"UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
|
||||
WHERE subscriptionid = ?";
|
||||
|
|
|
|||
|
|
@ -82,14 +82,20 @@ 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);
|
||||
my (
|
||||
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
|
||||
$newinnerloop1, $newinnerloop2, $newinnerloop3
|
||||
) = GetNextSeq( $subscription, $pattern, $frequency, $expected->{publisheddate}, $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;
|
||||
|
||||
my (
|
||||
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
|
||||
$newinnerloop1, $newinnerloop2, $newinnerloop3
|
||||
)
|
||||
= GetNextSeq(
|
||||
$subscription, $pattern, $frequency, $expected->{publisheddate}, $nextpublisheddate,
|
||||
$count_forward
|
||||
);
|
||||
|
||||
my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
|
||||
## Creating the new issue
|
||||
NewIssue(
|
||||
$newserialseq, $subscriptionid, $subscription->{'biblionumber'},
|
||||
|
|
|
|||
|
|
@ -259,6 +259,6 @@ sub _next_seq {
|
|||
$seq, $subscription->{lastvalue1}, $subscription->{lastvalue2},
|
||||
$subscription->{lastvalue3}, $subscription->{innerloop1},
|
||||
$subscription->{innerloop2}, $subscription->{innerloop3}
|
||||
) = GetNextSeq( $subscription, $pattern, undef, undef, $count_forward );
|
||||
) = GetNextSeq( $subscription, $pattern, undef, undef, undef, $count_forward );
|
||||
return $seq;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -727,14 +727,16 @@ subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub {
|
|||
'GetSeq correctly calculates numbering from first aqui date, leap year'
|
||||
);
|
||||
|
||||
my $planneddate = '1970-11-01';
|
||||
($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate );
|
||||
is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from planned date' );
|
||||
$planneddate = '2024-02-29';
|
||||
($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate );
|
||||
my $planneddate = '1970-10-01';
|
||||
my $nextpublisheddate = '1970-11-01';
|
||||
($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate, $nextpublisheddate );
|
||||
is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from next published date' );
|
||||
$planneddate = '2024-01-29';
|
||||
$nextpublisheddate = '2024-02-29';
|
||||
($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate, $nextpublisheddate );
|
||||
is(
|
||||
$numbering, '2024 29 Thursday 2 February',
|
||||
'GetNextSeq correctly calculates numbering from planned date, leap year'
|
||||
'GetNextSeq correctly calculates numbering from next published date, leap year'
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue