+=head2 GetNextExpected
+
+=over 4
+
+$nextexpected = GetNextExpected($subscriptionid)
+
+Get the planneddate for the current expected issue of the subscription.
+
+returns a hashref:
+
+$nextexepected = {
+ serialid => int
+ planneddate => C4::Dates object
+ }
+
+=back
+
+=cut
+
+sub GetNextExpected($) {
+ my ($subscriptionid) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('SELECT serialid, planneddate FROM serial WHERE subscriptionid=? AND status=?');
+ # Each subscription has only one 'expected' issue, with serial.status==1.
+ $sth->execute( $subscriptionid, 1 );
+ my ( $nextissue ) = $sth->fetchrow_hashref;
+ $nextissue->{planneddate} = C4::Dates->new($nextissue->{planneddate},'iso');
+ return $nextissue;
+}
+=head2 ModNextExpected
+
+=over 4
+
+ModNextExpected($subscriptionid,$date)
+
+Update the planneddate for the current expected issue of the subscription.
+This will modify all future prediction results.
+
+C<$date> is a C4::Dates object.
+
+=back
+
+=cut
+
+sub ModNextExpected($$) {
+ my ($subscriptionid,$date) = @_;
+ my $dbh = C4::Context->dbh;
+ #FIXME: Would expect to only set planneddate, but we set both on new issue creation, so updating it here
+ my $sth = $dbh->prepare('UPDATE serial SET planneddate=?,publisheddate=? WHERE subscriptionid=? AND status=?');
+ # Each subscription has only one 'expected' issue, with serial.status==1.
+ $sth->execute( $date->output('iso'),$date->output('iso'), $subscriptionid, 1);
+ return 0;
+
+}
+