Bugzilla – Attachment 22676 Details for
Bug 10869
Can't cancel order line if title deleted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PATCH 2/2] Bug 10869 Followup : change DelOrder and adds UT
0002-Bug-10869-Followup-change-DelOrder-and-adds-UT.patch (text/plain), 10.02 KB, created by
Mathieu Saby
on 2013-11-03 18:38:47 UTC
(
hide
)
Description:
[PATCH 2/2] Bug 10869 Followup : change DelOrder and adds UT
Filename:
MIME Type:
Creator:
Mathieu Saby
Created:
2013-11-03 18:38:47 UTC
Size:
10.02 KB
patch
obsolete
>From 71651583f44dcac6fd4c5a31338848b21ef1cf4e Mon Sep 17 00:00:00 2001 >From: Mathieu Saby <mathieu.saby@univ-rennes2.fr> >Date: Wed, 23 Oct 2013 00:38:25 +0200 >Subject: [PATCH 2/2] Bug 10869 Followup : change DelOrder and adds UT >Content-Type: text/plain; charset="utf-8" > >Changes made to DelOrder : >Returns undef if no param >DelOrder does no more need a biblionumber. It can be retreived inside the sub. >DelOrder is now cleaning aqorders_items. > >UT added for DelOrder > >To test : >A. With syspref AcqCreateItem = on placing an order > >1. Fill a basket with some orders (some records with already existing items or holds, some without items). New items linked with the order will be created >2. Keep the basket open >3. In the catalog, supress all the items attached to one of the record used in the basket, then suppress the record >4. In the basket, check you can delete the order that was using deleted record (click on link "Delete order" in the right column of the table) >5. After deleting the order, check there is a new line in the "Deleted orders" table >6. Regression test : try to delete other orders, and check the deletion of the order implies the deletion of items created when ordering >a/ If no items were attached to the record before you created the basket, you can delete some other orders, AND their record. Try to delete order and record. >b/ If some items were attached to the record before you created the basket, you can delete some other orders, BUT NOT their record. Try to delete only order. After you have deleted it, the items created when ordering must have been deleted. > >7. Add some other orders to your basket (some records with already existing items or holds, some without items). New items linked with the order will be created >8. In the catalog, supress all the items attached to one of the record used in the basket, then suppress the record >9. Close the basket >10. Go on receipt page >11. Search the orders of your basket >12. In receipt page, check you can delete the order that was using deleted record (click on link "Delete order" in the right column of the table) >13. Regression test : try to delete other orders >a/ If no items were attached to the record before you created the basket, you can delete some other orders, AND their record. Try to delete order and record. >b/ If some items were attached to the record before you created the basket, you can delete some other orders, BUT NOT their record. Try to delete only order. After you have deleted it, the items created when ordering must have been deleted. > >B. With syspref AcqCreateItem = on receiving an order > >1. Fill a basket with some orders (some records with already existing items or holds, some without items). >2. Keep the basket open >3. In the catalog, supress all the items attached to one of the record used in the basket, then suppress the record >4. In the basket, check you can delete the order that was using deleted record (click on link "Delete order" in the right column of the table) >5. After deleting the order, check there is a new line in the "Deleted orders" table >6. Regression test : try to delete other orders >a/ If no items were attached to the record before you created the basket, you can delete some other orders, AND their record. Try to delete order and record. >b/ If some items were attached to the record before you created the basket, you can delete some other orders, BUT NOT their record. Try to delete only order. >7. Add some other orders to your basket (some records with already existing items or holds, some without items). >8. In the catalog, supress all the items attached to one of the record used in the basket, then suppress the record >9. Close the basket >10. Go on receipt page >11. Search the orders of your basket >12. In receipt page, check you can delete the order that was using deleted record (click on link "Delete order" in the right column of the table) >13. Regression test : try to delete other orders >a/ If no items were attached to the record before you created the basket, you can delete some other orders, AND their record. Try to delete order and record. >b/ If some items were attached to the record before you created the basket, you can delete some other orders, BUT NOT their record. Try to delete only order. > >and to test the UT : >prove t/db_dependant/Acquisition.t >--- > C4/Acquisition.pm | 46 +++++++++++++++++++++++------------ > acqui/addorder.pl | 2 +- > t/db_dependent/Acquisition.t | 55 +++++++++++++++++++++++++++++++++++++++++- > 3 files changed, 86 insertions(+), 17 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 16644bd..b3e3723 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1285,7 +1285,7 @@ sub NewOrder { > > =head3 NewOrderItem > >- &NewOrderItem(); >+ &NewOrderItem ($itemnumber, $ordernumber); > > =cut > >@@ -1750,30 +1750,46 @@ sub SearchOrders { > > =head3 DelOrder > >- &DelOrder($ordernumber, $biblionumber); >+ &DelOrder($ordernumber); > >-Cancel the order with the given order and biblio numbers. It does not >-delete any entries in the aqorders table, it merely marks them as >-cancelled. >+Cancel the order with the given order, by filling the datecancellationprinted and orderstatus fields. >+C<$ordernumber > is mandatory >+If no ordernumber is passed, the function returns undef and does not try to update database. >+All the items linked with that order are deleted. >+Other items are not deleted. > > =cut > > sub DelOrder { >- my ($ordernumber,$biblionumber) = @_; >+ my ($ordernumber) = @_; >+ return unless $ordernumber; > my $dbh = C4::Context->dbh; >- my $query = " >+ my $query = qq { > UPDATE aqorders > SET datecancellationprinted=now(), orderstatus='cancelled' >- WHERE ordernumber=? >- "; >+ WHERE ordernumber = ? >+ }; > my $sth = $dbh->prepare($query); > $sth->execute($ordernumber ); >- $sth->finish; >- if ($biblionumber) { >- my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); >- foreach my $itemnumber (@itemnumbers){ >- C4::Items::DelItem( $dbh, $biblionumber, $itemnumber ); >- } >+# get the biblionumber (we need it to run DelItem >+ $query = qq{ >+ SELECT biblionumber >+ FROM aqorders >+ WHERE ordernumber = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($ordernumber ); >+ my $record = $sth->fetchrow_hashref; >+# delete items from items and aqorders_items tables >+ my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); >+ foreach my $itemnumber (@itemnumbers) { >+ $query = qq{ >+ DELETE FROM aqorders_items >+ WHERE aqorders_items.itemnumber = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($itemnumber ); >+ C4::Items::DelItem( $dbh, $record->{biblionumber}, $itemnumber ) if $record->{biblionumber}; > } > } > >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index 5a34856..a3aabae 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -323,7 +323,7 @@ if ( $orderinfo->{quantity} ne '0' ) { > > else { # qty=0, delete the line > my $biblionumber = $input->param('biblionumber'); >- DelOrder($$orderinfo{ordernumber}, $biblionumber ); >+ DelOrder($$orderinfo{ordernumber}); > if ($orderinfo->{delbiblio} == 1){ > DelBiblio($biblionumber); > } >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 8b737ba..0e742c1 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -7,8 +7,10 @@ use Modern::Perl; > use POSIX qw(strftime); > > use C4::Bookseller qw( GetBookSellerFromId ); >+use C4::Items qw (AddItem GetItem); >+use C4::Branch qw (ModBranch); > >-use Test::More tests => 60; >+use Test::More tests => 65; > > BEGIN { > use_ok('C4::Acquisition'); >@@ -220,4 +222,55 @@ is($order3->{'quantityreceived'}, 2, 'Order not split up'); > is($order3->{'quantity'}, 2, '2 items on order'); > is($order3->{'budget_id'}, $budgetid2, 'Budget has changed'); > >+# >+# test DelOrder >+# use: >+# &DelOrder($ordernumber); >+ >+# create 3 items on the same record and link 2 of them to the order >+ >+# Add a branch >+my $b1 = { >+ add => 1, >+ branchcode => 'BRA', >+ branchname => 'BranchA', >+ branchaddress1 => 'adr1A', >+ branchaddress2 => 'adr2A', >+ branchaddress3 => 'adr3A', >+ branchzip => 'zipA', >+ branchcity => 'cityA', >+ branchstate => 'stateA', >+ branchcountry => 'countryA', >+ branchphone => 'phoneA', >+ branchfax => 'faxA', >+ branchemail => 'emailA', >+ branchurl => 'urlA', >+ branchip => 'ipA', >+ branchprinter => undef, >+ branchnotes => 'noteA', >+ opac_info => 'opacA' >+}; >+ModBranch($b1); >+ >+my ($item_bibnum1, $item_bibitemnum1, $itemnumber1) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); >+my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); >+my ($item_bibnum3, $item_bibitemnum3, $itemnumber3) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); >+NewOrderItem ($itemnumber1, $ordernumber3); >+NewOrderItem ($itemnumber2, $ordernumber3); >+ >+# If no ordernumber is passed, the function returns undef and does not try to update database >+my $return_DelOrder = DelOrder (); >+is($return_DelOrder , undef, 'DelOrder returns undef with no param'); >+# Cancel the order with the given order, by filling the datecancellationprinted and orderstatus fields. >+DelOrder ($ordernumber3); >+$order3 = GetOrder( $ordernumber3 ); >+ok(($order3->{'orderstatus'} eq 'cancelled')&& (defined $order3->{'datecancellationprinted'}),'DelOrders update orderstatus and fill datecancellationprinted fields'); >+ >+# All the items linked with that order are deleted. >+is(scalar GetItemnumbersFromOrder($ordernumber3), 0, 'DelOrders delete items linked with cancelled order in aqorders_items table'); >+ok(!defined GetItem($itemnumber1) && !defined GetItem($itemnumber2), "DelOrder deletes items linked with order in items table"); >+ >+# Other items (created manually) are not deleted. >+is(GetItem($itemnumber3)->{biblionumber},$biblionumber2, "DelOrder does not delete item created manually"); >+ > $dbh->rollback; >-- >1.7.9.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10869
:
20970
|
21106
|
21294
|
21295
|
21480
|
22104
|
22299
|
22300
|
22342
|
22676
|
23839
|
24743
|
24744
|
24992
|
25000
|
25001
|
25002
|
25003
|
26692
|
26693
|
27270
|
27292
|
28516
|
29668
|
78862
|
78863
|
78864