Bug 11699: fixed saving notes entered when receiving orders
[koha.git] / t / db_dependent / Acquisition.t
blobed352b0faf7f03a5ea008ebac037e30853ca35a9
1 #!/usr/bin/perl
3 # This Koha test module is a stub!
4 # Add more tests here!!!
6 use Modern::Perl;
7 use POSIX qw(strftime);
9 use C4::Bookseller qw( GetBookSellerFromId );
11 use Test::More tests => 71;
13 BEGIN {
14 use_ok('C4::Acquisition');
15 use_ok('C4::Bookseller');
16 use_ok('C4::Biblio');
17 use_ok('C4::Budgets');
18 use_ok('C4::Bookseller');
21 # Sub used for testing C4::Acquisition subs returning order(s):
22 # GetOrdersByStatus, GetOrders, GetDeletedOrders, GetOrder etc.
23 # (\@test_missing_fields,\@test_extra_fields,\@test_different_fields,$test_nbr_fields) =
24 # _check_fields_of_order ($exp_fields, $original_order_content, $order_to_check);
25 # params :
26 # $exp_fields : arrayref whose elements are the keys we expect to find
27 # $original_order_content : hashref whose 2 keys str and num contains hashrefs
28 # containing content fields of the order created with NewOrder
29 # $order_to_check : hashref whose keys/values are the content of an order
30 # returned by the C4::Acquisition sub we are testing
31 # returns :
32 # \@test_missing_fields : arrayref void if ok ; otherwise contains the list of
33 # fields missing in $order_to_check
34 # \@test_extra_fields : arrayref void if ok ; otherwise contains the list of
35 # fields unexpected in $order_to_check
36 # \@test_different_fields : arrayref void if ok ; otherwise contains the list of
37 # fields which value is not the same in between $order_to_check and
38 # $test_nbr_fields : contains the number of fields of $order_to_check
40 sub _check_fields_of_order {
41 my ( $exp_fields, $original_order_content, $order_to_check ) = @_;
42 my @test_missing_fields = ();
43 my @test_extra_fields = ();
44 my @test_different_fields = ();
45 my $test_nbr_fields = scalar( keys %$order_to_check );
46 foreach my $field (@$exp_fields) {
47 push @test_missing_fields, $field
48 unless exists( $order_to_check->{$field} );
50 foreach my $field ( keys %$order_to_check ) {
51 push @test_extra_fields, $field
52 unless grep ( /^$field$/, @$exp_fields );
54 foreach my $field ( keys %{ $original_order_content->{str} } ) {
55 push @test_different_fields, $field
56 unless ( !exists $order_to_check->{$field} )
57 or ( $original_order_content->{str}->{$field} eq
58 $order_to_check->{$field} );
60 foreach my $field ( keys %{ $original_order_content->{num} } ) {
61 push @test_different_fields, $field
62 unless ( !exists $order_to_check->{$field} )
63 or ( $original_order_content->{num}->{$field} ==
64 $order_to_check->{$field} );
66 return (
67 \@test_missing_fields, \@test_extra_fields,
68 \@test_different_fields, $test_nbr_fields
72 # Sub used for testing C4::Acquisition subs returning several orders
73 # (\@test_missing_fields,\@test_extra_fields,\@test_different_fields,\@test_nbr_fields) =
74 # _check_fields_of_orders ($exp_fields, $original_orders_content, $orders_to_check)
75 sub _check_fields_of_orders {
76 my ( $exp_fields, $original_orders_content, $orders_to_check ) = @_;
77 my @test_missing_fields = ();
78 my @test_extra_fields = ();
79 my @test_different_fields = ();
80 my @test_nbr_fields = ();
81 foreach my $order_to_check (@$orders_to_check) {
82 my $original_order_content =
83 ( grep { $_->{str}->{ordernumber} eq $order_to_check->{ordernumber} }
84 @$original_orders_content )[0];
85 my (
86 $t_missing_fields, $t_extra_fields,
87 $t_different_fields, $t_nbr_fields
89 = _check_fields_of_order( $exp_fields, $original_order_content,
90 $order_to_check );
91 push @test_missing_fields, @$t_missing_fields;
92 push @test_extra_fields, @$t_extra_fields;
93 push @test_different_fields, @$t_different_fields;
94 push @test_nbr_fields, $t_nbr_fields;
96 @test_missing_fields = keys %{ { map { $_ => 1 } @test_missing_fields } };
97 @test_extra_fields = keys %{ { map { $_ => 1 } @test_extra_fields } };
98 @test_different_fields =
99 keys %{ { map { $_ => 1 } @test_different_fields } };
100 return (
101 \@test_missing_fields, \@test_extra_fields,
102 \@test_different_fields, \@test_nbr_fields
106 my $dbh = C4::Context->dbh;
107 $dbh->{AutoCommit} = 0;
108 $dbh->{RaiseError} = 1;
110 # Creating some orders
111 my $booksellerid = C4::Bookseller::AddBookseller(
113 name => "my vendor",
114 address1 => "bookseller's address",
115 phone => "0123456",
116 active => 1,
117 deliverytime => 5,
121 my $booksellerinfo = C4::Bookseller::GetBookSellerFromId($booksellerid);
123 is( $booksellerinfo->{deliverytime},
124 5, 'set deliverytime when creating vendor (Bug 10556)' );
126 my ( $basket, $basketno );
128 $basketno = NewBasket( $booksellerid, 1 ),
129 "NewBasket( $booksellerid , 1 ) returns $basketno"
131 ok( $basket = GetBasket($basketno), "GetBasket($basketno) returns $basket" );
133 my $budgetid = C4::Budgets::AddBudget(
135 budget_code => "budget_code_test_getordersbybib",
136 budget_name => "budget_name_test_getordersbybib",
139 my $budget = C4::Budgets::GetBudget($budgetid);
141 my @ordernumbers;
142 my ( $biblionumber1, $biblioitemnumber1 ) = AddBiblio( MARC::Record->new, '' );
143 my ( $biblionumber2, $biblioitemnumber2 ) = AddBiblio( MARC::Record->new, '' );
144 my ( $biblionumber3, $biblioitemnumber3 ) = AddBiblio( MARC::Record->new, '' );
145 my ( $biblionumber4, $biblioitemnumber4 ) = AddBiblio( MARC::Record->new, '' );
148 # Test NewOrder
151 my ( $mandatoryparams, $return_error, $basketnum );
153 # returns undef and croaks if basketno, quantity, biblionumber or budget_id is missing
154 eval { ( $basketnum, $ordernumbers[0] ) = C4::Acquisition::NewOrder() };
155 $return_error = $@;
157 ( !( defined $basketnum || defined $ordernumbers[0] ) )
158 && ( defined $return_error ),
159 "NewOrder with no params returns undef and croaks"
162 $mandatoryparams = {
163 basketno => $basketno,
164 quantity => 24,
165 biblionumber => $biblionumber1,
166 budget_id => $budget->{budget_id},
168 my @mandatoryparams_keys = keys %$mandatoryparams;
169 foreach my $mandatoryparams_key (@mandatoryparams_keys) {
170 my %test_missing_mandatoryparams = %$mandatoryparams;
171 delete $test_missing_mandatoryparams{$mandatoryparams_key};
172 eval {
173 ( $basketnum, $ordernumbers[0] ) =
174 C4::Acquisition::NewOrder( \%test_missing_mandatoryparams );
176 $return_error = $@;
177 my $expected_error = "Mandatory parameter $mandatoryparams_key missing";
179 ( !( defined $basketnum || defined $ordernumbers[0] ) )
180 && ( index( $return_error, $expected_error ) >= 0 ),
181 "NewOrder with no $mandatoryparams_key returns undef and croaks with expected error message"
185 # FIXME to do : test the other features of NewOrder
187 # Prepare 5 orders, and make distinction beween fields to be tested with eq and with ==
188 # Ex : a price of 50.1 will be stored internally as 5.100000
190 my @order_content = (
192 str => {
193 basketno => $basketno,
194 biblionumber => $biblionumber1,
195 budget_id => $budget->{budget_id},
196 uncertainprice => 0,
197 notes => "some notes",
199 num => {
200 quantity => 24,
201 listprice => 50.121111,
202 ecost => 38.15,
203 rrp => 40.15,
204 discount => 5.1111,
205 gstrate => 0.0515
209 str => {
210 basketno => $basketno,
211 biblionumber => $biblionumber2,
212 budget_id => $budget->{budget_id}
214 num => { quantity => 42 }
217 str => {
218 basketno => $basketno,
219 biblionumber => $biblionumber2,
220 budget_id => $budget->{budget_id},
221 uncertainprice => 0,
222 notes => "ordernotes"
224 num => {
225 quantity => 4,
226 ecost => 42.1,
227 rrp => 42.1,
228 listprice => 10.1,
229 ecost => 38.1,
230 rrp => 11.0,
231 discount => 5.1,
232 gstrate => 0.1
236 str => {
237 basketno => $basketno,
238 biblionumber => $biblionumber3,
239 budget_id => $budget->{budget_id},
240 notes => "ordernotes"
242 num => {
243 quantity => 4,
244 ecost => 40,
245 rrp => 42,
246 listprice => 10,
247 ecost => 38.15,
248 rrp => 11.00,
249 discount => 0,
250 uncertainprice => 0,
251 gstrate => 0
255 str => {
256 basketno => $basketno,
257 biblionumber => $biblionumber4,
258 budget_id => $budget->{budget_id},
259 notes => "ordernotes"
261 num => {
262 quantity => 1,
263 ecost => 10,
264 rrp => 10,
265 listprice => 10,
266 ecost => 10,
267 rrp => 10,
268 discount => 0,
269 uncertainprice => 0,
270 gstrate => 0
275 # Create 4 orders in database
276 for ( 0 .. 4 ) {
277 my %ocontent;
278 @ocontent{ keys %{ $order_content[$_]->{num} } } =
279 values %{ $order_content[$_]->{num} };
280 @ocontent{ keys %{ $order_content[$_]->{str} } } =
281 values %{ $order_content[$_]->{str} };
282 ( undef, $ordernumbers[$_] ) = C4::Acquisition::NewOrder( \%ocontent );
283 $order_content[$_]->{str}->{ordernumber} = $ordernumbers[$_];
286 # Test UT sub _check_fields_of_order
288 my (
289 $test_missing_fields, $test_extra_fields,
290 $test_different_fields, $test_nbr_fields
292 = _check_fields_of_order(
293 [qw /a b c d e/],
294 { str => { a => "bla", b => "105" }, num => { c => 15.12 } },
295 { a => "blabla", f => "f", b => "105", c => 15.1200, g => '' }
299 ( $test_nbr_fields == 5 )
300 and ( join( " ", sort @$test_missing_fields ) eq 'd e' )
301 and ( join( " ", sort @$test_extra_fields ) eq 'f g' )
302 and ( join( " ", @$test_different_fields ) eq 'a' )
304 "_check_fields_of_order can check an order (test 1)"
307 $test_missing_fields, $test_extra_fields,
308 $test_different_fields, $test_nbr_fields
310 = _check_fields_of_order(
311 [qw /a b c /],
312 { str => { a => "bla", b => "105" }, num => { c => 15.00 } },
313 { a => "bla", b => "105", c => 15 }
317 ( $test_nbr_fields == 3 )
318 and ( scalar @$test_missing_fields == 0 )
319 and ( scalar @$test_extra_fields == 0 )
320 and ( scalar @$test_different_fields == 0 )
322 "_check_fields_of_order can check an order (test 2)"
325 $test_missing_fields, $test_extra_fields,
326 $test_different_fields, $test_nbr_fields
328 = _check_fields_of_order(
329 [qw /a b c d e/],
330 { str => { a => "bla", b => "105" }, num => { c => 15.12 } },
331 { a => "blabla", b => "105", c => 15, d => "error" }
335 ( $test_nbr_fields == 4 )
336 and ( join( " ", sort @$test_missing_fields ) eq 'e' )
337 and ( scalar @$test_extra_fields == 0 )
338 and ( join( " ", @$test_different_fields ) eq 'a c' )
340 "_check_fields_of_order can check an order (test 3)"
344 # test GetOrder
347 my @expectedfields = qw(
348 ordernumber
349 biblionumber
350 entrydate
351 quantity
352 currency
353 listprice
354 totalamount
355 datereceived
356 invoiceid
357 freight
358 unitprice
359 quantityreceived
360 cancelledby
361 datecancellationprinted
362 notes
363 supplierreference
364 purchaseordernumber
365 basketno
366 timestamp
368 ecost
369 unitpricesupplier
370 unitpricelib
371 gstrate
372 discount
373 budget_id
374 budgetgroup_id
375 budgetdate
376 sort1
377 sort2
378 sort1_authcat
379 sort2_authcat
380 uncertainprice
381 claims_count
382 claimed_date
383 subscriptionid
384 parent_ordernumber
385 orderstatus
386 title
387 author
388 basketname
389 branchcode
390 publicationyear
391 copyrightdate
392 editionstatement
393 isbn
395 seriestitle
396 publishercode
397 publisher
398 budget
399 supplier
400 supplierid
401 estimateddeliverydate
402 orderdate
403 quantity_to_receive
404 subtotal
405 latesince
408 $test_missing_fields, $test_extra_fields,
409 $test_different_fields, $test_nbr_fields
411 = _check_fields_of_order( \@expectedfields, $order_content[0],
412 GetOrder( $ordernumbers[0] ) );
414 $test_nbr_fields,
415 scalar @expectedfields,
416 "GetOrder gets an order with the right number of fields"
418 is( join( " ", @$test_missing_fields ),
419 '', "GetOrder gets an order with no missing fields" );
420 is( join( " ", @$test_extra_fields ),
421 '', "GetOrder gets an order with no unexpected fields" );
422 is( join( " ", @$test_different_fields ),
423 '', "GetOrder gets an order with the right content in every fields" );
426 # Test GetOrders
429 my @base_expectedfields = qw(
430 ordernumber
431 ecost
432 uncertainprice
433 marc
434 cancelledby
436 isbn
437 copyrightdate
438 serial
439 cn_suffix
440 cn_item
441 marcxml
442 freight
443 cn_class
444 title
445 pages
446 budget_encumb
447 budget_name
448 number
449 itemtype
450 totalissues
451 author
452 budget_permission
453 parent_ordernumber
454 size
455 claims_count
456 currency
457 seriestitle
458 timestamp
459 editionstatement
460 budget_parent_id
461 publishercode
462 unitprice
463 collectionvolume
464 budget_amount
465 budget_owner_id
466 datecreated
467 claimed_date
468 subscriptionid
469 editionresponsibility
470 sort2
471 notes
472 volumedate
473 budget_id
474 illus
476 biblioitemnumber
477 datereceived
478 orderstatus
479 supplierreference
480 agerestriction
481 budget_branchcode
482 gstrate
483 listprice
484 budget_code
485 budgetdate
486 basketno
487 discount
488 abstract
489 collectionissn
490 publicationyear
491 collectiontitle
492 invoiceid
493 budgetgroup_id
494 place
495 issn
496 quantityreceived
497 entrydate
498 cn_source
499 sort1_authcat
500 budget_notes
501 biblionumber
502 unititle
503 sort2_authcat
504 budget_expend
506 cn_sort
507 totalamount
508 lccn
509 sort1
510 volume
511 purchaseordernumber
512 quantity
513 budget_period_id
514 frameworkcode
515 volumedesc
516 datecancellationprinted
518 @expectedfields =
519 ( @base_expectedfields,
520 ( 'transferred_from_timestamp', 'transferred_from' ) );
521 is( GetOrders(), undef, "GetOrders with no params returns undef" );
522 DelOrder( $order_content[3]->{str}->{biblionumber}, $ordernumbers[3] );
523 my @get_orders = GetOrders($basketno);
525 $test_missing_fields, $test_extra_fields,
526 $test_different_fields, $test_nbr_fields
528 = _check_fields_of_orders( \@expectedfields, \@order_content, \@get_orders );
530 $$test_nbr_fields[0],
531 scalar @expectedfields,
532 "GetOrders gets orders with the right number of fields"
534 is( join( " ", @$test_missing_fields ),
535 '', "GetOrders gets orders with no missing fields" );
536 is( join( " ", @$test_extra_fields ),
537 '', "GetOrders gets orders with no unexpected fields" );
538 is( join( " ", @$test_different_fields ),
539 '', "GetOrders gets orders with the right content in every fields" );
542 ( scalar @get_orders == 4 )
543 and !grep ( $_->{ordernumber} eq $ordernumbers[3], @get_orders )
545 "GetOrders only gets non-cancelled orders"
549 # Test GetCancelledOrders
552 @expectedfields =
553 ( @base_expectedfields, ( 'transferred_to_timestamp', 'transferred_to' ) );
554 is( GetCancelledOrders(), undef,
555 "GetCancelledOrders with no params returns undef" );
556 @get_orders = GetCancelledOrders($basketno);
558 $test_missing_fields, $test_extra_fields,
559 $test_different_fields, $test_nbr_fields
561 = _check_fields_of_orders( \@expectedfields, \@order_content, \@get_orders );
563 $$test_nbr_fields[0],
564 scalar @expectedfields,
565 "GetCancelledOrders gets orders with the right number of fields"
567 is( join( " ", @$test_missing_fields ),
568 '', "GetCancelledOrders gets orders with no missing fields" );
569 is( join( " ", @$test_extra_fields ),
570 '', "GetCancelledOrders gets orders with no unexpected fields" );
571 is( join( " ", @$test_different_fields ),
573 "GetCancelledOrders gets orders with the right content in every fields" );
576 ( scalar @get_orders == 1 )
577 and grep ( $_->{ordernumber} eq $ordernumbers[3], @get_orders )
579 "GetCancelledOrders only gets cancelled orders"
583 # Test SearchOrders
586 @expectedfields = qw (
587 basketgroupid
588 basketgroupname
589 firstname
590 biblioitemnumber
591 ecost
592 uncertainprice
593 creationdate
594 datereceived
595 orderstatus
596 supplierreference
597 cancelledby
598 isbn
599 copyrightdate
600 gstrate
601 serial
602 listprice
603 budgetdate
604 basketno
605 discount
606 surname
607 freight
608 abstract
609 title
610 closedate
611 basketname
612 budgetgroup_id
613 invoiceid
614 author
615 parent_ordernumber
616 claims_count
617 entrydate
618 currency
619 quantityreceived
620 seriestitle
621 sort1_authcat
622 timestamp
623 biblionumber
624 unititle
625 sort2_authcat
627 unitprice
628 totalamount
629 sort1
630 ordernumber
631 datecreated
632 purchaseordernumber
633 quantity
634 claimed_date
635 subscriptionid
636 frameworkcode
637 sort2
638 notes
639 datecancellationprinted
640 budget_id
641 authorisedby
642 booksellerid
645 # note that authorisedby was added to the return of SearchOrder by the
646 # patch for bug 11777
648 my $invoiceid = AddInvoice(
649 invoicenumber => 'invoice',
650 booksellerid => $booksellerid,
651 unknown => "unknown"
654 my ( $datereceived, $new_ordernumber ) =
655 ModReceiveOrder( $biblionumber4, $ordernumbers[4], 1, undef, 10, 10,
656 $invoiceid, 10, $order_content[4]->{str}->{budget_id} );
658 my $search_orders = SearchOrders({
659 booksellerid => $booksellerid,
660 basketno => $basketno
662 isa_ok( $search_orders, 'ARRAY' );
664 $test_missing_fields, $test_extra_fields,
665 $test_different_fields, $test_nbr_fields
667 = _check_fields_of_orders( \@expectedfields, \@order_content,
668 $search_orders );
670 $$test_nbr_fields[0],
671 scalar @expectedfields,
672 "SearchOrders gets orders with the right number of fields"
674 is( join( " ", @$test_missing_fields ),
675 '', "SearchOrders gets orders with no missing fields" );
676 is( join( " ", @$test_extra_fields ),
677 '', "SearchOrders gets orders with no unexpected fields" );
678 is( join( " ", @$test_different_fields ),
679 '', "SearchOrders gets orders with the right content in every fields" );
682 ( scalar @$search_orders == 4 )
683 and !grep ( $_->{ordernumber} eq $ordernumbers[3], @$search_orders )
685 "SearchOrders only gets non-cancelled orders"
688 $search_orders = SearchOrders({
689 booksellerid => $booksellerid,
690 basketno => $basketno,
691 pending => 1
695 ( scalar @$search_orders == 3 ) and !grep ( (
696 ( $_->{ordernumber} eq $ordernumbers[3] )
697 or ( $_->{ordernumber} eq $ordernumbers[4] )
699 @$search_orders )
701 "SearchOrders with pending params gets only pending orders (bug 10723)"
704 $search_orders = SearchOrders({
705 booksellerid => $booksellerid,
706 basketno => $basketno,
707 pending => 1,
708 ordered => 1,
710 is( scalar (@$search_orders), 0, "SearchOrders with pending and ordered params gets only pending ordered orders (bug 11170)" );
714 # Test GetBudgetByOrderNumber
716 ok( GetBudgetByOrderNumber( $ordernumbers[0] )->{'budget_id'} eq $budgetid,
717 "GetBudgetByOrderNumber returns expected budget" );
720 # Test GetLateOrders
723 @expectedfields = qw (
724 orderdate
725 author
726 budget
727 supplierid
728 claims_count
729 supplier
730 publisher
731 ordernumber
732 quantity
733 basketno
734 claimed_date
735 branch
736 estimateddeliverydate
737 title
738 publicationyear
739 unitpricelib
740 unitpricesupplier
741 subtotal
742 latesince
744 my @lateorders = GetLateOrders(0);
745 is( scalar grep ( $_->{basketno} eq $basketno, @lateorders ),
746 0, "GetLateOrders does not get orders from opened baskets" );
747 C4::Acquisition::CloseBasket($basketno);
748 @lateorders = GetLateOrders(0);
749 isnt( scalar grep ( $_->{basketno} eq $basketno, @lateorders ),
750 0, "GetLateOrders gets orders from closed baskets" );
751 ok( !grep ( $_->{ordernumber} eq $ordernumbers[3], @lateorders ),
752 "GetLateOrders does not gets cancelled orders" );
753 ok( !grep ( $_->{ordernumber} eq $ordernumbers[4], @lateorders ),
754 "GetLateOrders does not gets reveived orders" );
756 $test_missing_fields, $test_extra_fields,
757 $test_different_fields, $test_nbr_fields
759 = _check_fields_of_orders( \@expectedfields, \@order_content, \@lateorders );
761 $$test_nbr_fields[0],
762 scalar @expectedfields,
763 "GetLateOrders gets orders with the right number of fields"
765 is( join( " ", @$test_missing_fields ),
766 '', "GetLateOrders gets orders with no missing fields" );
767 is( join( " ", @$test_extra_fields ),
768 '', "GetLateOrders gets orders with no unexpected fields" );
769 is( join( " ", @$test_different_fields ),
770 '', "GetLateOrders gets orders with the right content in every fields" );
772 $search_orders = SearchOrders({
773 booksellerid => $booksellerid,
774 basketno => $basketno,
775 pending => 1,
776 ordered => 1,
778 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)" );
782 # Test AddClaim
785 my $order = $lateorders[0];
786 AddClaim( $order->{ordernumber} );
787 my $neworder = GetOrder( $order->{ordernumber} );
789 $neworder->{claimed_date},
790 strftime( "%Y-%m-%d", localtime(time) ),
791 "AddClaim : Check claimed_date"
794 ( $datereceived, $new_ordernumber ) =
795 ModReceiveOrder( $biblionumber2, $ordernumbers[1], 2, undef, 12, 12,
796 $invoiceid, 42, undef, undef, undef, "my notes");
797 my $order2 = GetOrder( $ordernumbers[1] );
798 is( $order2->{'quantityreceived'},
799 0, 'Splitting up order did not receive any on original order' );
800 is( $order2->{'quantity'}, 40, '40 items on original order' );
801 is( $order2->{'budget_id'}, $budgetid,
802 'Budget on original order is unchanged' );
803 is( $order2->{notes}, "my notes",
804 'ModReceiveOrder and GetOrder deal with notes' );
806 $neworder = GetOrder($new_ordernumber);
807 is( $neworder->{'quantity'}, 2, '2 items on new order' );
808 is( $neworder->{'quantityreceived'},
809 2, 'Splitting up order received items on new order' );
810 is( $neworder->{'budget_id'}, $budgetid, 'Budget on new order is unchanged' );
812 my $budgetid2 = C4::Budgets::AddBudget(
814 budget_code => "budget_code_test_modrecv",
815 budget_name => "budget_name_test_modrecv",
819 ( $datereceived, $new_ordernumber ) =
820 ModReceiveOrder( $biblionumber2, $ordernumbers[2], 2, undef, 12, 12,
821 $invoiceid, 42, $budgetid2, undef, undef, "my other notes" );
823 my $order3 = GetOrder( $ordernumbers[2] );
824 is( $order3->{'quantityreceived'},
825 0, 'Splitting up order did not receive any on original order' );
826 is( $order3->{'quantity'}, 2, '2 items on original order' );
827 is( $order3->{'budget_id'}, $budgetid,
828 'Budget on original order is unchanged' );
829 is( $order3->{notes}, "my other notes",
830 'ModReceiveOrder and GetOrder deal with notes' );
832 $neworder = GetOrder($new_ordernumber);
833 is( $neworder->{'quantity'}, 2, '2 items on new order' );
834 is( $neworder->{'quantityreceived'},
835 2, 'Splitting up order received items on new order' );
836 is( $neworder->{'budget_id'}, $budgetid2, 'Budget on new order is changed' );
838 ( $datereceived, $new_ordernumber ) =
839 ModReceiveOrder( $biblionumber2, $ordernumbers[2], 2, undef, 12, 12,
840 $invoiceid, 42, $budgetid2, undef, undef, "my third notes" );
842 $order3 = GetOrder( $ordernumbers[2] );
843 is( $order3->{'quantityreceived'}, 2, 'Order not split up' );
844 is( $order3->{'quantity'}, 2, '2 items on order' );
845 is( $order3->{'budget_id'}, $budgetid2, 'Budget has changed' );
846 is( $order3->{notes}, "my third notes", 'ModReceiveOrder and GetOrder deal with notes' );
848 my $nonexistent_order = GetOrder();
849 is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is given' );
850 $nonexistent_order = GetOrder( 424242424242 );
851 is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' );
853 $dbh->rollback;