You are here

commerce_reports_tax.install in Commerce Reporting 7.4

Install, update, and uninstall functions for the commerce_reports_tax module.

File

modules/tax/commerce_reports_tax.install
View source
<?php

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

/**
 * Implements hook_schema().
 */
function commerce_reports_tax_schema() {
  $schema = array();
  $schema['commerce_reports_tax'] = array(
    'description' => 'Information about the tax rates applied to individual orders.',
    'fields' => array(
      'tax_rate' => array(
        'description' => 'The machine-name of the applied rate.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
      ),
      'order_id' => array(
        'description' => 'Order ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'currency_code' => array(
        'description' => 'The currency of the taxes collected, as per the currency of the total order amount.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'taxable' => array(
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The orders taxable amount.',
      ),
      'taxed' => array(
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The applied amount of tax.',
      ),
    ),
    'primary key' => array(
      'tax_rate',
      'order_id',
      'currency_code',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function commerce_reports_tax_uninstall() {
  variable_del('commerce_reports_tax_order_generate_statuses');
  variable_del('commerce_reports_tax_order_statuses');
  variable_del('commerce_reports_tax_batch_finished');
}

/**
 * Changes to the database structure.
 */
function commerce_reports_tax_update_7300(&$sandbox) {

  // Delete all tables that existed in the alpha4 release.
  $previous_tables = array(
    'commerce_reports_tax',
    'commerce_reports_tax_rate_orders',
    'commerce_reports_tax_rate_aggregate',
    'commerce_reports_tax_rate',
  );
  foreach ($previous_tables as $table) {
    if (db_table_exists($table)) {
      db_drop_table($table);
    }
  }

  // Install the new database schema.
  drupal_install_schema('commerce_reports_tax');
}

/**
 * Recommendation that users regenerate all tax information.
 */
function commerce_reports_tax_update_7401(&$sandbox) {
  drupal_set_message(t('This Commerce Tax Reporting update fixed a bug that sometimes rounded cents incorrectly in tax reports. It is highly recommended that you manually <a href="/admin/commerce/config/tax-reports">regenerate all tax information</a>.'), 'warning');
}

Functions

Namesort descending Description
commerce_reports_tax_schema Implements hook_schema().
commerce_reports_tax_uninstall Implements hook_uninstall().
commerce_reports_tax_update_7300 Changes to the database structure.
commerce_reports_tax_update_7401 Recommendation that users regenerate all tax information.