Bug 11492: Keep routing notes when receiving next serial
authorAleisha Amohia <aleishaamohia@hotmail.com>
Fri, 7 Dec 2018 01:03:42 +0000 (01:03 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 4 Jun 2019 08:32:48 +0000 (09:32 +0100)
This patch ensures the routing notes are carried over when generating
the next serial.

To test:
1) Create a routing list for a subscription
2) Add a borrower and a note to the routing list
3) Generate the next serial (serials-collection.pl)
4) Edit the routing list to see the notes
5) Note that the notes have disappeared
6) Apply patch
7) Edit the routing list, add a note
8) Generate the next serial
9) Edit the routing list and confirm the note is still there
10) Confirm you are still able to edit serials (serials-edit.pl) and
routing notes stay

Sponsored-by: Plant and Food Research Limited
Signed-off-by: Nazlı Çetin <nazli@devinim.com.tr>
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
C4/Serials.pm
serials/serials-collection.pl
serials/serials-edit.pl
t/db_dependent/Serials.t

index 4eb23df..a647f02 100644 (file)
@@ -1086,13 +1086,13 @@ sub ModSerialStatus {
     #It is a usual serial
     # 1st, get previous status :
     my $dbh   = C4::Context->dbh;
-    my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity
+    my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity,serial.routingnotes
         FROM serial, subscription
         WHERE serial.subscriptionid=subscription.subscriptionid
             AND serialid=?";
     my $sth   = $dbh->prepare($query);
     $sth->execute($serialid);
-    my ( $subscriptionid, $oldstatus, $periodicity ) = $sth->fetchrow;
+    my ( $subscriptionid, $oldstatus, $periodicity, $routingnotes ) = $sth->fetchrow;
     my $frequency = GetSubscriptionFrequency($periodicity);
 
     # change status & update subscriptionhistory
@@ -1100,16 +1100,15 @@ sub ModSerialStatus {
     if ( $status == DELETED ) {
         DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } );
     } else {
-
         my $query = '
             UPDATE serial
             SET serialseq = ?, publisheddate = ?, publisheddatetext = ?,
-                planneddate = ?, status = ?, notes = ?
+                planneddate = ?, status = ?, notes = ?, routingnotes = ?
             WHERE  serialid = ?
         ';
         $sth = $dbh->prepare($query);
         $sth->execute( $serialseq, $publisheddate, $publisheddatetext,
-            $planneddate, $status, $notes, $serialid );
+            $planneddate, $status, $notes, $routingnotes, $serialid );
         $query = "SELECT * FROM   subscription WHERE  subscriptionid = ?";
         $sth   = $dbh->prepare($query);
         $sth->execute($subscriptionid);
@@ -1164,9 +1163,7 @@ sub ModSerialStatus {
                     WHERE  subscriptionid = ?";
         $sth = $dbh->prepare($query);
         $sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid );
-
-        NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate );
-
+        NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate, $publisheddatetext, $notes, $routingnotes );
         # check if an alert must be sent... (= a letter is defined & status became "arrived"
         if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) {
             require C4::Letters;
@@ -1533,7 +1530,7 @@ sub ReNewSubscription {
 
 =head2 NewIssue
 
-NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate,  $notes)
+NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes, $routingnotes)
 
 Create a new issue stored on the database.
 Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription.
@@ -1543,7 +1540,7 @@ returns the serial id
 
 sub NewIssue {
     my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate,
-        $publisheddate, $publisheddatetext, $notes ) = @_;
+        $publisheddate, $publisheddatetext, $notes, $routingnotes ) = @_;
     ### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ?
 
     return unless ($subscriptionid);
@@ -1565,6 +1562,7 @@ sub NewIssue {
             publisheddate     => $publisheddate,
             publisheddatetext => $publisheddatetext,
             notes             => $notes,
+            routingnotes      => $routingnotes
         }
     )->store();
 
index e5adb36..18a46b5 100755 (executable)
@@ -59,7 +59,7 @@ if($op eq 'gennext' && @subscriptionid){
     my $subscriptionid = $subscriptionid[0];
     my $sth = $dbh->prepare("
         SELECT publisheddate, publisheddatetext, serialid, serialseq,
-            planneddate
+            planneddate, notes, routingnotes
         FROM serial
         WHERE status = 1 AND subscriptionid = ?
     ");
@@ -90,7 +90,8 @@ if($op eq 'gennext' && @subscriptionid){
              my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
              ## Creating the new issue
              NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
-                     1, $planneddate, $nextpublisheddate );
+                     1, $planneddate, $nextpublisheddate, $issue->{publisheddatetext},
+                     $issue->{notes}, $issue->{routingnotes} );
 
              ## Updating the subscription seq status
              my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
index 33e11ad..0b25dc4 100755 (executable)
@@ -238,7 +238,8 @@ if ( $op and $op eq 'serialchangestatus' ) {
                     $plan_date,
                     $pub_date,
                     $publisheddatetexts[$i],
-                    $notes[$i]
+                    $notes[$i],
+                    $serialdatalist[0]->{'routingnotes'}
                 );
             }
         }
index d30a32a..cfad08a 100755 (executable)
@@ -163,7 +163,7 @@ subtest 'Values should not be erased on editing' => sub {
     );
     my ( undef, undef, $itemnumber ) = C4::Items::AddItemFromMarc( $item_record, $biblionumber );
     my $serialid = C4::Serials::NewIssue( "serialseq", $subscriptionid, $biblionumber,
-                                          1, undef, undef, "publisheddatetext", "notes" );
+                                          1, undef, undef, "publisheddatetext", "notes", "routingnotes" );
     C4::Serials::AddItem2Serial( $serialid, $itemnumber );
     my $serial_info = C4::Serials::GetSerialInformation($serialid);
     my ($itemcallnumber_info) = grep { $_->{kohafield} eq 'items.itemcallnumber' }