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

(-)a/C4/Serials.pm (-15 / +16 lines)
Lines 864-882 sub GetDistributedTo { Link Here
864
    my (
864
    my (
865
        $nextseq,       $newlastvalue1, $newlastvalue2, $newlastvalue3,
865
        $nextseq,       $newlastvalue1, $newlastvalue2, $newlastvalue3,
866
        $newinnerloop1, $newinnerloop2, $newinnerloop3
866
        $newinnerloop1, $newinnerloop2, $newinnerloop3
867
    ) = GetNextSeq( $subscription, $pattern, $planneddate );
867
    ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate );
868
868
869
$subscription is a hashref containing all the attributes of the table
869
$subscription is a hashref containing all the attributes of the table
870
'subscription'.
870
'subscription'.
871
$pattern is a hashref containing all the attributes of the table
871
$pattern is a hashref containing all the attributes of the table
872
'subscription_numberpatterns'.
872
'subscription_numberpatterns'.
873
$frequency is a hashref containing all the attributes of the table 'subscription_frequencies'
873
$planneddate is a date string in iso format.
874
$planneddate is a date string in iso format.
874
This function get the next issue for the subscription given on input arg
875
This function get the next issue for the subscription given on input arg
875
876
876
=cut
877
=cut
877
878
878
sub GetNextSeq {
879
sub GetNextSeq {
879
    my ($subscription, $pattern, $planneddate) = @_;
880
    my ($subscription, $pattern, $frequency, $planneddate) = @_;
880
881
881
    return unless ($subscription and $pattern);
882
    return unless ($subscription and $pattern);
882
883
Lines 889-895 sub GetNextSeq { Link Here
889
        if(@irreg > 0) {
890
        if(@irreg > 0) {
890
            my $irregularities = {};
891
            my $irregularities = {};
891
            $irregularities->{$_} = 1 foreach(@irreg);
892
            $irregularities->{$_} = 1 foreach(@irreg);
892
            my $issueno = GetFictiveIssueNumber($subscription, $planneddate) + 1;
893
            my $issueno = GetFictiveIssueNumber($subscription, $planneddate, $frequency) + 1;
893
            while($irregularities->{$issueno}) {
894
            while($irregularities->{$issueno}) {
894
                $count++;
895
                $count++;
895
                $issueno++;
896
                $issueno++;
Lines 1032-1038 sub GetExpirationDate { Link Here
1032
1033
1033
            #calculate the date of the last issue.
1034
            #calculate the date of the last issue.
1034
            for ( my $i = 1 ; $i <= $length ; $i++ ) {
1035
            for ( my $i = 1 ; $i <= $length ; $i++ ) {
1035
                $enddate = GetNextDate( $subscription, $enddate );
1036
                $enddate = GetNextDate( $subscription, $enddate, $frequency );
1036
            }
1037
            }
1037
        } elsif ( $subscription->{monthlength} ) {
1038
        } elsif ( $subscription->{monthlength} ) {
1038
            if ( $$subscription{startdate} ) {
1039
            if ( $$subscription{startdate} ) {
Lines 1184-1199 sub ModSerialStatus { Link Here
1184
    if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
1185
    if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
1185
        my $subscription = GetSubscription($subscriptionid);
1186
        my $subscription = GetSubscription($subscriptionid);
1186
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1187
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1188
        my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
1187
1189
1188
        # next issue number
1190
        # next issue number
1189
        my (
1191
        my (
1190
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1192
            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
1191
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1193
            $newinnerloop1, $newinnerloop2, $newinnerloop3
1192
          )
1194
          )
1193
          = GetNextSeq( $subscription, $pattern, $publisheddate );
1195
          = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
1194
1196
1195
        # next date (calculated from actual date & frequency parameters)
1197
        # next date (calculated from actual date & frequency parameters)
1196
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1);
1198
        my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency, 1);
1197
        my $nextpubdate = $nextpublisheddate;
1199
        my $nextpubdate = $nextpublisheddate;
1198
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1200
        $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
1199
                    WHERE  subscriptionid = ?";
1201
                    WHERE  subscriptionid = ?";
Lines 2193-2199 sub abouttoexpire { Link Here
2193
        my $expirationdate = GetExpirationDate($subscriptionid);
2195
        my $expirationdate = GetExpirationDate($subscriptionid);
2194
2196
2195
        my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid);
2197
        my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid);
2196
        my $nextdate = GetNextDate($subscription, $res);
2198
        my $nextdate = GetNextDate($subscription, $res, $frequency);
2197
2199
2198
        # only compare dates if both dates exist.
2200
        # only compare dates if both dates exist.
2199
        if ($nextdate and $expirationdate) {
2201
        if ($nextdate and $expirationdate) {
Lines 2259-2265 sub GetSubscriptionsFromBorrower { Link Here
2259
2261
2260
=head2 GetFictiveIssueNumber
2262
=head2 GetFictiveIssueNumber
2261
2263
2262
$issueno = GetFictiveIssueNumber($subscription, $publishedate);
2264
$issueno = GetFictiveIssueNumber($subscription, $publishedate, $frequency);
2263
2265
2264
Get the position of the issue published at $publisheddate, considering the
2266
Get the position of the issue published at $publisheddate, considering the
2265
first issue (at firstacquidate) is at position 1, the next is at position 2, etc...
2267
first issue (at firstacquidate) is at position 1, the next is at position 2, etc...
Lines 2273-2281 date, and $publisheddate. Link Here
2273
=cut
2275
=cut
2274
2276
2275
sub GetFictiveIssueNumber {
2277
sub GetFictiveIssueNumber {
2276
    my ($subscription, $publisheddate) = @_;
2278
    my ($subscription, $publisheddate, $frequency) = @_;
2277
2279
2278
    my $frequency = GetSubscriptionFrequency($subscription->{'periodicity'});
2279
    my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef;
2280
    my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef;
2280
    my $issueno = 0;
2281
    my $issueno = 0;
2281
2282
Lines 2393-2404 sub _get_next_date_year { Link Here
2393
2394
2394
=head2 GetNextDate
2395
=head2 GetNextDate
2395
2396
2396
$resultdate = GetNextDate($publisheddate,$subscription)
2397
$resultdate = GetNextDate($publisheddate,$subscription,$freqdata,$updatecount)
2397
2398
2398
this function it takes the publisheddate and will return the next issue's date
2399
this function it takes the publisheddate and will return the next issue's date
2399
and will skip dates if there exists an irregularity.
2400
and will skip dates if there exists an irregularity.
2400
$publisheddate has to be an ISO date
2401
$publisheddate has to be an ISO date
2401
$subscription is a hashref containing at least 'periodicity', 'firstacquidate', 'irregularity', and 'countissuesperunit'
2402
$subscription is a hashref containing at least 'firstacquidate', 'irregularity', and 'countissuesperunit'
2403
$frequency is a hashref containing frequency informations
2402
$updatecount is a boolean value which, when set to true, update the 'countissuesperunit' in database
2404
$updatecount is a boolean value which, when set to true, update the 'countissuesperunit' in database
2403
- eg if periodicity is monthly and $publisheddate is 2007-02-10 but if March and April is to be
2405
- eg if periodicity is monthly and $publisheddate is 2007-02-10 but if March and April is to be
2404
skipped then the returned date will be 2007-05-10
2406
skipped then the returned date will be 2007-05-10
Lines 2411-2421 Return undef if subscription is irregular Link Here
2411
=cut
2413
=cut
2412
2414
2413
sub GetNextDate {
2415
sub GetNextDate {
2414
    my ( $subscription, $publisheddate, $updatecount ) = @_;
2416
    my ( $subscription, $publisheddate, $freqdata, $updatecount ) = @_;
2415
2417
2416
    return unless $subscription and $publisheddate;
2418
    return unless $subscription and $publisheddate;
2417
2419
2418
    my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
2419
2420
2420
    if ($freqdata->{'unit'}) {
2421
    if ($freqdata->{'unit'}) {
2421
        my ( $year, $month, $day ) = split /-/, $publisheddate;
2422
        my ( $year, $month, $day ) = split /-/, $publisheddate;
Lines 2435-2441 sub GetNextDate { Link Here
2435
2436
2436
        # Get the 'fictive' next issue number
2437
        # Get the 'fictive' next issue number
2437
        # It is used to check if next issue is an irregular issue.
2438
        # It is used to check if next issue is an irregular issue.
2438
        my $issueno = GetFictiveIssueNumber($subscription, $publisheddate) + 1;
2439
        my $issueno = GetFictiveIssueNumber($subscription, $publisheddate, $freqdata) + 1;
2439
2440
2440
        # Then get the next date
2441
        # Then get the next date
2441
        my $unit = lc $freqdata->{'unit'};
2442
        my $unit = lc $freqdata->{'unit'};
(-)a/Koha/SharedContent.pm (+20 lines)
Lines 40-45 sub manaRequest { Link Here
40
    return $result if ( $response->code =~ /^2..$/ );
40
    return $result if ( $response->code =~ /^2..$/ );
41
}
41
}
42
42
43
sub manaNewUserPatchRequest {
44
    my $resource = shift;
45
    my $id       = shift;
46
47
    my $url = "$MANA_IP/$resource/$id.json/newUser";
48
    my $request = HTTP::Request->new( PATCH => $url );
49
50
    return manaRequest($request);
51
}
52
43
sub manaPostRequest {
53
sub manaPostRequest {
44
    my $resource = shift;
54
    my $resource = shift;
45
    my $content  = shift;
55
    my $content  = shift;
Lines 54-59 sub manaPostRequest { Link Here
54
    return manaRequest($request);
64
    return manaRequest($request);
55
}
65
}
56
66
67
sub manaGetRequestWithId {
68
    my $resource = shift;
69
    my $id       = shift;
70
71
    my $url = "$MANA_IP/$resource/$id.json";
72
    my $request = HTTP::Request->new( GET => $url );
73
74
    return manaRequest($request);
75
}
76
57
sub manaGetRequest {
77
sub manaGetRequest {
58
    my $resource   = shift;
78
    my $resource   = shift;
59
    my $parameters = shift;
79
    my $parameters = shift;
(-)a/Koha/Subscription.pm (+15 lines)
Lines 45-50 Koha::Subscription - Koha Subscription Object class Link Here
45
45
46
=cut
46
=cut
47
47
48
sub get_search_info {
49
    my $searched_sub_id = shift;
50
    my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } );
51
    my $biblioitem =
52
      Koha::Biblioitems->find( { 'biblionumber' => $searched_sub_id } );
53
54
    my $sub_mana_info = {
55
        'title'         => $biblio->title,
56
        'issn'          => $biblioitem->issn,
57
        'ean'           => $biblioitem->ean,
58
        'publishercode' => $biblioitem->publishercode
59
    };
60
    return $sub_mana_info;
61
}
62
48
sub get_sharable_info {
63
sub get_sharable_info {
49
    my $shared_sub_id = shift;
64
    my $shared_sub_id = shift;
50
    my $subscription  = Koha::Subscriptions->find($shared_sub_id);
65
    my $subscription  = Koha::Subscriptions->find($shared_sub_id);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt (+1 lines)
Line 0 Link Here
1
[% INCLUDE 'mana-subscription-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-23 / +191 lines)
Lines 1-5 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Koha %]
3
4
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Serials &rsaquo; [% IF ( modify ) %][% bibliotitle |html %] &rsaquo; Modify subscription[% ELSE %]New subscription[% END %]</title>
6
<title>Koha &rsaquo; Serials &rsaquo; [% IF ( modify ) %][% bibliotitle |html %] &rsaquo; Modify subscription[% ELSE %]New subscription[% END %]</title>
Lines 11-21 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
11
    width: 300px;  /* not enough for IE7 apparently */
12
    width: 300px;  /* not enough for IE7 apparently */
12
}
13
}
13
</style>
14
</style>
15
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
16
[% INCLUDE 'datatables.inc' %]
14
<script type="text/javascript">
17
<script type="text/javascript">
15
//<![CDATA[
18
//<![CDATA[
16
19
17
var globalnumpatterndata;
20
var globalnumpatterndata;
18
var globalfreqdata;
21
var globalfreqdata;
22
var mananumpatterndata;
23
var manafreqdata;
24
var manaid;
19
var advancedpatternlocked;
25
var advancedpatternlocked;
20
var patternneedtobetested = 0;
26
var patternneedtobetested = 0;
21
[% IF ( irregularity ) %]patternneedtobetested = 1;[% END %]
27
[% IF ( irregularity ) %]patternneedtobetested = 1;[% END %]
Lines 98-128 function Check_page2(){ Link Here
98
}
104
}
99
105
100
function frequencyload(){
106
function frequencyload(){
101
    $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'},
107
    if ($("#frequency option:selected").val() === "mana"){
102
        function(freqdata){
108
        globalfreqdata=manafreqdata;
103
            globalfreqdata=freqdata;
109
        $("input[name='sfdescription']").val(manafreqdata.description);
104
            if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) {
110
        $("input[name='unit']").val(manafreqdata.unit);
105
                var option = $("#subtype option[value='issues']");
111
        $("input[name='unitsperissue']").val(manafreqdata.unitsperissue);
106
                $(option).attr('selected', 'selected');
112
        $("input[name='issuesperunit']").val(manafreqdata.issuesperunit);
107
                $("#subtype option[value!='issues']").prop('disabled', true)
113
        if ($( "#numberpattern option:selected" ).val() === "mana" ) {
108
            } else {
114
            $("input[name='mana_id']").val(manaid);
109
                $("#subtype option").prop('disabled', false)
110
            }
111
        }
115
        }
112
    )
116
    } else {
117
        $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'},
118
            function(freqdata){
119
                globalfreqdata=freqdata;
120
                if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) {
121
                    var option = $("#subtype option[value='issues']");
122
                    $(option).attr('selected', 'selected');
123
                    $("#subtype option[value!='issues']").prop('disabled', true);
124
                } else {
125
                    $("#subtype option").prop('disabled', false);
126
                }
127
            }
128
        );
129
        $("input[name='mana_id']").val("");
130
    }
113
}
131
}
114
132
115
function numberpatternload(){
133
function numberpatternload(){
116
    $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'},
134
    if($("#numberpattern option:selected" ).val() === "mana"){
117
        function(numpatterndata){
135
        globalnumpatterndata=mananumpatterndata;
118
            globalnumpatterndata=numpatterndata;
136
        $("input[name='sndescription']").val(mananumpatterndata.description);
119
            if (globalnumpatterndata==undefined){
137
        if($("#frequency option:selected" ).val() === "mana"){
120
                return false;
138
            $("input[name='mana_id']").val(manaid);
121
            }
139
        }
122
            displaymoreoptions();
140
        if (globalnumpatterndata==undefined){
123
            restoreAdvancedPattern();
141
            return false;
124
        }
142
        }
125
    );
143
        displaymoreoptions();
144
        restoreAdvancedPattern();
145
    } else {
146
        $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'},
147
            function(numpatterndata){
148
                globalnumpatterndata=numpatterndata;
149
                if (globalnumpatterndata==undefined){
150
                    return false;
151
                }
152
                displaymoreoptions();
153
                restoreAdvancedPattern();
154
            }
155
        );
156
        $("input[name='mana_id']").val("");
157
    }
126
}
158
}
127
159
128
function displaymoreoptions() {
160
function displaymoreoptions() {
Lines 285-291 function testPredictionPattern() { Link Here
285
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
317
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
286
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
318
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
287
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
319
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
288
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
320
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'sfdescription',
321
        'unitsperissue', 'issuesperunit', 'unit'
289
    ];
322
    ];
290
    for(i in ajaxParams) {
323
    for(i in ajaxParams) {
291
        var param = ajaxParams[i];
324
        var param = ajaxParams[i];
Lines 372-379 function show_page_2() { Link Here
372
    displaymoreoptions();
405
    displaymoreoptions();
373
}
406
}
374
407
408
function mana_search() {
409
    $.ajax({
410
        type: "POST",
411
        url: "/cgi-bin/koha/svc/mana/search",
412
        data: {biblionumber : $("#biblionumber").val()},
413
        dataType: "html",
414
    })
415
    .done( function( result ) {
416
    $("#mana_search_result .modal-body").html(result);
417
        $("#mana_search_result_label").text("Results from Mana");
418
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
419
            "sPaginationType": "four_button",
420
            "aoColumnDefs": [
421
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
422
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
423
                { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
424
            ]
425
        }));
426
        if($("td.dataTables_empty").length == 0){
427
            $("#mana_search").show();
428
        }
429
    }).fail(function(result){
430
    });
431
}
432
433
function mana_use(mana_id){
434
    $("tr").removeClass("selected");
435
    $("#row"+mana_id).addClass("selected");
436
    $.ajax( {
437
        type: "POST",
438
        url: "/cgi-bin/koha/svc/mana/use",
439
        data: {id : mana_id},
440
        dataType: "json",
441
    })
442
    .done(function(result){
443
        var select = document.getElementById('numberpattern');
444
        for(i = 0; i < select.length; i++){
445
            if(select[i].value === "mana"){
446
                select.remove(i);
447
            }
448
        }
449
        var optionnumpattern = document.createElement("option");
450
        optionnumpattern.text = result.label + " (mana)";
451
        optionnumpattern.selected = true;
452
        optionnumpattern.value="mana";
453
        select.add(optionnumpattern);
454
455
        mananumpatterndata = {
456
            id:"mana",
457
            add1:result.add1,
458
            add2:result.add2,
459
            add3:result.add3,
460
            description:result.sndescription,
461
            displayorder:result.displayorder,
462
            every1:result.every1,
463
            every2:result.every2,
464
            every3:result.every3,
465
            label:result.label,
466
            label1:result.label1,
467
            label2:result.label2,
468
            label3:result.label3,
469
            numbering1:result.numbering1,
470
            numbering2:result.numbering2,
471
            numbering3:result.numbering3,
472
            numberingmethod:result.numberingmethod,
473
            setto1:result.setto1,
474
            setto2:result.setto2,
475
            setto3:result.setto3,
476
            whenmorethan1:result.whenmorethan1,
477
            whenmorethan2:result.whenmorethan2,
478
            whenmorethan3:result.whenmorethan3,
479
        };
480
        select = document.getElementById("frequency");
481
        for(i = 0; i < select.length; i++){
482
            if(select[i].value === "mana"){
483
                select.remove(i);
484
            }
485
        }
486
        var optionfreq = document.createElement("option");
487
        optionfreq.text = result.sfdescription + " (mana)";
488
        optionfreq.selected = true;
489
        optionfreq.value="mana";
490
        select.add(optionfreq);
491
        manafreqdata = {
492
            id:"mana",
493
            description:result.sfdescription,
494
            displayorder:result.displayorder,
495
            issuesperunit:result.issuesperunit,
496
            unit:result.unit,
497
            unitsperissue:result.unitsperissue,
498
        };
499
        manaid = result.id;
500
        $("input[name='mana_id']").val(manaid);
501
        $("#mana_search_result").modal("hide");
502
        frequencyload();
503
        numberpatternload();
504
    }).fail( function( result ){
505
    });
506
}
507
508
function removeDisabledAttr() {
509
    $('select:disabled').removeAttr('disabled');
510
}
511
375
512
376
$(document).ready(function() {
513
$(document).ready(function() {
514
    $("#mana_search_result").modal("hide");
377
    $("#aqbooksellerid").on('keypress', function(e) {
515
    $("#aqbooksellerid").on('keypress', function(e) {
378
        if (e.keyCode == 13) {
516
        if (e.keyCode == 13) {
379
            e.preventDefault();
517
            e.preventDefault();
Lines 456-461 $(document).ready(function() { Link Here
456
        }
594
        }
457
    [% END %]
595
    [% END %]
458
596
597
    $("#mana_search").hide();
598
459
    show_page_1();
599
    show_page_1();
460
    $("#subscription_add_form").on("submit",function(){
600
    $("#subscription_add_form").on("submit",function(){
461
        return Check_page2();
601
        return Check_page2();
Lines 477-483 $(document).ready(function() { Link Here
477
        }
617
        }
478
    });
618
    });
479
    $("#subscription_add_next").on("click",function(){
619
    $("#subscription_add_next").on("click",function(){
480
        if ( Check_page1() ){
620
        if ( Check_page1() ) {
621
            [% IF Koha.Preference('Mana') %]
622
                mana_search();
623
            [% END %]
481
            show_page_2();
624
            show_page_2();
482
        }
625
        }
483
    });
626
    });
Lines 701-706 $(document).ready(function() { Link Here
701
844
702
                <div id="page_2">
845
                <div id="page_2">
703
                    <div class="yui-u first">
846
                    <div class="yui-u first">
847
                        <div id="mana_search" class="dialog message">
848
                            <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>
849
                        </div>
704
                        <div id="subscription_form_planning">
850
                        <div id="subscription_form_planning">
705
                            <fieldset class="rows">
851
                            <fieldset class="rows">
706
                                <legend>Serials planning</legend>
852
                                <legend>Serials planning</legend>
Lines 965-974 $(document).ready(function() { Link Here
965
                              </div>
1111
                              </div>
966
                            [% END %]
1112
                            [% END %]
967
1113
1114
                            <input type="hidden" id="mana_id"  name="mana_id" value=""/>
1115
                            <input type="hidden" id="sndescription"  name="sndescription" value=""/>
1116
                            <input type="hidden" id="sfdescription"  name="sfdescription" value=""/>
1117
                            <input type="hidden" id="unit"  name="unit" value=""/>
1118
                            <input type="hidden" id="unitsperissue"  name="unitsperissue" value=""/>
1119
                            <input type="hidden" id="issuesperunit"  name="issuesperunit" value=""/>
968
                            <fieldset class="action">
1120
                            <fieldset class="action">
969
                                <input type="button" id="subscription_add_previous" value="&lt;&lt; Previous" style="float:left;"/>
1121
                                <input type="button" id="subscription_add_previous" value="&lt;&lt; Previous" style="float:left;"/>
970
                                <input id="testpatternbutton" type="button" value="Test prediction pattern" />
1122
                                <input id="testpatternbutton" type="button" value="Test prediction pattern" />
971
                                <input type="submit" value="Save subscription" style="float:right;" accesskey="w" />
1123
                                <input type="submit" onclick="removeDisabledAttr()" value="Save subscription" style="float:right;" accesskey="w"/>
972
                            </fieldset>
1124
                            </fieldset>
973
                        </div>
1125
                        </div>
974
                    </div>
1126
                    </div>
Lines 981-984 $(document).ready(function() { Link Here
981
    </div>
1133
    </div>
982
</div>
1134
</div>
983
1135
1136
<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;">
1137
    <div class="modal-dialog">
1138
        <div class="modal-content">
1139
            <div class="modal-header">
1140
                <h3 id="mana_search_result_label"></h3>
1141
            </div>
1142
            <div class="modal-body">
1143
            </div>
1144
            <div class="modal-footer">
1145
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
1146
            </div>
1147
        </div>
1148
    </div>
1149
</div>
1150
1151
984
[% INCLUDE 'intranet-bottom.inc' %]
1152
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/misc/cronjobs/serialsUpdate.pl (-1 / +3 lines)
Lines 33-38 use C4::Debug; Link Here
33
use C4::Serials;
33
use C4::Serials;
34
use C4::Log;
34
use C4::Log;
35
use Koha::DateUtils;
35
use Koha::DateUtils;
36
use C4::Serials::Frequency;
36
37
37
use Date::Calc qw/Date_to_Days check_date/;
38
use Date::Calc qw/Date_to_Days check_date/;
38
use Getopt::Long;
39
use Getopt::Long;
Lines 118-124 while ( my $issue = $sth->fetchrow_hashref ) { Link Here
118
    my $publisheddate  = $issue->{publisheddate};
119
    my $publisheddate  = $issue->{publisheddate};
119
120
120
    if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
121
    if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
121
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate );
122
        my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
123
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata );
122
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
124
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
123
125
124
        if ( $nextpublisheddate && $today ) {
126
        if ( $nextpublisheddate && $today ) {
(-)a/serials/serials-collection.pl (-2 / +4 lines)
Lines 74-87 if($op eq 'gennext' && @subscriptionid){ Link Here
74
            require C4::Serials::Numberpattern;
74
            require C4::Serials::Numberpattern;
75
            my $subscription = GetSubscription($subscriptionid);
75
            my $subscription = GetSubscription($subscriptionid);
76
            my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
76
            my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
77
            my $frequency = C4::Serials::Frequency::GetSubscriptionFrequencies($subscription->{periodicity});
77
            my $expected = GetNextExpected($subscriptionid);
78
            my $expected = GetNextExpected($subscriptionid);
78
            my (
79
            my (
79
                 $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
80
                 $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
80
                 $newinnerloop1, $newinnerloop2, $newinnerloop3
81
                 $newinnerloop1, $newinnerloop2, $newinnerloop3
81
            ) = GetNextSeq($subscription, $pattern, $expected->{publisheddate});
82
            ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate});
82
83
83
             ## We generate the next publication date
84
             ## We generate the next publication date
84
             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1);
85
             my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
86
             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
85
             ## Creating the new issue
87
             ## Creating the new issue
86
             NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
88
             NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
87
                     1, $nextpublisheddate, $nextpublisheddate );
89
                     1, $nextpublisheddate, $nextpublisheddate );
(-)a/serials/showpredictionpattern.pl (-5 / +18 lines)
Lines 56-62 my $subtype = $input->param('subtype'); Link Here
56
my $sublength = $input->param('sublength');
56
my $sublength = $input->param('sublength');
57
my $custompattern = $input->param('custompattern');
57
my $custompattern = $input->param('custompattern');
58
58
59
my $frequency = GetSubscriptionFrequency($frequencyid);
59
60
my $frequency;
61
if ( $frequencyid eq 'mana' ) {
62
    $frequency = {
63
        'id'            => undef,
64
        'displayorder'  => undef,
65
        'description'   => scalar $input->param('sfdescription') // '',
66
        'unitsperissue' => scalar $input->param('unitsperissue') // '',
67
        'issuesperunit' => scalar $input->param('issuesperunit') // '',
68
        'unit'          => scalar $input->param('unit') // ''
69
    };
70
}
71
else {
72
    $frequency = GetSubscriptionFrequency($frequencyid);
73
}
60
74
61
my %pattern = (
75
my %pattern = (
62
    numberingmethod => scalar $input->param('numberingmethod') // '',
76
    numberingmethod => scalar $input->param('numberingmethod') // '',
Lines 98-111 my %subscription = ( Link Here
98
    innerloop2      => scalar $input->param('innerloop2') // '',
112
    innerloop2      => scalar $input->param('innerloop2') // '',
99
    innerloop3      => scalar $input->param('innerloop3') // '',
113
    innerloop3      => scalar $input->param('innerloop3') // '',
100
    irregularity    => '',
114
    irregularity    => '',
101
    periodicity     => $frequencyid,
102
    countissuesperunit  => 1,
115
    countissuesperunit  => 1,
103
    firstacquidate  => $firstacquidate,
116
    firstacquidate  => $firstacquidate,
104
);
117
);
105
118
106
my $issuenumber;
119
my $issuenumber;
107
if(defined $subscriptionid) {
120
if(defined $subscriptionid) {
108
    ($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date);
121
    ($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date, $frequency);
109
} else {
122
} else {
110
    $issuenumber = 1;
123
    $issuenumber = 1;
111
}
124
}
Lines 135-141 while( $i < 1000 ) { Link Here
135
    my %line;
148
    my %line;
136
149
137
    if(defined $date){
150
    if(defined $date){
138
        $date = GetNextDate(\%subscription, $date);
151
        $date = GetNextDate(\%subscription, $date, $frequency);
139
    }
152
    }
140
    if(defined $date){
153
    if(defined $date){
141
        $line{'publicationdate'} = $date;
154
        $line{'publicationdate'} = $date;
Lines 156-162 while( $i < 1000 ) { Link Here
156
        last;
169
        last;
157
    }
170
    }
158
171
159
    ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern);
172
    ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern, $frequency);
160
    $issuenumber++;
173
    $issuenumber++;
161
    $line{'number'} = $calculated;
174
    $line{'number'} = $calculated;
162
    $line{'issuenumber'} = $issuenumber;
175
    $line{'issuenumber'} = $issuenumber;
(-)a/serials/subscription-add.pl (-7 / +84 lines)
Lines 34-39 use Koha::AdditionalField; Link Here
34
use Koha::DateUtils;
34
use Koha::DateUtils;
35
use Carp;
35
use Carp;
36
36
37
use Koha::Subscription::Numberpattern;
38
use Koha::Subscription::Frequency;
39
use Koha::SharedContent;
40
37
#use Smart::Comments;
41
#use Smart::Comments;
38
42
39
our $query = CGI->new;
43
our $query = CGI->new;
Lines 282-296 sub _guess_enddate { Link Here
282
    return $enddate;
286
    return $enddate;
283
}
287
}
284
288
289
sub manage_subscription_numbering_pattern_id {
290
    my $numberpattern;
291
    if ( $query->param('numbering_pattern') eq 'mana' ) {
292
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set(
293
            {
294
                label           => $query->param('patternname'),
295
                description     => $query->param('sndescription'),
296
                numberingmethod => $query->param('numberingmethod'),
297
                label1          => $query->param('label1'),
298
                add1            => $query->param('add1'),
299
                every1          => $query->param('every1'),
300
                whenmorethan1   => $query->param('whenmorethan1'),
301
                setto1          => $query->param('setto1'),
302
                numbering1      => $query->param('numbering1'),
303
                label2          => $query->param('label2'),
304
                add2            => $query->param('add2'),
305
                every2          => $query->param('every2'),
306
                whenmorethan2   => $query->param('whenmorethan2'),
307
                setto2          => $query->param('setto2'),
308
                numbering2      => $query->param('numbering2'),
309
                label3          => $query->param('label3'),
310
                add3            => $query->param('add3'),
311
                every3          => $query->param('every3'),
312
                whenmorethan3   => $query->param('whenmorethan3'),
313
                setto3          => $query->param('setto3'),
314
                numbering3      => $query->param('numbering3'),
315
            }
316
        )->store();
317
        $numberpattern = $subscription_np->id;
318
    }
319
    else {
320
        $numberpattern = $query->param('numbering_pattern');
321
    }
322
    return $numberpattern;
323
}
324
325
sub manage_subscription_frequencies_id {
326
    my $periodicity;
327
    if ( $query->param('frequency') eq 'mana' ) {
328
        my $subscription_freq = Koha::Subscription::Frequency->new()->set(
329
            {
330
                description   => $query->param('sfdescription'),
331
                unit          => $query->param('unit'),
332
                unitsperissue => $query->param('unitsperissue'),
333
                issuesperunit => $query->param('issuesperunit'),
334
            }
335
        )->store();
336
        $periodicity = $subscription_freq->id;
337
    }
338
    else {
339
        $periodicity = $query->param('frequency');
340
    }
341
    return $periodicity;
342
}
343
285
sub redirect_add_subscription {
344
sub redirect_add_subscription {
345
    my $periodicity = manage_subscription_frequencies_id();
346
    my $numberpattern = manage_subscription_numbering_pattern_id();
347
286
    my $auser          = $query->param('user');
348
    my $auser          = $query->param('user');
287
    my $branchcode     = $query->param('branchcode');
349
    my $branchcode     = $query->param('branchcode');
288
    my $aqbooksellerid = $query->param('aqbooksellerid');
350
    my $aqbooksellerid = $query->param('aqbooksellerid');
289
    my $cost           = $query->param('cost');
351
    my $cost           = $query->param('cost');
290
    my $aqbudgetid     = $query->param('aqbudgetid');
352
    my $aqbudgetid     = $query->param('aqbudgetid');
291
    my $periodicity    = $query->param('frequency');
292
    my @irregularity   = $query->multi_param('irregularity');
353
    my @irregularity   = $query->multi_param('irregularity');
293
    my $numberpattern  = $query->param('numbering_pattern');
294
    my $locale         = $query->param('locale');
354
    my $locale         = $query->param('locale');
295
    my $graceperiod    = $query->param('graceperiod') || 0;
355
    my $graceperiod    = $query->param('graceperiod') || 0;
296
356
Lines 320-325 sub redirect_add_subscription { Link Here
320
    my $previousitemtype  = $query->param('previousitemtype');
380
    my $previousitemtype  = $query->param('previousitemtype');
321
    my $skip_serialseq    = $query->param('skip_serialseq');
381
    my $skip_serialseq    = $query->param('skip_serialseq');
322
382
383
    my $mana_id;
384
    if ( $query->param('mana_id') ne "" ) {
385
        $mana_id = $query->param('mana_id');
386
        Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id);
387
    }
388
    else {
389
        $mana_id = undef;
390
    }
391
323
    my $startdate      = output_pref( { str => scalar $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
392
    my $startdate      = output_pref( { str => scalar $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
324
    my $enddate        = output_pref( { str => scalar $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
393
    my $enddate        = output_pref( { str => scalar $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
325
    my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
394
    my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
Lines 331-337 sub redirect_add_subscription { Link Here
331
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
400
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
332
        }
401
        }
333
    }
402
    }
334
335
    my $subscriptionid = NewSubscription(
403
    my $subscriptionid = NewSubscription(
336
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
404
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
337
        $startdate, $periodicity, $numberlength, $weeklength,
405
        $startdate, $periodicity, $numberlength, $weeklength,
Lines 340-346 sub redirect_add_subscription { Link Here
340
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
408
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
341
        $manualhistory, $internalnotes, $serialsadditems,
409
        $manualhistory, $internalnotes, $serialsadditems,
342
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
410
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
343
        $skip_serialseq
411
        $skip_serialseq, $mana_id
344
    );
412
    );
345
413
346
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
414
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
Lines 370-382 sub redirect_mod_subscription { Link Here
370
        ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } )
438
        ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } )
371
        : $firstacquidate;
439
        : $firstacquidate;
372
440
373
    my $periodicity = $query->param('frequency');
441
    my $periodicity = manage_subscription_frequencies_id();
442
    my $numberpattern = manage_subscription_numbering_pattern_id();
374
443
375
    my $subtype = $query->param('subtype');
444
    my $subtype = $query->param('subtype');
376
    my $sublength = $query->param('sublength');
445
    my $sublength = $query->param('sublength');
377
    my ($numberlength, $weeklength, $monthlength)
446
    my ($numberlength, $weeklength, $monthlength)
378
        = _get_sub_length( $subtype, $sublength );
447
        = _get_sub_length( $subtype, $sublength );
379
    my $numberpattern = $query->param('numbering_pattern');
380
    my $locale = $query->param('locale');
448
    my $locale = $query->param('locale');
381
    my $lastvalue1 = $query->param('lastvalue1');
449
    my $lastvalue1 = $query->param('lastvalue1');
382
    my $innerloop1 = $query->param('innerloop1');
450
    my $innerloop1 = $query->param('innerloop1');
Lines 399-404 sub redirect_mod_subscription { Link Here
399
    my $previousitemtype  = $query->param('previousitemtype');
467
    my $previousitemtype  = $query->param('previousitemtype');
400
    my $skip_serialseq    = $query->param('skip_serialseq');
468
    my $skip_serialseq    = $query->param('skip_serialseq');
401
469
470
    my $mana_id;
471
    if ( defined( $query->param('mana_id') ) ) {
472
        $mana_id = $query->param('mana_id');
473
        Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id);
474
    }
475
    else {
476
        $mana_id = undef;
477
    }
478
402
    # Guess end date
479
    # Guess end date
403
    if(!defined $enddate || $enddate eq '') {
480
    if(!defined $enddate || $enddate eq '') {
404
        if($subtype eq "issues") {
481
        if($subtype eq "issues") {
Lines 424-430 sub redirect_mod_subscription { Link Here
424
        $status, $biblionumber, $callnumber, $notes, $letter,
501
        $status, $biblionumber, $callnumber, $notes, $letter,
425
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
502
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
426
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
503
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
427
        $skip_serialseq, $itemtype, $previousitemtype
504
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
428
    );
505
    );
429
506
430
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
507
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
(-)a/svc/mana/search (+62 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Morgane Alonso
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
use strict;
22
use warnings;
23
24
use Koha::SharedContent;
25
use Koha::Subscription;
26
use C4::Auth qw(check_cookie_auth), qw(get_template_and_user);
27
use C4::Output qw( output_with_http_headers );
28
29
use CGI;
30
use JSON;
31
32
my $input = new CGI;
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43
    {
44
        template_name   => "serials/mana-subscription-search-result.tt",
45
        query           => $input,
46
        type            => "intranet",
47
        authnotrequired => 0,
48
49
        # flagsrequired   => { serials => $permission },
50
        flagsrequired => { serials => 'create_subscription' },
51
        debug         => 1,
52
    }
53
);
54
55
my $biblionumber = $input->param('biblionumber');
56
57
my $sub_mana_info = Koha::Subscription::get_search_info($biblionumber);
58
my $result =
59
  Koha::SharedContent::manaGetRequest( "subscription", $sub_mana_info );
60
$template->param( subscriptions => $result->{data} );
61
62
output_with_http_headers $input, $cookie, $template->output, 'json';
(-)a/svc/mana/use (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Morgane Alonso
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
use strict;
22
use warnings;
23
24
use Koha::SharedContent;
25
use C4::Auth qw(check_cookie_auth);
26
27
use CGI;
28
use JSON;
29
30
31
my $input = new CGI;
32
binmode STDOUT, ":encoding(UTF-8)";
33
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
34
35
my ( $auth_status, $sessionID ) =
36
  check_cookie_auth( $input->cookie('CGISESSID'),
37
    { serials => 'create_subscription' } );
38
39
if ( $auth_status ne "ok" ) {
40
    exit 0;
41
}
42
43
my $result = Koha::SharedContent::manaGetRequestWithId("subscription", $input->param('id') );
44
45
my $subscription;
46
$subscription = $result->{data};
47
48
print(to_json($subscription));
(-)a/t/db_dependent/Serials.t (-1 / +2 lines)
Lines 253-259 my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscrip Link Here
253
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
253
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
254
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
254
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
255
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
255
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
256
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, 1);
256
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
257
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1);
257
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 );
258
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 );
258
# Add 14 serials
259
# Add 14 serials
259
my $counter = 0;
260
my $counter = 0;
(-)a/t/db_dependent/Serials/GetFictiveIssueNumber.t (+126 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use C4::Context;
4
use Test::More tests => 18;
5
use Modern::Perl;
6
7
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
11
use C4::Serials::Frequency;
12
use C4::Serials;
13
14
# TEST CASE - 1 issue per day, no irregularities
15
my $frequency = {
16
    description   => "One issue per day",
17
    unit          => 'day',
18
    issuesperunit => 1,
19
    unitsperissue => 1,
20
};
21
22
my $subscription = {
23
    firstacquidate     => '1970-01-01',
24
    irregularity       => '',
25
    countissuesperunit => 1,
26
};
27
my $issueNumber;
28
29
$issueNumber =
30
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
31
is( $issueNumber, '1' );
32
33
$issueNumber =
34
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
35
is( $issueNumber, '2' );
36
$issueNumber =
37
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
38
is( $issueNumber, '3' );
39
40
# TEST CASE - 2 issues per day, no irregularity
41
$frequency = {
42
    description   => "Two issues per day",
43
    unit          => 'day',
44
    issuesperunit => 2,
45
    unitsperissue => 1,
46
};
47
$subscription = {
48
    firstacquidate     => '1970-01-01',
49
    irregularity       => '',
50
    countissuesperunit => 1,
51
};
52
$issueNumber =
53
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
54
is( $issueNumber, '1' );
55
$issueNumber =
56
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
57
is( $issueNumber, '3' );
58
$issueNumber =
59
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
60
is( $issueNumber, '5' );
61
62
$subscription->{countissuesperunit} = 2;
63
$issueNumber =
64
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
65
is( $issueNumber, '2' );
66
$issueNumber =
67
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
68
is( $issueNumber, '4' );
69
$issueNumber =
70
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
71
is( $issueNumber, '6' );
72
73
# TEST CASE - 1 issue every 2 days, no irregularity
74
$frequency = {
75
    description   => "one issue every two days",
76
    unit          => 'day',
77
    issuesperunit => 1,
78
    unitsperissue => 2,
79
};
80
$subscription = {
81
    firstacquidate     => '1970-01-01',
82
    irregularity       => '',
83
    countissuesperunit => 1,
84
};
85
$issueNumber =
86
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
87
is( $issueNumber, 1 );
88
$issueNumber =
89
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
90
is( $issueNumber, 1 );
91
$issueNumber =
92
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
93
is( $issueNumber, 2 );
94
$issueNumber =
95
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-04', $frequency );
96
is( $issueNumber, 2 );
97
$issueNumber =
98
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-05', $frequency );
99
is( $issueNumber, 3 );
100
101
# TEST CASE - 1 issue per week, no irregularity
102
$frequency = {
103
    description   => "one issue per week",
104
    unit          => 'week',
105
    issuesperunit => 1,
106
    unitsperissue => 1,
107
};
108
$subscription = {
109
    firstacquidate     => '1970-01-01',
110
    irregularity       => '',
111
    countissuesperunit => 1,
112
};
113
$issueNumber =
114
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
115
is( $issueNumber, 1 );
116
$issueNumber =
117
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
118
is( $issueNumber, 1 );
119
$issueNumber =
120
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-08', $frequency );
121
is( $issueNumber, 2 );
122
$issueNumber =
123
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-15', $frequency );
124
is( $issueNumber, 3 );
125
126
$dbh->rollback;
(-)a/t/db_dependent/Serials/GetNextDate.t (-150 / +122 lines)
Lines 18-541 my $frequency = { Link Here
18
    issuesperunit => 1,
18
    issuesperunit => 1,
19
    unitsperissue => 1,
19
    unitsperissue => 1,
20
};
20
};
21
my $id = AddSubscriptionFrequency($frequency);
22
21
23
my $subscription = {
22
my $subscription = {
24
    periodicity => $id,
25
    firstacquidate => '1970-01-01',
23
    firstacquidate => '1970-01-01',
26
    irregularity => '',
24
    irregularity => '',
27
    countissuesperunit => 1,
25
    countissuesperunit => 1,
28
};
26
};
29
my $publisheddate = $subscription->{firstacquidate};
27
my $publisheddate = $subscription->{firstacquidate};
30
28
31
$publisheddate = GetNextDate($subscription, $publisheddate);
29
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
32
is($publisheddate, '1970-01-02');
30
is($publisheddate, '1970-01-02');
33
$publisheddate = GetNextDate($subscription, $publisheddate);
31
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
34
is($publisheddate, '1970-01-03');
32
is($publisheddate, '1970-01-03');
35
$publisheddate = GetNextDate($subscription, $publisheddate);
33
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
36
is($publisheddate, '1970-01-04');
34
is($publisheddate, '1970-01-04');
37
35
38
# TEST CASE - 1 issue per day, irregularities
36
# TEST CASE - 1 issue per day, irregularities
39
$subscription = {
37
$subscription = {
40
    periodicity => $id,
41
    firstacquidate => '1970-01-01',
38
    firstacquidate => '1970-01-01',
42
    irregularity => '2;4',  # Skip the second and fourth issues
39
    irregularity => '2;4',  # Skip the second and fourth issues
43
    countissuesperunit => 1,
40
    countissuesperunit => 1,
44
};
41
};
45
$publisheddate = $subscription->{firstacquidate};
42
$publisheddate = $subscription->{firstacquidate};
46
$publisheddate = GetNextDate($subscription, $publisheddate);
43
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
47
is($publisheddate, '1970-01-03');
44
is($publisheddate, '1970-01-03');
48
$publisheddate = GetNextDate($subscription, $publisheddate);
45
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
49
is($publisheddate, '1970-01-05');
46
is($publisheddate, '1970-01-05');
50
$publisheddate = GetNextDate($subscription, $publisheddate);
47
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
51
is($publisheddate, '1970-01-06');
48
is($publisheddate, '1970-01-06');
52
49
53
# TEST CASE - 2 issues per day, no irregularity
50
# TEST CASE - 2 issues per day, no irregularity
54
$id = AddSubscriptionFrequency({
51
$frequency = {
55
    description => "Two issues per day",
52
    description => "Two issues per day",
56
    unit => 'day',
53
    unit => 'day',
57
    issuesperunit => 2,
54
    issuesperunit => 2,
58
    unitsperissue => 1,
55
    unitsperissue => 1,
59
});
56
};
60
$subscription = {
57
$subscription = {
61
    periodicity => $id,
62
    firstacquidate => '1970-01-01',
58
    firstacquidate => '1970-01-01',
63
    irregularity => '',
59
    irregularity => '',
64
    countissuesperunit => 1,
60
    countissuesperunit => 1,
65
};
61
};
66
$publisheddate = $subscription->{firstacquidate};
62
$publisheddate = $subscription->{firstacquidate};
67
$publisheddate = GetNextDate($subscription, $publisheddate);
63
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
68
is($publisheddate, '1970-01-01');
64
is($publisheddate, '1970-01-01');
69
$publisheddate = GetNextDate($subscription, $publisheddate);
65
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
70
is($publisheddate, '1970-01-02');
66
is($publisheddate, '1970-01-02');
71
$publisheddate = GetNextDate($subscription, $publisheddate);
67
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
72
is($publisheddate, '1970-01-02');
68
is($publisheddate, '1970-01-02');
73
$publisheddate = GetNextDate($subscription, $publisheddate);
69
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
74
is($publisheddate, '1970-01-03');
70
is($publisheddate, '1970-01-03');
75
71
76
# TEST CASE - 2 issues per day, irregularities
72
# TEST CASE - 2 issues per day, irregularities
77
$subscription = {
73
$subscription = {
78
    periodicity => $id,
79
    firstacquidate => '1970-01-01',
74
    firstacquidate => '1970-01-01',
80
    irregularity => '3;5;6',
75
    irregularity => '3;5;6',
81
    countissuesperunit => 1,
76
    countissuesperunit => 1,
82
};
77
};
83
$publisheddate = $subscription->{firstacquidate};
78
$publisheddate = $subscription->{firstacquidate};
84
$publisheddate = GetNextDate($subscription, $publisheddate);
79
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
85
is($publisheddate, '1970-01-01');
80
is($publisheddate, '1970-01-01');
86
$publisheddate = GetNextDate($subscription, $publisheddate);
81
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
87
is($publisheddate, '1970-01-02');
82
is($publisheddate, '1970-01-02');
88
$publisheddate = GetNextDate($subscription, $publisheddate);
83
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
89
is($publisheddate, '1970-01-04');
84
is($publisheddate, '1970-01-04');
90
$publisheddate = GetNextDate($subscription, $publisheddate);
85
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
91
is($publisheddate, '1970-01-04');
86
is($publisheddate, '1970-01-04');
92
$publisheddate = GetNextDate($subscription, $publisheddate);
87
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
93
is($publisheddate, '1970-01-05');
88
is($publisheddate, '1970-01-05');
94
89
95
# TEST CASE - 1 issue every 2 days, no irregularity
90
# TEST CASE - 1 issue every 2 days, no irregularity
96
$id = AddSubscriptionFrequency({
91
$frequency = {
97
    description => "one issue every two days",
92
    description => "one issue every two days",
98
    unit => 'day',
93
    unit => 'day',
99
    issuesperunit => 1,
94
    issuesperunit => 1,
100
    unitsperissue => 2,
95
    unitsperissue => 2,
101
});
96
};
102
$subscription = {
97
$subscription = {
103
    periodicity => $id,
104
    firstacquidate => '1970-01-01',
98
    firstacquidate => '1970-01-01',
105
    irregularity => '',
99
    irregularity => '',
106
    countissuesperunit => 1,
100
    countissuesperunit => 1,
107
};
101
};
108
$publisheddate = $subscription->{firstacquidate};
102
$publisheddate = $subscription->{firstacquidate};
109
$publisheddate = GetNextDate($subscription, $publisheddate);
103
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
110
is($publisheddate, '1970-01-03');
104
is($publisheddate, '1970-01-03');
111
$publisheddate = GetNextDate($subscription, $publisheddate);
105
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
112
is($publisheddate, '1970-01-05');
106
is($publisheddate, '1970-01-05');
113
107
114
# TEST CASE - 1 issue every 2 days, irregularities
108
# TEST CASE - 1 issue every 2 days, irregularities
115
$subscription = {
109
$subscription = {
116
    periodicity => $id,
117
    firstacquidate => '1970-01-01',
110
    firstacquidate => '1970-01-01',
118
    irregularity => '3',
111
    irregularity => '3',
119
    countissuesperunit => 1,
112
    countissuesperunit => 1,
120
};
113
};
121
$publisheddate = $subscription->{firstacquidate};
114
$publisheddate = $subscription->{firstacquidate};
122
$publisheddate = GetNextDate($subscription, $publisheddate);
115
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
123
is($publisheddate, '1970-01-03');
116
is($publisheddate, '1970-01-03');
124
$publisheddate = GetNextDate($subscription, $publisheddate);
117
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
125
is($publisheddate, '1970-01-07');
118
is($publisheddate, '1970-01-07');
126
$publisheddate = GetNextDate($subscription, $publisheddate);
119
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
127
is($publisheddate, '1970-01-09');
120
is($publisheddate, '1970-01-09');
128
121
129
# TEST CASE - 1 issue per week, no irregularity
122
# TEST CASE - 1 issue per week, no irregularity
130
$id = AddSubscriptionFrequency({
123
$frequency = {
131
    description => "one issue per week",
124
    description => "one issue per week",
132
    unit => 'week',
125
    unit => 'week',
133
    issuesperunit => 1,
126
    issuesperunit => 1,
134
    unitsperissue => 1,
127
    unitsperissue => 1,
135
});
128
};
136
$subscription = {
129
$subscription = {
137
    periodicity => $id,
138
    firstacquidate => '1970-01-01',
130
    firstacquidate => '1970-01-01',
139
    irregularity => '',
131
    irregularity => '',
140
    countissuesperunit => 1,
132
    countissuesperunit => 1,
141
};
133
};
142
$publisheddate = $subscription->{firstacquidate};
134
$publisheddate = $subscription->{firstacquidate};
143
$publisheddate = GetNextDate($subscription, $publisheddate);
135
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
144
is($publisheddate, '1970-01-08');
136
is($publisheddate, '1970-01-08');
145
$publisheddate = GetNextDate($subscription, $publisheddate);
137
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
146
is($publisheddate, '1970-01-15');
138
is($publisheddate, '1970-01-15');
147
139
148
# TEST CASE - 1 issue per week, irregularities
140
# TEST CASE - 1 issue per week, irregularities
149
$subscription = {
141
$subscription = {
150
    periodicity => $id,
151
    firstacquidate => '1970-01-01',
142
    firstacquidate => '1970-01-01',
152
    irregularity => '3',
143
    irregularity => '3',
153
    countissuesperunit => 1,
144
    countissuesperunit => 1,
154
};
145
};
155
$publisheddate = $subscription->{firstacquidate};
146
$publisheddate = $subscription->{firstacquidate};
156
$publisheddate = GetNextDate($subscription, $publisheddate);
147
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
157
is($publisheddate, '1970-01-08');
148
is($publisheddate, '1970-01-08');
158
$publisheddate = GetNextDate($subscription, $publisheddate);
149
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
159
is($publisheddate, '1970-01-22');
150
is($publisheddate, '1970-01-22');
160
$publisheddate = GetNextDate($subscription, $publisheddate);
151
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
161
is($publisheddate, '1970-01-29');
152
is($publisheddate, '1970-01-29');
162
153
163
# TEST CASE - 1 issue every 2 weeks, no irregularity
154
# TEST CASE - 1 issue every 2 weeks, no irregularity
164
$id = AddSubscriptionFrequency({
155
$frequency = {
165
    description => "one issue every 2 weeks",
156
    description => "one issue every 2 weeks",
166
    unit => 'week',
157
    unit => 'week',
167
    issuesperunit => 1,
158
    issuesperunit => 1,
168
    unitsperissue => 2,
159
    unitsperissue => 2,
169
});
160
};
170
$subscription = {
161
$subscription = {
171
    periodicity => $id,
172
    firstacquidate => '1970-01-01',
162
    firstacquidate => '1970-01-01',
173
    irregularity => '',
163
    irregularity => '',
174
    countissuesperunit => 1,
164
    countissuesperunit => 1,
175
};
165
};
176
$publisheddate = $subscription->{firstacquidate};
166
$publisheddate = $subscription->{firstacquidate};
177
$publisheddate = GetNextDate($subscription, $publisheddate);
167
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
178
is($publisheddate, '1970-01-15');
168
is($publisheddate, '1970-01-15');
179
$publisheddate = GetNextDate($subscription, $publisheddate);
169
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
180
is($publisheddate, '1970-01-29');
170
is($publisheddate, '1970-01-29');
181
$publisheddate = GetNextDate($subscription, $publisheddate);
171
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
182
is($publisheddate, '1970-02-12');
172
is($publisheddate, '1970-02-12');
183
173
184
# TEST CASE - 1 issue every 2 weeks, irregularities
174
# TEST CASE - 1 issue every 2 weeks, irregularities
185
$subscription = {
175
$subscription = {
186
    periodicity => $id,
187
    firstacquidate => '1970-01-01',
176
    firstacquidate => '1970-01-01',
188
    irregularity => '3',
177
    irregularity => '3',
189
    countissuesperunit => 1,
178
    countissuesperunit => 1,
190
};
179
};
191
$publisheddate = $subscription->{firstacquidate};
180
$publisheddate = $subscription->{firstacquidate};
192
$publisheddate = GetNextDate($subscription, $publisheddate);
181
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
193
is($publisheddate, '1970-01-15');
182
is($publisheddate, '1970-01-15');
194
$publisheddate = GetNextDate($subscription, $publisheddate);
183
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
195
is($publisheddate, '1970-02-12');
184
is($publisheddate, '1970-02-12');
196
$publisheddate = GetNextDate($subscription, $publisheddate);
185
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
197
is($publisheddate, '1970-02-26');
186
is($publisheddate, '1970-02-26');
198
187
199
# TEST CASE - 2 issues per week, no irregularity
188
# TEST CASE - 2 issues per week, no irregularity
200
$id = AddSubscriptionFrequency({
189
$frequency = {
201
    description => "two issues per week",
190
    description => "two issues per week",
202
    unit => 'week',
191
    unit => 'week',
203
    issuesperunit => 2,
192
    issuesperunit => 2,
204
    unitsperissue => 1,
193
    unitsperissue => 1,
205
});
194
};
206
$subscription = {
195
$subscription = {
207
    periodicity => $id,
208
    firstacquidate => '1970-01-01',
196
    firstacquidate => '1970-01-01',
209
    irregularity => '',
197
    irregularity => '',
210
    countissuesperunit => 1,
198
    countissuesperunit => 1,
211
};
199
};
212
$publisheddate = $subscription->{firstacquidate};
200
$publisheddate = $subscription->{firstacquidate};
213
$publisheddate = GetNextDate($subscription, $publisheddate);
201
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
214
is($publisheddate, '1970-01-03');
202
is($publisheddate, '1970-01-03');
215
# when more than 1 issue per week, date is automatically set to the same day of
203
# when more than 1 issue per week, date is automatically set to the same day of
216
# week as firstacquidate
204
# week as firstacquidate
217
$publisheddate = GetNextDate($subscription, $publisheddate);
205
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
218
is($publisheddate, '1970-01-08');
206
is($publisheddate, '1970-01-08');
219
$publisheddate = GetNextDate($subscription, $publisheddate);
207
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
220
is($publisheddate, '1970-01-10');
208
is($publisheddate, '1970-01-10');
221
$publisheddate = GetNextDate($subscription, $publisheddate);
209
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
222
is($publisheddate, '1970-01-15');
210
is($publisheddate, '1970-01-15');
223
211
224
# TEST CASE - 2 issues per week, irregularities
212
# TEST CASE - 2 issues per week, irregularities
225
$subscription = {
213
$subscription = {
226
    periodicity => $id,
227
    firstacquidate => '1970-01-01',
214
    firstacquidate => '1970-01-01',
228
    irregularity => '3;5;6',
215
    irregularity => '3;5;6',
229
    countissuesperunit => 1,
216
    countissuesperunit => 1,
230
};
217
};
231
$publisheddate = $subscription->{firstacquidate};
218
$publisheddate = $subscription->{firstacquidate};
232
$publisheddate = GetNextDate($subscription, $publisheddate);
219
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
233
is($publisheddate, '1970-01-03');
220
is($publisheddate, '1970-01-03');
234
$publisheddate = GetNextDate($subscription, $publisheddate);
221
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
235
is($publisheddate, '1970-01-10');
222
is($publisheddate, '1970-01-10');
236
$publisheddate = GetNextDate($subscription, $publisheddate);
223
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
237
is($publisheddate, '1970-01-22');
224
is($publisheddate, '1970-01-22');
238
$publisheddate = GetNextDate($subscription, $publisheddate);
225
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
239
is($publisheddate, '1970-01-24');
226
is($publisheddate, '1970-01-24');
240
$publisheddate = GetNextDate($subscription, $publisheddate);
227
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
241
is($publisheddate, '1970-01-29');
228
is($publisheddate, '1970-01-29');
242
229
243
# TEST CASE - 6 issues per week, no irregularity
230
# TEST CASE - 6 issues per week, no irregularity
244
$id = AddSubscriptionFrequency({
231
$frequency = {
245
    description => "six issues per week",
232
    description => "six issues per week",
246
    unit => 'week',
233
    unit => 'week',
247
    issuesperunit => 6,
234
    issuesperunit => 6,
248
    unitsperissue => 1,
235
    unitsperissue => 1,
249
});
236
};
250
$subscription = {
237
$subscription = {
251
    periodicity => $id,
252
    firstacquidate => '1970-01-06',
238
    firstacquidate => '1970-01-06',
253
    irregularity => '',
239
    irregularity => '',
254
    countissuesperunit => 1,
240
    countissuesperunit => 1,
255
};
241
};
256
$publisheddate = $subscription->{firstacquidate};
242
$publisheddate = $subscription->{firstacquidate};
257
$publisheddate = GetNextDate($subscription, $publisheddate);
243
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
258
is($publisheddate, '1970-01-07');
244
is($publisheddate, '1970-01-07');
259
$publisheddate = GetNextDate($subscription, $publisheddate);
245
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
260
is($publisheddate, '1970-01-08');
246
is($publisheddate, '1970-01-08');
261
$publisheddate = GetNextDate($subscription, $publisheddate);
247
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
262
is($publisheddate, '1970-01-09');
248
is($publisheddate, '1970-01-09');
263
$publisheddate = GetNextDate($subscription, $publisheddate);
249
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
264
is($publisheddate, '1970-01-10');
250
is($publisheddate, '1970-01-10');
265
$publisheddate = GetNextDate($subscription, $publisheddate);
251
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
266
is($publisheddate, '1970-01-11');
252
is($publisheddate, '1970-01-11');
267
$publisheddate = GetNextDate($subscription, $publisheddate);
253
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
268
is($publisheddate, '1970-01-13');
254
is($publisheddate, '1970-01-13');
269
255
270
# TEST CASE - 6 issues per week, irregularities
256
# TEST CASE - 6 issues per week, irregularities
271
$subscription = {
257
$subscription = {
272
    periodicity => $id,
273
    firstacquidate => '1970-01-06',
258
    firstacquidate => '1970-01-06',
274
    irregularity => '3;5;6',
259
    irregularity => '3;5;6',
275
    countissuesperunit => 1,
260
    countissuesperunit => 1,
276
};
261
};
277
$publisheddate = $subscription->{firstacquidate};
262
$publisheddate = $subscription->{firstacquidate};
278
$publisheddate = GetNextDate($subscription, $publisheddate);
263
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
279
is($publisheddate, '1970-01-07');
264
is($publisheddate, '1970-01-07');
280
$publisheddate = GetNextDate($subscription, $publisheddate);
265
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
281
is($publisheddate, '1970-01-09');
266
is($publisheddate, '1970-01-09');
282
$publisheddate = GetNextDate($subscription, $publisheddate);
267
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
283
is($publisheddate, '1970-01-13');
268
is($publisheddate, '1970-01-13');
284
$publisheddate = GetNextDate($subscription, $publisheddate);
269
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
285
is($publisheddate, '1970-01-14');
270
is($publisheddate, '1970-01-14');
286
271
287
# TEST CASE - 1 issue per month, no irregularity
272
# TEST CASE - 1 issue per month, no irregularity
288
$id = AddSubscriptionFrequency({
273
$frequency = {
289
    description => "1 issue per month",
274
    description => "1 issue per month",
290
    unit => 'month',
275
    unit => 'month',
291
    issuesperunit => 1,
276
    issuesperunit => 1,
292
    unitsperissue => 1,
277
    unitsperissue => 1,
293
});
278
};
294
$subscription = {
279
$subscription = {
295
    periodicity => $id,
296
    firstacquidate => '1970-01-01',
280
    firstacquidate => '1970-01-01',
297
    irregularity => '',
281
    irregularity => '',
298
    countissuesperunit => 1,
282
    countissuesperunit => 1,
299
};
283
};
300
$publisheddate = $subscription->{firstacquidate};
284
$publisheddate = $subscription->{firstacquidate};
301
$publisheddate = GetNextDate($subscription, $publisheddate);
285
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
302
is($publisheddate, '1970-02-01');
286
is($publisheddate, '1970-02-01');
303
$publisheddate = GetNextDate($subscription, $publisheddate);
287
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
304
is($publisheddate, '1970-03-01');
288
is($publisheddate, '1970-03-01');
305
$publisheddate = GetNextDate($subscription, $publisheddate);
289
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
306
is($publisheddate, '1970-04-01');
290
is($publisheddate, '1970-04-01');
307
291
308
# TEST CASE - 1 issue per month, irregularities
292
# TEST CASE - 1 issue per month, irregularities
309
$subscription = {
293
$subscription = {
310
    periodicity => $id,
311
    firstacquidate => '1970-01-01',
294
    firstacquidate => '1970-01-01',
312
    irregularity => '2;4',
295
    irregularity => '2;4',
313
    countissuesperunit => 1,
296
    countissuesperunit => 1,
314
};
297
};
315
$publisheddate = $subscription->{firstacquidate};
298
$publisheddate = $subscription->{firstacquidate};
316
$publisheddate = GetNextDate($subscription, $publisheddate);
299
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
317
is($publisheddate, '1970-03-01');
300
is($publisheddate, '1970-03-01');
318
$publisheddate = GetNextDate($subscription, $publisheddate);
301
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
319
is($publisheddate, '1970-05-01');
302
is($publisheddate, '1970-05-01');
320
$publisheddate = GetNextDate($subscription, $publisheddate);
303
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
321
is($publisheddate, '1970-06-01');
304
is($publisheddate, '1970-06-01');
322
305
323
# TEST CASE - 1 issue every 2 months, no irregularity
306
# TEST CASE - 1 issue every 2 months, no irregularity
324
$id = AddSubscriptionFrequency({
307
$frequency = {
325
    description => "1 issue every 2 months",
308
    description => "1 issue every 2 months",
326
    unit => 'month',
309
    unit => 'month',
327
    issuesperunit => 1,
310
    issuesperunit => 1,
328
    unitsperissue => 2,
311
    unitsperissue => 2,
329
});
312
};
330
$subscription = {
313
$subscription = {
331
    periodicity => $id,
332
    firstacquidate => '1970-01-01',
314
    firstacquidate => '1970-01-01',
333
    irregularity => '',
315
    irregularity => '',
334
    countissuesperunit => 1,
316
    countissuesperunit => 1,
335
};
317
};
336
$publisheddate = $subscription->{firstacquidate};
318
$publisheddate = $subscription->{firstacquidate};
337
$publisheddate = GetNextDate($subscription, $publisheddate);
319
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
338
is($publisheddate, '1970-03-01');
320
is($publisheddate, '1970-03-01');
339
$publisheddate = GetNextDate($subscription, $publisheddate);
321
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
340
is($publisheddate, '1970-05-01');
322
is($publisheddate, '1970-05-01');
341
$publisheddate = GetNextDate($subscription, $publisheddate);
323
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
342
is($publisheddate, '1970-07-01');
324
is($publisheddate, '1970-07-01');
343
325
344
# TEST CASE - 1 issue every 2 months, irregularities
326
# TEST CASE - 1 issue every 2 months, irregularities
345
$subscription = {
327
$subscription = {
346
    periodicity => $id,
347
    firstacquidate => '1970-01-01',
328
    firstacquidate => '1970-01-01',
348
    irregularity => '2;3',
329
    irregularity => '2;3',
349
    countissuesperunit => 1,
330
    countissuesperunit => 1,
350
};
331
};
351
$publisheddate = $subscription->{firstacquidate};
332
$publisheddate = $subscription->{firstacquidate};
352
$publisheddate = GetNextDate($subscription, $publisheddate);
333
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
353
is($publisheddate, '1970-07-01');
334
is($publisheddate, '1970-07-01');
354
$publisheddate = GetNextDate($subscription, $publisheddate);
335
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
355
is($publisheddate, '1970-09-01');
336
is($publisheddate, '1970-09-01');
356
$publisheddate = GetNextDate($subscription, $publisheddate);
337
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
357
is($publisheddate, '1970-11-01');
338
is($publisheddate, '1970-11-01');
358
339
359
# TEST CASE - 2 issues per month, no irregularity
340
# TEST CASE - 2 issues per month, no irregularity
360
$id = AddSubscriptionFrequency({
341
$frequency = {
361
    description => "2 issues per month",
342
    description => "2 issues per month",
362
    unit => 'month',
343
    unit => 'month',
363
    issuesperunit => 2,
344
    issuesperunit => 2,
364
    unitsperissue => 1,
345
    unitsperissue => 1,
365
});
346
};
366
$subscription = {
347
$subscription = {
367
    periodicity => $id,
368
    firstacquidate => '1970-01-01',
348
    firstacquidate => '1970-01-01',
369
    irregularity => '',
349
    irregularity => '',
370
    countissuesperunit => 1,
350
    countissuesperunit => 1,
371
};
351
};
372
$publisheddate = $subscription->{firstacquidate};
352
$publisheddate = $subscription->{firstacquidate};
373
$publisheddate = GetNextDate($subscription, $publisheddate);
353
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
374
is($publisheddate, '1970-01-16', 'January has 31 days');
354
is($publisheddate, '1970-01-16', 'January has 31 days');
375
$publisheddate = GetNextDate($subscription, $publisheddate);
355
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
376
is($publisheddate, '1970-02-01');
356
is($publisheddate, '1970-02-01');
377
$publisheddate = GetNextDate($subscription, $publisheddate);
357
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
378
is($publisheddate, '1970-02-15', 'February has only 28 days');
358
is($publisheddate, '1970-02-15', 'February has only 28 days');
379
$publisheddate = GetNextDate($subscription, $publisheddate);
359
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
380
is($publisheddate, '1970-03-01');
360
is($publisheddate, '1970-03-01');
381
361
382
# TEST CASE - 2 issues per month, irregularities
362
# TEST CASE - 2 issues per month, irregularities
383
$subscription = {
363
$subscription = {
384
    periodicity => $id,
385
    firstacquidate => '1970-01-01',
364
    firstacquidate => '1970-01-01',
386
    irregularity => '3;5;6',
365
    irregularity => '3;5;6',
387
    countissuesperunit => 1,
366
    countissuesperunit => 1,
388
};
367
};
389
$publisheddate = $subscription->{firstacquidate};
368
$publisheddate = $subscription->{firstacquidate};
390
$publisheddate = GetNextDate($subscription, $publisheddate);
369
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
391
is($publisheddate, '1970-01-16', 'January has 31 days');
370
is($publisheddate, '1970-01-16', 'January has 31 days');
392
$publisheddate = GetNextDate($subscription, $publisheddate);
371
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
393
is($publisheddate, '1970-02-15', 'February has only 28 days');
372
is($publisheddate, '1970-02-15', 'February has only 28 days');
394
$publisheddate = GetNextDate($subscription, $publisheddate);
373
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
395
is($publisheddate, '1970-04-01');
374
is($publisheddate, '1970-04-01');
396
$publisheddate = GetNextDate($subscription, $publisheddate);
375
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
397
is($publisheddate, '1970-04-16', 'April has 30 days');
376
is($publisheddate, '1970-04-16', 'April has 30 days');
398
$publisheddate = GetNextDate($subscription, $publisheddate);
377
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
399
is($publisheddate, '1970-05-01');
378
is($publisheddate, '1970-05-01');
400
379
401
# TEST CASE - 1 issue per year, no irregularity
380
# TEST CASE - 1 issue per year, no irregularity
402
$id = AddSubscriptionFrequency({
381
$frequency = {
403
    description => "1 issue per year",
382
    description => "1 issue per year",
404
    unit => 'year',
383
    unit => 'year',
405
    issuesperunit => 1,
384
    issuesperunit => 1,
406
    unitsperissue => 1,
385
    unitsperissue => 1,
407
});
386
};
408
$subscription = {
387
$subscription = {
409
    periodicity => $id,
410
    firstacquidate => '1970-01-01',
388
    firstacquidate => '1970-01-01',
411
    irregularity => '',
389
    irregularity => '',
412
    countissuesperunit => 1,
390
    countissuesperunit => 1,
413
};
391
};
414
$publisheddate = $subscription->{firstacquidate};
392
$publisheddate = $subscription->{firstacquidate};
415
$publisheddate = GetNextDate($subscription, $publisheddate);
393
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
416
is($publisheddate, '1971-01-01');
394
is($publisheddate, '1971-01-01');
417
$publisheddate = GetNextDate($subscription, $publisheddate);
395
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
418
is($publisheddate, '1972-01-01');
396
is($publisheddate, '1972-01-01');
419
$publisheddate = GetNextDate($subscription, $publisheddate);
397
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
420
is($publisheddate, '1973-01-01');
398
is($publisheddate, '1973-01-01');
421
399
422
# TEST CASE - 1 issue per year, irregularities
400
# TEST CASE - 1 issue per year, irregularities
423
$subscription = {
401
$subscription = {
424
    periodicity => $id,
425
    firstacquidate => '1970-01-01',
402
    firstacquidate => '1970-01-01',
426
    irregularity => '2;4',
403
    irregularity => '2;4',
427
    countissuesperunit => 1,
404
    countissuesperunit => 1,
428
};
405
};
429
$publisheddate = $subscription->{firstacquidate};
406
$publisheddate = $subscription->{firstacquidate};
430
$publisheddate = GetNextDate($subscription, $publisheddate);
407
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
431
is($publisheddate, '1972-01-01');
408
is($publisheddate, '1972-01-01');
432
$publisheddate = GetNextDate($subscription, $publisheddate);
409
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
433
is($publisheddate, '1974-01-01');
410
is($publisheddate, '1974-01-01');
434
$publisheddate = GetNextDate($subscription, $publisheddate);
411
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
435
is($publisheddate, '1975-01-01');
412
is($publisheddate, '1975-01-01');
436
413
437
# TEST CASE - 1 issue every 2 years, no irregularity
414
# TEST CASE - 1 issue every 2 years, no irregularity
438
$id = AddSubscriptionFrequency({
415
$frequency = {
439
    description => "1 issue every 2 years",
416
    description => "1 issue every 2 years",
440
    unit => 'year',
417
    unit => 'year',
441
    issuesperunit => 1,
418
    issuesperunit => 1,
442
    unitsperissue => 2,
419
    unitsperissue => 2,
443
});
420
};
444
$subscription = {
421
$subscription = {
445
    periodicity => $id,
446
    firstacquidate => '1970-01-01',
422
    firstacquidate => '1970-01-01',
447
    irregularity => '',
423
    irregularity => '',
448
    countissuesperunit => 1,
424
    countissuesperunit => 1,
449
};
425
};
450
$publisheddate = $subscription->{firstacquidate};
426
$publisheddate = $subscription->{firstacquidate};
451
$publisheddate = GetNextDate($subscription, $publisheddate);
427
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
452
is($publisheddate, '1972-01-01');
428
is($publisheddate, '1972-01-01');
453
$publisheddate = GetNextDate($subscription, $publisheddate);
429
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
454
is($publisheddate, '1974-01-01');
430
is($publisheddate, '1974-01-01');
455
$publisheddate = GetNextDate($subscription, $publisheddate);
431
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
456
is($publisheddate, '1976-01-01');
432
is($publisheddate, '1976-01-01');
457
433
458
# TEST CASE - 1 issue every 2 years, irregularities
434
# TEST CASE - 1 issue every 2 years, irregularities
459
$subscription = {
435
$subscription = {
460
    periodicity => $id,
461
    firstacquidate => '1970-01-01',
436
    firstacquidate => '1970-01-01',
462
    irregularity => '2;4',
437
    irregularity => '2;4',
463
    countissuesperunit => 1,
438
    countissuesperunit => 1,
464
};
439
};
465
$publisheddate = $subscription->{firstacquidate};
440
$publisheddate = $subscription->{firstacquidate};
466
$publisheddate = GetNextDate($subscription, $publisheddate);
441
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
467
is($publisheddate, '1974-01-01');
442
is($publisheddate, '1974-01-01');
468
$publisheddate = GetNextDate($subscription, $publisheddate);
443
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
469
is($publisheddate, '1978-01-01');
444
is($publisheddate, '1978-01-01');
470
$publisheddate = GetNextDate($subscription, $publisheddate);
445
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
471
is($publisheddate, '1980-01-01');
446
is($publisheddate, '1980-01-01');
472
447
473
# TEST CASE - 2 issues per year, no irregularity
448
# TEST CASE - 2 issues per year, no irregularity
474
$id = AddSubscriptionFrequency({
449
$frequency = {
475
    description => "1 issue every 2 years",
450
    description => "1 issue every 2 years",
476
    unit => 'year',
451
    unit => 'year',
477
    issuesperunit => 2,
452
    issuesperunit => 2,
478
    unitsperissue => 1,
453
    unitsperissue => 1,
479
});
454
};
480
$subscription = {
455
$subscription = {
481
    periodicity => $id,
482
    firstacquidate => '1970-01-01',
456
    firstacquidate => '1970-01-01',
483
    irregularity => '',
457
    irregularity => '',
484
    countissuesperunit => 1,
458
    countissuesperunit => 1,
485
};
459
};
486
$publisheddate = $subscription->{firstacquidate};
460
$publisheddate = $subscription->{firstacquidate};
487
$publisheddate = GetNextDate($subscription, $publisheddate);
461
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
488
is($publisheddate, '1970-07-02');
462
is($publisheddate, '1970-07-02');
489
$publisheddate = GetNextDate($subscription, $publisheddate);
463
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
490
is($publisheddate, '1971-01-01');
464
is($publisheddate, '1971-01-01');
491
$publisheddate = GetNextDate($subscription, $publisheddate);
465
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
492
is($publisheddate, '1971-07-02');
466
is($publisheddate, '1971-07-02');
493
$publisheddate = GetNextDate($subscription, $publisheddate);
467
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
494
is($publisheddate, '1972-01-01');
468
is($publisheddate, '1972-01-01');
495
469
496
# TEST CASE - 2 issues per year, irregularities
470
# TEST CASE - 2 issues per year, irregularities
497
$subscription = {
471
$subscription = {
498
    periodicity => $id,
499
    firstacquidate => '1970-01-01',
472
    firstacquidate => '1970-01-01',
500
    irregularity => '3;5;6',
473
    irregularity => '3;5;6',
501
    countissuesperunit => 1,
474
    countissuesperunit => 1,
502
};
475
};
503
$publisheddate = $subscription->{firstacquidate};
476
$publisheddate = $subscription->{firstacquidate};
504
$publisheddate = GetNextDate($subscription, $publisheddate);
477
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
505
is($publisheddate, '1970-07-02');
478
is($publisheddate, '1970-07-02');
506
$publisheddate = GetNextDate($subscription, $publisheddate);
479
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
507
is($publisheddate, '1971-07-02');
480
is($publisheddate, '1971-07-02');
508
$publisheddate = GetNextDate($subscription, $publisheddate);
481
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
509
is($publisheddate, '1973-01-01');
482
is($publisheddate, '1973-01-01');
510
$publisheddate = GetNextDate($subscription, $publisheddate);
483
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
511
is($publisheddate, '1973-07-02');
484
is($publisheddate, '1973-07-02');
512
$publisheddate = GetNextDate($subscription, $publisheddate);
485
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
513
is($publisheddate, '1974-01-01');
486
is($publisheddate, '1974-01-01');
514
487
515
# TEST CASE - Irregular
488
# TEST CASE - Irregular
516
$id = AddSubscriptionFrequency({
489
$frequency = {
517
    description => "Irregular",
490
    description => "Irregular",
518
    unit => undef,
491
    unit => undef,
519
    issuesperunit => 1,
492
    issuesperunit => 1,
520
    unitsperissue => 1,
493
    unitsperissue => 1,
521
});
494
};
522
$subscription = {
495
$subscription = {
523
    periodicity => $id,
524
    firstacquidate => '1970-01-01',
496
    firstacquidate => '1970-01-01',
525
    irregularity => '',
497
    irregularity => '',
526
    countissuesperunit => 1,
498
    countissuesperunit => 1,
527
};
499
};
528
$publisheddate = $subscription->{firstacquidate};
500
$publisheddate = $subscription->{firstacquidate};
529
# GetNextDate always return undef if subscription is irregular
501
# GetNextDate always return undef if subscription is irregular
530
$publisheddate = GetNextDate($subscription, $publisheddate);
502
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
531
is($publisheddate, undef);
503
is($publisheddate, undef);
532
504
533
# GetNextDate returns undef if one of two first parameters is undef
505
# GetNextDate returns undef if one of two first parameters is undef
534
$publisheddate = GetNextDate($subscription, undef);
506
$publisheddate = GetNextDate($subscription, undef, $frequency);
535
is($publisheddate, undef);
507
is($publisheddate, undef);
536
$publisheddate = GetNextDate(undef, $subscription->{firstacquidate});
508
$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}, $frequency);
537
is($publisheddate, undef);
509
is($publisheddate, undef);
538
$publisheddate = GetNextDate(undef, undef);
510
$publisheddate = GetNextDate(undef, undef, $frequency);
539
is($publisheddate, undef);
511
is($publisheddate, undef);
540
512
541
$dbh->rollback;
513
$dbh->rollback;
(-)a/t/db_dependent/Serials/GetNextSeq.t (-63 / +62 lines)
Lines 43-58 my $subscription = { Link Here
43
};
43
};
44
my $publisheddate = $subscription->{firstacquidate};
44
my $publisheddate = $subscription->{firstacquidate};
45
45
46
my $seq = _next_seq($subscription, $pattern, $publisheddate);
46
my $seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
47
is($seq, 'X: 2');
47
is($seq, 'X: 2');
48
$publisheddate = GetNextDate($subscription, $publisheddate);
48
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
49
$seq = _next_seq($subscription, $pattern, $publisheddate);
49
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
50
is($seq, 'X: 4');
50
is($seq, 'X: 4');
51
$publisheddate = GetNextDate($subscription, $publisheddate);
51
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
52
$seq = _next_seq($subscription, $pattern, $publisheddate);
52
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
53
is($seq, 'X: 2');
53
is($seq, 'X: 2');
54
$publisheddate = GetNextDate($subscription, $publisheddate);
54
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
55
$seq = _next_seq($subscription, $pattern, $publisheddate);
55
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
56
is($seq, 'X: 3');
56
is($seq, 'X: 3');
57
57
58
# TEST CASE 2 - 1 variable, use 'dayname' numbering, from 1 to 7
58
# TEST CASE 2 - 1 variable, use 'dayname' numbering, from 1 to 7
Lines 79-97 $pattern = { Link Here
79
79
80
$publisheddate = $subscription->{firstacquidate};
80
$publisheddate = $subscription->{firstacquidate};
81
81
82
$seq = _next_seq($subscription, $pattern, $publisheddate);
82
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
83
is($seq, 'X: Tuesday');
83
is($seq, 'X: Tuesday');
84
$publisheddate = GetNextDate($subscription, $publisheddate);
84
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
85
$seq = _next_seq($subscription, $pattern, $publisheddate);
85
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
86
is($seq, 'X: Friday');
86
is($seq, 'X: Friday');
87
$publisheddate = GetNextDate($subscription, $publisheddate);
87
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
88
$seq = _next_seq($subscription, $pattern, $publisheddate);
88
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
89
is($seq, 'X: Sunday');
89
is($seq, 'X: Sunday');
90
$publisheddate = GetNextDate($subscription, $publisheddate);
90
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
91
$seq = _next_seq($subscription, $pattern, $publisheddate);
91
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
92
is($seq, 'X: Monday');
92
is($seq, 'X: Monday');
93
$publisheddate = GetNextDate($subscription, $publisheddate);
93
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
94
$seq = _next_seq($subscription, $pattern, $publisheddate);
94
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
95
is($seq, 'X: Tuesday');
95
is($seq, 'X: Tuesday');
96
96
97
# TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2
97
# TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2
Lines 118-136 $pattern = { Link Here
118
118
119
$publisheddate = $subscription->{firstacquidate};
119
$publisheddate = $subscription->{firstacquidate};
120
120
121
$seq = _next_seq($subscription, $pattern, $publisheddate);
121
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
122
is($seq, 'X: March');
122
is($seq, 'X: March');
123
$publisheddate = GetNextDate($subscription, $publisheddate);
123
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
124
$seq = _next_seq($subscription, $pattern, $publisheddate);
124
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
125
is($seq, 'X: September');
125
is($seq, 'X: September');
126
$publisheddate = GetNextDate($subscription, $publisheddate);
126
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
127
$seq = _next_seq($subscription, $pattern, $publisheddate);
127
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
128
is($seq, 'X: January');
128
is($seq, 'X: January');
129
$publisheddate = GetNextDate($subscription, $publisheddate);
129
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
130
$seq = _next_seq($subscription, $pattern, $publisheddate);
130
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
131
is($seq, 'X: March');
131
is($seq, 'X: March');
132
$publisheddate = GetNextDate($subscription, $publisheddate);
132
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
133
$seq = _next_seq($subscription, $pattern, $publisheddate);
133
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
134
is($seq, 'X: May');
134
is($seq, 'X: May');
135
135
136
# TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3
136
# TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3
Lines 157-175 $pattern = { Link Here
157
157
158
$publisheddate = $subscription->{firstacquidate};
158
$publisheddate = $subscription->{firstacquidate};
159
159
160
$seq = _next_seq($subscription, $pattern, $publisheddate);
160
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
161
is($seq, 'X: Summer');
161
is($seq, 'X: Summer');
162
$publisheddate = GetNextDate($subscription, $publisheddate);
162
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
163
$seq = _next_seq($subscription, $pattern, $publisheddate);
163
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
164
is($seq, 'X: Spring');
164
is($seq, 'X: Spring');
165
$publisheddate = GetNextDate($subscription, $publisheddate);
165
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
166
$seq = _next_seq($subscription, $pattern, $publisheddate);
166
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
167
is($seq, 'X: Fall');
167
is($seq, 'X: Fall');
168
$publisheddate = GetNextDate($subscription, $publisheddate);
168
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
169
$seq = _next_seq($subscription, $pattern, $publisheddate);
169
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
170
is($seq, 'X: Winter');
170
is($seq, 'X: Winter');
171
$publisheddate = GetNextDate($subscription, $publisheddate);
171
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
172
$seq = _next_seq($subscription, $pattern, $publisheddate);
172
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
173
is($seq, 'X: Spring');
173
is($seq, 'X: Spring');
174
174
175
# TEST CASE 5 - 2 variables, from 1 to 12, and from 1 to 4
175
# TEST CASE 5 - 2 variables, from 1 to 12, and from 1 to 4
Lines 196-214 $pattern = { Link Here
196
196
197
$publisheddate = $subscription->{firstacquidate};
197
$publisheddate = $subscription->{firstacquidate};
198
198
199
$seq = _next_seq($subscription, $pattern, $publisheddate);
199
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
200
is($seq, 'Y: 1, X: 2');
200
is($seq, 'Y: 1, X: 2');
201
$publisheddate = GetNextDate($subscription, $publisheddate);
201
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
202
$seq = _next_seq($subscription, $pattern, $publisheddate);
202
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
203
is($seq, 'Y: 2, X: 1');
203
is($seq, 'Y: 2, X: 1');
204
$publisheddate = GetNextDate($subscription, $publisheddate);
204
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
205
$seq = _next_seq($subscription, $pattern, $publisheddate);
205
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
206
is($seq, 'Y: 2, X: 3');
206
is($seq, 'Y: 2, X: 3');
207
$publisheddate = GetNextDate($subscription, $publisheddate);
207
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
208
$seq = _next_seq($subscription, $pattern, $publisheddate);
208
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
209
is($seq, 'Y: 2, X: 4');
209
is($seq, 'Y: 2, X: 4');
210
$publisheddate = GetNextDate($subscription, $publisheddate);
210
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
211
$seq = _next_seq($subscription, $pattern, $publisheddate);
211
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
212
is($seq, 'Y: 3, X: 1');
212
is($seq, 'Y: 3, X: 1');
213
213
214
# TEST CASE 6 - 3 variables, from 1 to 12, from 1 to 8, and from 1 to 4
214
# TEST CASE 6 - 3 variables, from 1 to 12, from 1 to 8, and from 1 to 4
Lines 235-278 $pattern = { Link Here
235
235
236
$publisheddate = $subscription->{firstacquidate};
236
$publisheddate = $subscription->{firstacquidate};
237
237
238
$seq = _next_seq($subscription, $pattern, $publisheddate);
238
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
239
is($seq, 'Z: 1, Y: 1, X: 2');
239
is($seq, 'Z: 1, Y: 1, X: 2');
240
$publisheddate = GetNextDate($subscription, $publisheddate);
240
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
241
$seq = _next_seq($subscription, $pattern, $publisheddate);
241
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
242
is($seq, 'Z: 1, Y: 2, X: 1');
242
is($seq, 'Z: 1, Y: 2, X: 1');
243
$publisheddate = GetNextDate($subscription, $publisheddate);
243
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
244
$seq = _next_seq($subscription, $pattern, $publisheddate);
244
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
245
is($seq, 'Z: 1, Y: 2, X: 3');
245
is($seq, 'Z: 1, Y: 2, X: 3');
246
$publisheddate = GetNextDate($subscription, $publisheddate);
246
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
247
$seq = _next_seq($subscription, $pattern, $publisheddate);
247
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
248
is($seq, 'Z: 1, Y: 2, X: 4');
248
is($seq, 'Z: 1, Y: 2, X: 4');
249
for (1..100) {
249
for (1..100) {
250
    $publisheddate = GetNextDate($subscription, $publisheddate);
250
    $publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
251
    $seq = _next_seq($subscription, $pattern, $publisheddate);
251
    $seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
252
}
252
}
253
$publisheddate = GetNextDate($subscription, $publisheddate);
253
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
254
$seq = _next_seq($subscription, $pattern, $publisheddate);
254
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
255
is($seq, 'Z: 4, Y: 4, X: 1');
255
is($seq, 'Z: 4, Y: 4, X: 1');
256
# 110th is here
256
# 110th is here
257
$publisheddate = GetNextDate($subscription, $publisheddate);
257
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
258
$seq = _next_seq($subscription, $pattern, $publisheddate);
258
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
259
is($seq, 'Z: 4, Y: 4, X: 3');
259
is($seq, 'Z: 4, Y: 4, X: 3');
260
$publisheddate = GetNextDate($subscription, $publisheddate);
260
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
261
$seq = _next_seq($subscription, $pattern, $publisheddate);
261
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
262
is($seq, 'Z: 4, Y: 4, X: 4');
262
is($seq, 'Z: 4, Y: 4, X: 4');
263
$publisheddate = GetNextDate($subscription, $publisheddate);
263
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency);
264
$seq = _next_seq($subscription, $pattern, $publisheddate);
264
$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate);
265
is($seq, 'Z: 4, Y: 5, X: 1');
265
is($seq, 'Z: 4, Y: 5, X: 1');
266
266
267
267
268
$dbh->rollback;
268
$dbh->rollback;
269
269
270
sub _next_seq {
270
sub _next_seq {
271
    my ($subscription, $pattern, $publisheddate) = @_;
271
    my ($subscription, $pattern, $frequency, $publisheddate) = @_;
272
    my $seq;
272
    my $seq;
273
    ($seq, $subscription->{lastvalue1}, $subscription->{lastvalue2},
273
    ($seq, $subscription->{lastvalue1}, $subscription->{lastvalue2},
274
        $subscription->{lastvalue3}, $subscription->{innerloop1},
274
        $subscription->{lastvalue3}, $subscription->{innerloop1},
275
        $subscription->{innerloop2}, $subscription->{innerloop3}) =
275
        $subscription->{innerloop2}, $subscription->{innerloop3}) =
276
            GetNextSeq($subscription, $pattern, $publisheddate);
276
            GetNextSeq($subscription, $pattern, $frequency, $publisheddate);
277
    return $seq;
277
    return $seq;
278
}
278
}
279
- 

Return to bug 17047