Lines 20-26
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
23 |
use Test::More tests => 4; |
23 |
use Test::More tests => 5; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
|
25 |
|
26 |
use t::lib::TestBuilder; |
26 |
use t::lib::TestBuilder; |
Lines 213-215
subtest 'filter_by_obsolete and cancel' => sub {
Link Here
|
213 |
|
213 |
|
214 |
$schema->storage->txn_rollback; |
214 |
$schema->storage->txn_rollback; |
215 |
}; |
215 |
}; |
216 |
- |
216 |
|
|
|
217 |
subtest 'unreceived_totals() tests' => sub { |
218 |
|
219 |
plan tests => 4; |
220 |
|
221 |
$schema->storage->txn_begin; |
222 |
|
223 |
my $empty_resultset = Koha::Acquisition::Orders->search->empty(); |
224 |
|
225 |
my $result = $empty_resultset->unreceived_totals(); |
226 |
is( $result->{items_count}, 0, 'Zero unreceived items' ); |
227 |
is( $result->{total_replacement_price}, 0, 'Zero cost for 0 items' ); |
228 |
|
229 |
my $rrp = 2.31; |
230 |
|
231 |
my $order_1 = $builder->build_object( |
232 |
{ |
233 |
class => 'Koha::Acquisition::Orders', |
234 |
value => { quantity => 10, quantityreceived => 5, rrp => $rrp } |
235 |
} |
236 |
); |
237 |
my $order_2 = $builder->build_object( |
238 |
{ |
239 |
class => 'Koha::Acquisition::Orders', |
240 |
value => { quantity => 10, quantityreceived => 4, rrp => $rrp } |
241 |
} |
242 |
); |
243 |
my $order_3 = $builder->build_object( |
244 |
{ |
245 |
class => 'Koha::Acquisition::Orders', |
246 |
value => { quantity => 10, quantityreceived => 3, rrp => $rrp } |
247 |
} |
248 |
); |
249 |
|
250 |
my $rs = Koha::Acquisition::Orders->search( |
251 |
{ |
252 |
ordernumber => [ |
253 |
$order_1->id, |
254 |
$order_2->id, |
255 |
$order_3->id, |
256 |
] |
257 |
} |
258 |
); |
259 |
|
260 |
$result = $rs->unreceived_totals(); |
261 |
is( $result->{items_count}, 18, '18 unreceived items' ); |
262 |
is( $result->{total_replacement_price}, 18 * $rrp, 'rrp * 18' ); |
263 |
|
264 |
$schema->storage->txn_rollback; |
265 |
}; |