Bugzilla – Attachment 33869 Details for
Bug 13323
Change the tax rate on receiving
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13323: Tax rate can change on receiving - DB changes
Bug-13323-Tax-rate-can-change-on-receiving---DB-ch.patch (text/plain), 4.23 KB, created by
Jonathan Druart
on 2014-11-24 16:27:19 UTC
(
hide
)
Description:
Bug 13323: Tax rate can change on receiving - DB changes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-11-24 16:27:19 UTC
Size:
4.23 KB
patch
obsolete
>From 67d6d26935fa6deed63df310085263e3edf2fc1b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 19 Nov 2014 16:59:39 +0100 >Subject: [PATCH] Bug 13323: Tax rate can change on receiving - DB changes > >This patch adds 4 new DB fields to the aqorders table: > * tax_rate_on_ordering > * tax_rate_on_receiving > * tax_value_on_ordering > * tax_value_on_receiving >--- > installer/data/mysql/kohastructure.sql | 8 +++-- > installer/data/mysql/updatedatabase.pl | 55 ++++++++++++++++++++++++++++++++++ > 2 files changed, 61 insertions(+), 2 deletions(-) > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index af9c95c..5ec28bf 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3067,8 +3067,12 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items > `ecost` decimal(13,2) DEFAULT NULL, -- the replacement cost for this line item > `ecost_tax_excluded` decimal(28,6) default NULL, -- the estimated cost excluding tax > `ecost_tax_included` decimal(28,6) default NULL, -- the estimated cost including tax >- `tax_rate` decimal(6,4) DEFAULT NULL, -- the tax rate for this line item (%) >- `tax_value` decimal(28,6) default NULL, -- the tax value for this line item >+ `tax_rate_bak` decimal(6,4) DEFAULT NULL, -- the tax rate for this line item (%) >+ `tax_rate_on_ordering` decimal(6,4) DEFAULT NULL, -- the tax rate on ordering for this line item (%) >+ `tax_rate_on_receiving` decimal(6,4) DEFAULT NULL, -- the tax rate on receiving for this line item (%) >+ `tax_value_bak` decimal(28,6) default NULL, -- the tax value for this line item >+ `tax_value_on_ordering` decimal(28,6) DEFAULT NULL, -- the tax value on ordering for this line item >+ `tax_value_on_receiving` decimal(28,6) DEFAULT NULL, -- the tax value on receiving for this line item > `discount` float(6,4) default NULL, -- the discount for this line item (%) > `budget_id` int(11) NOT NULL, -- the fund this order goes against (aqbudgets.budget_id) > `budgetgroup_id` int(11) NOT NULL, -- not used? always zero >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 9a94d97..dc33491 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -9635,6 +9635,61 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = '3.17.00.XXX'; >+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 XXXXX - Tax rate can change on receiving)\n"; >+ SetVersion($DBversion); >+ >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >-- >2.1.0
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 13323
:
33869
|
33870
|
33871
|
47495
|
47496
|
47499
|
48874
|
48875
|
48876
|
51982
|
51983
|
51984
|
56096
|
56097
|
56098
|
56387
|
56433
|
56434
|
56435
|
56436
|
56894
|
56895
|
56896
|
56897