|
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 2297-2302
sub GetFictiveIssueNumber {
Link Here
|
| 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 = $year - $fa_year; |
|
|
2303 |
if( $frequency->{issuesperunit} > 1 ) { |
| 2304 |
$delta-- if $month < $fa_month || |
| 2305 |
( $month == $fa_month && $day < $fa_day ); |
| 2306 |
} |
| 2300 |
} |
2307 |
} |
| 2301 |
if($frequency->{'unitsperissue'} == 1) { |
2308 |
if($frequency->{'unitsperissue'} == 1) { |
| 2302 |
$issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'}; |
2309 |
$issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'}; |
|
Lines 2372-2394
sub _get_next_date_month {
Link Here
|
| 2372 |
sub _get_next_date_year { |
2379 |
sub _get_next_date_year { |
| 2373 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2380 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
| 2374 |
|
2381 |
|
| 2375 |
my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{firstacquidate}; |
2382 |
my (undef, $fa_month, $fa_day) = split /-/, $subscription->{firstacquidate}; |
| 2376 |
|
2383 |
|
| 2377 |
if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){ |
2384 |
my @newissue; # ( yy, mm, dd ) |
| 2378 |
$subscription->{countissuesperunit} = 1; |
2385 |
if( $freqdata->{issuesperunit} == 1 ) { # adding years |
| 2379 |
($year) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
2386 |
@newissue = Add_Delta_YM( |
| 2380 |
$month = $fa_month; |
2387 |
$year, $month, $day, $freqdata->{"unitsperissue"}, 0 ); |
| 2381 |
my $days_in_month = Days_in_Month($year, $month); |
|
|
| 2382 |
$day = $fa_day <= $days_in_month ? $fa_day : $days_in_month; |
| 2383 |
} else { |
2388 |
} else { |
| 2384 |
# Try to guess the next day in year |
2389 |
# Add rounded number of days based on frequency. |
| 2385 |
my $days_in_year = Days_in_Year($year,12); #Sum the days of all the months of this year |
2390 |
# We always use the same number of days (calculated with 365.25). |
| 2386 |
my $delta_days = int(($days_in_year - ($fa_day - 1)) / $freqdata->{issuesperunit}); |
2391 |
my $delta_days = int( 365.25 / $freqdata->{issuesperunit} ); |
| 2387 |
($year,$month,$day) = Add_Delta_Days($year, $month, $day, $delta_days); |
2392 |
@newissue = Add_Delta_Days( $year, $month, $day, $delta_days ); |
| 2388 |
$subscription->{countissuesperunit}++; |
|
|
| 2389 |
} |
| 2390 |
|
2393 |
|
| 2391 |
return ($year, $month, $day); |
2394 |
# Did we finish a cycle of issues within a unit? Correct rounding. |
|
|
2395 |
if( $subscription->{countissuesperunit} >= $freqdata->{issuesperunit} ) |
| 2396 |
{ |
| 2397 |
$subscription->{countissuesperunit} = 1; |
| 2398 |
my $newyr = $newissue[0]; |
| 2399 |
$newyr++ if $fa_month < $newissue[1]; |
| 2400 |
my $days_in_month = Days_in_Month($newyr, $fa_month); |
| 2401 |
$fa_day = $days_in_month if $fa_day > $days_in_month; |
| 2402 |
# If newissue is older than the firstacqui based date, and |
| 2403 |
# difference <= number of issues per unit, we accept |
| 2404 |
# the firstacqui based date. |
| 2405 |
# Note: We use <= because of leap years! |
| 2406 |
$delta_days = Delta_Days( @newissue, $newyr, $fa_month, $fa_day ); |
| 2407 |
@newissue = ( $newyr, $fa_month, $fa_day ) |
| 2408 |
if $delta_days > 0 && $delta_days <= $freqdata->{issuesperunit}; |
| 2409 |
} else { |
| 2410 |
$subscription->{countissuesperunit}++; |
| 2411 |
} |
| 2412 |
} |
| 2413 |
return @newissue; |
| 2392 |
} |
2414 |
} |
| 2393 |
|
2415 |
|
| 2394 |
=head2 GetNextDate |
2416 |
=head2 GetNextDate |
| 2395 |
- |
|
|