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

(-)a/C4/Serials.pm (-3 / +4 lines)
Lines 2706-2714 sub _can_do_on_subscription { Link Here
2706
2706
2707
=cut
2707
=cut
2708
2708
2709
sub findSerialsByStatus{
2709
sub findSerialsByStatus {
2710
    my($status, $subscriptionid) = @_;
2710
    my ( $status, $subscriptionid ) = @_;
2711
    my $dbh = C4::Context->dbh;
2711
    my $dbh   = C4::Context->dbh;
2712
    my $query = q| SELECT * from serial
2712
    my $query = q| SELECT * from serial
2713
                    WHERE status = ?
2713
                    WHERE status = ?
2714
                    AND subscriptionid = ?
2714
                    AND subscriptionid = ?
Lines 2716-2721 sub findSerialsByStatus{ Link Here
2716
    my $serials = $dbh->selectall_arrayref( $query, { Slice => {} }, $status, $subscriptionid );
2716
    my $serials = $dbh->selectall_arrayref( $query, { Slice => {} }, $status, $subscriptionid );
2717
    return @$serials;
2717
    return @$serials;
2718
}
2718
}
2719
2719
1;
2720
1;
2720
__END__
2721
__END__
2721
2722
(-)a/t/db_dependent/Serials.t (-17 / +24 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 => 49;
18
use Test::More tests => 48;
19
19
20
BEGIN {
20
BEGIN {
21
    use_ok('C4::Serials');
21
    use_ok('C4::Serials');
Lines 248-267 for my $am ( @arrived_missing ) { Link Here
248
}
248
}
249
is( $subscription->{missinglist}, join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" );
249
is( $subscription->{missinglist}, join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" );
250
250
251
my ( $expected_serial ) = GetSerials2( $subscriptionid, [1] );
251
subtest "Do not generate an expected if one already exists" => sub {
252
#Find serialid for serial with status Expected
252
    plan tests => 2;
253
my $serialexpected = (C4::Serials::findSerialsByStatus(1,$subscriptionid))[0];
253
    my ($expected_serial) = GetSerials2( $subscriptionid, [1] );
254
#delete serial with status Expected
254
255
C4::Serials::ModSerialStatus( $serialexpected->{serialid},$serialexpected->{serialseq},$publisheddate,$publisheddate, $publisheddate,'1','an useless note');
255
    #Find serialid for serial with status Expected
256
@serialsByStatus = C4::Serials::findSerialsByStatus(1,$subscriptionid);
256
    my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0];
257
is (@serialsByStatus,1,"ModSerialStatus delete corectly serial expected and create another if not exist");
257
258
# add 1 serial with status=Expected 1
258
    #delete serial with status Expected
259
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
259
    C4::Serials::ModSerialStatus( $serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
260
#Now we have two serials it have status expected
260
    @serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid );
261
#put status delete for last serial
261
    is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and create another if not exist" );
262
C4::Serials::ModSerialStatus( $serialexpected->{serialid},$serialexpected->{serialseq},$publisheddate,$publisheddate, $publisheddate,'1','an useless note');
262
263
#try if create or note another serial with status is expected
263
    # add 1 serial with status=Expected 1
264
@serialsByStatus = C4::Serials::findSerialsByStatus(1,$subscriptionid);
264
    C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
265
is(@serialsByStatus,1,"ModSerialStatus delete corectly serial expected and not create another if exist");
265
266
    #Now we have two serials it have status expected
267
    #put status delete for last serial
268
    C4::Serials::ModSerialStatus( $serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
269
270
    #try if create or not another serial with status is expected
271
    @serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid );
272
    is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" );
273
};
266
274
267
$dbh->rollback;
275
$dbh->rollback;
268
- 

Return to bug 12748