You are here

uc_taxes.install in Ubercart 6.2

Same filename and directory in other branches
  1. 5 uc_taxes/uc_taxes.install
  2. 7.3 uc_taxes/uc_taxes.install

Install, update and uninstall functions for the uc_taxes module.

File

uc_taxes/uc_taxes.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the uc_taxes module.
 */

/**
 * Implements hook_schema().
 */
function uc_taxes_schema() {
  $schema = array();
  $schema['uc_taxes'] = array(
    'description' => 'Stores tax information.',
    'fields' => array(
      'id' => array(
        'description' => 'Primary key: Unique tax rate id.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The tax rate name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'rate' => array(
        'description' => 'The tax rate multiplier.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'shippable' => array(
        'description' => 'Flag that describes how this rate applies to shippable and non-shippable products. 0 => Disregard shipability. 1 => Apply tax to shippable products only.',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'taxed_product_types' => array(
        'description' => 'Serialized array of node types to be taxed.',
        'type' => 'text',
        'serialize' => TRUE,
      ),
      'taxed_line_items' => array(
        'description' => 'Serialized array of line item types to be taxed.',
        'type' => 'text',
        'serialize' => TRUE,
      ),
      'weight' => array(
        'description' => 'The weight of this tax rate in relation to other rates.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function uc_taxes_install() {
  drupal_install_schema('uc_taxes');

  // Increase the module weight so taxes are calculated after other line items.
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'uc_taxes'");
}

/**
 * Implements hook_uninstall().
 */
function uc_taxes_uninstall() {
  drupal_uninstall_schema('uc_taxes');
}

/**
 * Implements hook_update_last_removed().
 */
function uc_taxes_update_last_removed() {
  return 7;
}
function uc_taxes_update_6000() {
  $ret = array();
  db_drop_primary_key($ret, 'uc_taxes');
  db_change_field($ret, 'uc_taxes', 'id', 'id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'id',
    ),
  ));
  return $ret;
}

/**
 * Change to signed floats.
 */
function uc_taxes_update_6001() {
  $ret = array();
  $schema = array(
    'rate' => array(
      'description' => 'The rate of taxation.',
      'type' => 'float',
      'not null' => TRUE,
      'default' => 0.0,
    ),
  );
  db_change_field($ret, 'uc_taxes', 'rate', 'rate', $schema['rate']);
  return $ret;
}
function uc_taxes_update_6002() {
  $ret = array();
  if (!db_column_exists('uc_taxes', 'shippable')) {
    db_add_field($ret, 'uc_taxes', 'shippable', array(
      'type' => 'int',
      'size' => 'tiny',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
    ));
  }
  return $ret;
}

/**
 * Increase the module weight so taxes are calculated after other line items.
 */
function uc_taxes_update_6003() {
  $ret = array();
  $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'uc_taxes'");
  return $ret;
}

Functions

Namesort descending Description
uc_taxes_install Implements hook_install().
uc_taxes_schema Implements hook_schema().
uc_taxes_uninstall Implements hook_uninstall().
uc_taxes_update_6000
uc_taxes_update_6001 Change to signed floats.
uc_taxes_update_6002
uc_taxes_update_6003 Increase the module weight so taxes are calculated after other line items.
uc_taxes_update_last_removed Implements hook_update_last_removed().