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

(-)a/C4/Serials.pm (-17 / +36 lines)
Lines 2270-2275 depending on how many rows are in serial table. Link Here
2270
The issue number calculation is based on subscription frequency, first acquisition
2270
The issue number calculation is based on subscription frequency, first acquisition
2271
date, and $publisheddate.
2271
date, and $publisheddate.
2272
2272
2273
The routine is used to skip irregularities when calculating the next issue
2274
date (in GetNextDate) or the next issue number (in GetNextSeq).
2275
2273
=cut
2276
=cut
2274
2277
2275
sub GetFictiveIssueNumber {
2278
sub GetFictiveIssueNumber {
Lines 2295-2302 sub GetFictiveIssueNumber { Link Here
2295
            $delta = ($fa_year == $year)
2298
            $delta = ($fa_year == $year)
2296
                   ? ($month - $fa_month)
2299
                   ? ($month - $fa_month)
2297
                   : ( ($year-$fa_year-1)*12 + (12-$fa_month+$month) );
2300
                   : ( ($year-$fa_year-1)*12 + (12-$fa_month+$month) );
2298
        } elsif($unit eq 'year') {
2301
        } elsif( $unit eq 'year' ) {
2299
            $delta = $year - $fa_year;
2302
            ( $delta ) = N_Delta_YMD( $fa_year, $fa_month, $fa_day, $year, $month, $day );
2303
            if( $frequency->{issuesperunit} > 1 ) {
2304
                $issueno = 1 + $delta * $frequency->{'issuesperunit'};
2305
                my @fa_upd = Add_Delta_YM( $fa_year, $fa_month, $fa_day, $delta, 0 );
2306
                $delta = Delta_Days( @fa_upd, $year, $month, $day );
2307
                my $incr = int( 365 / $frequency->{issuesperunit} );
2308
                if( $incr > 0 ) {
2309
                    $delta = int( $delta / $incr );
2310
                    $delta = $delta < $frequency->{issuesperunit} ? $delta : $frequency->{issuesperunit} - 1;
2311
                } else {
2312
                    $delta = $frequency->{issuesperunit} - 1;
2313
                }
2314
                $issueno += $delta;
2315
            } else {
2316
                $issueno = 1 + int( $delta / $frequency->{'unitsperissue'} );
2317
            }
2318
            return $issueno;
2300
        }
2319
        }
2301
        if($frequency->{'unitsperissue'} == 1) {
2320
        if($frequency->{'unitsperissue'} == 1) {
2302
            $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
2321
            $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
Lines 2372-2394 sub _get_next_date_month { Link Here
2372
sub _get_next_date_year {
2391
sub _get_next_date_year {
2373
    my ($subscription, $freqdata, $year, $month, $day) = @_;
2392
    my ($subscription, $freqdata, $year, $month, $day) = @_;
2374
2393
2375
    my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{firstacquidate};
2394
    my @newissue; # ( yy, mm, dd )
2395
    my $delta_days = int( 365 / $freqdata->{issuesperunit} );
2376
2396
2377
    if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){
2397
    if( $freqdata->{issuesperunit} == 1 ) {
2378
        $subscription->{countissuesperunit} = 1;
2398
        # Add full years
2379
        ($year) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0);
2399
        @newissue = Add_Delta_YM( $year, $month, $day, $freqdata->{"unitsperissue"}, 0 );
2380
        $month = $fa_month;
2400
    } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) {
2381
        my $days_in_month = Days_in_Month($year, $month);
2401
        # Add rounded number of days based on frequency.
2382
        $day = $fa_day <= $days_in_month ? $fa_day : $days_in_month;
2402
        @newissue = Add_Delta_Days( $year, $month, $day, $delta_days );
2383
    } else {
2384
        # Try to guess the next day in year
2385
        my $days_in_year = Days_in_Year($year,12); #Sum the days of all the months of this year
2386
        my $delta_days = int(($days_in_year - ($fa_day - 1)) / $freqdata->{issuesperunit});
2387
        ($year,$month,$day) = Add_Delta_Days($year, $month, $day, $delta_days);
2388
        $subscription->{countissuesperunit}++;
2403
        $subscription->{countissuesperunit}++;
2404
    } else {
2405
        # We finished a cycle of issues within a unit.
2406
        # Subtract delta * (issues - 1), add 1 year
2407
        @newissue = Add_Delta_Days( $year, $month, $day, -$delta_days * ($freqdata->{issuesperunit} - 1) );
2408
        @newissue = Add_Delta_YM( @newissue, 1, 0 );
2409
        $subscription->{countissuesperunit} = 1;
2389
    }
2410
    }
2390
2411
    return @newissue;
2391
    return ($year, $month, $day);
2392
}
2412
}
2393
2413
2394
=head2 GetNextDate
2414
=head2 GetNextDate
2395
- 

Return to bug 18356