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

(-)a/C4/Serials.pm (-2 / +22 lines)
Lines 1172-1179 sub ModSerialStatus { Link Here
1172
        }
1172
        }
1173
    }
1173
    }
1174
1174
1175
    # create new waited entry if needed (ie : was a "waited" and has changed)
1175
    # create new expected entry if needed (ie : was "expected" and has changed)
1176
    if ( $oldstatus == EXPECTED && $status != EXPECTED ) {
1176
    # BUG 12748: Check if there are no other expected issues.
1177
    my $otherIssueExpected = scalar findSerialByStatus(EXPECTED, $subscriptionid);
1178
    if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {
1177
        my $subscription = GetSubscription($subscriptionid);
1179
        my $subscription = GetSubscription($subscriptionid);
1178
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1180
        my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
1179
1181
Lines 2805-2810 sub _can_do_on_subscription { Link Here
2805
    return 0;
2807
    return 0;
2806
}
2808
}
2807
2809
2810
=head2 findSerialByStatus
2811
2812
    @serials = findSerialByStatus($status, $subscriptionid);
2813
2814
    Returns an array of serials matching a given status and subscription id.
2815
2816
=cut
2817
2818
sub findSerialByStatus{
2819
    my($status, $subscriptionid) = @_;
2820
    my $dbh = C4::Context->dbh;
2821
    my $query = q| SELECT * from serial
2822
                    WHERE status = ?
2823
                    AND subscriptionid = ?
2824
                |;
2825
    my $serials = $dbh->selectall_arrayref( $query, { Slice => {} }, $status, $subscriptionid );
2826
    return @$serials;
2827
}
2808
1;
2828
1;
2809
__END__
2829
__END__
2810
2830
(-)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