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 533-537 subtest 'filter_by_late' => sub { Link Here
533
    );
533
    );
534
    is( $late_orders->count, 1 );
534
    is( $late_orders->count, 1 );
535
535
536
    $schema->storage->txn_rollback;
537
};
538
539
subtest 'filter_by_current & filter_by_cancelled' => sub {
540
    plan tests => 2;
541
542
    $schema->storage->txn_begin;
543
    my $now        = dt_from_string;
544
    my $order_1 = $builder->build_object(
545
        {
546
            class => 'Koha::Acquisition::Orders',
547
            value => {
548
                datecancellationprinted => undef,
549
            }
550
        }
551
    );
552
    my $order_2 = $builder->build_object(
553
        {
554
            class => 'Koha::Acquisition::Orders',
555
            value => {
556
                datecancellationprinted => undef,
557
            }
558
        }
559
    );
560
    my $order_3 = $builder->build_object(
561
        {
562
            class => 'Koha::Acquisition::Orders',
563
            value => {
564
                datecancellationprinted => dt_from_string,
565
            }
566
        }
567
    );
568
569
    my $orders = Koha::Acquisition::Orders->search(
570
        {
571
            ordernumber => {
572
                -in => [
573
                    $order_1->ordernumber, $order_2->ordernumber,
574
                    $order_3->ordernumber,
575
                ]
576
            }
577
        }
578
    );
579
580
    is( $orders->filter_by_current->count, 2);
581
    is( $orders->filter_by_cancelled->count, 1);
582
583
536
    $schema->storage->txn_rollback;
584
    $schema->storage->txn_rollback;
537
};
585
};
538
- 

Return to bug 23166