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 <nadine.pierre@inLibro.com>
Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2019-08-02 13:22:37 +00:00 committed by Martin Renvoize
parent e1b79db3e5
commit a64c8cd1a4
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
5 changed files with 37 additions and 2 deletions

View File

@ -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;

View File

@ -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";
}

View File

@ -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'),

View File

@ -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.

View File

@ -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(