Bugzilla – Attachment 43986 Details for
Bug 11626
Cannot receive serial issues after subscription expiry date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11626 - Cannot receive serial issues after subscription expiry date
Bug-11626---Cannot-receive-serial-issues-after-sub.patch (text/plain), 4.36 KB, created by
Olli-Antti Kivilahti
on 2015-10-26 12:59:25 UTC
(
hide
)
Description:
Bug 11626 - Cannot receive serial issues after subscription expiry date
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-10-26 12:59:25 UTC
Size:
4.36 KB
patch
obsolete
>From 94707a38dbd168fdd0e5464664ad148e49bf981e Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Mon, 26 Oct 2015 14:15:09 +0200 >Subject: [PATCH] Bug 11626 - Cannot receive serial issues after subscription > expiry date > >Some of our serials subscriptions were not renewed after 31/12/2013 but I >cannot receive any of the outstanding 2013 issues unless I renew the >subscription record (a couple of publishers are about 3 months late with their >printing/postage schedules compared to the subscription/cover dates). > >We should still be able to receive late issues after the subscription expiry >date (the date published for these issues would in most cases be on or before >the expiry date). > >THIS PATCH: > >Changes expiration date checking for each serial to be calculated from the >individual Serial's serial.publicationdate instead of the Serial's >Subscription's expirationdate. >Thus you can still receive late serials if their publicationdate is within >the Subscription period. > >Replicating this issue in finicky, just as the Serials module is, but this >patch fixes this design flaw in the Serials-module. > >REPLICATE THE ISSUE: >0. Have a Subscription with an end date. >1. Receive all the Subscription's Serials. >2. You cannot receive the last Serial of the subscription period. > >TEST PLAN: >0. Have a Subscription with an end date. >1. Receive all the Subscription's Serials. >2. Receive the last Subscription of the subscription period. >--- > C4/Serials.pm | 46 +++++++++++++++++++++++++++++++++++++++++++++- > serials/serials-edit.pl | 2 +- > 2 files changed, 46 insertions(+), 2 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 973ac46..4706193 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -24,6 +24,7 @@ use C4::Auth qw(haspermission); > use C4::Context; > use C4::Dates qw(format_date format_date_in_iso); > use DateTime; >+use DateTime::Format::MySQL; > use Date::Calc qw(:all); > use POSIX qw(strftime); > use C4::Biblio; >@@ -268,7 +269,7 @@ sub GetSerialInformation { > } > } > $data->{ "status" . $data->{'serstatus'} } = 1; >- $data->{'subscriptionexpired'} = HasSubscriptionExpired( $data->{'subscriptionid'} ) && $data->{'status'} == 1; >+ $data->{'subscriptionexpired'} = C4::Serials::HasSerialExpired( $data ) && $data->{'status'} == 1; > $data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} ); > $data->{cannotedit} = not can_edit_subscription( $data ); > return $data; >@@ -1878,6 +1879,49 @@ sub HasSubscriptionExpired { > return 0; # Notice that you'll never get here. > } > >+=head2 HasSerialExpired >+ >+$has_expired = HasSerialExpired($serial) >+ >+the serial has expired when the serials.publisheddate is beyond the subscription expiration date. >+ >+Used to check if individual serials can still be received even if the subscription >+has already expired. >+ >+@param {HASHRef} Serial >+ >+@returns : 0 if the serial has not expired >+ 1 if the serial has expired >+ 2 if has serial does not have a valid expiration date set >+ undef if something bad/strange hapened. This is VERY ODD default behaviour. >+ >+=cut >+ >+sub HasSerialExpired { >+ my ($serial) = @_; >+ >+ return unless ($serial); >+ >+ #Normalize dates for comparison >+ my ($expirationdate, $publisheddate); >+ eval { >+ $expirationdate = DateTime::Format::MySQL->parse_date($serial->{enddate} || GetExpirationDate($serial->{subscriptionid})); >+ $publisheddate = Koha::DateUtils::dt_from_string($serial->{publisheddate}); >+ }; >+ if ($@) { #DateTime::Format can be finicky so let's not die on parsing errors. >+ warn $@; >+ return; >+ } >+ >+ if (!defined $expirationdate) { >+ return 2; >+ } >+ if (DateTime->compare($publisheddate, $expirationdate) == -1) { #publisheddate < expirationdate >+ return 0; >+ } >+ return 1; >+} >+ > =head2 SetDistributedto > > SetDistributedto($distributedto,$subscriptionid); >diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl >index c6151c7..a19129e 100755 >--- a/serials/serials-edit.pl >+++ b/serials/serials-edit.pl >@@ -147,7 +147,7 @@ foreach my $serialid (@serialids) { > > $serinfo->{'editdisable'} = ( > ( >- HasSubscriptionExpired( $serinfo->{subscriptionid} ) >+ C4::Serials::HasSerialExpired( $serinfo ) > && $serinfo->{'status1'} > ) > || $serinfo->{'cannotedit'} >-- >1.9.1
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 11626
:
43985
| 43986