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

(-)a/Koha/Acquisition/Orders.pm (-2 / +4 lines)
Lines 152-158 sub filter_by_lates { Link Here
152
Returns a new resultset containing active orders only.
152
Returns a new resultset containing active orders only.
153
153
154
Note: An active order (line) has status ordered or partial, or it has status new
154
Note: An active order (line) has status ordered or partial, or it has status new
155
and the basket is marked as standing order.
155
and the basket is marked as standing order. Additionally, we still expect items
156
on this order (checking quantity and quantityreceived).
156
157
157
=cut
158
=cut
158
159
Lines 164-170 sub filter_by_active { Link Here
164
                { 'basket.is_standing' => 1,
165
                { 'basket.is_standing' => 1,
165
                  'orderstatus' => [ 'new', 'ordered', 'partial' ] },
166
                  'orderstatus' => [ 'new', 'ordered', 'partial' ] },
166
                { 'orderstatus' => [ 'ordered', 'partial' ] }
167
                { 'orderstatus' => [ 'ordered', 'partial' ] }
167
            ]
168
            ],
169
            quantityreceived => { '<', \['COALESCE(quantity,0)'] },
168
        },
170
        },
169
        { join => 'basket' }
171
        { join => 'basket' }
170
    );
172
    );
(-)a/t/db_dependent/Koha/Acquisition/Orders.t (-8 / +15 lines)
Lines 32-38 my $builder = t::lib::TestBuilder->new; Link Here
32
32
33
subtest 'filter_by_active() tests' => sub {
33
subtest 'filter_by_active() tests' => sub {
34
34
35
    plan tests => 4;
35
    plan tests => 5;
36
36
37
    $schema->storage->txn_begin;
37
    $schema->storage->txn_begin;
38
38
Lines 66-94 subtest 'filter_by_active() tests' => sub { Link Here
66
        {
66
        {
67
            class => 'Koha::Acquisition::Orders',
67
            class => 'Koha::Acquisition::Orders',
68
            value => {
68
            value => {
69
                basketno    => $basket_1->basketno,
69
                basketno         => $basket_1->basketno,
70
                orderstatus => 'new'
70
                orderstatus      => 'new',
71
                quantity         => 1,
72
                quantityreceived => 0,
71
            }
73
            }
72
        }
74
        }
73
    );
75
    );
74
    my $order_4 = $builder->build_object(
76
    my $order_4 = $builder->build_object(
75
        {
77
        {
76
            class => 'Koha::Acquisition::Orders',
78
            class => 'Koha::Acquisition::Orders',
77
            value => { orderstatus => 'ordered' }
79
            value => { orderstatus => 'ordered', quantity => 1, quantityreceived => 0 }
78
        }
80
        }
79
    );
81
    );
80
    my $order_5 = $builder->build_object(
82
    my $order_5 = $builder->build_object(
81
        {
83
        {
82
            class => 'Koha::Acquisition::Orders',
84
            class => 'Koha::Acquisition::Orders',
83
            value => { orderstatus => 'partial' }
85
            value => { orderstatus => 'partial', quantity => 2, quantityreceived => 1 }
84
        }
86
        }
85
    );
87
    );
86
    my $order_6 = $builder->build_object(
88
    my $order_6 = $builder->build_object(
87
        {
89
        {
88
            class => 'Koha::Acquisition::Orders',
90
            class => 'Koha::Acquisition::Orders',
89
            value => {
91
            value => {
90
                basketno    => $basket_2->basketno,
92
                basketno         => $basket_2->basketno,
91
                orderstatus => 'new'
93
                orderstatus      => 'new',
94
                quantity         => 1,
95
                quantityreceived => 0,
92
            }
96
            }
93
        }
97
        }
94
    );
98
    );
Lines 116-121 subtest 'filter_by_active() tests' => sub { Link Here
116
    is( $rs->next->ordernumber, $order_4->ordernumber , 'Expected order in resultset' );
120
    is( $rs->next->ordernumber, $order_4->ordernumber , 'Expected order in resultset' );
117
    is( $rs->next->ordernumber, $order_5->ordernumber , 'Expected order in resultset' );
121
    is( $rs->next->ordernumber, $order_5->ordernumber , 'Expected order in resultset' );
118
122
123
    # If we change quantities on order_5 (partial), we should no longer see it
124
    $order_5->quantityreceived(2)->store;
125
    is( $this_orders_rs->filter_by_active->count, 2, 'Dropped one order as expected' );
126
119
    $schema->storage->txn_rollback;
127
    $schema->storage->txn_rollback;
120
};
128
};
121
129
122
- 

Return to bug 36018