00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 $installer = $this;
00028
00029
00030 $installer->startSetup();
00031
00032 $installer->run("
00033
00034 /*Table structure for table `tax_class` */
00035
00036 -- DROP TABLE IF EXISTS {$this->getTable('tax_class')};
00037 CREATE TABLE {$this->getTable('tax_class')} (
00038 `class_id` smallint(6) NOT NULL auto_increment,
00039 `class_name` varchar(255) NOT NULL default '',
00040 `class_type` enum('CUSTOMER','PRODUCT') NOT NULL default 'CUSTOMER',
00041 PRIMARY KEY (`class_id`)
00042 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00043
00044 /*Data for the table `tax_class` */
00045
00046 insert into {$this->getTable('tax_class')}(`class_id`,`class_name`,`class_type`) values (2,'Taxable Goods','PRODUCT'),(3,'Retail Customer','CUSTOMER');
00047
00048 /*Table structure for table `tax_rate` */
00049
00050 -- DROP TABLE IF EXISTS {$this->getTable('tax_rate')};
00051
00052 CREATE TABLE {$this->getTable('tax_rate')} (
00053 `tax_rate_id` tinyint(4) NOT NULL auto_increment,
00054 `tax_county_id` smallint(6) default NULL,
00055 `tax_region_id` mediumint(9) unsigned default NULL,
00056 `tax_postcode` varchar(12) default NULL,
00057 PRIMARY KEY (`tax_rate_id`)
00058 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Base tax rates';
00059
00060 /*Data for the table `tax_rate` */
00061
00062 insert into {$this->getTable('tax_rate')}(`tax_rate_id`,`tax_county_id`,`tax_region_id`,`tax_postcode`) values (1,0,12,NULL),(2,0,43,NULL);
00063
00064 /*Table structure for table `tax_rate_data` */
00065
00066 -- DROP TABLE IF EXISTS {$this->getTable('tax_rate_data')};
00067
00068 CREATE TABLE {$this->getTable('tax_rate_data')} (
00069 `tax_rate_data_id` tinyint(4) NOT NULL auto_increment,
00070 `tax_rate_id` tinyint(4) NOT NULL default '0',
00071 `rate_value` decimal(12,4) NOT NULL default '0.0000',
00072 `rate_type_id` tinyint(4) NOT NULL default '0',
00073 PRIMARY KEY (`tax_rate_data_id`),
00074 KEY `rate_id` (`tax_rate_id`),
00075 KEY `rate_type_id` (`rate_type_id`),
00076 UNIQUE idx_rate_rate_type (tax_rate_id, rate_type_id),
00077 CONSTRAINT `FK_TAX_RATE_DATA_TAX_RATE` FOREIGN KEY (`tax_rate_id`) REFERENCES {$this->getTable('tax_rate')} (`tax_rate_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00078 CONSTRAINT `FK_TAX_RATE_DATE_TAX_RATE_TYPE` FOREIGN KEY (`rate_type_id`) REFERENCES {$this->getTable('tax_rate_type')} (`type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00079 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00080
00081 /*Data for the table `tax_rate_data` */
00082
00083 insert into {$this->getTable('tax_rate_data')}(`tax_rate_data_id`,`tax_rate_id`,`rate_value`,`rate_type_id`) values (6,2,8.3750,1),(7,2,0.0000,2),(8,2,0.0000,3),(9,2,0.0000,4),(10,2,0.0000,5),(31,1,8.2500,1),(32,1,0.0000,2),(33,1,0.0000,3),(34,1,0.0000,4),(35,1,0.0000,5);
00084
00085 /*Table structure for table `tax_rate_type` */
00086
00087 -- DROP TABLE IF EXISTS {$this->getTable('tax_rate_type')};
00088 CREATE TABLE {$this->getTable('tax_rate_type')} (
00089 `type_id` tinyint(4) NOT NULL auto_increment,
00090 `type_name` varchar(255) NOT NULL default '',
00091 PRIMARY KEY (`type_id`)
00092 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00093
00094 /*Data for the table `tax_rate_type` */
00095
00096 insert into {$this->getTable('tax_rate_type')}(`type_id`,`type_name`) values (1,'Rate 1'),(2,'Rate 2'),(3,'Rate 3'),(4,'Rate 4'),(5,'Rate 5');
00097
00098 /*Table structure for table `tax_rule` */
00099
00100 -- DROP TABLE IF EXISTS {$this->getTable('tax_rule')};
00101 CREATE TABLE {$this->getTable('tax_rule')} (
00102 `tax_rule_id` tinyint(4) NOT NULL auto_increment,
00103 `tax_customer_class_id` smallint(6) NOT NULL default '0',
00104 `tax_product_class_id` smallint(6) NOT NULL default '0',
00105 `tax_rate_type_id` tinyint(4) NOT NULL default '0',
00106 `tax_shipping` tinyint (1) NOT NULL default '0',
00107 PRIMARY KEY (`tax_rule_id`),
00108 KEY `tax_customer_class_id` (`tax_customer_class_id`,`tax_product_class_id`),
00109 KEY `tax_customer_class_id_2` (`tax_customer_class_id`),
00110 KEY `tax_product_class_id` (`tax_product_class_id`),
00111 KEY `tax_rate_id` (`tax_rate_type_id`),
00112 CONSTRAINT `FK_TAX_RULE_TAX_CLASS_CUSTOMER` FOREIGN KEY (`tax_customer_class_id`) REFERENCES {$this->getTable('tax_class')} (`class_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00113 CONSTRAINT `FK_TAX_RULE_TAX_CLASS_PRODUCT` FOREIGN KEY (`tax_product_class_id`) REFERENCES {$this->getTable('tax_class')} (`class_id`) ON DELETE CASCADE ON UPDATE CASCADE
00114 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00115
00116 /*Data for the table `tax_rule` */
00117
00118 insert into {$this->getTable('tax_rule')}(`tax_rule_id`,`tax_customer_class_id`,`tax_product_class_id`,`tax_rate_type_id`) values (1,3,2,1);
00119
00120 ");
00121
00122 $installer->endSetup();