Bugzilla – Attachment 56179 Details for
Bug 17047
Mana Knowledge Base : Data sharing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17047 ability to import a subscription model from mana
Bug-17047-ability-to-import-a-subscription-model-f.patch (text/plain), 77.68 KB, created by
Alex Arnaud
on 2016-10-11 13:08:55 UTC
(
hide
)
Description:
Bug 17047 ability to import a subscription model from mana
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2016-10-11 13:08:55 UTC
Size:
77.68 KB
patch
obsolete
>From 701685015fd04abc797ac5f98000e364dcd9b5a6 Mon Sep 17 00:00:00 2001 >From: morgane alonso <morgane.alonso@biblibre.com> >Date: Thu, 25 Aug 2016 14:26:47 +0000 >Subject: [PATCH] Bug 17047 ability to import a subscription model from mana > >- modify subscription-add.tt and subscription.pl to manage a >import from mana during a subscription creation >- add 2 script in svc for ajax calling from subscription-add.tt >to communicate with mana server during a asubscription creation >- add a function in Subscription.pm to have all the info for a mana research >from a biblionumber >- modify functions used by subscription-add.pl in C4/Serials to manage a >frequency which came from mana server and not already created on the >koha database, and modify the tests of the said functions >--- > C4/Serials.pm | 31 +-- > Koha/SharedContent.pm | 20 ++ > Koha/Subscription.pm | 15 ++ > .../serials/mana-subscription-search-result.tt | 1 + > .../prog/en/modules/serials/subscription-add.tt | 214 ++++++++++++++-- > misc/cronjobs/serialsUpdate.pl | 4 +- > serials/serials-collection.pl | 6 +- > serials/showpredictionpattern.pl | 23 +- > serials/subscription-add.pl | 91 ++++++- > svc/mana/search | 62 +++++ > svc/mana/use | 48 ++++ > t/db_dependent/Serials.t | 3 +- > t/db_dependent/Serials/GetFictiveIssueNumber.t | 126 ++++++++++ > t/db_dependent/Serials/GetNextDate.t | 272 +++++++++------------ > t/db_dependent/Serials/GetNextSeq.t | 124 +++++----- > 15 files changed, 774 insertions(+), 266 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt > create mode 100755 svc/mana/search > create mode 100755 svc/mana/use > create mode 100644 t/db_dependent/Serials/GetFictiveIssueNumber.t > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 885192e..027ca20 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -864,19 +864,20 @@ sub GetDistributedTo { > my ( > $nextseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, > $newinnerloop1, $newinnerloop2, $newinnerloop3 >- ) = GetNextSeq( $subscription, $pattern, $planneddate ); >+ ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate ); > > $subscription is a hashref containing all the attributes of the table > 'subscription'. > $pattern is a hashref containing all the attributes of the table > 'subscription_numberpatterns'. >+$frequency is a hashref containing all the attributes of the table 'subscription_frequencies' > $planneddate is a date string in iso format. > This function get the next issue for the subscription given on input arg > > =cut > > sub GetNextSeq { >- my ($subscription, $pattern, $planneddate) = @_; >+ my ($subscription, $pattern, $frequency, $planneddate) = @_; > > return unless ($subscription and $pattern); > >@@ -889,7 +890,7 @@ sub GetNextSeq { > if(@irreg > 0) { > my $irregularities = {}; > $irregularities->{$_} = 1 foreach(@irreg); >- my $issueno = GetFictiveIssueNumber($subscription, $planneddate) + 1; >+ my $issueno = GetFictiveIssueNumber($subscription, $planneddate, $frequency) + 1; > while($irregularities->{$issueno}) { > $count++; > $issueno++; >@@ -1032,7 +1033,7 @@ sub GetExpirationDate { > > #calculate the date of the last issue. > for ( my $i = 1 ; $i <= $length ; $i++ ) { >- $enddate = GetNextDate( $subscription, $enddate ); >+ $enddate = GetNextDate( $subscription, $enddate, $frequency ); > } > } elsif ( $subscription->{monthlength} ) { > if ( $$subscription{startdate} ) { >@@ -1184,16 +1185,17 @@ sub ModSerialStatus { > if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) { > my $subscription = GetSubscription($subscriptionid); > my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); > > # next issue number > my ( > $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, > $newinnerloop1, $newinnerloop2, $newinnerloop3 > ) >- = GetNextSeq( $subscription, $pattern, $publisheddate ); >+ = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate ); > > # next date (calculated from actual date & frequency parameters) >- my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1); >+ my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency, 1); > my $nextpubdate = $nextpublisheddate; > $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? > WHERE subscriptionid = ?"; >@@ -2193,7 +2195,7 @@ sub abouttoexpire { > my $expirationdate = GetExpirationDate($subscriptionid); > > my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid); >- my $nextdate = GetNextDate($subscription, $res); >+ my $nextdate = GetNextDate($subscription, $res, $frequency); > > # only compare dates if both dates exist. > if ($nextdate and $expirationdate) { >@@ -2259,7 +2261,7 @@ sub GetSubscriptionsFromBorrower { > > =head2 GetFictiveIssueNumber > >-$issueno = GetFictiveIssueNumber($subscription, $publishedate); >+$issueno = GetFictiveIssueNumber($subscription, $publishedate, $frequency); > > Get the position of the issue published at $publisheddate, considering the > first issue (at firstacquidate) is at position 1, the next is at position 2, etc... >@@ -2273,9 +2275,8 @@ date, and $publisheddate. > =cut > > sub GetFictiveIssueNumber { >- my ($subscription, $publisheddate) = @_; >+ my ($subscription, $publisheddate, $frequency) = @_; > >- my $frequency = GetSubscriptionFrequency($subscription->{'periodicity'}); > my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef; > my $issueno = 0; > >@@ -2393,12 +2394,13 @@ sub _get_next_date_year { > > =head2 GetNextDate > >-$resultdate = GetNextDate($publisheddate,$subscription) >+$resultdate = GetNextDate($publisheddate,$subscription,$freqdata,$updatecount) > > this function it takes the publisheddate and will return the next issue's date > and will skip dates if there exists an irregularity. > $publisheddate has to be an ISO date >-$subscription is a hashref containing at least 'periodicity', 'firstacquidate', 'irregularity', and 'countissuesperunit' >+$subscription is a hashref containing at least 'firstacquidate', 'irregularity', and 'countissuesperunit' >+$frequency is a hashref containing frequency informations > $updatecount is a boolean value which, when set to true, update the 'countissuesperunit' in database > - eg if periodicity is monthly and $publisheddate is 2007-02-10 but if March and April is to be > skipped then the returned date will be 2007-05-10 >@@ -2411,11 +2413,10 @@ Return undef if subscription is irregular > =cut > > sub GetNextDate { >- my ( $subscription, $publisheddate, $updatecount ) = @_; >+ my ( $subscription, $publisheddate, $freqdata, $updatecount ) = @_; > > return unless $subscription and $publisheddate; > >- my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); > > if ($freqdata->{'unit'}) { > my ( $year, $month, $day ) = split /-/, $publisheddate; >@@ -2435,7 +2436,7 @@ sub GetNextDate { > > # Get the 'fictive' next issue number > # It is used to check if next issue is an irregular issue. >- my $issueno = GetFictiveIssueNumber($subscription, $publisheddate) + 1; >+ my $issueno = GetFictiveIssueNumber($subscription, $publisheddate, $freqdata) + 1; > > # Then get the next date > my $unit = lc $freqdata->{'unit'}; >diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm >index 81a6a3e..e0c512b 100644 >--- a/Koha/SharedContent.pm >+++ b/Koha/SharedContent.pm >@@ -40,6 +40,16 @@ sub manaRequest { > return $result if ( $response->code =~ /^2..$/ ); > } > >+sub manaNewUserPatchRequest { >+ my $resource = shift; >+ my $id = shift; >+ >+ my $url = "$MANA_IP/$resource/$id.json/newUser"; >+ my $request = HTTP::Request->new( PATCH => $url ); >+ >+ return manaRequest($request); >+} >+ > sub manaPostRequest { > my $resource = shift; > my $content = shift; >@@ -54,6 +64,16 @@ sub manaPostRequest { > return manaRequest($request); > } > >+sub manaGetRequestWithId { >+ my $resource = shift; >+ my $id = shift; >+ >+ my $url = "$MANA_IP/$resource/$id.json"; >+ my $request = HTTP::Request->new( GET => $url ); >+ >+ return manaRequest($request); >+} >+ > sub manaGetRequest { > my $resource = shift; > my $parameters = shift; >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index 29a2c66..40943dd 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -45,6 +45,21 @@ Koha::Subscription - Koha Subscription Object class > > =cut > >+sub get_search_info { >+ my $searched_sub_id = shift; >+ my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } ); >+ my $biblioitem = >+ Koha::Biblioitems->find( { 'biblionumber' => $searched_sub_id } ); >+ >+ my $sub_mana_info = { >+ 'title' => $biblio->title, >+ 'issn' => $biblioitem->issn, >+ 'ean' => $biblioitem->ean, >+ 'publishercode' => $biblioitem->publishercode >+ }; >+ return $sub_mana_info; >+} >+ > sub get_sharable_info { > my $shared_sub_id = shift; > my $subscription = Koha::Subscriptions->find($shared_sub_id); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt >new file mode 100644 >index 0000000..0afe02c >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt >@@ -0,0 +1 @@ >+[% INCLUDE 'mana-subscription-search-result.inc' %] >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 ff918b0..bddb7f7 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 >@@ -1,5 +1,6 @@ > [% USE KohaDates %] > [% USE Branches %] >+[% USE Koha %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials › [% IF ( modify ) %][% bibliotitle |html %] › Modify subscription[% ELSE %]New subscription[% END %]</title> >@@ -11,11 +12,16 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ > width: 300px; /* not enough for IE7 apparently */ > } > </style> >+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >+[% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> > //<![CDATA[ > > var globalnumpatterndata; > var globalfreqdata; >+var mananumpatterndata; >+var manafreqdata; >+var manaid; > var advancedpatternlocked; > var patternneedtobetested = 0; > [% IF ( irregularity ) %]patternneedtobetested = 1;[% END %] >@@ -98,31 +104,57 @@ function Check_page2(){ > } > > function frequencyload(){ >- $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'}, >- function(freqdata){ >- globalfreqdata=freqdata; >- if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) { >- var option = $("#subtype option[value='issues']"); >- $(option).attr('selected', 'selected'); >- $("#subtype option[value!='issues']").prop('disabled', true) >- } else { >- $("#subtype option").prop('disabled', false) >- } >+ if ($("#frequency option:selected").val() === "mana"){ >+ globalfreqdata=manafreqdata; >+ $("input[name='sfdescription']").val(manafreqdata.description); >+ $("input[name='unit']").val(manafreqdata.unit); >+ $("input[name='unitsperissue']").val(manafreqdata.unitsperissue); >+ $("input[name='issuesperunit']").val(manafreqdata.issuesperunit); >+ if ($( "#numberpattern option:selected" ).val() === "mana" ) { >+ $("input[name='mana_id']").val(manaid); > } >- ) >+ } else { >+ $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'}, >+ function(freqdata){ >+ globalfreqdata=freqdata; >+ if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) { >+ var option = $("#subtype option[value='issues']"); >+ $(option).attr('selected', 'selected'); >+ $("#subtype option[value!='issues']").prop('disabled', true); >+ } else { >+ $("#subtype option").prop('disabled', false); >+ } >+ } >+ ); >+ $("input[name='mana_id']").val(""); >+ } > } > > function numberpatternload(){ >- $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'}, >- function(numpatterndata){ >- globalnumpatterndata=numpatterndata; >- if (globalnumpatterndata==undefined){ >- return false; >- } >- displaymoreoptions(); >- restoreAdvancedPattern(); >+ if($("#numberpattern option:selected" ).val() === "mana"){ >+ globalnumpatterndata=mananumpatterndata; >+ $("input[name='sndescription']").val(mananumpatterndata.description); >+ if($("#frequency option:selected" ).val() === "mana"){ >+ $("input[name='mana_id']").val(manaid); >+ } >+ if (globalnumpatterndata==undefined){ >+ return false; > } >- ); >+ displaymoreoptions(); >+ restoreAdvancedPattern(); >+ } else { >+ $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'}, >+ function(numpatterndata){ >+ globalnumpatterndata=numpatterndata; >+ if (globalnumpatterndata==undefined){ >+ return false; >+ } >+ displaymoreoptions(); >+ restoreAdvancedPattern(); >+ } >+ ); >+ $("input[name='mana_id']").val(""); >+ } > } > > function displaymoreoptions() { >@@ -285,7 +317,8 @@ function testPredictionPattern() { > 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', > 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', > 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >- 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale' >+ 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'sfdescription', >+ 'unitsperissue', 'issuesperunit', 'unit' > ]; > for(i in ajaxParams) { > var param = ajaxParams[i]; >@@ -372,8 +405,113 @@ function show_page_2() { > displaymoreoptions(); > } > >+function mana_search() { >+ $.ajax({ >+ type: "POST", >+ url: "/cgi-bin/koha/svc/mana/search", >+ data: {biblionumber : $("#biblionumber").val()}, >+ dataType: "html", >+ }) >+ .done( function( result ) { >+ $("#mana_search_result .modal-body").html(result); >+ $("#mana_search_result_label").text("Results from Mana"); >+ $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sPaginationType": "four_button", >+ "aoColumnDefs": [ >+ { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, >+ { "sType": "title-string", "aTargets" : [ "title-string" ] }, >+ { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } >+ ] >+ })); >+ if($("td.dataTables_empty").length == 0){ >+ $("#mana_search").show(); >+ } >+ }).fail(function(result){ >+ }); >+} >+ >+function mana_use(mana_id){ >+ $("tr").removeClass("selected"); >+ $("#row"+mana_id).addClass("selected"); >+ $.ajax( { >+ type: "POST", >+ url: "/cgi-bin/koha/svc/mana/use", >+ data: {id : mana_id}, >+ dataType: "json", >+ }) >+ .done(function(result){ >+ var select = document.getElementById('numberpattern'); >+ for(i = 0; i < select.length; i++){ >+ if(select[i].value === "mana"){ >+ select.remove(i); >+ } >+ } >+ var optionnumpattern = document.createElement("option"); >+ optionnumpattern.text = result.label + " (mana)"; >+ optionnumpattern.selected = true; >+ optionnumpattern.value="mana"; >+ select.add(optionnumpattern); >+ >+ mananumpatterndata = { >+ id:"mana", >+ add1:result.add1, >+ add2:result.add2, >+ add3:result.add3, >+ description:result.sndescription, >+ displayorder:result.displayorder, >+ every1:result.every1, >+ every2:result.every2, >+ every3:result.every3, >+ label:result.label, >+ label1:result.label1, >+ label2:result.label2, >+ label3:result.label3, >+ numbering1:result.numbering1, >+ numbering2:result.numbering2, >+ numbering3:result.numbering3, >+ numberingmethod:result.numberingmethod, >+ setto1:result.setto1, >+ setto2:result.setto2, >+ setto3:result.setto3, >+ whenmorethan1:result.whenmorethan1, >+ whenmorethan2:result.whenmorethan2, >+ whenmorethan3:result.whenmorethan3, >+ }; >+ select = document.getElementById("frequency"); >+ for(i = 0; i < select.length; i++){ >+ if(select[i].value === "mana"){ >+ select.remove(i); >+ } >+ } >+ var optionfreq = document.createElement("option"); >+ optionfreq.text = result.sfdescription + " (mana)"; >+ optionfreq.selected = true; >+ optionfreq.value="mana"; >+ select.add(optionfreq); >+ manafreqdata = { >+ id:"mana", >+ description:result.sfdescription, >+ displayorder:result.displayorder, >+ issuesperunit:result.issuesperunit, >+ unit:result.unit, >+ unitsperissue:result.unitsperissue, >+ }; >+ manaid = result.id; >+ $("input[name='mana_id']").val(manaid); >+ $("#mana_search_result").modal("hide"); >+ frequencyload(); >+ numberpatternload(); >+ }).fail( function( result ){ >+ }); >+} >+ >+function removeDisabledAttr() { >+ $('select:disabled').removeAttr('disabled'); >+} >+ > > $(document).ready(function() { >+ $("#mana_search_result").modal("hide"); > $("#aqbooksellerid").on('keypress', function(e) { > if (e.keyCode == 13) { > e.preventDefault(); >@@ -456,6 +594,8 @@ $(document).ready(function() { > } > [% END %] > >+ $("#mana_search").hide(); >+ > show_page_1(); > $("#subscription_add_form").on("submit",function(){ > return Check_page2(); >@@ -477,7 +617,10 @@ $(document).ready(function() { > } > }); > $("#subscription_add_next").on("click",function(){ >- if ( Check_page1() ){ >+ if ( Check_page1() ) { >+ [% IF Koha.Preference('Mana') %] >+ mana_search(); >+ [% END %] > show_page_2(); > } > }); >@@ -701,6 +844,9 @@ $(document).ready(function() { > > <div id="page_2"> > <div class="yui-u first"> >+ <div id="mana_search" class="dialog message"> >+ <p>Frequency and Numbering pattern have been already proposed for this subscription on Mana. To show results, click <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Here</a></p> >+ </div> > <div id="subscription_form_planning"> > <fieldset class="rows"> > <legend>Serials planning</legend> >@@ -965,10 +1111,16 @@ $(document).ready(function() { > </div> > [% END %] > >+ <input type="hidden" id="mana_id" name="mana_id" value=""/> >+ <input type="hidden" id="sndescription" name="sndescription" value=""/> >+ <input type="hidden" id="sfdescription" name="sfdescription" value=""/> >+ <input type="hidden" id="unit" name="unit" value=""/> >+ <input type="hidden" id="unitsperissue" name="unitsperissue" value=""/> >+ <input type="hidden" id="issuesperunit" name="issuesperunit" value=""/> > <fieldset class="action"> > <input type="button" id="subscription_add_previous" value="<< Previous" style="float:left;"/> > <input id="testpatternbutton" type="button" value="Test prediction pattern" /> >- <input type="submit" value="Save subscription" style="float:right;" accesskey="w" /> >+ <input type="submit" onclick="removeDisabledAttr()" value="Save subscription" style="float:right;" accesskey="w"/> > </fieldset> > </div> > </div> >@@ -981,4 +1133,20 @@ $(document).ready(function() { > </div> > </div> > >+<div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 90%; left:5%; margin-left: auto; display: none;"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h3 id="mana_search_result_label"></h3> >+ </div> >+ <div class="modal-body"> >+ </div> >+ <div class="modal-footer"> >+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> >+ </div> >+</div> >+ >+ > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl >index aae1e56..a478476 100755 >--- a/misc/cronjobs/serialsUpdate.pl >+++ b/misc/cronjobs/serialsUpdate.pl >@@ -33,6 +33,7 @@ use C4::Debug; > use C4::Serials; > use C4::Log; > use Koha::DateUtils; >+use C4::Serials::Frequency; > > use Date::Calc qw/Date_to_Days check_date/; > use Getopt::Long; >@@ -118,7 +119,8 @@ while ( my $issue = $sth->fetchrow_hashref ) { > my $publisheddate = $issue->{publisheddate}; > > if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) { >- my $nextpublisheddate = GetNextDate( $subscription, $publisheddate ); >+ my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); >+ my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata ); > my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); > > if ( $nextpublisheddate && $today ) { >diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl >index 47d07eb..12e21f7 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -74,14 +74,16 @@ if($op eq 'gennext' && @subscriptionid){ > require C4::Serials::Numberpattern; > my $subscription = GetSubscription($subscriptionid); > my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequencies($subscription->{periodicity}); > my $expected = GetNextExpected($subscriptionid); > my ( > $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, > $newinnerloop1, $newinnerloop2, $newinnerloop3 >- ) = GetNextSeq($subscription, $pattern, $expected->{publisheddate}); >+ ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}); > > ## We generate the next publication date >- my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1); >+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); >+ my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1); > ## Creating the new issue > NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, > 1, $nextpublisheddate, $nextpublisheddate ); >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index 6986b5e..ec55f0e 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -56,7 +56,21 @@ my $subtype = $input->param('subtype'); > my $sublength = $input->param('sublength'); > my $custompattern = $input->param('custompattern'); > >-my $frequency = GetSubscriptionFrequency($frequencyid); >+ >+my $frequency; >+if ( $frequencyid eq 'mana' ) { >+ $frequency = { >+ 'id' => undef, >+ 'displayorder' => undef, >+ 'description' => scalar $input->param('sfdescription') // '', >+ 'unitsperissue' => scalar $input->param('unitsperissue') // '', >+ 'issuesperunit' => scalar $input->param('issuesperunit') // '', >+ 'unit' => scalar $input->param('unit') // '' >+ }; >+} >+else { >+ $frequency = GetSubscriptionFrequency($frequencyid); >+} > > my %pattern = ( > numberingmethod => scalar $input->param('numberingmethod') // '', >@@ -98,14 +112,13 @@ my %subscription = ( > innerloop2 => scalar $input->param('innerloop2') // '', > innerloop3 => scalar $input->param('innerloop3') // '', > irregularity => '', >- periodicity => $frequencyid, > countissuesperunit => 1, > firstacquidate => $firstacquidate, > ); > > my $issuenumber; > if(defined $subscriptionid) { >- ($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date); >+ ($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date, $frequency); > } else { > $issuenumber = 1; > } >@@ -135,7 +148,7 @@ while( $i < 1000 ) { > my %line; > > if(defined $date){ >- $date = GetNextDate(\%subscription, $date); >+ $date = GetNextDate(\%subscription, $date, $frequency); > } > if(defined $date){ > $line{'publicationdate'} = $date; >@@ -156,7 +169,7 @@ while( $i < 1000 ) { > last; > } > >- ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern); >+ ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern, $frequency); > $issuenumber++; > $line{'number'} = $calculated; > $line{'issuenumber'} = $issuenumber; >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index f66b650..3457dd0 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -34,6 +34,10 @@ use Koha::AdditionalField; > use Koha::DateUtils; > use Carp; > >+use Koha::Subscription::Numberpattern; >+use Koha::Subscription::Frequency; >+use Koha::SharedContent; >+ > #use Smart::Comments; > > our $query = CGI->new; >@@ -282,15 +286,71 @@ sub _guess_enddate { > return $enddate; > } > >+sub manage_subscription_numbering_pattern_id { >+ my $numberpattern; >+ if ( $query->param('numbering_pattern') eq 'mana' ) { >+ my $subscription_np = Koha::Subscription::Numberpattern->new()->set( >+ { >+ label => $query->param('patternname'), >+ description => $query->param('sndescription'), >+ numberingmethod => $query->param('numberingmethod'), >+ label1 => $query->param('label1'), >+ add1 => $query->param('add1'), >+ every1 => $query->param('every1'), >+ whenmorethan1 => $query->param('whenmorethan1'), >+ setto1 => $query->param('setto1'), >+ numbering1 => $query->param('numbering1'), >+ label2 => $query->param('label2'), >+ add2 => $query->param('add2'), >+ every2 => $query->param('every2'), >+ whenmorethan2 => $query->param('whenmorethan2'), >+ setto2 => $query->param('setto2'), >+ numbering2 => $query->param('numbering2'), >+ label3 => $query->param('label3'), >+ add3 => $query->param('add3'), >+ every3 => $query->param('every3'), >+ whenmorethan3 => $query->param('whenmorethan3'), >+ setto3 => $query->param('setto3'), >+ numbering3 => $query->param('numbering3'), >+ } >+ )->store(); >+ $numberpattern = $subscription_np->id; >+ } >+ else { >+ $numberpattern = $query->param('numbering_pattern'); >+ } >+ return $numberpattern; >+} >+ >+sub manage_subscription_frequencies_id { >+ my $periodicity; >+ if ( $query->param('frequency') eq 'mana' ) { >+ my $subscription_freq = Koha::Subscription::Frequency->new()->set( >+ { >+ description => $query->param('sfdescription'), >+ unit => $query->param('unit'), >+ unitsperissue => $query->param('unitsperissue'), >+ issuesperunit => $query->param('issuesperunit'), >+ } >+ )->store(); >+ $periodicity = $subscription_freq->id; >+ } >+ else { >+ $periodicity = $query->param('frequency'); >+ } >+ return $periodicity; >+} >+ > sub redirect_add_subscription { >+ my $periodicity = manage_subscription_frequencies_id(); >+ my $numberpattern = manage_subscription_numbering_pattern_id(); >+ > my $auser = $query->param('user'); > my $branchcode = $query->param('branchcode'); > my $aqbooksellerid = $query->param('aqbooksellerid'); > my $cost = $query->param('cost'); > my $aqbudgetid = $query->param('aqbudgetid'); >- my $periodicity = $query->param('frequency'); > my @irregularity = $query->multi_param('irregularity'); >- my $numberpattern = $query->param('numbering_pattern'); > my $locale = $query->param('locale'); > my $graceperiod = $query->param('graceperiod') || 0; > >@@ -320,6 +380,15 @@ sub redirect_add_subscription { > my $previousitemtype = $query->param('previousitemtype'); > my $skip_serialseq = $query->param('skip_serialseq'); > >+ my $mana_id; >+ if ( $query->param('mana_id') ne "" ) { >+ $mana_id = $query->param('mana_id'); >+ Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id); >+ } >+ else { >+ $mana_id = undef; >+ } >+ > my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); > my $enddate = output_pref( { str => scalar $query->param('enddate'), dateonly => 1, dateformat => 'iso' } ); > my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); >@@ -331,7 +400,6 @@ sub redirect_add_subscription { > $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) > } > } >- > my $subscriptionid = NewSubscription( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, > $startdate, $periodicity, $numberlength, $weeklength, >@@ -340,7 +408,7 @@ sub redirect_add_subscription { > join(";",@irregularity), $numberpattern, $locale, $callnumber, > $manualhistory, $internalnotes, $serialsadditems, > $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, >- $skip_serialseq >+ $skip_serialseq, $mana_id > ); > > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >@@ -370,13 +438,13 @@ sub redirect_mod_subscription { > ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } ) > : $firstacquidate; > >- my $periodicity = $query->param('frequency'); >+ my $periodicity = manage_subscription_frequencies_id(); >+ my $numberpattern = manage_subscription_numbering_pattern_id(); > > my $subtype = $query->param('subtype'); > my $sublength = $query->param('sublength'); > my ($numberlength, $weeklength, $monthlength) > = _get_sub_length( $subtype, $sublength ); >- my $numberpattern = $query->param('numbering_pattern'); > my $locale = $query->param('locale'); > my $lastvalue1 = $query->param('lastvalue1'); > my $innerloop1 = $query->param('innerloop1'); >@@ -399,6 +467,15 @@ sub redirect_mod_subscription { > my $previousitemtype = $query->param('previousitemtype'); > my $skip_serialseq = $query->param('skip_serialseq'); > >+ my $mana_id; >+ if ( defined( $query->param('mana_id') ) ) { >+ $mana_id = $query->param('mana_id'); >+ Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id); >+ } >+ else { >+ $mana_id = undef; >+ } >+ > # Guess end date > if(!defined $enddate || $enddate eq '') { > if($subtype eq "issues") { >@@ -424,7 +501,7 @@ sub redirect_mod_subscription { > $status, $biblionumber, $callnumber, $notes, $letter, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, > $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, >- $skip_serialseq, $itemtype, $previousitemtype >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id > ); > > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >diff --git a/svc/mana/search b/svc/mana/search >new file mode 100755 >index 0000000..0f58c84 >--- /dev/null >+++ b/svc/mana/search >@@ -0,0 +1,62 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+# >+ >+use strict; >+use warnings; >+ >+use Koha::SharedContent; >+use Koha::Subscription; >+use C4::Auth qw(check_cookie_auth), qw(get_template_and_user); >+use C4::Output qw( output_with_http_headers ); >+ >+use CGI; >+use JSON; >+ >+my $input = new CGI; >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $input->cookie('CGISESSID'), >+ { serials => 'create_subscription' } ); >+ >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "serials/mana-subscription-search-result.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ >+ # flagsrequired => { serials => $permission }, >+ flagsrequired => { serials => 'create_subscription' }, >+ debug => 1, >+ } >+); >+ >+my $biblionumber = $input->param('biblionumber'); >+ >+my $sub_mana_info = Koha::Subscription::get_search_info($biblionumber); >+my $result = >+ Koha::SharedContent::manaGetRequest( "subscription", $sub_mana_info ); >+$template->param( subscriptions => $result->{data} ); >+ >+output_with_http_headers $input, $cookie, $template->output, 'json'; >diff --git a/svc/mana/use b/svc/mana/use >new file mode 100755 >index 0000000..a2f2e44 >--- /dev/null >+++ b/svc/mana/use >@@ -0,0 +1,48 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+# >+ >+use strict; >+use warnings; >+ >+use Koha::SharedContent; >+use C4::Auth qw(check_cookie_auth); >+ >+use CGI; >+use JSON; >+ >+ >+my $input = new CGI; >+binmode STDOUT, ":encoding(UTF-8)"; >+print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $input->cookie('CGISESSID'), >+ { serials => 'create_subscription' } ); >+ >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $result = Koha::SharedContent::manaGetRequestWithId("subscription", $input->param('id') ); >+ >+my $subscription; >+$subscription = $result->{data}; >+ >+print(to_json($subscription)); >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index e09a076..798f9d8 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -253,7 +253,8 @@ my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscrip > ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); > my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); > ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); >-my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, 1); >+my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); >+my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1); > my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 ); > # Add 14 serials > my $counter = 0; >diff --git a/t/db_dependent/Serials/GetFictiveIssueNumber.t b/t/db_dependent/Serials/GetFictiveIssueNumber.t >new file mode 100644 >index 0000000..e944de9 >--- /dev/null >+++ b/t/db_dependent/Serials/GetFictiveIssueNumber.t >@@ -0,0 +1,126 @@ >+#!/usr/bin/perl >+ >+use C4::Context; >+use Test::More tests => 18; >+use Modern::Perl; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{AutoCommit} = 0; >+ >+use C4::Serials::Frequency; >+use C4::Serials; >+ >+# TEST CASE - 1 issue per day, no irregularities >+my $frequency = { >+ description => "One issue per day", >+ unit => 'day', >+ issuesperunit => 1, >+ unitsperissue => 1, >+}; >+ >+my $subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, >+}; >+my $issueNumber; >+ >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, '1' ); >+ >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, '2' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, '3' ); >+ >+# TEST CASE - 2 issues per day, no irregularity >+$frequency = { >+ description => "Two issues per day", >+ unit => 'day', >+ issuesperunit => 2, >+ unitsperissue => 1, >+}; >+$subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, >+}; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, '1' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, '3' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, '5' ); >+ >+$subscription->{countissuesperunit} = 2; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, '2' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, '4' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, '6' ); >+ >+# TEST CASE - 1 issue every 2 days, no irregularity >+$frequency = { >+ description => "one issue every two days", >+ unit => 'day', >+ issuesperunit => 1, >+ unitsperissue => 2, >+}; >+$subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, >+}; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, 2 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-04', $frequency ); >+is( $issueNumber, 2 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-05', $frequency ); >+is( $issueNumber, 3 ); >+ >+# TEST CASE - 1 issue per week, no irregularity >+$frequency = { >+ description => "one issue per week", >+ unit => 'week', >+ issuesperunit => 1, >+ unitsperissue => 1, >+}; >+$subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, >+}; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-08', $frequency ); >+is( $issueNumber, 2 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-15', $frequency ); >+is( $issueNumber, 3 ); >+ >+$dbh->rollback; >diff --git a/t/db_dependent/Serials/GetNextDate.t b/t/db_dependent/Serials/GetNextDate.t >index fe6059f..1161a65 100644 >--- a/t/db_dependent/Serials/GetNextDate.t >+++ b/t/db_dependent/Serials/GetNextDate.t >@@ -18,524 +18,496 @@ my $frequency = { > issuesperunit => 1, > unitsperissue => 1, > }; >-my $id = AddSubscriptionFrequency($frequency); > > my $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > my $publisheddate = $subscription->{firstacquidate}; > >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); > > # TEST CASE - 1 issue per day, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', # Skip the second and fourth issues > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-05'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-06'); > > # TEST CASE - 2 issues per day, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "Two issues per day", > unit => 'day', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); > > # TEST CASE - 2 issues per day, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-05'); > > # TEST CASE - 1 issue every 2 days, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "one issue every two days", > unit => 'day', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-05'); > > # TEST CASE - 1 issue every 2 days, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-07'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-09'); > > # TEST CASE - 1 issue per week, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "one issue per week", > unit => 'week', > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); > > # TEST CASE - 1 issue per week, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-22'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-29'); > > # TEST CASE - 1 issue every 2 weeks, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "one issue every 2 weeks", > unit => 'week', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-29'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-12'); > > # TEST CASE - 1 issue every 2 weeks, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-12'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-26'); > > # TEST CASE - 2 issues per week, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "two issues per week", > unit => 'week', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); > # when more than 1 issue per week, date is automatically set to the same day of > # week as firstacquidate >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-10'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); > > # TEST CASE - 2 issues per week, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-10'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-22'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-24'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-29'); > > # TEST CASE - 6 issues per week, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "six issues per week", > unit => 'week', > issuesperunit => 6, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-06', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-07'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-09'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-10'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-11'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-13'); > > # TEST CASE - 6 issues per week, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-06', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-07'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-09'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-13'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-14'); > > # TEST CASE - 1 issue per month, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue per month", > unit => 'month', > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-04-01'); > > # TEST CASE - 1 issue per month, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-05-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-06-01'); > > # TEST CASE - 1 issue every 2 months, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue every 2 months", > unit => 'month', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-05-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-01'); > > # TEST CASE - 1 issue every 2 months, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-09-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-11-01'); > > # TEST CASE - 2 issues per month, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "2 issues per month", > unit => 'month', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-16', 'January has 31 days'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-15', 'February has only 28 days'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); > > # TEST CASE - 2 issues per month, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-16', 'January has 31 days'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-15', 'February has only 28 days'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-04-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-04-16', 'April has 30 days'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-05-01'); > > # TEST CASE - 1 issue per year, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue per year", > unit => 'year', > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1973-01-01'); > > # TEST CASE - 1 issue per year, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1975-01-01'); > > # TEST CASE - 1 issue every 2 years, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue every 2 years", > unit => 'year', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1976-01-01'); > > # TEST CASE - 1 issue every 2 years, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1978-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1980-01-01'); > > # TEST CASE - 2 issues per year, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue every 2 years", > unit => 'year', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); > > # TEST CASE - 2 issues per year, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1973-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1973-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); > > # TEST CASE - Irregular >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "Irregular", > unit => undef, > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; > # GetNextDate always return undef if subscription is irregular >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, undef); > > # GetNextDate returns undef if one of two first parameters is undef >-$publisheddate = GetNextDate($subscription, undef); >+$publisheddate = GetNextDate($subscription, undef, $frequency); > is($publisheddate, undef); >-$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}); >+$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}, $frequency); > is($publisheddate, undef); >-$publisheddate = GetNextDate(undef, undef); >+$publisheddate = GetNextDate(undef, undef, $frequency); > is($publisheddate, undef); > > $dbh->rollback; >diff --git a/t/db_dependent/Serials/GetNextSeq.t b/t/db_dependent/Serials/GetNextSeq.t >index fc6e3f2..c4152dd 100644 >--- a/t/db_dependent/Serials/GetNextSeq.t >+++ b/t/db_dependent/Serials/GetNextSeq.t >@@ -43,16 +43,16 @@ my $subscription = { > }; > my $publisheddate = $subscription->{firstacquidate}; > >-my $seq = _next_seq($subscription, $pattern, $publisheddate); >+my $seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 4'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 3'); > > # TEST CASE 2 - 1 variable, use 'dayname' numbering, from 1 to 7 >@@ -79,19 +79,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Tuesday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Friday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Sunday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Monday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Tuesday'); > > # TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2 >@@ -118,19 +118,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: March'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: September'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: January'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: March'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: May'); > > # TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3 >@@ -157,19 +157,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Summer'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Spring'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Fall'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Winter'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Spring'); > > # TEST CASE 5 - 2 variables, from 1 to 12, and from 1 to 4 >@@ -196,19 +196,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 1, X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 2, X: 1'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 2, X: 3'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 2, X: 4'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 3, X: 1'); > > # TEST CASE 6 - 3 variables, from 1 to 12, from 1 to 8, and from 1 to 4 >@@ -235,44 +235,44 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 1, X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 2, X: 1'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 2, X: 3'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 2, X: 4'); > for (1..100) { >- $publisheddate = GetNextDate($subscription, $publisheddate); >- $seq = _next_seq($subscription, $pattern, $publisheddate); >+ $publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+ $seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > } >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 4, X: 1'); > # 110th is here >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 4, X: 3'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 4, X: 4'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 5, X: 1'); > > > $dbh->rollback; > > sub _next_seq { >- my ($subscription, $pattern, $publisheddate) = @_; >+ my ($subscription, $pattern, $frequency, $publisheddate) = @_; > my $seq; > ($seq, $subscription->{lastvalue1}, $subscription->{lastvalue2}, > $subscription->{lastvalue3}, $subscription->{innerloop1}, > $subscription->{innerloop2}, $subscription->{innerloop3}) = >- GetNextSeq($subscription, $pattern, $publisheddate); >+ GetNextSeq($subscription, $pattern, $frequency, $publisheddate); > return $seq; > } >-- >2.7.4
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 17047
:
56175
|
56176
|
56177
|
56178
|
56179
|
56180
|
56181
|
59728
|
59729
|
59931
|
61905
|
62045
|
62046
|
62047
|
62048
|
62049
|
62050
|
62051
|
62052
|
62053
|
62054
|
62075
|
62465
|
62475
|
62485
|
62540
|
62542
|
62543
|
62544
|
62545
|
62546
|
62547
|
62548
|
62549
|
62550
|
62551
|
62552
|
62553
|
62589
|
62591
|
62592
|
62593
|
62594
|
62595
|
62596
|
62597
|
62598
|
62599
|
62603
|
62604
|
62605
|
62606
|
62607
|
62768
|
63476
|
63601
|
63618
|
63619
|
63620
|
63621
|
63622
|
63623
|
64484
|
64530
|
64618
|
64619
|
64620
|
64621
|
64622
|
64623
|
64624
|
64625
|
64626
|
64627
|
64628
|
64629
|
64630
|
64631
|
64632
|
64633
|
64634
|
64635
|
64636
|
64637
|
64638
|
64639
|
64640
|
64641
|
64642
|
64643
|
64648
|
64649
|
64650
|
64651
|
64652
|
64653
|
64654
|
64706
|
64962
|
65058
|
65059
|
65060
|
65061
|
65062
|
65063
|
65064
|
65065
|
65773
|
66667
|
66668
|
66987
|
67003
|
67004
|
67005
|
67006
|
67009
|
67010
|
67011
|
67012
|
67013
|
67014
|
67015
|
67016
|
67017
|
67018
|
67019
|
67020
|
67021
|
67022
|
67023
|
69034
|
69035
|
69036
|
69037
|
69038
|
69039
|
69040
|
69041
|
69091
|
70203
|
70204
|
70205
|
70206
|
70208
|
70209
|
70210
|
70211
|
70561
|
70874
|
72660
|
72661
|
72662
|
72663
|
72664
|
72665
|
72666
|
72667
|
72668
|
72669
|
72670
|
73699
|
73737
|
73738
|
73739
|
73740
|
73741
|
73742
|
73743
|
73744
|
73745
|
73746
|
73747
|
73748
|
73975
|
73976
|
73977
|
73978
|
73979
|
73980
|
73981
|
73982
|
73983
|
73984
|
73985
|
73986
|
76673
|
76674
|
76675
|
76676
|
76677
|
76678
|
76679
|
76680
|
76681
|
76682
|
76683
|
76684
|
78215
|
78216
|
78217
|
78218
|
78219
|
78220
|
78221
|
78222
|
78223
|
78224
|
78225
|
78226
|
78227
|
78228
|
78229
|
79868
|
79869
|
79870
|
79871
|
79872
|
79874
|
79877
|
79878
|
79879
|
79880
|
79881
|
79882
|
79883
|
79884
|
79885
|
79886
|
79887
|
79888
|
79922
|
79923
|
79924
|
79925
|
79926
|
79927
|
79928
|
79929
|
79930
|
79931
|
79932
|
79933
|
79934
|
79935
|
79936
|
79937
|
79938
|
79939
|
80183
|
80184
|
80185
|
80186
|
80187
|
80188
|
80189
|
80190
|
80191
|
80192
|
80193
|
80194
|
80195
|
80196
|
80197
|
80198
|
80199
|
80200
|
80471
|
80472
|
80473
|
80907
|
80908
|
80909
|
80910
|
80911
|
80912
|
80913
|
80914
|
80915
|
80916
|
80917
|
80918
|
80919
|
80920
|
80921
|
80922
|
80923
|
80924
|
81935
|
81936
|
81937
|
81938
|
81939
|
81940
|
81941
|
81942
|
81943
|
81944
|
81945
|
81946
|
81947
|
81948
|
81949
|
81950
|
81951
|
81952
|
81968
|
83863
|
83864
|
83865
|
83866
|
83867
|
83868
|
83869
|
83870
|
83871
|
83872
|
83873
|
83874
|
83875
|
83876
|
83877
|
83878
|
83879
|
83880
|
83881
|
83892
|
83893
|
83894
|
83895
|
83896
|
83897
|
83898
|
83899
|
83900
|
83901
|
83902
|
83903
|
83904
|
83905
|
83906
|
83907
|
83908
|
83909
|
83910
|
83911
|
83912
|
84142
|
84145
|
84210
|
84260
|
84261
|
84262
|
84263
|
84264
|
84265
|
84323
|
84324
|
84325
|
84326
|
84327
|
84328
|
84329
|
84332