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

(-)a/Koha/Acquisition/Orders.pm (+35 lines)
Lines 130-135 sub filter_by_lates { Link Here
130
    );
130
    );
131
}
131
}
132
132
133
=head3 filter_by_current
134
135
    $orders->filter_by_current
136
137
Return the orders of the set that have not been cancelled.
138
139
=cut
140
141
sub filter_by_current {
142
    my ($self) = @_;
143
    return $self->search(
144
        {
145
            datecancellationprinted => [ undef, '0000-00-00' ]
146
        }
147
    );
148
}
149
150
=head3 filter_by_cancelled
151
152
    $orders->filter_by_cancelled
153
154
Return the orders of the set that have been cancelled.
155
156
=cut
157
158
sub filter_by_cancelled {
159
    my ($self) = @_;
160
    return $self->search(
161
        {
162
            datecancellationprinted =>
163
              [ { '!=' => [ -and => ( undef, '0000-00-00' ) ] } ]
164
        }
165
    );
166
}
167
133
=head2 Internal methods
168
=head2 Internal methods
134
169
135
=head3 _type (internal)
170
=head3 _type (internal)
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-2 / +49 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 10;
22
use Test::More tests => 11;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 536-538 subtest 'filter_by_late' => sub { Link Here
536
536
537
    $schema->storage->txn_rollback;
537
    $schema->storage->txn_rollback;
538
};
538
};
539
- 
539
540
subtest 'filter_by_current & filter_by_cancelled' => sub {
541
    plan tests => 2;
542
543
    $schema->storage->txn_begin;
544
    my $now        = dt_from_string;
545
    my $order_1 = $builder->build_object(
546
        {
547
            class => 'Koha::Acquisition::Orders',
548
            value => {
549
                datecancellationprinted => undef,
550
            }
551
        }
552
    );
553
    my $order_2 = $builder->build_object(
554
        {
555
            class => 'Koha::Acquisition::Orders',
556
            value => {
557
                datecancellationprinted => undef,
558
            }
559
        }
560
    );
561
    my $order_3 = $builder->build_object(
562
        {
563
            class => 'Koha::Acquisition::Orders',
564
            value => {
565
                datecancellationprinted => dt_from_string,
566
            }
567
        }
568
    );
569
570
    my $orders = Koha::Acquisition::Orders->search(
571
        {
572
            ordernumber => {
573
                -in => [
574
                    $order_1->ordernumber, $order_2->ordernumber,
575
                    $order_3->ordernumber,
576
                ]
577
            }
578
        }
579
    );
580
581
    is( $orders->filter_by_current->count, 2);
582
    is( $orders->filter_by_cancelled->count, 1);
583
584
585
    $schema->storage->txn_rollback;
586
};

Return to bug 23166