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

(-)a/C4/Acquisition.pm (-1 / +2 lines)
Lines 1299-1305 sub NewOrder { Link Here
1299
1299
1300
=head3 NewOrderItem
1300
=head3 NewOrderItem
1301
1301
1302
  &NewOrderItem();
1302
  &NewOrderItem( $itemnumber, $ordernumber );
1303
1303
1304
=cut
1304
=cut
1305
1305
Lines 1833-1838 cancelled. Link Here
1833
1833
1834
sub DelOrder {
1834
sub DelOrder {
1835
    my ($ordernumber,$biblionumber) = @_;
1835
    my ($ordernumber,$biblionumber) = @_;
1836
    return if !$ordernumber;
1836
    my $dbh = C4::Context->dbh;
1837
    my $dbh = C4::Context->dbh;
1837
    my $query = "
1838
    my $query = "
1838
        UPDATE aqorders
1839
        UPDATE aqorders
(-)a/t/db_dependent/Acquisition.t (-2 / +54 lines)
Lines 7-14 use Modern::Perl; Link Here
7
use POSIX qw(strftime);
7
use POSIX qw(strftime);
8
8
9
use C4::Bookseller qw( GetBookSellerFromId );
9
use C4::Bookseller qw( GetBookSellerFromId );
10
use C4::Items qw (AddItem GetItem);
11
use C4::Branch qw (ModBranch);
10
12
11
use Test::More tests => 76;
13
use Test::More tests => 80;
12
14
13
BEGIN {
15
BEGIN {
14
    use_ok('C4::Acquisition');
16
    use_ok('C4::Acquisition');
Lines 911-914 is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is give Link Here
911
$nonexistent_order = GetOrder( 424242424242 );
913
$nonexistent_order = GetOrder( 424242424242 );
912
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' );
914
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' );
913
915
916
#
917
# test DelOrder
918
# use:
919
# &DelOrder($ordernumber,$biblionumber);
920
921
# create 3 items on the same record and link 2 of them to the order
922
# we use the order $ordernumbers[2], which has the status 'complete' and no cancellation date before we try to delete it
923
924
# Add a branch
925
my $b1 = {
926
    add            => 1,
927
    branchcode     => 'BRA',
928
    branchname     => 'BranchA',
929
    branchaddress1 => 'adr1A',
930
    branchaddress2 => 'adr2A',
931
    branchaddress3 => 'adr3A',
932
    branchzip      => 'zipA',
933
    branchcity     => 'cityA',
934
    branchstate    => 'stateA',
935
    branchcountry  => 'countryA',
936
    branchphone    => 'phoneA',
937
    branchfax      => 'faxA',
938
    branchemail    => 'emailA',
939
    branchurl      => 'urlA',
940
    branchip       => 'ipA',
941
    branchprinter  => undef,
942
    branchnotes    => 'noteA',
943
    opac_info      => 'opacA'
944
};
945
ModBranch($b1);
946
947
my ($item_bibnum1, $item_bibitemnum1, $itemnumber1) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2);
948
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2);
949
my ($item_bibnum3, $item_bibitemnum3, $itemnumber3) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2);
950
NewOrderItem ($itemnumber1, $ordernumbers[2]);
951
NewOrderItem ($itemnumber2, $ordernumbers[2]);
952
953
# If no ordernumber is passed, the function returns undef and does not try to update database
954
my $return_DelOrder = DelOrder ();
955
is($return_DelOrder , undef, 'DelOrder returns undef with no param');
956
# Cancel the order with the given order, by filling the datecancellationprinted and orderstatus fields.
957
DelOrder ($ordernumbers[2],$biblionumber2);
958
$order3 = GetOrder( $ordernumbers[2] );
959
ok(($order3->{'orderstatus'} eq 'cancelled')&& (defined $order3->{'datecancellationprinted'}),'DelOrders update orderstatus and fill datecancellationprinted fields');
960
961
# All the items linked with that order are deleted (in items, not in aqorders_items by the way)
962
ok(!defined GetItem($itemnumber1) && !defined GetItem($itemnumber2),  "DelOrder deletes items linked with order in items table");
963
964
# Other items (created manually) are not deleted.
965
is(GetItem($itemnumber3)->{biblionumber},$biblionumber2, "DelOrder does not delete item created manually");
966
914
$dbh->rollback;
967
$dbh->rollback;
915
- 

Return to bug 10869