From: Janusz Dobrowolski Date: Fri, 23 Jul 2010 13:07:04 +0000 (+0000) Subject: Added upgrade from 2.3beta to 2.3RC. X-Git-Tag: v2.4.2~19^2~779 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=b9185a0190595e671a9750eb4e9f8e0bd6c713f9;p=fa-stable.git Added upgrade from 2.3beta to 2.3RC. --- diff --git a/sql/alter2.3.php b/sql/alter2.3.php index 44e161f6..fe455bfb 100644 --- a/sql/alter2.3.php +++ b/sql/alter2.3.php @@ -14,6 +14,7 @@ class fa2_3 { var $description; var $sql = 'alter2.3.sql'; var $preconf = true; + var $beta = false; // upgrade from 2.2 or 2.3beta; function fa2_3() { $this->description = _('Upgrade from version 2.2 to 2.3'); @@ -25,83 +26,97 @@ class fa2_3 { // function install($pref, $force) { - $sql = "SELECT debtor_no, payment_terms FROM {$pref}debtors_master"; + global $core_version; + + if (!$this->beta) { + // all specials below are already done on 2.3beta + + $sql = "SELECT debtor_no, payment_terms FROM {$pref}debtors_master"; - $result = db_query($sql); - if (!$result) { - display_error("Cannot read customers" - .':
'. db_error_msg($db)); - return false; - } - // update all sales orders and transactions with customer std payment terms - while($cust = db_fetch($result)) { - $sql = "UPDATE {$pref}debtor_trans SET " - ."payment_terms = '" .$cust['payment_terms'] - ."' WHERE debtor_no='".$cust['debtor_no']."'"; - if (db_query($sql)==false) { - display_error("Cannot update cust trans payment" + $result = db_query($sql); + if (!$result) { + display_error("Cannot read customers" .':
'. db_error_msg($db)); return false; } - $sql = "UPDATE {$pref}sales_orders SET " - ."payment_terms = '" .$cust['payment_terms'] - ."' WHERE debtor_no='".$cust['debtor_no']."'"; - if (db_query($sql)==false) { - display_error("Cannot update sales order payment" - .':
'. db_error_msg($db)); + // update all sales orders and transactions with customer std payment terms + while($cust = db_fetch($result)) { + $sql = "UPDATE {$pref}debtor_trans SET " + ."payment_terms = '" .$cust['payment_terms'] + ."' WHERE debtor_no='".$cust['debtor_no']."'"; + if (db_query($sql)==false) { + display_error("Cannot update cust trans payment" + .':
'. db_error_msg($db)); + return false; + } + $sql = "UPDATE {$pref}sales_orders SET " + ."payment_terms = '" .$cust['payment_terms'] + ."' WHERE debtor_no='".$cust['debtor_no']."'"; + if (db_query($sql)==false) { + display_error("Cannot update sales order payment" + .':
'. db_error_msg($db)); + return false; + } + } + if (!$this->update_totals($pref)) { + display_error("Cannot update order totals"); return false; } - } - if (!$this->update_totals($pref)) { - display_error("Cannot update order totals"); - return false; - } - if (!$this->update_line_relations($pref)) { - display_error("Cannot update sales document links"); - return false; - } - //remove obsolete and temporary columns. - // this have to be done here as db_import rearranges alter query order - $dropcol = array( - 'crm_persons' => array('tmp_id','tmp_class'), - 'debtors_master' => array('email'), - 'cust_branch' => array('phone', 'phone2', 'fax', 'email'), - 'suppliers' => array('phone', 'phone2', 'fax', 'email'), - 'debtor_trans' => array('trans_link') - ); - - foreach($dropcol as $table => $columns) - foreach($columns as $col) { - if (db_query("ALTER TABLE `{$pref}{$table}` DROP `$col`")==false) { - display_error("Cannot drop {$table}.{$col} column:
".db_error_msg($db)); + if (!$this->update_line_relations($pref)) { + display_error("Cannot update sales document links"); return false; } - } - // remove old preferences table after upgrade script has been executed - $sql = "DROP TABLE IF EXISTS `{$pref}company`"; + //remove obsolete and temporary columns. + // this have to be done here as db_import rearranges alter query order + $dropcol = array( + 'crm_persons' => array('tmp_id','tmp_class'), + 'debtors_master' => array('email'), + 'cust_branch' => array('phone', 'phone2', 'fax', 'email'), + 'suppliers' => array('phone', 'phone2', 'fax', 'email'), + 'debtor_trans' => array('trans_link') + ); - return db_query($sql) && update_company_prefs(array('version_id'=>'2.3'), $pref); + foreach($dropcol as $table => $columns) + foreach($columns as $col) { + if (db_query("ALTER TABLE `{$pref}{$table}` DROP `$col`")==false) { + display_error("Cannot drop {$table}.{$col} column:
".db_error_msg($db)); + return false; + } + } + // remove old preferences table after upgrade script has been executed + $sql = "DROP TABLE IF EXISTS `{$pref}company`"; + if (!db_query($sql)) + return false; + } + return update_company_prefs(array('version_id'=>$core_version), $pref); } // // Checking before install // function pre_check($pref, $force) { + if ($this->beta && !$force) + $this->sql = 'alter2.3rc.sql'; + return true; } // // Test if patch was applied before. // function installed($pref) { - $n = 3; // number of patches to be installed - $patchcnt = 0; + $this->beta = !check_table($pref, 'suppliers', 'tax_included'); - if (!check_table($pref, 'comments', 'type', array('Key'=>'MUL'))) $patchcnt++; - if (!check_table($pref, 'sys_prefs')) $patchcnt++; - if (!check_table($pref, 'sales_orders', 'payment_terms')) $patchcnt++; + $n = 1; // number of patches to be installed + $patchcnt = 0; - $n -= $patchcnt; - return $n == 0 ? true : $patchcnt; + if (!$this->beta) { + $n += 3; + if (!check_table($pref, 'comments', 'type', array('Key'=>'MUL'))) $patchcnt++; + if (!check_table($pref, 'sys_prefs')) $patchcnt++; + if (!check_table($pref, 'sales_orders', 'payment_terms')) $patchcnt++; + } + if (!check_table($pref, 'purch_orders', 'tax_included')) $patchcnt++; + return $n == $patchcnt ? true : ($patchcnt ? ($patchcnt.'/'. $n) : 0); } //========================================================================================= // 2.3 specific update functions diff --git a/sql/alter2.3.sql b/sql/alter2.3.sql index 65f1ef4b..496144d0 100644 --- a/sql/alter2.3.sql +++ b/sql/alter2.3.sql @@ -247,3 +247,5 @@ INSERT INTO `0_crm_contacts` (`person_id`, `type`, `action`, `entity_id`) ALTER TABLE `0_debtor_trans_details` ADD COLUMN `src_id` int(11) default NULL; ALTER TABLE `0_debtor_trans_details` ADD KEY (`src_id`); ALTER TABLE `0_suppliers` ADD COLUMN `tax_included` tinyint(1) NOT NULL default '0' AFTER `payment_terms`; +ALTER TABLE `0_supp_trans` ADD COLUMN `tax_included` tinyint(1) NOT NULL default '0'; +ALTER TABLE `0_purch_orders` ADD COLUMN `tax_included` tinyint(1) NOT NULL default '0'; diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index bdcfcb81..cd6fc572 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -1332,6 +1332,7 @@ CREATE TABLE IF NOT EXISTS `0_purch_orders` ( `into_stock_location` varchar(5) NOT NULL default '', `delivery_address` tinytext NOT NULL, `total` double NOT NULL default '0', + `tax_included` tinyint(1) NOT NULL default '0', PRIMARY KEY (`order_no`), KEY `ord_date` (`ord_date`) ) TYPE=InnoDB AUTO_INCREMENT=3 ; @@ -1340,8 +1341,8 @@ CREATE TABLE IF NOT EXISTS `0_purch_orders` ( -- Dumping data for table `0_purch_orders` -- -INSERT INTO `0_purch_orders` VALUES(1, 2, '', '2009-06-01', '1', '', 'DEF', 'Delivery 1\nDelivery 2\nDelivery 3', 0); -INSERT INTO `0_purch_orders` VALUES(2, 3, '', '2009-06-21', '2', '', 'DEF', 'Delivery 1\nDelivery 2\nDelivery 3', 0); +INSERT INTO `0_purch_orders` VALUES(1, 2, '', '2009-06-01', '1', '', 'DEF', 'Delivery 1\nDelivery 2\nDelivery 3', 0, 0); +INSERT INTO `0_purch_orders` VALUES(2, 3, '', '2009-06-21', '2', '', 'DEF', 'Delivery 1\nDelivery 2\nDelivery 3', 0, 0); -- -------------------------------------------------------- @@ -1975,6 +1976,7 @@ CREATE TABLE IF NOT EXISTS `0_supp_trans` ( `ov_gst` double NOT NULL default '0', `rate` double NOT NULL default '1', `alloc` double NOT NULL default '0', + `tax_included` tinyint(1) NOT NULL default '0', PRIMARY KEY (`type`,`trans_no`), KEY `supplier_id` (`supplier_id`), KEY `SupplierID_2` (`supplier_id`,`supp_reference`), @@ -1986,9 +1988,9 @@ CREATE TABLE IF NOT EXISTS `0_supp_trans` ( -- Dumping data for table `0_supp_trans` -- -INSERT INTO `0_supp_trans` VALUES(7, 20, 2, '1', '5t', '2009-06-21', '2009-07-01', 3300, 0, 165, 1, 3465); -INSERT INTO `0_supp_trans` VALUES(8, 20, 2, '2', 'cc', '2009-06-21', '2009-07-01', 20, 0, 0, 1, 0); -INSERT INTO `0_supp_trans` VALUES(4, 22, 2, '1', '', '2009-06-21', '2009-06-21', -3465, 0, 0, 1, 3465); +INSERT INTO `0_supp_trans` VALUES(7, 20, 2, '1', '5t', '2009-06-21', '2009-07-01', 3300, 0, 165, 1, 3465, 0); +INSERT INTO `0_supp_trans` VALUES(8, 20, 2, '2', 'cc', '2009-06-21', '2009-07-01', 20, 0, 0, 1, 0, 0); +INSERT INTO `0_supp_trans` VALUES(4, 22, 2, '1', '', '2009-06-21', '2009-06-21', -3465, 0, 0, 1, 3465, 0); -- -------------------------------------------------------- diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index e2a761c8..078442bc 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -1165,6 +1165,7 @@ CREATE TABLE IF NOT EXISTS `0_purch_orders` ( `into_stock_location` varchar(5) NOT NULL default '', `delivery_address` tinytext NOT NULL, `total` double NOT NULL default '0', + `tax_included` tinyint(1) NOT NULL default '0', PRIMARY KEY (`order_no`), KEY `ord_date` (`ord_date`) ) TYPE=InnoDB AUTO_INCREMENT=1 ; @@ -1739,6 +1740,7 @@ CREATE TABLE IF NOT EXISTS `0_supp_trans` ( `ov_gst` double NOT NULL default '0', `rate` double NOT NULL default '1', `alloc` double NOT NULL default '0', + `tax_included` tinyint(1) NOT NULL default '0', PRIMARY KEY (`type`,`trans_no`), KEY `supplier_id` (`supplier_id`), KEY `SupplierID_2` (`supplier_id`,`supp_reference`),