From a64c8cd1a4b2c237b3abf777480d7fc8733986d3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 2 Aug 2019 13:22:37 +0000 Subject: [PATCH] Bug 23416: Add PreserveSerialNotes system preference Bug 11492 intended to pass routinglists forward. It also passed forward serial notes. This may or not me desired behvaiour, to avoid changing functionality twice I add a syspref to control this behaviour. To test: 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 10 - Set it to 'Do not' 11 - Receive the expected serial leavign the note 12 - Note the newly generated expected serial has no note 13 - prove -v t/db_dependent/Serials.t Signed-off-by: Nadine Pierre Signed-off-by: Maryse Simard Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- C4/Serials.pm | 3 ++- ...ug_23416_add_PreserveSerialNotes_pref.perl | 10 ++++++++++ installer/data/mysql/sysprefs.sql | 1 + .../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 diff --git a/C4/Serials.pm b/C4/Serials.pm index f2290f4f7b..1841397dc4 100644 --- a/C4/Serials.pm +++ b/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; diff --git a/installer/data/mysql/atomicupdate/Bug_23416_add_PreserveSerialNotes_pref.perl b/installer/data/mysql/atomicupdate/Bug_23416_add_PreserveSerialNotes_pref.perl new file mode 100644 index 0000000000..751739f74f --- /dev/null +++ b/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"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 3d09ca477b..82a8402a36 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -480,6 +480,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'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref index c64abdd499..d7fa40f61f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref +++ b/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. diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 1b3b0e3762..735af75430 100755 --- a/t/db_dependent/Serials.t +++ b/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( -- 2.39.5