View | Details | Raw Unified | Return to bug 37796
Collapse All | Expand All

(-)a/C4/Serials.pm (-7 / +9 lines)
Lines 813-819 sub GetPreviousSerialid { Link Here
813
    my (
813
    my (
814
        $nextseq,       $newlastvalue1, $newlastvalue2, $newlastvalue3,
814
        $nextseq,       $newlastvalue1, $newlastvalue2, $newlastvalue3,
815
        $newinnerloop1, $newinnerloop2, $newinnerloop3
815
        $newinnerloop1, $newinnerloop2, $newinnerloop3
816
    ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $count_forward );
816
    ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $nextpublisheddate, $count_forward );
817
817
818
$subscription is a hashref containing all the attributes of the table
818
$subscription is a hashref containing all the attributes of the table
819
'subscription'.
819
'subscription'.
Lines 821-833 $pattern is a hashref containing all the attributes of the table Link Here
821
'subscription_numberpatterns'.
821
'subscription_numberpatterns'.
822
$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
822
$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
823
$planneddate is a date string in iso format.
823
$planneddate is a date string in iso format.
824
$nextpublishedddate is a date string in iso format.
824
$count_forward is the number of issues to count forward, defaults to 1 if omitted
825
$count_forward is the number of issues to count forward, defaults to 1 if omitted
825
This function get the next issue for the subscription given on input arg
826
This function get the next issue for the subscription given on input arg
826
827
827
=cut
828
=cut
828
829
829
sub GetNextSeq {
830
sub GetNextSeq {
830
    my ( $subscription, $pattern, $frequency, $planneddate, $count_forward ) = @_;
831
    my ( $subscription, $pattern, $frequency, $planneddate, $nextpublisheddate, $count_forward ) = @_;
831
832
832
    return unless ( $subscription and $pattern );
833
    return unless ( $subscription and $pattern );
833
834
Lines 918-924 sub GetNextSeq { Link Here
918
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
919
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
919
        }
920
        }
920
921
921
        my $dt = dt_from_string($planneddate);
922
        my $dt = dt_from_string($nextpublisheddate);
922
        $calculated =~ s/\{Month\}/$dt->month/eg;
923
        $calculated =~ s/\{Month\}/$dt->month/eg;
923
        $calculated =~ s/\{MonthName\}/$dt->month_name/eg;
924
        $calculated =~ s/\{MonthName\}/$dt->month_name/eg;
924
        $calculated =~ s/\{Year\}/$dt->year/eg;
925
        $calculated =~ s/\{Year\}/$dt->year/eg;
Lines 1170-1184 sub ModSerialStatus { Link Here
1170
        my $pattern      = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
1171
        my $pattern      = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
1171
        my $frequency    = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
1172
        my $frequency    = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
1172
1173
1174
        # next date (calculated from actual date & frequency parameters)
1175
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $frequency, 1 );
1176
        my $nextpubdate       = $nextpublisheddate;
1177
1173
        # next issue number
1178
        # next issue number
1174
        my (
1179
        my (
1175
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1180
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1176
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1181
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1177
        ) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $count );
1182
        ) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $nextpublisheddate, $count );
1178
1183
1179
        # next date (calculated from actual date & frequency parameters)
1180
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $frequency, 1 );
1181
        my $nextpubdate       = $nextpublisheddate;
1182
        $query =
1184
        $query =
1183
            "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1185
            "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1184
                    WHERE  subscriptionid = ?";
1186
                    WHERE  subscriptionid = ?";
(-)a/serials/serials-collection.pl (-4 / +10 lines)
Lines 82-95 if ( $op eq 'cud-gennext' && @subscriptionid ) { Link Here
82
            my $pattern   = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
82
            my $pattern   = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
83
            my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
83
            my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
84
            my $expected  = GetNextExpected($subscriptionid);
84
            my $expected  = GetNextExpected($subscriptionid);
85
86
            ## We generate the next publication date
87
            my $nextpublisheddate = GetNextDate( $subscription, $expected->{publisheddate}, $frequency, 1 );
88
85
            my (
89
            my (
86
                $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
90
                $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
87
                $newinnerloop1, $newinnerloop2, $newinnerloop3
91
                $newinnerloop1, $newinnerloop2, $newinnerloop3
88
            ) = GetNextSeq( $subscription, $pattern, $frequency, $expected->{publisheddate}, $count_forward );
92
                )
93
                = GetNextSeq(
94
                $subscription, $pattern, $frequency, $expected->{publisheddate}, $nextpublisheddate,
95
                $count_forward
96
                );
89
97
90
            ## We generate the next publication date
98
            my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
91
            my $nextpublisheddate = GetNextDate( $subscription, $expected->{publisheddate}, $frequency, 1 );
92
            my $planneddate       = $date_received_today ? dt_from_string : $nextpublisheddate;
93
            ## Creating the new issue
99
            ## Creating the new issue
94
            NewIssue(
100
            NewIssue(
95
                $newserialseq,   $subscriptionid, $subscription->{'biblionumber'},
101
                $newserialseq,   $subscriptionid, $subscription->{'biblionumber'},
(-)a/t/Serials/GetNextSeq.t (-1 / +1 lines)
Lines 259-264 sub _next_seq { Link Here
259
        $seq,                        $subscription->{lastvalue1}, $subscription->{lastvalue2},
259
        $seq,                        $subscription->{lastvalue1}, $subscription->{lastvalue2},
260
        $subscription->{lastvalue3}, $subscription->{innerloop1},
260
        $subscription->{lastvalue3}, $subscription->{innerloop1},
261
        $subscription->{innerloop2}, $subscription->{innerloop3}
261
        $subscription->{innerloop2}, $subscription->{innerloop3}
262
    ) = GetNextSeq( $subscription, $pattern, undef, undef, $count_forward );
262
    ) = GetNextSeq( $subscription, $pattern, undef, undef, undef, $count_forward );
263
    return $seq;
263
    return $seq;
264
}
264
}
(-)a/t/db_dependent/Serials.t (-7 / +8 lines)
Lines 726-739 subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { Link Here
726
        'GetSeq correctly calculates numbering from first aqui date, leap year'
726
        'GetSeq correctly calculates numbering from first aqui date, leap year'
727
    );
727
    );
728
728
729
    my $planneddate = '1970-11-01';
729
    my $planneddate       = '1970-10-01';
730
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate );
730
    my $nextpublisheddate = '1970-11-01';
731
    is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from planned date' );
731
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate, $nextpublisheddate );
732
    $planneddate = '2024-02-29';
732
    is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from next published date' );
733
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate );
733
    $planneddate       = '2024-01-29';
734
    $nextpublisheddate = '2024-02-29';
735
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate, $nextpublisheddate );
734
    is(
736
    is(
735
        $numbering, '2024 29 Thursday 2 February',
737
        $numbering, '2024 29 Thursday 2 February',
736
        'GetNextSeq correctly calculates numbering from planned date, leap year'
738
        'GetNextSeq correctly calculates numbering from next published date, leap year'
737
    );
739
    );
738
740
739
};
741
};
740
- 

Return to bug 37796