From 56989ae5aff33d76a79d365374e16b6e1bfba6da Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Wed, 17 May 2017 15:10:45 +0200
Subject: [PATCH] Add missing fields making not possible to enter reference
 price of products into another currency

---
 htdocs/install/mysql/migration/5.0.0-6.0.0.sql   | 16 ++++++++++++++++
 .../tables/llx_product_fournisseur_price.sql     |  8 +++++++-
 .../tables/llx_product_fournisseur_price_log.sql |  7 ++++++-
 .../install/mysql/tables/llx_product_price.sql   |  5 ++++-
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
index 88260498f28..6ba7707b249 100644
--- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
+++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
@@ -189,6 +189,22 @@ ALTER TABLE llx_cronjob ADD COLUMN processing integer NOT NULL DEFAULT 0;
 ALTER TABLE llx_website ADD COLUMN fk_user_create integer;
 ALTER TABLE llx_website ADD COLUMN fk_user_modif integer;
 
+-- Add missing fields making not possible to enter reference price of products into another currency
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN multicurrency_tx			double(24,8) DEFAULT 1;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN multicurrency_price_ttc	double(24,8) DEFAULT NULL;
+
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_multicurrency		 integer;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN multicurrency_code		 varchar(255);
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN multicurrency_tx	     double(24,8) DEFAULT 1;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN multicurrency_price	 double(24,8) DEFAULT NULL;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL;
+
+ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN fk_multicurrency		 integer;
+ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_code		 varchar(255);
+ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx	     double(24,8) DEFAULT 1;
+ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price	 double(24,8) DEFAULT NULL;
+ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL;
+
 
 create table llx_payment_various
 (
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
index 94032b784f4..f341b103edb 100755
--- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
+++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
@@ -43,5 +43,11 @@ create table llx_product_fournisseur_price
   fk_supplier_price_expression	integer,            -- Link to the rule for dynamic price calculation
   import_key			varchar(14),                -- Import key
   delivery_time_days    integer,
-  supplier_reputation varchar(10)
+  supplier_reputation varchar(10),
+  
+  fk_multicurrency		integer,
+  multicurrency_code	varchar(255),
+  multicurrency_tx			double(24,8) DEFAULT 1,
+  multicurrency_price	double(24,8) DEFAULT NULL,
+  multicurrency_price_ttc	double(24,8) DEFAULT NULL
 )ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price_log.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price_log.sql
index 3d54f9ef341..e9b78922413 100644
--- a/htdocs/install/mysql/tables/llx_product_fournisseur_price_log.sql
+++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price_log.sql
@@ -24,6 +24,11 @@ create table llx_product_fournisseur_price_log
   fk_product_fournisseur      integer      NOT NULL,
   price                       double(24,8) DEFAULT 0,
   quantity                    double,
-  fk_user                     integer
+  fk_user                     integer,
 
+  fk_multicurrency		integer,
+  multicurrency_code	varchar(255),
+  multicurrency_tx			double(24,8) DEFAULT 1,
+  multicurrency_price	double(24,8) DEFAULT NULL,
+  multicurrency_price_ttc	double(24,8) DEFAULT NULL
 )ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql
index ee2ee953c49..a7f9ba38751 100755
--- a/htdocs/install/mysql/tables/llx_product_price.sql
+++ b/htdocs/install/mysql/tables/llx_product_price.sql
@@ -46,6 +46,9 @@ create table llx_product_price
   
   fk_multicurrency		integer,
   multicurrency_code	varchar(255),
-  multicurrency_price	double(24,8) DEFAULT NULL
+  multicurrency_tx			double(24,8) DEFAULT 1,
+  multicurrency_price	double(24,8) DEFAULT NULL,
+  multicurrency_price_ttc	double(24,8) DEFAULT NULL
+  
 )ENGINE=innodb;
 
-- 
GitLab