From 7de9a99da11f2d144cb8b871fcc64ff5896b628d Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Thu, 11 Jan 2018 14:08:25 +0000 Subject: [PATCH] Bug 17656 - Fix QA comments - Make day and month names translatable, - Update unit tests, - Fix a typo in C4/Serials.pm (GessEndDate), - rename subtype subroutine to lengthtype - DB Change: add changes in kohastructure.sql and Bug_17656-add-permanent-irregularities.perl --- C4/Serials.pm | 4 ++-- Koha/Subscription.pm | 4 ++-- .../Bug_17656-add-permanent-irregularities.perl | 9 +++++++++ .../Bug_17656-add-permanent-irregularities.sql | 1 - installer/data/mysql/kohastructure.sql | 1 + .../en/includes/serials/subscription_daily_choice.inc | 14 +++++++++++++- .../includes/serials/subscription_monthly_choice.inc | 19 ++++++++++++++++++- .../prog/en/modules/serials/subscription-renew.tt | 2 +- serials/subscription-renew.pl | 5 ++--- t/Koha/DateUtils.t | 5 +++-- t/db_dependent/Koha/Subscription.t | 8 ++++---- 11 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl delete mode 100644 installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql diff --git a/C4/Serials.pm b/C4/Serials.pm index e6aec3c..b828f4b 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2716,9 +2716,9 @@ sub findSerialsByStatus { return @$serials; } -=head2 GessEnddate +=head2 GuessEnddate -my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength); +my $enddate = GuessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength); =cut diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm index 40b2ae0..f00e88c 100644 --- a/Koha/Subscription.pm +++ b/Koha/Subscription.pm @@ -130,13 +130,13 @@ sub permanent_irregularities { return split(';', $self->permanent_irregularity); } -=head3 subtype +=head3 lengthtype Return the length type (issues, weeks, months) =cut -sub subtype { +sub lengthtype { my ($self) = @_; if ($self->numberlength) { diff --git a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl new file mode 100644 index 0000000..fb6314d --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + if( !column_exists( 'subscription', 'permanent_irregularity' ) ) { + $dbh->do( "ALTER TABLE `subscription` ADD permanent_irregularity MEDIUMTEXT AFTER irregularity" ); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 17656 - Irregularities in serial prediction pattern are planned only for current subscription)\n"; +} diff --git a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql deleted file mode 100644 index cb9cd1d..0000000 --- a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index f7970c0..66f345d 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2091,6 +2091,7 @@ CREATE TABLE `subscription` ( -- information related to the subscription `firstacquidate` date default NULL, -- first issue received date `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually `irregularity` MEDIUMTEXT, -- any irregularities in the subscription + `permanent_irregularity` MEDIUMTEXT, skip_serialseq BOOLEAN NOT NULL DEFAULT 0, `letter` varchar(20) default NULL, `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc index 4e1688d..cf6f63e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc @@ -4,6 +4,18 @@

[% daily_choice = [ {name => 'monday', desc => 'Monday', value => 1}, {name => 'tuesday', desc => 'Tuesday', value => 2}, {name => 'wednesday', desc => 'Wednesday', value => 3}, {name => 'thursday', desc => 'Thursday', value => 4}, {name => 'friday', desc => 'Friday', value => 5}, {name => 'saturday', desc => 'Saturday', value => 6}, {name => 'sunday', desc => 'Sunday', value => 7} ] %] +[% BLOCK days %] + [% SWITCH d %] + [% CASE 'monday' %]Monday + [% CASE 'tuesday' %]Tuesday + [% CASE 'wednesday' %]Wednesday + [% CASE 'thursday' %]Thursday + [% CASE 'friday' %]Friday + [% CASE 'saturday' %]Saturday + [% CASE 'sunday' %]Sunday + [% END %] +[% END %] + [% FOREACH day IN daily_choice %] [% IF permanent_irreg.grep( day.value ).0 == day.value %] [% END %] - + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc index 29bf9fd..fde9b60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc @@ -4,6 +4,23 @@

[% monthly_choice = [ {name => 'january', desc => 'January', value => 1}, {name => 'february', desc => 'February', value => 2}, {name => 'march', desc => 'March', value => 3}, {name => 'april', desc => 'April', value => 4}, {name => 'may', desc => 'May', value => 5}, {name => 'june', desc => 'June', value => 6}, {name => 'july', desc => 'July', value => 7}, {name => 'august', desc => 'August', value => 8}, {name => 'september', desc => 'September', value => 9}, {name => 'october', desc => 'October', value => 10}, {name => 'november', desc => 'November', value => 11}, {name => 'december', desc => 'December', value =>12} ] %] +[% BLOCK months %] + [% SWITCH m %] + [% CASE 'january' %]January + [% CASE 'february' %]February + [% CASE 'march' %]March + [% CASE 'april' %]April + [% CASE 'may' %]May + [% CASE 'june' %]June + [% CASE 'july' %]July + [% CASE 'august' %]August + [% CASE 'september' %]September + [% CASE 'october' %]October + [% CASE 'november' %]November + [% CASE 'december' %]December + [% END %] +[% END %] + [% FOREACH month IN monthly_choice %] [% IF permanent_irreg.grep( month.value ).0 == month.value %] [% END %] - + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt index 7816cc7..723bde0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt @@ -32,7 +32,7 @@ - + diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index 9bd24f6..602461c 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -119,7 +119,7 @@ if ( $op eq "renew" ) { } my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid}); - my $subtype = $subscription_o->subtype; + my $lengthtype = $subscription_o->lengthtype; my $nextexpected = GetNextExpected($subscriptionid); my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string, $subscription->{periodicity}, @@ -144,14 +144,13 @@ if ( $op eq "renew" ) { startdate => $newstartdate, nextacquidate => $nextexpected->{planneddate}, enddate => $enddate, - subtype => $subtype, + lengthtype => $lengthtype, sublength => $sub_length, ); } $template->param( op => $op, - #$op => 1, popup => ($mode eq 'popup'), ); diff --git a/t/Koha/DateUtils.t b/t/Koha/DateUtils.t index f0af15c..fa47c0d 100644 --- a/t/Koha/DateUtils.t +++ b/t/Koha/DateUtils.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Warn; BEGIN { @@ -27,6 +27,7 @@ BEGIN { my $dt = DateTime->new(year => 2017, month => 1, day => 1); eval { issue_number('2017', 'day'); }; +is(ref($@), 'Koha::Exceptions::WrongParameter'); is($@, 'Date passed to issue_number is not a valid DateTime object'); is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week'); @@ -41,6 +42,6 @@ is(issue_number($dt, 'day'), 6, '2022-09-17 is the sixth day of week'); is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year'); -is(issue_number($dt, 'month'), 9, '2017-09-17 is the ninth month of the year'); +is(issue_number($dt, 'month'), 9, '2022-09-17 is the ninth month of the year'); is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type'); diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t index d9700bc..2d9e096 100644 --- a/t/db_dependent/Koha/Subscription.t +++ b/t/db_dependent/Koha/Subscription.t @@ -90,7 +90,7 @@ subtest 'Koha::Subscription->vendor' => sub { is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' ); }; -subtest 'Koha::Subscription::subtype' => sub { +subtest 'Koha::Subscription::lengthtype' => sub { plan tests => 3; my $subs = $builder->build({ @@ -102,7 +102,7 @@ subtest 'Koha::Subscription::subtype' => sub { } }); my $subscription = Koha::Subscriptions->find($subs->{subscriptionid}); - is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type'); + is($subscription->lengthtype, 'issues', 'Subscription with numberlength has issues type'); my $subs2 = $builder->build({ source => 'Subscription', @@ -113,7 +113,7 @@ subtest 'Koha::Subscription::subtype' => sub { } }); my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid}); - is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type'); + is($subscription2->lengthtype, 'weeks', 'Subscription with weeklength has weeks type'); my $subs3 = $builder->build({ source => 'Subscription', @@ -124,7 +124,7 @@ subtest 'Koha::Subscription::subtype' => sub { } }); my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid}); - is($subscription3->subtype, 'months', 'Subscription with monthlength has months type'); + is($subscription3->lengthtype, 'months', 'Subscription with monthlength has months type'); }; $schema->storage->txn_rollback; -- 2.7.4