Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Tax_Block_Adminhtml_Frontend_Region_Updater
  • Mage_Tax_Block_Checkout_Discount
  • Mage_Tax_Block_Checkout_Grandtotal
  • Mage_Tax_Block_Checkout_Shipping
  • Mage_Tax_Block_Checkout_Subtotal
  • Mage_Tax_Block_Checkout_Tax
  • Mage_Tax_Block_Sales_Order_Tax
  • Mage_Tax_Helper_Data
  • Mage_Tax_Model_Calculation
  • Mage_Tax_Model_Calculation_Rate
  • Mage_Tax_Model_Calculation_Rate_Title
  • Mage_Tax_Model_Calculation_Rule
  • Mage_Tax_Model_Class
  • Mage_Tax_Model_Class_Source_Customer
  • Mage_Tax_Model_Class_Source_Product
  • Mage_Tax_Model_Config
  • Mage_Tax_Model_Config_Price_Include
  • Mage_Tax_Model_Mysql4_Calculation
  • Mage_Tax_Model_Mysql4_Calculation_Collection
  • Mage_Tax_Model_Mysql4_Calculation_Rate
  • Mage_Tax_Model_Mysql4_Calculation_Rate_Collection
  • Mage_Tax_Model_Mysql4_Calculation_Rate_Title
  • Mage_Tax_Model_Mysql4_Calculation_Rate_Title_Collection
  • Mage_Tax_Model_Mysql4_Calculation_Rule
  • Mage_Tax_Model_Mysql4_Calculation_Rule_Collection
  • Mage_Tax_Model_Mysql4_Class
  • Mage_Tax_Model_Mysql4_Class_Collection
  • Mage_Tax_Model_Mysql4_Report_Collection
  • Mage_Tax_Model_Mysql4_Report_Tax
  • Mage_Tax_Model_Mysql4_Report_Updatedat_Collection
  • Mage_Tax_Model_Mysql4_Sales_Order_Tax
  • Mage_Tax_Model_Mysql4_Sales_Order_Tax_Collection
  • Mage_Tax_Model_Mysql4_Setup
  • Mage_Tax_Model_Observer
  • Mage_Tax_Model_Resource_Calculation
  • Mage_Tax_Model_Resource_Calculation_Collection
  • Mage_Tax_Model_Resource_Calculation_Rate
  • Mage_Tax_Model_Resource_Calculation_Rate_Collection
  • Mage_Tax_Model_Resource_Calculation_Rate_Title
  • Mage_Tax_Model_Resource_Calculation_Rate_Title_Collection
  • Mage_Tax_Model_Resource_Calculation_Rule
  • Mage_Tax_Model_Resource_Calculation_Rule_Collection
  • Mage_Tax_Model_Resource_Class
  • Mage_Tax_Model_Resource_Class_Collection
  • Mage_Tax_Model_Resource_Report_Collection
  • Mage_Tax_Model_Resource_Report_Tax
  • Mage_Tax_Model_Resource_Report_Tax_Createdat
  • Mage_Tax_Model_Resource_Report_Tax_Updatedat
  • Mage_Tax_Model_Resource_Report_Updatedat_Collection
  • Mage_Tax_Model_Resource_Sales_Order_Tax
  • Mage_Tax_Model_Resource_Sales_Order_Tax_Collection
  • Mage_Tax_Model_Resource_Sales_Order_Tax_Item
  • Mage_Tax_Model_Resource_Sales_Order_Tax_Item_Collection
  • Mage_Tax_Model_Resource_Setup
  • Mage_Tax_Model_Sales_Order_Tax
  • Mage_Tax_Model_Sales_Order_Tax_Item
  • Mage_Tax_Model_Sales_Pdf_Grandtotal
  • Mage_Tax_Model_Sales_Pdf_Shipping
  • Mage_Tax_Model_Sales_Pdf_Subtotal
  • Mage_Tax_Model_Sales_Pdf_Tax
  • Mage_Tax_Model_Sales_Total_Quote_Discount
  • Mage_Tax_Model_Sales_Total_Quote_Nominal_Subtotal
  • Mage_Tax_Model_Sales_Total_Quote_Nominal_Tax
  • Mage_Tax_Model_Sales_Total_Quote_Shipping
  • Mage_Tax_Model_Sales_Total_Quote_Subtotal
  • Mage_Tax_Model_Sales_Total_Quote_Tax
  • Mage_Tax_Model_System_Config_Source_Algorithm
  • Mage_Tax_Model_System_Config_Source_Apply
  • Mage_Tax_Model_System_Config_Source_PriceType
  • Mage_Tax_Model_System_Config_Source_Tax_Country
  • Mage_Tax_Model_System_Config_Source_Tax_Display_Type
  • Mage_Tax_Model_System_Config_Source_Tax_Region

Exceptions

  • Mage_Tax_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Tax
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Tax rule collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Tax
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Tax_Model_Resource_Calculation_Rule_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 36: {
 37:     /**
 38:      * Resource initialization
 39:      */
 40:     protected function _construct()
 41:     {
 42:         $this->_init('tax/calculation_rule');
 43:     }
 44: 
 45:     /**
 46:      * Join calculation data to result
 47:      *
 48:      * @param string $alias table alias
 49:      * @return Mage_Tax_Model_Resource_Calculation_Rule_Collection
 50:      */
 51:     public function joinCalculationData($alias)
 52:     {
 53:         $this->getSelect()->joinLeft(
 54:             array($alias => $this->getTable('tax/tax_calculation')),
 55:             "main_table.tax_calculation_rule_id = {$alias}.tax_calculation_rule_id",
 56:             array()
 57:         );
 58:         $this->getSelect()->group('main_table.tax_calculation_rule_id');
 59: 
 60:         return $this;
 61:     }
 62: 
 63:     /**
 64:      * Join tax data to collection
 65:      *
 66:      * @param string $itemTable
 67:      * @param string $primaryJoinField
 68:      * @param string $secondaryJoinField
 69:      * @param string $titleField
 70:      * @param string $dataField
 71:      * @return Mage_Tax_Model_Resource_Calculation_Rule_Collection
 72:      */
 73:     protected function _add($itemTable, $primaryJoinField, $secondaryJoinField, $titleField, $dataField)
 74:     {
 75:         $children = array();
 76:         foreach ($this as $rule) {
 77:             $children[$rule->getId()] = array();
 78:         }
 79:         if (!empty($children)) {
 80:             $joinCondition = sprintf('item.%s = calculation.%s', $secondaryJoinField, $primaryJoinField);
 81:             $select = $this->getConnection()->select()
 82:                 ->from(
 83:                     array('calculation' => $this->getTable('tax/tax_calculation')),
 84:                     array('calculation.tax_calculation_rule_id')
 85:                 )
 86:                 ->join(
 87:                     array('item' => $this->getTable($itemTable)),
 88:                     $joinCondition,
 89:                     array("item.{$titleField}", "item.{$secondaryJoinField}")
 90:                 )
 91:                 ->where('calculation.tax_calculation_rule_id IN (?)', array_keys($children))
 92:                 ->distinct(true);
 93: 
 94:             $data = $this->getConnection()->fetchAll($select);
 95:             foreach ($data as $row) {
 96:                $children[$row['tax_calculation_rule_id']][$row[$secondaryJoinField]] = $row[$titleField];
 97:             }
 98:         }
 99: 
100:         foreach ($this as $rule) {
101:             if (isset($children[$rule->getId()])) {
102:                 $rule->setData($dataField, array_keys($children[$rule->getId()]));
103:             }
104:         }
105: 
106:         return $this;
107:     }
108: 
109:     /**
110:      * Add product tax classes to result
111:      *
112:      * @return Mage_Tax_Model_Resource_Calculation_Rule_Collection
113:      */
114:     public function addProductTaxClassesToResult()
115:     {
116:         return $this->_add('tax_class', 'product_tax_class_id', 'class_id', 'class_name', 'product_tax_classes');
117:     }
118: 
119:     /**
120:      * Add customer tax classes to result
121:      *
122:      * @return Mage_Tax_Model_Resource_Calculation_Rule_Collection
123:      */
124:     public function addCustomerTaxClassesToResult()
125:     {
126:         return $this->_add('tax_class', 'customer_tax_class_id', 'class_id', 'class_name', 'customer_tax_classes');
127:     }
128: 
129:     /**
130:      * Add rates to result
131:      *
132:      * @return Mage_Tax_Model_Resource_Calculation_Rule_Collection
133:      */
134:     public function addRatesToResult()
135:     {
136:         return $this->_add('tax_calculation_rate', 'tax_calculation_rate_id', 'tax_calculation_rate_id', 'code', 'tax_rates');
137:     }
138: 
139:     /**
140:      * Add class type filter
141:      *
142:      * @param string $type
143:      * @param int $id
144:      * @throws Mage_Core_Exception
145:      * @return Mage_Tax_Model_Resource_Calculation_Rule_Collection
146:      */
147:     public function setClassTypeFilter($type, $id)
148:     {
149:         switch ($type) {
150:             case Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT:
151:                 $field = 'cd.product_tax_class_id';
152:                 break;
153:             case Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER:
154:                 $field = 'cd.customer_tax_class_id';
155:                 break;
156:             default:
157:                 Mage::throwException('Invalid type supplied');
158:         }
159: 
160:         $this->joinCalculationData('cd');
161:         $this->addFieldToFilter($field, $id);
162:         return $this;
163:     }
164: }
165: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0