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

(-)a/C4/Serials.pm (-12 / +12 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
Returns undef when called for irregular frequencies.
2274
2273
The routine is used to skip irregularities when calculating the next issue
2275
The routine is used to skip irregularities when calculating the next issue
2274
date (in GetNextDate) or the next issue number (in GetNextSeq).
2276
date (in GetNextDate) or the next issue number (in GetNextSeq).
2275
2277
Lines 2280-2305 sub GetFictiveIssueNumber { Link Here
2280
2282
2281
    my $frequency = GetSubscriptionFrequency($subscription->{'periodicity'});
2283
    my $frequency = GetSubscriptionFrequency($subscription->{'periodicity'});
2282
    my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef;
2284
    my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef;
2283
    my $issueno = 0;
2285
    return if !$unit;
2286
    my $issueno;
2284
2287
2285
    if($unit) {
2288
    my ( $year, $month, $day ) = split /-/, $publisheddate;
2286
        my ($year, $month, $day) = split /-/, $publisheddate;
2289
    my ( $fa_year, $fa_month, $fa_day ) = split /-/, $subscription->{'firstacquidate'};
2287
        my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{'firstacquidate'};
2290
    my $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit );
2288
        my $wkno;
2289
        my $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit );
2290
2291
2291
        if($frequency->{'unitsperissue'} == 1) {
2292
    if( $frequency->{'unitsperissue'} == 1 ) {
2292
            $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
2293
        $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
2293
        } else {
2294
    } else { # issuesperunit == 1
2294
            # Assuming issuesperunit == 1
2295
        $issueno = 1 + int( $delta / $frequency->{'unitsperissue'} );
2295
            $issueno = int( ($delta + $frequency->{'unitsperissue'}) / $frequency->{'unitsperissue'} );
2296
        }
2297
    }
2296
    }
2298
    return $issueno;
2297
    return $issueno;
2299
}
2298
}
2300
2299
2301
sub _delta_units {
2300
sub _delta_units {
2302
    my ( $date1, $date2, $unit ) = @_;
2301
    my ( $date1, $date2, $unit ) = @_;
2302
    # date1 and date2 are array refs in the form [ yy, mm, dd ]
2303
2303
2304
    if( $unit eq 'day' ) {
2304
    if( $unit eq 'day' ) {
2305
        return Delta_Days( @$date1, @$date2 );
2305
        return Delta_Days( @$date1, @$date2 );
(-)a/t/db_dependent/Serials/GetFictiveIssueNumber.t (-3 / +2 lines)
Lines 27-34 subtest 'Tests for irregular frequency' => sub { Link Here
27
        periodicity => $freq_irr,
27
        periodicity => $freq_irr,
28
        firstacquidate => '1972-02-07',
28
        firstacquidate => '1972-02-07',
29
    };
29
    };
30
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-12-31'), 0, 'Irregular: should be zero' );
30
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-12-31'), undef, 'Irregular: should be undef' );
31
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-12-31'), 0, 'Irregular: still zero' );
31
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-12-31'), undef, 'Irregular: still undef' );
32
};
32
};
33
33
34
subtest 'Tests for yearly frequencies' => sub {
34
subtest 'Tests for yearly frequencies' => sub {
35
- 

Return to bug 18697