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

(-)a/C4/Serials.pm (-7 / +9 lines)
Lines 810-816 sub GetPreviousSerialid { Link Here
810
    my (
810
    my (
811
        $nextseq,       $newlastvalue1, $newlastvalue2, $newlastvalue3,
811
        $nextseq,       $newlastvalue1, $newlastvalue2, $newlastvalue3,
812
        $newinnerloop1, $newinnerloop2, $newinnerloop3
812
        $newinnerloop1, $newinnerloop2, $newinnerloop3
813
    ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $count_forward );
813
    ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $nextpublisheddate, $count_forward );
814
814
815
$subscription is a hashref containing all the attributes of the table
815
$subscription is a hashref containing all the attributes of the table
816
'subscription'.
816
'subscription'.
Lines 818-830 $pattern is a hashref containing all the attributes of the table Link Here
818
'subscription_numberpatterns'.
818
'subscription_numberpatterns'.
819
$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
819
$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
820
$planneddate is a date string in iso format.
820
$planneddate is a date string in iso format.
821
$nextpublishedddate is a date string in iso format.
821
$count_forward is the number of issues to count forward, defaults to 1 if omitted
822
$count_forward is the number of issues to count forward, defaults to 1 if omitted
822
This function get the next issue for the subscription given on input arg
823
This function get the next issue for the subscription given on input arg
823
824
824
=cut
825
=cut
825
826
826
sub GetNextSeq {
827
sub GetNextSeq {
827
    my ( $subscription, $pattern, $frequency, $planneddate, $count_forward ) = @_;
828
    my ( $subscription, $pattern, $frequency, $planneddate, $nextpublisheddate, $count_forward ) = @_;
828
829
829
    return unless ( $subscription and $pattern );
830
    return unless ( $subscription and $pattern );
830
831
Lines 915-921 sub GetNextSeq { Link Here
915
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
916
            $calculated =~ s/\{Z\}/$newlastvalue3string/g;
916
        }
917
        }
917
918
918
        my $dt = dt_from_string($planneddate);
919
        my $dt = dt_from_string($nextpublisheddate);
919
        $calculated =~ s/\{Month\}/$dt->month/eg;
920
        $calculated =~ s/\{Month\}/$dt->month/eg;
920
        $calculated =~ s/\{MonthName\}/$dt->month_name/eg;
921
        $calculated =~ s/\{MonthName\}/$dt->month_name/eg;
921
        $calculated =~ s/\{Year\}/$dt->year/eg;
922
        $calculated =~ s/\{Year\}/$dt->year/eg;
Lines 1167-1181 sub ModSerialStatus { Link Here
1167
        my $pattern      = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
1168
        my $pattern      = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} );
1168
        my $frequency    = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
1169
        my $frequency    = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} );
1169
1170
1171
        # next date (calculated from actual date & frequency parameters)
1172
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $frequency, 1 );
1173
        my $nextpubdate       = $nextpublisheddate;
1174
1170
        # next issue number
1175
        # next issue number
1171
        my (
1176
        my (
1172
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1177
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1173
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1178
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1174
        ) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $count );
1179
        ) = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $nextpublisheddate, $count );
1175
1180
1176
        # next date (calculated from actual date & frequency parameters)
1177
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $frequency, 1 );
1178
        my $nextpubdate       = $nextpublisheddate;
1179
        $query =
1181
        $query =
1180
            "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1182
            "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1181
                    WHERE  subscriptionid = ?";
1183
                    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 727-740 subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { Link Here
727
        'GetSeq correctly calculates numbering from first aqui date, leap year'
727
        'GetSeq correctly calculates numbering from first aqui date, leap year'
728
    );
728
    );
729
729
730
    my $planneddate = '1970-11-01';
730
    my $planneddate       = '1970-10-01';
731
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate );
731
    my $nextpublisheddate = '1970-11-01';
732
    is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from planned date' );
732
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate, $nextpublisheddate );
733
    $planneddate = '2024-02-29';
733
    is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from next published date' );
734
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate );
734
    $planneddate       = '2024-01-29';
735
    $nextpublisheddate = '2024-02-29';
736
    ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate, $nextpublisheddate );
735
    is(
737
    is(
736
        $numbering, '2024 29 Thursday 2 February',
738
        $numbering, '2024 29 Thursday 2 February',
737
        'GetNextSeq correctly calculates numbering from planned date, leap year'
739
        'GetNextSeq correctly calculates numbering from next published date, leap year'
738
    );
740
    );
739
741
740
};
742
};
741
- 

Return to bug 37796