c92046e05c9ee3daaf5ce9159121a8342b5aa77e
[fa-stable.git] / sql / alter2.5.sql
1 # reliable cost change log in stock_moves
2 ALTER TABLE `0_stock_moves` CHANGE COLUMN `standard_cost` `unit_cost` double NOT NULL DEFAULT '0';
3 ALTER TABLE `0_debtor_trans_details` CHANGE COLUMN `standard_cost` `unit_cost` double NOT NULL DEFAULT '0';
4
5 # naming cleanups
6 ALTER TABLE `0_purch_orders` CHANGE COLUMN `requisition_no` `supp_reference` tinytext;
7
8 # cleanups in work orders
9 ALTER TABLE  `0_workorders` DROP INDEX `wo_ref`;
10 ALTER TABLE  `0_workorders` ADD KEY `wo_ref` (`wo_ref`);
11 ALTER TABLE  `0_workorders` DROP COLUMN `additional_costs`;
12
13 # improvements in tax systems support
14 ALTER TABLE `0_stock_category` ADD COLUMN  `vat_category` tinyint(1) NOT NULL DEFAULT '0' AFTER `dflt_no_purchase`;
15 ALTER TABLE `0_stock_master` ADD COLUMN  `vat_category` tinyint(1) NOT NULL DEFAULT '0' AFTER `fa_class_id`;
16 ALTER TABLE `0_trans_tax_details` ADD COLUMN  `vat_category` tinyint(1) NOT NULL DEFAULT '0' AFTER `reg_type`;
17 ALTER TABLE `0_trans_tax_details` ADD COLUMN `tax_group_id` int(11) DEFAULT NULL AFTER `vat_category`;
18
19 UPDATE `0_trans_tax_details` tax
20         LEFT JOIN `0_supp_trans` purch ON tax.trans_no=purch.trans_no AND tax.trans_type=purch.type
21         LEFT JOIN `0_suppliers` supp ON purch.supplier_id=supp.supplier_id
22         LEFT JOIN `0_debtor_trans` sales ON tax.trans_no=sales.trans_no AND tax.trans_type=sales.type
23         LEFT JOIN `0_cust_branch` cust ON sales.branch_code=cust.branch_code
24  SET tax.tax_group_id = IFNULL(supp.tax_group_id, cust.tax_group_id);
25
26 ALTER TABLE `0_tax_groups` ADD COLUMN `tax_area` tinyint(1) NOT NULL DEFAULT '0' AFTER `name`;