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

(-)a/C4/Serials.pm (-4 / +3 lines)
Lines 1176-1183 sub ModSerialStatus { Link Here
1176
    }
1176
    }
1177
1177
1178
    # create new expected entry if needed (ie : was "expected" and has changed)
1178
    # create new expected entry if needed (ie : was "expected" and has changed)
1179
    # BUG 12748: Check if there are no other expected issues.
1179
    my $otherIssueExpected = scalar findSerialsByStatus(EXPECTED, $subscriptionid);
1180
    my $otherIssueExpected = scalar findSerialByStatus(EXPECTED, $subscriptionid);
1181
    if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
1180
    if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
1182
        my $subscription = GetSubscription($subscriptionid);
1181
        my $subscription = GetSubscription($subscriptionid);
1183
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1182
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
Lines 2689-2695 sub _can_do_on_subscription { Link Here
2689
    return 0;
2688
    return 0;
2690
}
2689
}
2691
2690
2692
=head2 findSerialByStatus
2691
=head2 findSerialsByStatus
2693
2692
2694
    @serials = findSerialByStatus($status, $subscriptionid);
2693
    @serials = findSerialByStatus($status, $subscriptionid);
2695
2694
Lines 2697-2703 sub _can_do_on_subscription { Link Here
2697
2696
2698
=cut
2697
=cut
2699
2698
2700
sub findSerialByStatus{
2699
sub findSerialsByStatus{
2701
    my($status, $subscriptionid) = @_;
2700
    my($status, $subscriptionid) = @_;
2702
    my $dbh = C4::Context->dbh;
2701
    my $dbh = C4::Context->dbh;
2703
    my $query = q| SELECT * from serial
2702
    my $query = q| SELECT * from serial
(-)a/t/db_dependent/Serials.t (-4 / +20 lines)
Lines 15-21 use C4::Bookseller; Link Here
15
use C4::Biblio;
15
use C4::Biblio;
16
use C4::Budgets;
16
use C4::Budgets;
17
use Koha::DateUtils;
17
use Koha::DateUtils;
18
use Test::More tests => 48;
18
use Test::More tests => 49;
19
19
20
BEGIN {
20
BEGIN {
21
    use_ok('C4::Serials');
21
    use_ok('C4::Serials');
Lines 173-179 is(C4::Serials::ModSubscriptionHistory(), undef, 'test modding subscription hist Link Here
173
173
174
is(C4::Serials::ModSerialStatus(),undef, 'test modding serials');
174
is(C4::Serials::ModSerialStatus(),undef, 'test modding serials');
175
175
176
is(C4::Serials::findSerialByStatus(), 0, 'test finding serial by status with no parameters');
176
is(C4::Serials::findSerialsByStatus(), 0, 'test finding serial by status with no parameters');
177
177
is(C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered');
178
is(C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered');
178
179
179
is(C4::Serials::HasSubscriptionStrictlyExpired(), undef, 'test if the subscriptions has expired');
180
is(C4::Serials::HasSubscriptionStrictlyExpired(), undef, 'test if the subscriptions has expired');
Lines 219-225 for my $status ( @statuses ) { Link Here
219
    $counter++;
220
    $counter++;
220
}
221
}
221
# Here we have 15 serials with statuses : 2*2 + 5*3 + 2*4 + 1*41 + 1*42 + 1*43 + 1*44 + 1*5 + 1*1
222
# Here we have 15 serials with statuses : 2*2 + 5*3 + 2*4 + 1*41 + 1*42 + 1*43 + 1*44 + 1*5 + 1*1
222
my @serialsByStatus = C4::Serials::findSerialByStatus(2,$subscriptionid);
223
my @serialsByStatus = C4::Serials::findSerialsByStatus(2,$subscriptionid);
223
is(@serialsByStatus,2,"findSerialByStatus returns all serials with chosen status");
224
is(@serialsByStatus,2,"findSerialByStatus returns all serials with chosen status");
224
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
225
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
225
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" );
226
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" );
Lines 247-250 for my $am ( @arrived_missing ) { Link Here
247
}
248
}
248
is( $subscription->{missinglist}, join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" );
249
is( $subscription->{missinglist}, join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" );
249
250
251
my ( $expected_serial ) = GetSerials2( $subscriptionid, [1] );
252
#Find serialid for serial with status Expected
253
my $serialexpected = (C4::Serials::findSerialsByStatus(1,$subscriptionid))[0];
254
#delete serial with status Expected
255
C4::Serials::ModSerialStatus( $serialexpected->{serialid},$serialexpected->{serialseq},$publisheddate,$publisheddate, $publisheddate,'1','an useless note');
256
my @serialsByStatus = C4::Serials::findSerialsByStatus(1,$subscriptionid);
257
is (@serialsByStatus,1,"ModSerialStatus delete corectly serial expected and create another if not exist");
258
# add 1 serial with status=Expected 1
259
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
260
#Now we have two serials it have status expected
261
#put status delete for last serial
262
C4::Serials::ModSerialStatus( $serialexpected->{serialid},$serialexpected->{serialseq},$publisheddate,$publisheddate, $publisheddate,'1','an useless note');
263
#try if create or note another serial with status is expected
264
@serialsByStatus = C4::Serials::findSerialsByStatus(1,$subscriptionid);
265
is(@serialsByStatus,1,"ModSerialStatus delete corectly serial expected and not create another if exist");
266
250
$dbh->rollback;
267
$dbh->rollback;
251
- 

Return to bug 12748