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:  * Tax totals modification block. Can be used just as subblock of Mage_Sales_Block_Order_Totals
 29:  */
 30: class Mage_Tax_Block_Sales_Order_Tax extends Mage_Core_Block_Template
 31: {
 32:     /**
 33:      * Tax configuration model
 34:      *
 35:      * @var Mage_Tax_Model_Config
 36:      */
 37:     protected $_config;
 38:     protected $_order;
 39:     protected $_source;
 40: 
 41:     /**
 42:      * Initialize configuration object
 43:      */
 44:     protected function _construct()
 45:     {
 46:         $this->_config = Mage::getSingleton('tax/config');
 47:     }
 48: 
 49:     /**
 50:      * Check if we nedd display full tax total info
 51:      *
 52:      * @return bool
 53:      */
 54:     public function displayFullSummary()
 55:     {
 56:         return $this->_config->displaySalesFullSummary($this->getOrder()->getStore());
 57:     }
 58: 
 59:     /**
 60:      * Get data (totals) source model
 61:      *
 62:      * @return Varien_Object
 63:      */
 64:     public function getSource()
 65:     {
 66:         return $this->_source;
 67:     }
 68: 
 69:     /**
 70:      * Initialize all order totals relates with tax
 71:      *
 72:      * @return Mage_Tax_Block_Sales_Order_Tax
 73:      */
 74:     public function initTotals()
 75:     {
 76:         /** @var $parent Mage_Adminhtml_Block_Sales_Order_Invoice_Totals */
 77:         $parent = $this->getParentBlock();
 78:         $this->_order   = $parent->getOrder();
 79:         $this->_source  = $parent->getSource();
 80: 
 81:         $store = $this->getStore();
 82:         $allowTax = ($this->_source->getTaxAmount() > 0) || ($this->_config->displaySalesZeroTax($store));
 83:         $grandTotal = (float) $this->_source->getGrandTotal();
 84:         if (!$grandTotal || ($allowTax && !$this->_config->displaySalesTaxWithGrandTotal($store))) {
 85:             $this->_addTax();
 86:         }
 87: 
 88:         $this->_initSubtotal();
 89:         $this->_initShipping();
 90:         $this->_initDiscount();
 91:         $this->_initGrandTotal();
 92:         return $this;
 93:     }
 94: 
 95:     /**
 96:      * Add tax total string
 97:      *
 98:      * @param string $after
 99:      * @return Mage_Tax_Block_Sales_Order_Tax
100:      */
101:     protected function _addTax($after='discount')
102:     {
103:         $taxTotal = new Varien_Object(array(
104:             'code'      => 'tax',
105:             'block_name'=> $this->getNameInLayout()
106:         ));
107:         $this->getParentBlock()->addTotal($taxTotal, $after);
108:         return $this;
109:     }
110: 
111:     /**
112:      * Get order store object
113:      *
114:      * @return Mage_Core_Model_Store
115:      */
116:     public function getStore()
117:     {
118:         return $this->_order->getStore();
119:     }
120: 
121:     protected function _initSubtotal()
122:     {
123:         $store  = $this->getStore();
124:         $parent = $this->getParentBlock();
125:         $subtotal = $parent->getTotal('subtotal');
126:         if (!$subtotal) {
127:             return $this;
128:         }
129:         if ($this->_config->displaySalesSubtotalBoth($store)) {
130:             $subtotal       = (float) $this->_source->getSubtotal();
131:             $baseSubtotal   = (float) $this->_source->getBaseSubtotal();
132:             $subtotalIncl   = (float) $this->_source->getSubtotalInclTax();
133:             $baseSubtotalIncl= (float) $this->_source->getBaseSubtotalInclTax();
134: 
135:             if (!$subtotalIncl) {
136:                 $subtotalIncl = $subtotal+ $this->_source->getTaxAmount()
137:                     - $this->_source->getShippingTaxAmount();
138:             }
139:             if (!$baseSubtotalIncl) {
140:                 $baseSubtotalIncl = $baseSubtotal + $this->_source->getBaseTaxAmount()
141:                     - $this->_source->getBaseShippingTaxAmount();
142:             }
143:             $subtotalIncl = max(0, $subtotalIncl);
144:             $baseSubtotalIncl = max(0, $baseSubtotalIncl);
145:             $totalExcl = new Varien_Object(array(
146:                 'code'      => 'subtotal_excl',
147:                 'value'     => $subtotal,
148:                 'base_value'=> $baseSubtotal,
149:                 'label'     => $this->__('Subtotal (Excl.Tax)')
150:             ));
151:             $totalIncl = new Varien_Object(array(
152:                 'code'      => 'subtotal_incl',
153:                 'value'     => $subtotalIncl,
154:                 'base_value'=> $baseSubtotalIncl,
155:                 'label'     => $this->__('Subtotal (Incl.Tax)')
156:             ));
157:             $parent->addTotal($totalExcl, 'subtotal');
158:             $parent->addTotal($totalIncl, 'subtotal_excl');
159:             $parent->removeTotal('subtotal');
160:         } elseif ($this->_config->displaySalesSubtotalInclTax($store)) {
161:             $subtotalIncl   = (float) $this->_source->getSubtotalInclTax();
162:             $baseSubtotalIncl= (float) $this->_source->getBaseSubtotalInclTax();
163: 
164:             if (!$subtotalIncl) {
165:                 $subtotalIncl = $this->_source->getSubtotal()
166:                     + $this->_source->getTaxAmount()
167:                     - $this->_source->getShippingTaxAmount();
168:             }
169:             if (!$baseSubtotalIncl) {
170:                 $baseSubtotalIncl = $this->_source->getBaseSubtotal()
171:                     + $this->_source->getBaseTaxAmount()
172:                     - $this->_source->getBaseShippingTaxAmount();
173:             }
174: 
175:             $total = $parent->getTotal('subtotal');
176:             if ($total) {
177:                 $total->setValue(max(0, $subtotalIncl));
178:                 $total->setBaseValue(max(0, $baseSubtotalIncl));
179:             }
180:         }
181:         return $this;
182:     }
183: 
184:     protected function _initShipping()
185:     {
186:         $store  = $this->getStore();
187:         $parent = $this->getParentBlock();
188:         $shipping = $parent->getTotal('shipping');
189:         if (!$shipping) {
190:             return $this;
191:         }
192: 
193:         if ($this->_config->displaySalesShippingBoth($store)) {
194:             $shipping           = (float) $this->_source->getShippingAmount();
195:             $baseShipping       = (float) $this->_source->getBaseShippingAmount();
196:             $shippingIncl       = (float) $this->_source->getShippingInclTax();
197:             if (!$shippingIncl) {
198:                 $shippingIncl   = $shipping + (float) $this->_source->getShippingTaxAmount();
199:             }
200:             $baseShippingIncl   = (float) $this->_source->getBaseShippingInclTax();
201:             if (!$baseShippingIncl) {
202:                 $baseShippingIncl = $baseShipping + (float) $this->_source->getBaseShippingTaxAmount();
203:             }
204: 
205:             $totalExcl = new Varien_Object(array(
206:                 'code'      => 'shipping',
207:                 'value'     => $shipping,
208:                 'base_value'=> $baseShipping,
209:                 'label'     => $this->__('Shipping & Handling (Excl.Tax)')
210:             ));
211:             $totalIncl = new Varien_Object(array(
212:                 'code'      => 'shipping_incl',
213:                 'value'     => $shippingIncl,
214:                 'base_value'=> $baseShippingIncl,
215:                 'label'     => $this->__('Shipping & Handling (Incl.Tax)')
216:             ));
217:             $parent->addTotal($totalExcl, 'shipping');
218:             $parent->addTotal($totalIncl, 'shipping');
219:         } elseif ($this->_config->displaySalesShippingInclTax($store)) {
220:             $shippingIncl       = $this->_source->getShippingInclTax();
221:             if (!$shippingIncl) {
222:                 $shippingIncl = $this->_source->getShippingAmount()
223:                     + $this->_source->getShippingTaxAmount();
224:             }
225:             $baseShippingIncl   = $this->_source->getBaseShippingInclTax();
226:             if (!$baseShippingIncl) {
227:                 $baseShippingIncl = $this->_source->getBaseShippingAmount()
228:                     + $this->_source->getBaseShippingTaxAmount();
229:             }
230:             $total = $parent->getTotal('shipping');
231:             if ($total) {
232:                 $total->setValue($shippingIncl);
233:                 $total->setBaseValue($baseShippingIncl);
234:             }
235:         }
236:         return $this;
237:     }
238: 
239:     protected function _initDiscount()
240:     {
241: //        $store  = $this->getStore();
242: //        $parent = $this->getParentBlock();
243: //        if ($this->_config->displaySales) {
244: //
245: //        } elseif ($this->_config->displaySales) {
246: //
247: //        }
248:     }
249: 
250:     protected function _initGrandTotal()
251:     {
252:         $store  = $this->getStore();
253:         $parent = $this->getParentBlock();
254:         $grandototal = $parent->getTotal('grand_total');
255:         if (!$grandototal || !(float)$this->_source->getGrandTotal()) {
256:             return $this;
257:         }
258: 
259:         if ($this->_config->displaySalesTaxWithGrandTotal($store)) {
260:             $grandtotal         = $this->_source->getGrandTotal();
261:             $baseGrandtotal     = $this->_source->getBaseGrandTotal();
262:             $grandtotalExcl     = $grandtotal - $this->_source->getTaxAmount();
263:             $baseGrandtotalExcl = $baseGrandtotal - $this->_source->getBaseTaxAmount();
264:             $grandtotalExcl     = max($grandtotalExcl, 0);
265:             $baseGrandtotalExcl = max($baseGrandtotalExcl, 0);
266:             $totalExcl = new Varien_Object(array(
267:                 'code'      => 'grand_total',
268:                 'strong'    => true,
269:                 'value'     => $grandtotalExcl,
270:                 'base_value'=> $baseGrandtotalExcl,
271:                 'label'     => $this->__('Grand Total (Excl.Tax)')
272:             ));
273:             $totalIncl = new Varien_Object(array(
274:                 'code'      => 'grand_total_incl',
275:                 'strong'    => true,
276:                 'value'     => $grandtotal,
277:                 'base_value'=> $baseGrandtotal,
278:                 'label'     => $this->__('Grand Total (Incl.Tax)')
279:             ));
280:             $parent->addTotal($totalExcl, 'grand_total');
281:             $this->_addTax('grand_total');
282:             $parent->addTotal($totalIncl, 'tax');
283:         }
284:         return $this;
285:     }
286: 
287:     public function getOrder()
288:     {
289:         return $this->_order;
290:     }
291: 
292:     public function getLabelProperties()
293:     {
294:         return $this->getParentBlock()->getLabelProperties();
295:     }
296: 
297:     public function getValueProperties()
298:     {
299:         return $this->getParentBlock()->getValueProperties();
300:     }
301: }
302: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0