@@ -, +, @@ 1 - Have or create a subscription in the serials module 2 - Recieve an issue, making sure ot ad a note 3 - Go to receive again, note the note from the last serial is set for the expected issue 4 - Apply patch 5 - Update database, restart all the things 6 - Receive the issue leaving the note in place 7 - Note the next expected issue has the note 8 - Find the syspref PreserveSerialNotes 9 - Confirm it defaulted to Do --- C4/Serials.pm | 3 ++- .../Bug_23416_add_PreserveSerialNotes_pref.perl | 10 ++++++++++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/serials.pref | 6 ++++++ t/db_dependent/Serials.t | 19 ++++++++++++++++++- 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_23416_add_PreserveSerialNotes_pref.perl --- a/C4/Serials.pm +++ a/C4/Serials.pm @@ -1161,7 +1161,8 @@ 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, undef, $notes, $routingnotes ); + my $newnote = C4::Context->preference('PreserveSerialNotes') ? $notes : ""; + NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate, undef, $newnote, $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; --- a/installer/data/mysql/atomicupdate/Bug_23416_add_PreserveSerialNotes_pref.perl +++ a/installer/data/mysql/atomicupdate/Bug_23416_add_PreserveSerialNotes_pref.perl @@ -0,0 +1,10 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q| + INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('PreserveSerialNotes','1','','When a new "Expected" issue is generated, should it be prefilled with last created issue notes?','YesNo'); + |); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 23416 - Add PreserveSerialNotes syspref)\n"; +} --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -479,6 +479,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PayPalSignature', '', NULL , 'Your PayPal API signature', 'Free'), ('PayPalUser', '', NULL , 'Your PayPal API username ( email address )', 'Free'), ('PrefillItem','0','','When a new item is added, should it be prefilled with last created item values?','YesNo'), +('PreserveSerialNotes','1','','When a new "Expected" issue is generated, should it be prefilled with last created issue notes?','YesNo'), ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'), ('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'), ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref @@ -56,3 +56,9 @@ Serials: yes: Make no: Do not make - previous serial automatically available when receiving a new serial issue. The previous issue can also be set to another item type when receiving a new one. Please note that the item-level_itypes syspref must be set to specific item. + - + - pref: PreserveSerialNotes + choices: + yes: Do + no: Do not + - prefill the notes from the last 'Arrived' serial when generating the next 'Expected' issue. --- a/t/db_dependent/Serials.t +++ a/t/db_dependent/Serials.t @@ -18,7 +18,7 @@ use Koha::DateUtils; use Koha::Acquisition::Booksellers; use t::lib::Mocks; use t::lib::TestBuilder; -use Test::More tests => 48; +use Test::More tests => 49; BEGIN { use_ok('C4::Serials'); @@ -371,6 +371,23 @@ subtest "Do not generate an expected if one already exists" => sub { is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); }; +subtest "PreserveSerialNotes preference" => sub { + plan tests => 2; + my ($expected_serial) = GetSerials2( $subscriptionid, [1] ); + + t::lib::Mocks::mock_preference( 'PreserveSerialNotes', 1 ); + + C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); + @serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); + is( $serialsByStatus[0]->{note},$expected_serial->{note}, "note passed through if supposed to"); + + t::lib::Mocks::mock_preference( 'PreserveSerialNotes', 0 ); + $expected_serial = $serialsByStatus[0]; + C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); + is( $serialsByStatus[0]->{note},$expected_serial->{note}, "note not passed through if not supposed to"); + +}; + subtest "NewSubscription" => sub { plan tests => 1; my $subscriptionid = NewSubscription( --