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

(-)a/C4/Serials.pm (-2 / +22 lines)
Lines 1125-1132 sub ModSerialStatus { Link Here
1125
        }
1125
        }
1126
    }
1126
    }
1127
1127
1128
    # create new waited entry if needed (ie : was a "waited" and has changed)
1128
    # create new expected entry if needed (ie : was "expected" and has changed)
1129
    if ( $oldstatus == EXPECTED && $status != EXPECTED ) {
1129
    # BUG 12748: Check if there are no other expected issues.
1130
    my $otherIssueExpected = scalar findSerialByStatus(EXPECTED, $subscriptionid);
1131
    if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
1130
        my $subscription = GetSubscription($subscriptionid);
1132
        my $subscription = GetSubscription($subscriptionid);
1131
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1133
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1132
1134
Lines 2731-2736 sub _can_do_on_subscription { Link Here
2731
    return 0;
2733
    return 0;
2732
}
2734
}
2733
2735
2736
=head2 findSerialByStatus
2737
2738
    @serials = findSerialByStatus($status, $subscriptionid);
2739
2740
    Returns an array of serials matching a given status and subscription id.
2741
2742
=cut
2743
2744
sub findSerialByStatus{
2745
    my($status, $subscriptionid) = @_;
2746
    my $dbh = C4::Context->dbh;
2747
    my $query = q| SELECT * from serial
2748
                    WHERE status = ?
2749
                    AND subscriptionid = ?
2750
                |;
2751
    my $serials = $dbh->selectall_arrayref( $query, { Slice => {} }, $status, $subscriptionid );
2752
    return @$serials;
2753
}
2734
1;
2754
1;
2735
__END__
2755
__END__
2736
2756
(-)a/t/db_dependent/Serials.t (-2 / +4 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 => 46;
18
use Test::More tests => 48;
19
19
20
BEGIN {
20
BEGIN {
21
    use_ok('C4::Serials');
21
    use_ok('C4::Serials');
Lines 173-178 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::NewIssue(), undef, 'test getting 0 when nothing is entered');
177
is(C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered');
177
178
178
is(C4::Serials::ItemizeSerials(),undef, 'test getting nothing when nothing is entered');
179
is(C4::Serials::ItemizeSerials(),undef, 'test getting nothing when nothing is entered');
Lines 220-225 for my $status ( @statuses ) { Link Here
220
    $counter++;
221
    $counter++;
221
}
222
}
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
223
# 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
224
my @serialsByStatus = C4::Serials::findSerialByStatus(2,$subscriptionid);
225
is(@serialsByStatus,2,"findSerialByStatus returns all serials with chosen status");
223
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
226
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
224
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" );
227
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" );
225
my @arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials;
228
my @arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials;
226
- 

Return to bug 12748