Lines 19-25
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use POSIX qw(strftime); |
20 |
use POSIX qw(strftime); |
21 |
|
21 |
|
22 |
use Test::More tests => 63; |
22 |
use Test::More tests => 65; |
23 |
use Koha::Database; |
23 |
use Koha::Database; |
24 |
|
24 |
|
25 |
BEGIN { |
25 |
BEGIN { |
Lines 166-171
my ( $biblionumber1, $biblioitemnumber1 ) = AddBiblio( MARC::Record->new, '' );
Link Here
|
166 |
my ( $biblionumber2, $biblioitemnumber2 ) = AddBiblio( MARC::Record->new, '' ); |
166 |
my ( $biblionumber2, $biblioitemnumber2 ) = AddBiblio( MARC::Record->new, '' ); |
167 |
my ( $biblionumber3, $biblioitemnumber3 ) = AddBiblio( MARC::Record->new, '' ); |
167 |
my ( $biblionumber3, $biblioitemnumber3 ) = AddBiblio( MARC::Record->new, '' ); |
168 |
my ( $biblionumber4, $biblioitemnumber4 ) = AddBiblio( MARC::Record->new, '' ); |
168 |
my ( $biblionumber4, $biblioitemnumber4 ) = AddBiblio( MARC::Record->new, '' ); |
|
|
169 |
my ( $biblionumber5, $biblioitemnumber5 ) = AddBiblio( MARC::Record->new, '' ); |
169 |
|
170 |
|
170 |
# Prepare 5 orders, and make distinction beween fields to be tested with eq and with == |
171 |
# Prepare 5 orders, and make distinction beween fields to be tested with eq and with == |
171 |
# Ex : a price of 50.1 will be stored internally as 5.100000 |
172 |
# Ex : a price of 50.1 will be stored internally as 5.100000 |
Lines 257-267
my @order_content = (
Link Here
|
257 |
uncertainprice => 0, |
258 |
uncertainprice => 0, |
258 |
tax_rate => 0 |
259 |
tax_rate => 0 |
259 |
} |
260 |
} |
|
|
261 |
}, |
262 |
{ |
263 |
str => { |
264 |
basketno => $basketno, |
265 |
biblionumber => $biblionumber5, |
266 |
budget_id => $budget->{budget_id}, |
267 |
order_internalnote => "internal note", |
268 |
order_vendornote => "vendor note" |
269 |
}, |
270 |
num => { |
271 |
quantity => 1, |
272 |
ecost => 10, |
273 |
rrp => 10, |
274 |
listprice => 10, |
275 |
ecost => 10, |
276 |
rrp => 10, |
277 |
discount => 0, |
278 |
uncertainprice => 0, |
279 |
tax_rate => 0 |
280 |
} |
260 |
} |
281 |
} |
261 |
); |
282 |
); |
262 |
|
283 |
|
263 |
# Create 4 orders in database |
284 |
# Create 5 orders in database |
264 |
for ( 0 .. 4 ) { |
285 |
for ( 0 .. 5 ) { |
265 |
my %ocontent; |
286 |
my %ocontent; |
266 |
@ocontent{ keys %{ $order_content[$_]->{num} } } = |
287 |
@ocontent{ keys %{ $order_content[$_]->{num} } } = |
267 |
values %{ $order_content[$_]->{num} }; |
288 |
values %{ $order_content[$_]->{num} }; |
Lines 298-304
my $search_orders = SearchOrders({
Link Here
|
298 |
isa_ok( $search_orders, 'ARRAY' ); |
319 |
isa_ok( $search_orders, 'ARRAY' ); |
299 |
ok( |
320 |
ok( |
300 |
( |
321 |
( |
301 |
( scalar @$search_orders == 4 ) |
322 |
( scalar @$search_orders == 5 ) |
302 |
and !grep ( $_->{ordernumber} eq $ordernumbers[3], @$search_orders ) |
323 |
and !grep ( $_->{ordernumber} eq $ordernumbers[3], @$search_orders ) |
303 |
), |
324 |
), |
304 |
"SearchOrders only gets non-cancelled orders" |
325 |
"SearchOrders only gets non-cancelled orders" |
Lines 311-317
$search_orders = SearchOrders({
Link Here
|
311 |
}); |
332 |
}); |
312 |
ok( |
333 |
ok( |
313 |
( |
334 |
( |
314 |
( scalar @$search_orders == 3 ) and !grep ( ( |
335 |
( scalar @$search_orders == 4 ) and !grep ( ( |
315 |
( $_->{ordernumber} eq $ordernumbers[3] ) |
336 |
( $_->{ordernumber} eq $ordernumbers[3] ) |
316 |
or ( $_->{ordernumber} eq $ordernumbers[4] ) |
337 |
or ( $_->{ordernumber} eq $ordernumbers[4] ) |
317 |
), |
338 |
), |
Lines 368-374
$search_orders = SearchOrders({
Link Here
|
368 |
pending => 1, |
389 |
pending => 1, |
369 |
ordered => 1, |
390 |
ordered => 1, |
370 |
}); |
391 |
}); |
371 |
is( scalar (@$search_orders), 3, "SearchOrders with pending and ordered params gets only pending ordered orders. After closing the basket, orders are marked as 'ordered' (bug 11170)" ); |
392 |
is( scalar (@$search_orders), 4, "SearchOrders with pending and ordered params gets only pending ordered orders. After closing the basket, orders are marked as 'ordered' (bug 11170)" ); |
372 |
|
393 |
|
373 |
# |
394 |
# |
374 |
# Test AddClaim |
395 |
# Test AddClaim |
Lines 498-503
$order4 = GetOrder($order4->{ordernumber});
Link Here
|
498 |
ok((defined $order4->{datecancellationprinted}), "order is cancelled"); |
519 |
ok((defined $order4->{datecancellationprinted}), "order is cancelled"); |
499 |
ok(($order4->{cancellationreason} eq "foobar"), "order has cancellation reason \"foobar\""); |
520 |
ok(($order4->{cancellationreason} eq "foobar"), "order has cancellation reason \"foobar\""); |
500 |
ok((not defined GetBiblio($order4->{biblionumber})), "biblio does not exist anymore"); |
521 |
ok((not defined GetBiblio($order4->{biblionumber})), "biblio does not exist anymore"); |
|
|
522 |
|
523 |
my $order5 = GetOrder($ordernumbers[4]); |
524 |
C4::Items::AddItem( { barcode => '0102030405' }, $order5->{biblionumber} ); |
525 |
$error = DelOrder($order5->{biblionumber}, $order5->{ordernumber}, 1); |
526 |
$order5 = GetOrder($order5->{ordernumber}); |
527 |
ok((defined $order5->{datecancellationprinted}), "order is cancelled"); |
528 |
ok(GetBiblio($order5->{biblionumber}), "biblio still exists"); |
529 |
|
501 |
# End of tests for DelOrder |
530 |
# End of tests for DelOrder |
502 |
|
531 |
|
503 |
subtest 'ModOrder' => sub { |
532 |
subtest 'ModOrder' => sub { |