View | Details | Raw Unified | Return to bug 17656
Collapse All | Expand All

(-)a/C4/Serials.pm (-2 / +2 lines)
Lines 2664-2672 sub findSerialsByStatus { Link Here
2664
    return @$serials;
2664
    return @$serials;
2665
}
2665
}
2666
2666
2667
=head2 GessEnddate
2667
=head2 GuessEnddate
2668
2668
2669
my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength);
2669
my $enddate = GuessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength);
2670
2670
2671
=cut
2671
=cut
2672
2672
(-)a/Koha/Subscription.pm (-2 / +2 lines)
Lines 221-233 sub permanent_irregularities { Link Here
221
    return split(';', $self->permanent_irregularity);
221
    return split(';', $self->permanent_irregularity);
222
}
222
}
223
223
224
=head3 subtype
224
=head3 lengthtype
225
225
226
Return the length type (issues, weeks, months)
226
Return the length type (issues, weeks, months)
227
227
228
=cut
228
=cut
229
229
230
sub subtype {
230
sub lengthtype {
231
    my ($self) = @_;
231
    my ($self) = @_;
232
232
233
    if ($self->numberlength) {
233
    if ($self->numberlength) {
(-)a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    if( !column_exists( 'subscription', 'permanent_irregularity' ) ) {
4
        $dbh->do( "ALTER TABLE `subscription` ADD permanent_irregularity MEDIUMTEXT AFTER irregularity" );
5
    }
6
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug 17656 - Irregularities in serial prediction pattern are planned only for current subscription)\n";
9
}
(-)a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql (-1 lines)
Line 1 Link Here
1
ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1955-1960 CREATE TABLE `subscription` ( -- information related to the subscription Link Here
1955
  `firstacquidate` date default NULL, -- first issue received date
1955
  `firstacquidate` date default NULL, -- first issue received date
1956
  `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually
1956
  `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually
1957
  `irregularity` MEDIUMTEXT, -- any irregularities in the subscription
1957
  `irregularity` MEDIUMTEXT, -- any irregularities in the subscription
1958
  `permanent_irregularity` MEDIUMTEXT,
1958
  skip_serialseq BOOLEAN NOT NULL DEFAULT 0,
1959
  skip_serialseq BOOLEAN NOT NULL DEFAULT 0,
1959
  `letter` varchar(20) default NULL,
1960
  `letter` varchar(20) default NULL,
1960
  `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id
1961
  `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc (-1 / +13 lines)
Lines 4-9 Link Here
4
</em></p>
4
</em></p>
5
[% 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} ] %]
5
[% 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} ] %]
6
6
7
[% BLOCK days %]
8
    [% SWITCH d %]
9
        [% CASE 'monday' %]Monday
10
        [% CASE 'tuesday' %]Tuesday
11
        [% CASE 'wednesday' %]Wednesday
12
        [% CASE 'thursday' %]Thursday
13
        [% CASE 'friday' %]Friday
14
        [% CASE 'saturday' %]Saturday
15
        [% CASE 'sunday' %]Sunday
16
    [% END %]
17
[% END %]
18
7
[% FOREACH day IN daily_choice %]
19
[% FOREACH day IN daily_choice %]
8
    [% IF permanent_irreg.grep( day.value ).0 == day.value %]
20
    [% IF permanent_irreg.grep( day.value ).0 == day.value %]
9
        <input type="checkbox" name="permanent_irregularity"
21
        <input type="checkbox" name="permanent_irregularity"
Lines 17-21 Link Here
17
               value="[% day.value %]" class="skip"
29
               value="[% day.value %]" class="skip"
18
        />
30
        />
19
    [% END %]
31
    [% END %]
20
    <label for="[% day.name %]">[% day.desc %]</label>
32
    <label for="[% day.name %]">[% PROCESS days d=day.name %]</label>
21
[% END %]
33
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc (-1 / +18 lines)
Lines 4-9 Link Here
4
</em></p>
4
</em></p>
5
[% 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} ] %]
5
[% 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} ] %]
6
6
7
[% BLOCK months %]
8
    [% SWITCH m %]
9
        [% CASE 'january' %]January
10
        [% CASE 'february' %]February
11
        [% CASE 'march' %]March
12
        [% CASE 'april' %]April
13
        [% CASE 'may' %]May
14
        [% CASE 'june' %]June
15
        [% CASE 'july' %]July
16
        [% CASE 'august' %]August
17
        [% CASE 'september' %]September
18
        [% CASE 'october' %]October
19
        [% CASE 'november' %]November
20
        [% CASE 'december' %]December
21
    [% END %]
22
[% END %]
23
7
[% FOREACH month IN monthly_choice %]
24
[% FOREACH month IN monthly_choice %]
8
    [% IF permanent_irreg.grep( month.value ).0 == month.value %]
25
    [% IF permanent_irreg.grep( month.value ).0 == month.value %]
9
        <input type="checkbox" name="permanent_irregularity"
26
        <input type="checkbox" name="permanent_irregularity"
Lines 17-21 Link Here
17
               value="[% month.value %]" class="skip"
34
               value="[% month.value %]" class="skip"
18
        />
35
        />
19
    [% END %]
36
    [% END %]
20
    <label for="[% month.name %]">[% month.desc %]</label>
37
    <label for="[% month.name %]">[% PROCESS months m=month.name %]</label>
21
[% END %]
38
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (-1 / +1 lines)
Lines 34-40 Link Here
34
        <input type="hidden" id="nextacquidate" value="[% nextacquidate | html %]" />
34
        <input type="hidden" id="nextacquidate" value="[% nextacquidate | html %]" />
35
35
36
        <input type="hidden" id="to" value="[% enddate | html %]" />
36
        <input type="hidden" id="to" value="[% enddate | html %]" />
37
        <input type="hidden" id="subtype" value="[% subtype | html %]" />
37
        <input type="hidden" id="subtype" value="[% lengthtype | html %]" />
38
        <input type="hidden" id="sublength" value="[% sublength | html %]" />
38
        <input type="hidden" id="sublength" value="[% sublength | html %]" />
39
        <input type="hidden" id="numberingmethod" value="[% numberpattern.numberingmethod | html %]" />
39
        <input type="hidden" id="numberingmethod" value="[% numberpattern.numberingmethod | html %]" />
40
        <input type="hidden" id="lastvalue1" value="[% subscription.lastvalue1 | html %]" />
40
        <input type="hidden" id="lastvalue1" value="[% subscription.lastvalue1 | html %]" />
(-)a/serials/subscription-renew.pl (-2 / +2 lines)
Lines 141-147 if ( $op eq "renew" ) { Link Here
141
    }
141
    }
142
142
143
    my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
143
    my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
144
    my $subtype = $subscription_o->subtype;
144
    my $lengthtype = $subscription_o->lengthtype;
145
    my $nextexpected = GetNextExpected($subscriptionid);
145
    my $nextexpected = GetNextExpected($subscriptionid);
146
    my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string,
146
    my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string,
147
                                 $subscription->{periodicity},
147
                                 $subscription->{periodicity},
Lines 166-172 if ( $op eq "renew" ) { Link Here
166
        startdate       => $newstartdate,
166
        startdate       => $newstartdate,
167
        nextacquidate   => $nextexpected->{planneddate},
167
        nextacquidate   => $nextexpected->{planneddate},
168
        enddate         => $enddate,
168
        enddate         => $enddate,
169
        subtype         => $subtype,
169
        lengthtype      => $lengthtype,
170
        sublength       => $sub_length,
170
        sublength       => $sub_length,
171
    );
171
    );
172
}
172
}
(-)a/t/Koha/DateUtils.t (-2 / +3 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 9;
20
use Test::More tests => 10;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
BEGIN {
23
BEGIN {
Lines 27-32 BEGIN { Link Here
27
my $dt = DateTime->new(year => 2017, month => 1, day => 1);
27
my $dt = DateTime->new(year => 2017, month => 1, day => 1);
28
28
29
eval { issue_number('2017', 'day'); };
29
eval { issue_number('2017', 'day'); };
30
is(ref($@), 'Koha::Exceptions::WrongParameter');
30
is($@, 'Date passed to issue_number is not a valid DateTime object');
31
is($@, 'Date passed to issue_number is not a valid DateTime object');
31
32
32
is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week');
33
is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week');
Lines 41-46 is(issue_number($dt, 'day'), 6, '2022-09-17 is the sixth day of week'); Link Here
41
42
42
is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year');
43
is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year');
43
44
44
is(issue_number($dt, 'month'), 9, '2017-09-17 is the ninth month of the year');
45
is(issue_number($dt, 'month'), 9, '2022-09-17 is the ninth month of the year');
45
46
46
is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type');
47
is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type');
(-)a/t/db_dependent/Koha/Subscription.t (-5 / +4 lines)
Lines 106-112 subtest 'Koha::Subscription->frequency' => sub { Link Here
106
    is( $subscription->frequency->id, $frequency->id, 'Koha::Subscription->frequency should return the correct frequency' );
106
    is( $subscription->frequency->id, $frequency->id, 'Koha::Subscription->frequency should return the correct frequency' );
107
};
107
};
108
108
109
subtest 'Koha::Subscription::subtype' => sub {
109
subtest 'Koha::Subscription::lengthtype' => sub {
110
    plan tests => 3;
110
    plan tests => 3;
111
111
112
    my $subs = $builder->build({
112
    my $subs = $builder->build({
Lines 118-124 subtest 'Koha::Subscription::subtype' => sub { Link Here
118
        }
118
        }
119
    });
119
    });
120
    my $subscription = Koha::Subscriptions->find($subs->{subscriptionid});
120
    my $subscription = Koha::Subscriptions->find($subs->{subscriptionid});
121
    is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type');
121
    is($subscription->lengthtype, 'issues', 'Subscription with numberlength has issues type');
122
122
123
    my $subs2 = $builder->build({
123
    my $subs2 = $builder->build({
124
        source => 'Subscription',
124
        source => 'Subscription',
Lines 129-135 subtest 'Koha::Subscription::subtype' => sub { Link Here
129
        }
129
        }
130
    });
130
    });
131
    my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid});
131
    my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid});
132
    is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type');
132
    is($subscription2->lengthtype, 'weeks', 'Subscription with weeklength has weeks type');
133
133
134
    my $subs3 = $builder->build({
134
    my $subs3 = $builder->build({
135
        source => 'Subscription',
135
        source => 'Subscription',
Lines 140-146 subtest 'Koha::Subscription::subtype' => sub { Link Here
140
        }
140
        }
141
    });
141
    });
142
    my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid});
142
    my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid});
143
    is($subscription3->subtype, 'months', 'Subscription with monthlength has months type');
143
    is($subscription3->lengthtype, 'months', 'Subscription with monthlength has months type');
144
};
144
};
145
145
146
my $nb_of_subs = Koha::Subscriptions->search->count;
146
my $nb_of_subs = Koha::Subscriptions->search->count;
147
- 

Return to bug 17656