Bugzilla – Attachment 102861 Details for
Bug 17656
Irregularities in serial prediction pattern are planned only for current subscription
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17656: Update irregularities on subscription renewals
Bug-17656-Update-irregularities-on-subscription-re.patch (text/plain), 23.88 KB, created by
Katrin Fischer
on 2020-04-13 15:58:25 UTC
(
hide
)
Description:
Bug 17656: Update irregularities on subscription renewals
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-04-13 15:58:25 UTC
Size:
23.88 KB
patch
obsolete
>From 6d174cf9c3a4068e748dd7225828b8809e34cc5d Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 19 Dec 2017 15:40:06 +0000 >Subject: [PATCH] Bug 17656: Update irregularities on subscription renewals > >Test plan: > - Apply this patch, > - Launch installer/data/mysql/updatedatabase.pl > - Launch misc/devel/update_dbix_class_files.pl > > - Create a daily subscription. i.e: > - From: 2017-10-09, To: 2017-10-15, > - Frequency: 1/day, > - 7 issues, > - test prediction pattern > - check Wednesday and Thursday as irregularity, > - save > - Renew subscription from 2017-10-16 > - Check that you have the prediction pattern table on renwal page > - Submit renewal > - Check that irregularity and permanent_irregularity column > have been updated. > > - Do the same for a monthly and weekly subscription >--- > C4/Serials.pm | 35 +++++++++++ > Koha/Subscription.pm | 22 +++++++ > .../prog/en/modules/serials/subscription-add.tt | 1 + > .../prog/en/modules/serials/subscription-renew.tt | 39 ++++++++++++ > .../intranet-tmpl/prog/js/showpredictionpattern.js | 3 +- > .../intranet-tmpl/prog/js/subscription-add.js | 70 --------------------- > koha-tmpl/intranet-tmpl/prog/js/subscription.js | 72 ++++++++++++++++++++++ > serials/subscription-add.pl | 42 ++++--------- > serials/subscription-renew.pl | 50 +++++++++++++-- > t/db_dependent/Koha/Subscription.t | 39 +++++++++++- > 10 files changed, 267 insertions(+), 106 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/subscription.js > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 48944bc2bc..8d7eca01d8 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -87,6 +87,7 @@ BEGIN { > &CountIssues > HasItems > &subscriptionCurrentlyOnOrder >+ &GuessEnddate > > ); > } >@@ -2650,6 +2651,40 @@ sub findSerialsByStatus { > return @$serials; > } > >+=head2 GessEnddate >+ >+my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength); >+ >+=cut >+ >+sub GuessEnddate { >+ my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_; >+ my ($year, $month, $day); >+ my $enddate; >+ if($numberlength != 0) { >+ my $frequency = GetSubscriptionFrequency($frequencyid); >+ if($frequency->{'unit'} eq 'day') { >+ ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); >+ } elsif($frequency->{'unit'} eq 'week') { >+ ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); >+ } elsif($frequency->{'unit'} eq 'month') { >+ ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); >+ } elsif($frequency->{'unit'} eq 'year') { >+ ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0); >+ } >+ } elsif($weeklength != 0) { >+ ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7); >+ } elsif($monthlength != 0) { >+ ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength); >+ } >+ if(defined $year) { >+ $enddate = sprintf("%04d-%02d-%02d", $year, $month, $day); >+ } else { >+ undef $enddate; >+ } >+ return $enddate; >+} >+ > 1; > __END__ > >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index 801cca511d..3d7c80e72c 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -221,6 +221,28 @@ sub permanent_irregularities { > return split(';', $self->permanent_irregularity); > } > >+=head3 subtype >+ >+Return the length type (issues, weeks, months) >+ >+=cut >+ >+sub subtype { >+ my ($self) = @_; >+ >+ if ($self->numberlength) { >+ return 'issues'; >+ } >+ >+ if ($self->weeklength) { >+ return 'weeks'; >+ } >+ >+ if ($self->monthlength) { >+ return 'months'; >+ } >+} >+ > =head3 type > > =cut >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >index fd603e167a..e5cc8f7038 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >@@ -558,6 +558,7 @@ fieldset.rows table { clear: none; margin: 0; } > > var BOOKSELLER_IDS = [% To.json( bookseller_ids ) || '[]' | $raw %]; > </script> >+ [% Asset.js("js/subscription.js") | $raw %] > [% Asset.js("js/subscription-add.js") | $raw %] > [% Asset.js("js/showpredictionpattern.js") | $raw %] > [% 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 4848538539..0b5cebf918 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 >@@ -1,3 +1,4 @@ >+[% USE Asset %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > [% IF subscription %] >@@ -28,6 +29,36 @@ > <form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post"> > <input type="hidden" name="op" value="renew" /> > <input type="hidden" name="subscriptionid" value="[% subscription.subscriptionid | html %]" /> >+ <input type="hidden" id="frequency" value="[% subscription.periodicity | html %]" /> >+ <input type="hidden" id="acqui_date" value="[% subscription.firstacquidate | html %]" /> >+ <input type="hidden" id="nextacquidate" value="[% nextacquidate | html %]" /> >+ >+ <input type="hidden" id="to" value="[% enddate | html %]" /> >+ <input type="hidden" id="subtype" value="[% subtype | html %]" /> >+ <input type="hidden" id="sublength" value="[% sublength | html %]" /> >+ <input type="hidden" id="numberingmethod" value="[% numberpattern.numberingmethod | html %]" /> >+ <input type="hidden" id="lastvalue1" value="[% subscription.lastvalue1 | html %]" /> >+ <input type="hidden" id="lastvalue2" value="[% subscription.lastvalue2 | html %]" /> >+ <input type="hidden" id="lastvalue3" value="[% subscription.lastvalue3 | html %]" /> >+ <input type="hidden" id="add1" value="[% numberpattern.add1 | html %]" /> >+ <input type="hidden" id="add2" value="[% numberpattern.add2 | html %]" /> >+ <input type="hidden" id="add3" value="[% numberpattern.add3 | html %]" /> >+ <input type="hidden" id="every1" value="[% numberpattern.every1 | html %]" /> >+ <input type="hidden" id="every2" value="[% numberpattern.every2 | html %]" /> >+ <input type="hidden" id="every3" value="[% numberpattern.every3 | html %]" /> >+ <input type="hidden" id="innerloop1" value="[% subscription.innerloop1 | html %]" /> >+ <input type="hidden" id="innerloop2" value="[% subscription.innerloop2 | html %]" /> >+ <input type="hidden" id="innerloop3" value="[% subscription.innerloop3 | html %]" /> >+ <input type="hidden" id="setto1" value="[% numberpattern.setto1 | html %]" /> >+ <input type="hidden" id="setto2" value="[% numberpattern.setto2 | html %]" /> >+ <input type="hidden" id="setto3" value="[% numberpattern.setto3 | html %]" /> >+ <input type="hidden" id="numbering1" value="[% numberpattern.numbering1 | html %]" /> >+ <input type="hidden" id="numbering2" value="[% numberpattern.numbering2 | html %]" /> >+ <input type="hidden" id="numbering3" value="[% numberpattern.numbering3 | html %]" /> >+ <input type="hidden" id="whenmorethan1" value="[% numberpattern.whenmorethan1 | html %]" /> >+ <input type="hidden" id="whenmorethan2" value="[% numberpattern.whenmorethan2 | html %]" /> >+ <input type="hidden" id="whenmorethan3" value="[% numberpattern.whenmorethan3 | html %]" /> >+ <input type="hidden" id="locale" value="[% subscription.locale | html %]" /> > <fieldset class="rows"><legend>Subscription renewal for [% subscription.bibliotitle | html %]</legend> > <ol> > <li> >@@ -73,14 +104,20 @@ > > <li><label for="note">Note for the librarian that will manage your renewal request: </label> > <textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset> >+ <li id="displayexample"></li> > <fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset> >+ > </form> > [% END %] > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'calendar.inc' %] > <script type="text/javascript"> >+ var subscriptionid = "[% subscription.subscriptionid %]"; >+ var irregularity = "[% subscription.irregularity %]"; >+ var more_than_one_serial = "[% more_than_one_serial %]"; > $(document).ready(function(){ >+ testPredictionPattern(); > $(".close").on("click", function(e){ > e.preventDefault(); > window.opener.location.reload(false); >@@ -88,6 +125,8 @@ > }); > }); > </script> >+ [% Asset.js("js/subscription.js") %] >+ [% Asset.js("js/showpredictionpattern.js") %] > [% END %] > > [% INCLUDE 'intranet-bottom.inc' popup_window=1 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js b/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js >index ffc70130f5..1efab8a3ff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js >@@ -2,10 +2,12 @@ function Check_boxes(dow) { > if($(":checkbox[data-dow='"+dow+"']:first").is(':checked')) { > $("#predictionst :checkbox[data-dow='"+dow+"']").each(function(){ > $(this).prop('checked', true); >+ return false; > }); > } else { > $("#predictionst :checkbox[data-dow='"+dow+"']").each(function(){ > $(this).prop('checked', false); >+ return false; > }); > } > } >@@ -21,7 +23,6 @@ function Check_permanent_irregularities() { > // So check them according to permanent irregularity > if (nothing_checked) { > $(".skip").each(function() { >- console.log('iciiiiiiiiiiiiii'); > if ($(this).is(':checked')) { > Check_boxes( $(this).data("dow")); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >index ac656eacbd..2c88d6e731 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -266,76 +266,6 @@ function restoreAdvancedPattern() { > advancedpatternlocked = 1; > } > >-function testPredictionPattern() { >- var frequencyid = $("#frequency").val(); >- var acquidate; >- var error = 0; >- var error_msg = ""; >- if(frequencyid == undefined || frequencyid == ""){ >- error_msg += "- " + MSG_FREQUENCY_UNDEFINED + "\n"; >- error ++; >- } >- acquidate = $("#acqui_date").val(); >- if(acquidate == undefined || acquidate == ""){ >- error_msg += "-" + MSG_PUB_DATE_UNDEFINED + "\n"; >- error ++; >- } >- if( more_than_one_serial !== "" ){ >- var nextacquidate = $("#nextacquidate").val(); >- if(nextacquidate == undefined || nextacquidate == ""){ >- error_msg += "-" + MSG_NEXT_ISSUE_UNDEFINED + "\n"; >- error ++; >- } >- } >- >- if(error){ >- alert( MSG_PATTERN_TEST_FAILED.format(error_msg) ); >- return false; >- } >- >- var custompattern = 0; >- if(advancedpatternlocked == 0) { >- custompattern = 1; >- } >- >- var ajaxData = { >- 'custompattern': custompattern, >- 'firstacquidate': acquidate >- }; >- >- if( subscriptionid !== "" ){ >- ajaxData.subscriptionid = subscriptionid; >- } >- if( more_than_one_serial !== "" ){ >- ajaxData.nextacquidate = nextacquidate; >- } >- >- >- var ajaxParams = [ >- 'to', 'subtype', 'sublength', 'frequency', 'numberingmethod', >- 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', >- 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', >- 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >- 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', >- 'sfdescription', 'unitsperissue', 'issuesperunit', 'unit' >- ]; >- for(i in ajaxParams) { >- var param = ajaxParams[i]; >- var value = $("#"+param).val(); >- if(value.length > 0) >- ajaxData[param] = value; >- } >- >- $.ajax({ >- url:"/cgi-bin/koha/serials/showpredictionpattern.pl", >- data: ajaxData, >- success: function(data) { >- showPredictionPatternTest( data ); >- patternneedtobetested = 0; >- } >- }); >-} >- > function saveAdvancedPattern() { > if ($("#patternname").val().length == 0) { > alert( MSG_PATTERN_NAME ); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription.js b/koha-tmpl/intranet-tmpl/prog/js/subscription.js >new file mode 100644 >index 0000000000..6e16f8b02b >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription.js >@@ -0,0 +1,72 @@ >+ >+var advancedpatternlocked; >+ >+function testPredictionPattern() { >+ var frequencyid = $("#frequency").val(); >+ var acquidate; >+ var error = 0; >+ var error_msg = ""; >+ if(frequencyid == undefined || frequencyid == ""){ >+ error_msg += "- " + MSG_FREQUENCY_UNDEFINED + "\n"; >+ error ++; >+ } >+ acquidate = $("#acqui_date").val(); >+ if(acquidate == undefined || acquidate == ""){ >+ error_msg += "-" + MSG_PUB_DATE_UNDEFINED + "\n"; >+ error ++; >+ } >+ if( more_than_one_serial !== "" ){ >+ var nextacquidate = $("#nextacquidate").val(); >+ if(nextacquidate == undefined || nextacquidate == ""){ >+ error_msg += "-" + MSG_NEXT_ISSUE_UNDEFINED + "\n"; >+ error ++; >+ } >+ } >+ >+ if(error){ >+ alert( MSG_PATTERN_TEST_FAILED.format(error_msg) ); >+ return false; >+ } >+ >+ var custompattern = 0; >+ if(advancedpatternlocked == 0) { >+ custompattern = 1; >+ } >+ >+ var ajaxData = { >+ 'custompattern': custompattern, >+ 'firstacquidate': acquidate >+ }; >+ >+ if( subscriptionid !== "" ){ >+ ajaxData.subscriptionid = subscriptionid; >+ } >+ if( more_than_one_serial !== "" ){ >+ ajaxData.nextacquidate = nextacquidate; >+ } >+ >+ >+ var ajaxParams = [ >+ 'to', 'subtype', 'sublength', 'frequency', 'numberingmethod', >+ 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', >+ 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', >+ 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >+ 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', >+ 'sfdescription', 'unitsperissue', 'issuesperunit', 'unit' >+ ]; >+ for(i in ajaxParams) { >+ var param = ajaxParams[i]; >+ var value = $("#"+param).val(); >+ if(value.length > 0) >+ ajaxData[param] = value; >+ } >+ >+ $.ajax({ >+ url:"/cgi-bin/koha/serials/showpredictionpattern.pl", >+ data: ajaxData, >+ success: function(data) { >+ showPredictionPatternTest( data ); >+ patternneedtobetested = 0; >+ } >+ }); >+} >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 0b0bacf64f..8d7e25cd9f 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -265,32 +265,14 @@ sub get_letter_loop { > ]; > } > >-sub _guess_enddate { >- my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_; >- my ($year, $month, $day); >- my $enddate; >- if($numberlength != 0) { >- my $frequency = GetSubscriptionFrequency($frequencyid); >- if($frequency->{'unit'} eq 'day') { >- ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); >- } elsif($frequency->{'unit'} eq 'week') { >- ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); >- } elsif($frequency->{'unit'} eq 'month') { >- ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); >- } elsif($frequency->{'unit'} eq 'year') { >- ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0); >- } >- } elsif($weeklength != 0) { >- ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7); >- } elsif($monthlength != 0) { >- ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength); >- } >- if(defined $year) { >- $enddate = sprintf("%04d-%02d-%02d", $year, $month, $day); >- } else { >- undef $enddate; >- } >- return $enddate; >+sub _get_sub_length { >+ my ($type, $length) = @_; >+ return >+ ( >+ $type eq 'issues' ? $length : 0, >+ $type eq 'weeks' ? $length : 0, >+ $type eq 'months' ? $length : 0, >+ ); > } > > sub redirect_add_subscription { >@@ -356,9 +338,9 @@ sub redirect_add_subscription { > > if(!defined $enddate || $enddate eq '') { > if($subtype eq "issues") { >- $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength) >+ $enddate = GuessEnddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength) > } else { >- $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) >+ $enddate = GuessEnddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) > } > } > my $subscriptionid = NewSubscription( >@@ -470,9 +452,9 @@ sub redirect_mod_subscription { > # Guess end date > if(!defined $enddate || $enddate eq '') { > if($subtype eq "issues") { >- $enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); >+ $enddate = GuessEnddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); > } else { >- $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); >+ $enddate = GuessEnddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); > } > } > >diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl >index 1889f9a5b6..318c51c4be 100755 >--- a/serials/subscription-renew.pl >+++ b/serials/subscription-renew.pl >@@ -53,6 +53,9 @@ use C4::Context; > use C4::Auth; > use C4::Output; > use C4::Serials; >+use C4::Serials::Frequency; >+use C4::Serials::Numberpattern; >+use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM); > use Koha::DateUtils; > > my $query = new CGI; >@@ -83,6 +86,9 @@ if ( $op eq "renew" ) { > # Make sure the subscription exists > my $subscription = GetSubscription( $subscriptionid ); > output_and_exit( $query, $cookie, $template, 'unknown_subscription') unless $subscription; >+ >+ my @permanent_irregularities = $query->param('permanent_irregularity'); >+ my @irregularities = $query->param('irregularity'); > my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); > ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength ); > ReNewSubscription( >@@ -97,6 +103,11 @@ if ( $op eq "renew" ) { > branchcode => $branchcode > } > ); >+ >+ my $subscription = Koha::Subscriptions->find($subscriptionid); >+ $subscription->permanent_irregularity(join(';', @permanent_irregularities)); >+ $subscription->irregularity(join(';', @irregularities)); >+ $subscription->store; > } elsif ( $op eq 'multi_renew' ) { > for my $subscriptionid ( @subscriptionids ) { > my $subscription = GetSubscription( $subscriptionid ); >@@ -124,17 +135,48 @@ if ( $op eq "renew" ) { > my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) > or output_pref( { dt => dt_from_string, dateonly => 1 } ); > >+ my ($serials_number) = GetSerials($subscriptionid); >+ if ($serials_number > 1) { >+ $template->param(more_than_one_serial => 1); >+ } >+ >+ my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid}); >+ my $subtype = $subscription_o->subtype; >+ my $nextexpected = GetNextExpected($subscriptionid); >+ my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string, >+ $subscription->{periodicity}, >+ $subscription->{numberlength}, >+ $subscription->{weeklength}, >+ $subscription->{monthlength}); >+ >+ my $sub_length; >+ foreach my $length_unit (qw(numberlength weeklength monthlength)) { >+ if ($subscription->{$length_unit}) { >+ $sub_length=$subscription->{$length_unit}; >+ last; >+ } >+ } >+ >+ my $numberpattern = GetSubscriptionNumberpattern($subscription->{numberpattern}); >+ > $template->param( >- startdate => $newstartdate, >- subscription => $subscription, >+ startdate => $newstartdate, >+ subscription => $subscription, >+ numberpattern => $numberpattern, >+ startdate => $newstartdate, >+ nextacquidate => $nextexpected->{planneddate}, >+ enddate => $enddate, >+ subtype => $subtype, >+ sublength => $sub_length, > ); > } > > my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); > > $template->param( >- op => $op, >- libraries => $libraries, >+ op => $op, >+ libraries => $libraries, >+ popup => ($mode eq 'popup'), > ); > > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t >index 926bdc198c..7220ca129e 100644 >--- a/t/db_dependent/Koha/Subscription.t >+++ b/t/db_dependent/Koha/Subscription.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 11; > > use Koha::Database; > use Koha::Subscription; >@@ -106,6 +106,43 @@ subtest 'Koha::Subscription->frequency' => sub { > is( $subscription->frequency->id, $frequency->id, 'Koha::Subscription->frequency should return the correct frequency' ); > }; > >+subtest 'Koha::Subscription::subtype' => sub { >+ plan tests => 3; >+ >+ my $subs = $builder->build({ >+ source => 'Subscription', >+ value => { >+ numberlength => 7, >+ weeklength => 0, >+ monthlength => 0, >+ } >+ }); >+ my $subscription = Koha::Subscriptions->find($subs->{subscriptionid}); >+ is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type'); >+ >+ my $subs2 = $builder->build({ >+ source => 'Subscription', >+ value => { >+ numberlength => 0, >+ weeklength => 52, >+ monthlength => 0, >+ } >+ }); >+ my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid}); >+ is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type'); >+ >+ my $subs3 = $builder->build({ >+ source => 'Subscription', >+ value => { >+ numberlength => 0, >+ weeklength => 0, >+ monthlength => 12, >+ } >+ }); >+ my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid}); >+ is($subscription3->subtype, 'months', 'Subscription with monthlength has months type'); >+}; >+ > my $nb_of_subs = Koha::Subscriptions->search->count; > my $biblio_1 = $builder->build( { source => 'Biblio' } ); > my $bi_1 = $builder->build( >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17656
:
68259
|
68261
|
68607
|
68608
|
68665
|
69124
|
69207
|
69279
|
69553
|
69814
|
69820
|
69915
|
70335
|
70336
|
70430
|
70619
|
75403
|
75404
|
75405
|
75406
|
75407
|
75408
|
75721
|
75722
|
75723
|
75724
|
75725
|
75726
|
75953
|
102724
|
102725
|
102726
|
102727
|
102728
|
102729
|
102730
|
102860
|
102861
|
102862
|
102863
|
102864
|
102865
|
102866
|
102867
|
102960
|
102961
|
102962
|
102963
|
102964
|
102965
|
102966
|
102967
|
102968
|
103623
|
103624
|
103625
|
103626
|
103627
|
103628
|
103629
|
103630
|
103631
|
103657
|
103658
|
103659
|
103660
|
103661
|
103662
|
103663
|
103664
|
103665
|
103667
|
117789
|
117790
|
117791
|
117792
|
117846
|
117851
|
117852
|
118856
|
119106
|
120863
|
121082
|
121083
|
121084
|
121085
|
121086
|
121087
|
121088
|
121192
|
121193
|
121194
|
121195
|
121196
|
121197
|
121198
|
121296
|
121297
|
121298
|
121299
|
121300
|
121301
|
121302
|
128489
|
128491
|
128492
|
128493
|
128494
|
128495
|
128496
|
128498
|
128499
|
128500
|
128501
|
128502
|
128503
|
128504
|
132412
|
132413
|
132415
|
132416
|
132417
|
132418
|
132447
|
132448
|
132692
|
132779