Bugzilla – Attachment 26683 Details for
Bug 12003
Next issues for irregular pattern not correctly predicted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12003: Do not calculate next pubdate for irregular subscriptions
Bug-12003-Do-not-calculate-next-pubdate-for-irregu.patch (text/plain), 9.08 KB, created by
Julian Maurice
on 2014-03-28 14:01:42 UTC
(
hide
)
Description:
Bug 12003: Do not calculate next pubdate for irregular subscriptions
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2014-03-28 14:01:42 UTC
Size:
9.08 KB
patch
obsolete
>From 778afd99f9520a77b9010b114dda1ffecb81305d Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 28 Mar 2014 14:38:25 +0100 >Subject: [PATCH] Bug 12003: Do not calculate next pubdate for irregular > subscriptions > >Show 'Unknown' when planneddate and publisheddate cannot be calculated > >Also fixes SQL query in misc/cronjobs/serialsUpdate.pl that was still >using "periodicity != 32" to exclude irregular subscriptions from >results > >Test plan: > >1) Create a subscription in the serials module. Make sure to choose: Frequency = Irregular >2) Test the prediction pattern, first publication date is set to "First >issue publication date" field, others will show as 'unknown' >3) Save the subscription >4) Check the created issue - it will show a published date and a planned >date (same as "First issue publication date" field) >5) Receive the issue and check the next generated issue, planned date >and published date should show as 'Unknown' >6) Generate a next issue, planned date and published date should also >show as 'Unknown' >--- > C4/Serials.pm | 17 ++++++----------- > .../prog/en/modules/serials/serials-collection.tt | 16 ++++++++++++++-- > .../prog/en/modules/serials/subscription-detail.tt | 12 ++++++++++-- > misc/cronjobs/serialsUpdate.pl | 4 +++- > serials/showpredictionpattern.pl | 4 ++-- > t/db_dependent/Serials/GetNextDate.t | 18 ++++++++++++------ > 6 files changed, 47 insertions(+), 24 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 6c035d5..46bec26 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -419,9 +419,9 @@ sub PrepareSerialsData { > > foreach my $subs (@{$lines}) { > for my $datefield ( qw(publisheddate planneddate) ) { >- # handle both undef and undef returned as 0000-00-00 >- if (!defined $subs->{$datefield} or $subs->{$datefield}=~m/^00/) { >- $subs->{$datefield} = 'XXX'; >+ # handle 0000-00-00 dates >+ if (defined $subs->{$datefield} and $subs->{$datefield} =~ m/^00/) { >+ $subs->{$datefield} = undef; > } > } > $subs->{ "status" . $subs->{'status'} } = 1; >@@ -1235,10 +1235,6 @@ sub ModSerialStatus { > DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } ); > } else { > >- unless ($frequency->{'unit'}) { >- if ( not $planneddate or $planneddate eq '0000-00-00' ) { $planneddate = C4::Dates->new()->output('iso') }; >- if ( not $publisheddate or $publisheddate eq '0000-00-00' ) { $publisheddate = C4::Dates->new()->output('iso') }; >- } > my $query = 'UPDATE serial SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? WHERE serialid = ?'; > $sth = $dbh->prepare($query); > $sth->execute( $serialseq, $publisheddate, $planneddate, $status, $notes, $serialid ); >@@ -2532,13 +2528,15 @@ skipped then the returned date will be 2007-05-10 > return : > $resultdate - then next date in the sequence (ISO date) > >-Return $publisheddate if subscription is irregular >+Return undef if subscription is irregular > > =cut > > sub GetNextDate { > my ( $subscription, $publisheddate, $updatecount ) = @_; > >+ return unless $subscription and $publisheddate; >+ > my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); > > if ($freqdata->{'unit'}) { >@@ -2676,9 +2674,6 @@ sub GetNextDate { > } > return sprintf("%04d-%02d-%02d", $year, $month, $day); > } >- else { >- return $publisheddate; >- } > } > > =head2 _numeration >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >index ed1dc39..ab39821 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >@@ -244,10 +244,22 @@ $(document).ready(function() { > <td><a href="serials-collection.pl?subscriptionid=[% serial.subscriptionid %]">[% serial.subscriptionid %]</a></td> > [% END %] > <td> >- <span title="[% serial.publisheddate %]">[% serial.publisheddate | $KohaDates %]</span> >+ <span title="[% serial.publisheddate %]"> >+ [% IF serial.publisheddate %] >+ [% serial.publisheddate | $KohaDates %] >+ [% ELSE %] >+ Unknown >+ [% END %] >+ </span> > </td> > <td> >- <span title="[% serial.planneddate %]">[% serial.planneddate | $KohaDates %]</span> >+ <span title="[% serial.planneddate %]"> >+ [% IF serial.planneddate %] >+ [% serial.planneddate | $KohaDates %] >+ [% ELSE %] >+ Unknown >+ [% END %] >+ </span> > </td> > <td> > [% serial.serialseq %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >index f02194e..b684e5e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >@@ -259,10 +259,18 @@ $(document).ready(function() { > [% serialslis.serialseq %] > </td> > <td> >- [% serialslis.planneddate %] >+ [% IF serialslis.planneddate %] >+ [% serialslis.planneddate %] >+ [% ELSE %] >+ Unknown >+ [% END %] > </td> > <td> >- [% serialslis.publisheddate %] >+ [% IF serialslis.publisheddate %] >+ [% serialslis.publisheddate %] >+ [% ELSE %] >+ Unknown >+ [% END %] > </td> > <td> > [% IF ( serialslis.status1 ) %]Expected[% END %] >diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl >index 07d418a..1299e63 100755 >--- a/misc/cronjobs/serialsUpdate.pl >+++ b/misc/cronjobs/serialsUpdate.pl >@@ -99,8 +99,10 @@ my $sth = $dbh->prepare( > FROM serial > LEFT JOIN subscription > ON (subscription.subscriptionid=serial.subscriptionid) >+ LEFT JOIN subscription_frequencies >+ ON (subscription.periodicity = subscription_frequencies.id) > WHERE serial.status = 1 >- AND periodicity <> 32 >+ AND subscription_frequencies.unit IS NOT NULL > AND DATE_ADD(planneddate, INTERVAL CAST(graceperiod AS SIGNED) DAY) < NOW() > AND subscription.closed = 0 > } >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index c654f55..82cf8af 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -119,7 +119,7 @@ my @predictions_loop; > my ($calculated) = GetSeq(\%subscription, \%pattern); > push @predictions_loop, { > number => $calculated, >- publicationdate => ($frequency->{unit} ? $date : undef), >+ publicationdate => $date, > issuenumber => $issuenumber, > dow => Day_of_Week(split /-/, $date), > }; >@@ -143,7 +143,7 @@ while( $i < 1000 ) { > $date = GetNextDate(\%subscription, $date); > } > if(defined $date){ >- $line{'publicationdate'} = $date if $frequency->{unit}; >+ $line{'publicationdate'} = $date; > $line{'dow'} = Day_of_Week(split /-/, $date); > } > >diff --git a/t/db_dependent/Serials/GetNextDate.t b/t/db_dependent/Serials/GetNextDate.t >index ed80f29..1572d0a 100644 >--- a/t/db_dependent/Serials/GetNextDate.t >+++ b/t/db_dependent/Serials/GetNextDate.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use C4::Context; >-use Test::More tests => 84; >+use Test::More tests => 86; > use Modern::Perl; > > my $dbh = C4::Context->dbh; >@@ -471,7 +471,7 @@ is($publisheddate, '1974-01-01'); > # TEST CASE 25 - Irregular > $id = AddSubscriptionFrequency({ > description => "Irregular", >- unit => '', >+ unit => undef, > issuesperunit => 1, > unitsperissue => 1, > }); >@@ -482,10 +482,16 @@ $subscription = { > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-# GetNextDate always return the same date if subscription is irregular >+# GetNextDate always return undef if subscription is irregular > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-01'); >+is($publisheddate, undef); >+ >+# GetNextDate returns undef if one of two first parameters is undef >+$publisheddate = GetNextDate($subscription, undef); >+is($publisheddate, undef); >+$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}); >+is($publisheddate, undef); >+$publisheddate = GetNextDate(undef, undef); >+is($publisheddate, undef); > > $dbh->rollback; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12003
:
26683
|
27050
|
27146