From da0337b374c5824c0f9edcb3e8545c812644ff63 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 4 Apr 2013 12:04:46 +0200 Subject: [PATCH] Bug 9987: Remove DB field aqorders.biblioitemnunmber The DB field aqorders.biblioitemnumber seems to be unused except to get the itype on the spent.pl page. This information can be retrieved uising another SQL join. Test plan: Try a complete workflow in the acquisition module: create an order, receive it, play with the syspref AcqCreateItem. Check that no regression is found and that the data for existing orders don't change. Signed-off-by: Mathieu Saby Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 65 ++----------------- C4/Letters.pm | 2 +- acqui/addorder.pl | 4 +- acqui/finishreceive.pl | 1 - acqui/neworderempty.pl | 1 - acqui/orderreceive.pl | 1 - acqui/spent.pl | 7 +- installer/data/mysql/kohastructure.sql | 1 - installer/data/mysql/updatedatabase.pl | 8 +++ .../prog/en/modules/acqui/neworderempty.tt | 1 - .../prog/en/modules/acqui/orderreceive.tt | 1 - t/db_dependent/lib/KohaTest/Acquisition.pm | 1 - 12 files changed, 18 insertions(+), 75 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index b6fab5de81..e406d81618 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -54,9 +54,9 @@ BEGIN { &GetBasketgroups &ReOpenBasketgroup &NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders &GetOrdersByBiblionumber - &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber + &GetLateOrders &GetOrderFromItemnumber &SearchOrder &GetHistory &GetRecentAcqui - &ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber + &ModReceiveOrder &CancelReceipt &GetCancelledOrders &GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid &NewOrderItem &ModOrderItem &ModItemOrder @@ -993,39 +993,6 @@ sub GetOrdersByBiblionumber { #------------------------------------------------------------# -=head3 GetOrderNumber - - $ordernumber = &GetOrderNumber($biblioitemnumber, $biblionumber); - -Looks up the ordernumber with the given biblionumber and biblioitemnumber. - -Returns the number of this order. - -=over - -=item C<$ordernumber> is the order number. - -=back - -=cut - -sub GetOrderNumber { - my ( $biblionumber,$biblioitemnumber ) = @_; - my $dbh = C4::Context->dbh; - my $query = " - SELECT ordernumber - FROM aqorders - WHERE biblionumber=? - AND biblioitemnumber=? - "; - my $sth = $dbh->prepare($query); - $sth->execute( $biblionumber, $biblioitemnumber ); - - return $sth->fetchrow; -} - -#------------------------------------------------------------# - =head3 GetOrder $order = &GetOrder($ordernumber); @@ -1142,7 +1109,7 @@ Else, the upcoming July 1st is used. =item defaults entrydate to Now -The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "biblioitemnumber", "rrp", "ecost", "gstrate", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "budget_id". +The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "rrp", "ecost", "gstrate", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "budget_id". =back @@ -1313,29 +1280,6 @@ sub ModItemOrder { #------------------------------------------------------------# - -=head3 ModOrderBibliotemNumber - - &ModOrderBiblioitemNumber($biblioitemnumber,$ordernumber, $biblionumber); - -Modifies the biblioitemnumber for an existing order. -Updates the order with order number C<$ordernum> and biblionumber C<$biblionumber>. - -=cut - -#FIXME: is this used at all? -sub ModOrderBiblioitemNumber { - my ($biblioitemnumber,$ordernumber, $biblionumber) = @_; - my $dbh = C4::Context->dbh; - my $query = " - UPDATE aqorders - SET biblioitemnumber = ? - WHERE ordernumber = ? - AND biblionumber = ?"; - my $sth = $dbh->prepare($query); - $sth->execute( $biblioitemnumber, $ordernumber, $biblionumber ); -} - =head3 GetCancelledOrders my @orders = GetCancelledOrders($basketno, $orderby); @@ -1377,8 +1321,7 @@ sub GetCancelledOrders { =head3 ModReceiveOrder &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user, - $unitprice, $invoiceid, $biblioitemnumber, - $bookfund, $rrp, \@received_itemnumbers); + $cost, $ecost, $invoiceid, rrp, budget_id, datereceived, \@received_itemnumbers); Updates an order, to reflect the fact that it was received, at least in part. All arguments not mentioned below update the fields with the diff --git a/C4/Letters.pm b/C4/Letters.pm index 0349efe6c1..d36c29ff41 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -323,7 +323,7 @@ sub SendAlerts { FROM aqorders LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber - LEFT JOIN biblioitems ON aqorders.biblioitemnumber=biblioitems.biblioitemnumber + LEFT JOIN biblioitems ON aqorders.biblionumber=biblioitems.biblionumber LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id WHERE aqorders.ordernumber IN ( } diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 077adaf0c1..42324aad86 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -162,7 +162,6 @@ my $user = $input->remote_user; # modify if $quantity>=0 and $existing='yes' # delete if $quantity has been set to 0 by the librarian # delete biblio if delbiblio has been set to 1 by the librarian -my $bibitemnum; if ( $orderinfo->{quantity} ne '0' ) { #TODO:check to see if biblio exists unless ( $$orderinfo{biblionumber} ) { @@ -194,8 +193,7 @@ if ( $orderinfo->{quantity} ne '0' ) { if ($$orderinfo{suggestionid}) { ModSuggestion( {suggestionid=>$$orderinfo{suggestionid}, STATUS=>'ORDERED', biblionumber=>$biblionumber} ); } - $orderinfo->{biblioitemnumber}=$bibitemnum; - $orderinfo->{biblionumber}=$biblionumber; + $orderinfo->{biblionumber}=$biblionumber; } $orderinfo->{unitprice} = $orderinfo->{ecost} if not defined $orderinfo->{unitprice} or $orderinfo->{unitprice} eq ''; diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 5ca2c98c33..f9c85320e6 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -40,7 +40,6 @@ checkauth($input, 0, $flagsrequired, 'intranet'); my $user = $input->remote_user; my $biblionumber = $input->param('biblionumber'); -my $biblioitemnumber = $input->param('biblioitemnumber'); my $ordernumber = $input->param('ordernumber'); my $origquantityrec = $input->param('origquantityrec'); my $quantityrec = $input->param('quantityrec'); diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index ce96ff39b2..9c9eed387f 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -379,7 +379,6 @@ $template->param( biblionumber => $biblionumber, uncertainprice => $data->{'uncertainprice'}, authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'}, - biblioitemnumber => $data->{'biblioitemnumber'}, discount_2dp => sprintf( "%.2f", $bookseller->{'discount'} ) , # for display discount => $bookseller->{'discount'}, orderdiscount_2dp => sprintf( "%.2f", $data->{'discount'} || 0 ), diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index fc79ccbba4..8fc760b02b 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -198,7 +198,6 @@ $template->param( count => 1, biblionumber => $order->{'biblionumber'}, ordernumber => $order->{'ordernumber'}, - biblioitemnumber => $order->{'biblioitemnumber'}, subscriptionid => $order->{subscriptionid}, booksellerid => $order->{'booksellerid'}, freight => $freight, diff --git a/acqui/spent.pl b/acqui/spent.pl index 2d555f9a76..c3c4693afb 100755 --- a/acqui/spent.pl +++ b/acqui/spent.pl @@ -67,15 +67,16 @@ SELECT datereceived, aqorders.biblionumber FROM (aqorders, aqbasket) -LEFT JOIN items ON - items.biblioitemnumber=aqorders.biblioitemnumber LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber +LEFT JOIN items ON + biblio.biblionumber = items.biblionumber LEFT JOIN aqorders_items ON - aqorders.ordernumber=aqorders_items.ordernumber + items.itemnumber = aqorders_items.itemnumber LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid WHERE + aqorders.ordernumber=aqorders_items.ordernumber AND aqorders.basketno=aqbasket.basketno AND budget_id=? AND (datecancellationprinted IS NULL OR diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index d7eebddfdc..f5e1862b19 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2914,7 +2914,6 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items `supplierreference` mediumtext, -- not used? always NULL `purchaseordernumber` mediumtext, -- not used? always NULL `basketno` int(11) default NULL, -- links this order line to a specific basket (aqbasket.basketno) - `biblioitemnumber` int(11) default NULL, -- links this order line the biblioitems table (biblioitems.biblioitemnumber) `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order line was last modified `rrp` decimal(13,2) default NULL, -- the replacement cost for this line item `ecost` decimal(13,2) default NULL, -- the estimated cost for this line item diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5963d24228..1b99a9ee0d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7010,6 +7010,14 @@ CREATE TABLE IF NOT EXISTS borrower_files ( SetVersion($DBversion); } + +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("ALTER TABLE aqorders DROP COLUMN biblioitemnumber"); + print "Upgrade to $DBversion done (Bug 9987 - Drop column aqorders.biblioitemnumber)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index 87cfa8a1bb..47ee2624a7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -228,7 +228,6 @@ $(document).ready(function() - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index a65236db40..0f454c066c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -265,7 +265,6 @@ - diff --git a/t/db_dependent/lib/KohaTest/Acquisition.pm b/t/db_dependent/lib/KohaTest/Acquisition.pm index c859038efc..3f0b789cd5 100644 --- a/t/db_dependent/lib/KohaTest/Acquisition.pm +++ b/t/db_dependent/lib/KohaTest/Acquisition.pm @@ -22,7 +22,6 @@ sub methods : Test( 1 ) { CloseBasket GetPendingOrders GetOrders - GetOrderNumber GetOrder NewOrder ModOrder -- 2.39.5