From 25adf52334917ceb6e67109a4041984dc2837e14 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 28 Oct 2016 14:28:40 +0000 Subject: [PATCH] Bug 13323 - DBRev 16.06.00.043 Signed-off-by: Kyle M Hall --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_13323.perl | 51 ------------------- installer/data/mysql/updatedatabase.pl | 51 +++++++++++++++++++ 3 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_13323.perl diff --git a/Koha.pm b/Koha.pm index e84c37ea04..5b59f99c6a 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "16.06.00.042"; +$VERSION = "16.06.00.043"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_13323.perl b/installer/data/mysql/atomicupdate/bug_13323.perl deleted file mode 100644 index e74c2f6841..0000000000 --- a/installer/data/mysql/atomicupdate/bug_13323.perl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env perl - -use Modern::Perl; -use C4::Context; - -my $dbh = C4::Context->dbh; - -# Add the new columns -$dbh->do(q| - ALTER TABLE aqorders - ADD COLUMN tax_rate_on_ordering decimal(6,4) default NULL AFTER tax_rate, - ADD COLUMN tax_rate_on_receiving decimal(6,4) default NULL AFTER tax_rate_on_ordering, - ADD COLUMN tax_value_on_ordering decimal(28,6) default NULL AFTER tax_value, - ADD COLUMN tax_value_on_receiving decimal(28,6) default NULL AFTER tax_value_on_ordering -|); - -my $orders = $dbh->selectall_arrayref(q| - SELECT * FROM aqorders -|, { Slice => {} } ); - -my $sth_update_order = $dbh->prepare(q| - UPDATE aqorders - SET tax_rate_on_ordering = tax_rate, - tax_rate_on_receiving = tax_rate, - tax_value_on_ordering = ?, - tax_value_on_receiving = ? - WHERE ordernumber = ? -|); - -require Koha::Number::Price; -for my $order (@$orders) { - my $tax_value_on_ordering = - $order->{quantity} * - $order->{ecost_tax_excluded} * - $order->{tax_rate}; - - my $tax_value_on_receiving = - ( defined $order->{unitprice_tax_excluded} ) - ? $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate} - : undef; - - $sth_update_order->execute( $tax_value_on_ordering, - $tax_value_on_receiving, $order->{ordernumber} ); -} - -# Remove the old columns -$dbh->do(q| - ALTER TABLE aqorders - CHANGE COLUMN tax_value tax_value_bak decimal(28,6) default NULL, - CHANGE COLUMN tax_rate tax_rate_bak decimal(6,4) default NULL -|); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 308f33dd6e..7666dbc8ec 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -13526,6 +13526,57 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = '16.06.00.043'; +if ( CheckVersion($DBversion) ) { + # Add the new columns + $dbh->do(q| + ALTER TABLE aqorders + ADD COLUMN tax_rate_on_ordering decimal(6,4) default NULL AFTER tax_rate, + ADD COLUMN tax_rate_on_receiving decimal(6,4) default NULL AFTER tax_rate_on_ordering, + ADD COLUMN tax_value_on_ordering decimal(28,6) default NULL AFTER tax_value, + ADD COLUMN tax_value_on_receiving decimal(28,6) default NULL AFTER tax_value_on_ordering + |); + + my $orders = $dbh->selectall_arrayref(q| + SELECT * FROM aqorders + |, { Slice => {} } ); + + my $sth_update_order = $dbh->prepare(q| + UPDATE aqorders + SET tax_rate_on_ordering = tax_rate, + tax_rate_on_receiving = tax_rate, + tax_value_on_ordering = ?, + tax_value_on_receiving = ? + WHERE ordernumber = ? + |); + + require Koha::Number::Price; + for my $order (@$orders) { + my $tax_value_on_ordering = + $order->{quantity} * + $order->{ecost_tax_excluded} * + $order->{tax_rate}; + + my $tax_value_on_receiving = + ( defined $order->{unitprice_tax_excluded} ) + ? $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate} + : undef; + + $sth_update_order->execute( $tax_value_on_ordering, + $tax_value_on_receiving, $order->{ordernumber} ); + } + + # Remove the old columns + $dbh->do(q| + ALTER TABLE aqorders + CHANGE COLUMN tax_value tax_value_bak decimal(28,6) default NULL, + CHANGE COLUMN tax_rate tax_rate_bak decimal(6,4) default NULL + |); + + print "Upgrade to $DBversion done (Bug 13323 - Change the tax rate on receiving)\n"; + SetVersion($DBversion); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5