From 04dbd152f890f14ef4424dd334e9294a723f9f7b Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Tue, 23 Feb 2010 08:56:27 +0100 Subject: [PATCH] (MT 3035) subscription created expired Subscription expiration date was not calculated on creation of a subscription (cherry picked from commit 263e9217c8cd736924f66d699981949e29b4c200) Signed-off-by: Colin Campbell --- C4/Serials.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index bf4a2e6f71..a81c91193f 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -909,7 +909,7 @@ sub GetSeq { =head2 GetExpirationDate -$sensddate = GetExpirationDate($subscriptionid, [$startdate]) +$enddate = GetExpirationDate($subscriptionid, [$startdate]) this function return the next expiration date for a subscription given on input args. @@ -1252,8 +1252,18 @@ sub NewSubscription { $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate ); - #then create the 1st waited number my $subscriptionid = $dbh->{'mysql_insertid'}; + unless ($enddate){ + $enddate = GetExpirationDate($subscriptionid,$startdate); + $query = q| + UPDATE subscription + SET enddate=? + WHERE subscriptionid=? + |; + $sth = $dbh->prepare($query); + $sth->execute( $enddate, $subscriptionid ); + } + #then create the 1st waited number $query = qq( INSERT INTO subscriptionhistory (biblionumber, subscriptionid, histstartdate, opacnote, librariannote) @@ -1604,7 +1614,7 @@ sub HasSubscriptionExpired { my $dbh = C4::Context->dbh; my $subscription = GetSubscription($subscriptionid); if ( ( $subscription->{periodicity} % 16 ) > 0 ) { - my $expirationdate = $subscription->{enddate}; + my $expirationdate = $subscription->{enddate} || GetExpirationDate($subscriptionid); if (!defined $expirationdate) { $expirationdate = q{}; } -- 2.39.5