Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Tax Class Reference
Inheritance diagram for Tax:
AbstractModel DataObject

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Tax\Model\CalculationFactory $calculationFactory, \Magento\Customer\Model\Session $customerSession, AccountManagementInterface $accountManagement, \Magento\Tax\Helper\Data $taxData, \Magento\Weee\Model\ResourceModel\Tax $resource, \Magento\Weee\Model\Config $weeeConfig, PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getWeeeAmount ( $product, $shipping=null, $billing=null, $website=null, $calculateTax=false)
 
 getWeeeAmountExclTax ( $product, $shipping=null, $billing=null, $website=null)
 
 getWeeeAttributeCodes ($forceEnabled=false)
 
 getWeeeTaxAttributeCodes ($store=null, $forceEnabled=false)
 
 isWeeeInLocation ($countryId, $regionId, $websiteId)
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const DISPLAY_INCL = 0
 
const DISPLAY_INCL_DESCR = 1
 
const DISPLAY_EXCL_DESCR_INCL = 2
 
const DISPLAY_EXCL = 3
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_allAttributes = null
 
 $_taxData = null
 
 $_attributeFactory
 
 $_storeManager
 
 $_calculationFactory
 
 $_customerSession
 
 $weeeConfig
 
 $priceCurrency
 
 $accountManagement
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

@SuppressWarnings(PHPMD.CouplingBetweenObjects) @api

Since
100.0.2

Definition at line 20 of file Tax.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Eav\Model\Entity\AttributeFactory  $attributeFactory,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Tax\Model\CalculationFactory  $calculationFactory,
\Magento\Customer\Model\Session  $customerSession,
AccountManagementInterface  $accountManagement,
\Magento\Tax\Helper\Data  $taxData,
\Magento\Weee\Model\ResourceModel\Tax  $resource,
\Magento\Weee\Model\Config  $weeeConfig,
PriceCurrencyInterface  $priceCurrency,
\Magento\Framework\Data\Collection\AbstractDb  $resourceCollection = null,
array  $data = [] 
)
Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Eav\Model\Entity\AttributeFactory$attributeFactory
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Tax\Model\CalculationFactory$calculationFactory
\Magento\Customer\Model\Session$customerSession
AccountManagementInterface$accountManagement
\Magento\Tax\Helper\Data$taxData
\Magento\Weee\Model\ResourceModel\Tax$resource
Config$weeeConfig
PriceCurrencyInterface$priceCurrency
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 107 of file Tax.php.

121  {
122  $this->_attributeFactory = $attributeFactory;
123  $this->_storeManager = $storeManager;
124  $this->_calculationFactory = $calculationFactory;
125  $this->_customerSession = $customerSession;
126  $this->accountManagement = $accountManagement;
127  $this->_taxData = $taxData;
128  $this->weeeConfig = $weeeConfig;
129  $this->priceCurrency = $priceCurrency;
130  parent::__construct($context, $registry, $resource, $resourceCollection, $data);
131  }
$storeManager
$resource
Definition: bulk.php:12

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize resource

Returns
void

Definition at line 138 of file Tax.php.

◆ getWeeeAmount()

getWeeeAmount (   $product,
  $shipping = null,
  $billing = null,
  $website = null,
  $calculateTax = false 
)
Parameters
Product$product
null | false | \Magento\Framework\DataObject$shipping
null | false | \Magento\Framework\DataObject$billing
Website$website
bool$calculateTax
Returns
float

Definition at line 151 of file Tax.php.

157  {
158  $amount = 0;
159  $attributes = $this->getProductWeeeAttributes(
160  $product,
161  $shipping,
162  $billing,
163  $website,
164  $calculateTax
165  );
166  foreach ($attributes as $attribute) {
167  $amount += $attribute->getAmount();
168  }
169  return $amount;
170  }
$amount
Definition: order.php:14
$attributes
Definition: matrix.phtml:13

◆ getWeeeAmountExclTax()

getWeeeAmountExclTax (   $product,
  $shipping = null,
  $billing = null,
  $website = null 
)
Parameters
Product$product
null | false | \Magento\Framework\DataObject$shipping
null | false | \Magento\Framework\DataObject$billing
Website$website
Returns
float

Definition at line 179 of file Tax.php.

184  {
185  $amountExclTax = 0;
186  $attributes = $this->getProductWeeeAttributes(
187  $product,
188  $shipping,
189  $billing,
190  $website,
191  true,
192  false
193  );
194  if (Type::TYPE_BUNDLE !== $product->getTypeId() || $product->getPriceType()) {
195  foreach ($attributes as $attribute) {
196  $amountExclTax += $attribute->getAmountExclTax();
197  }
198  }
199  return $amountExclTax;
200  }
$attributes
Definition: matrix.phtml:13

◆ getWeeeAttributeCodes()

getWeeeAttributeCodes (   $forceEnabled = false)
Parameters
bool$forceEnabled
Returns
array

Definition at line 206 of file Tax.php.

207  {
208  return $this->getWeeeTaxAttributeCodes(null, $forceEnabled);
209  }
getWeeeTaxAttributeCodes($store=null, $forceEnabled=false)
Definition: Tax.php:218

◆ getWeeeTaxAttributeCodes()

getWeeeTaxAttributeCodes (   $store = null,
  $forceEnabled = false 
)

Retrieve Wee tax attribute codes

Parameters
null | string | bool | int | Store$store
bool$forceEnabled
Returns
array

Definition at line 218 of file Tax.php.

219  {
220  if (!$forceEnabled && !$this->weeeConfig->isEnabled($store)) {
221  return [];
222  }
223 
224  if ($this->_allAttributes === null) {
225  $this->_allAttributes = $this->_attributeFactory->create()->getAttributeCodesByFrontendType('weee');
226  }
227  return $this->_allAttributes;
228  }

◆ isWeeeInLocation()

isWeeeInLocation (   $countryId,
  $regionId,
  $websiteId 
)
Parameters
int$countryId
int$regionId
int$websiteId
Returns
boolean

Definition at line 382 of file Tax.php.

383  {
384  return $this->getResource()->isWeeeInLocation($countryId, $regionId, $websiteId);
385  }

Field Documentation

◆ $_allAttributes

$_allAttributes = null
protected

Definition at line 45 of file Tax.php.

◆ $_attributeFactory

$_attributeFactory
protected

Definition at line 57 of file Tax.php.

◆ $_calculationFactory

$_calculationFactory
protected

Definition at line 67 of file Tax.php.

◆ $_customerSession

$_customerSession
protected

Definition at line 72 of file Tax.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 62 of file Tax.php.

◆ $_taxData

$_taxData = null
protected

Definition at line 52 of file Tax.php.

◆ $accountManagement

$accountManagement
protected

Definition at line 89 of file Tax.php.

◆ $priceCurrency

$priceCurrency
protected

Definition at line 84 of file Tax.php.

◆ $weeeConfig

$weeeConfig
protected

Definition at line 79 of file Tax.php.

◆ DISPLAY_EXCL

const DISPLAY_EXCL = 3

Excluding FPT

Definition at line 40 of file Tax.php.

◆ DISPLAY_EXCL_DESCR_INCL

const DISPLAY_EXCL_DESCR_INCL = 2

Excluding FPT. Including FPT description and final price

Definition at line 35 of file Tax.php.

◆ DISPLAY_INCL

const DISPLAY_INCL = 0

Including FPT only

Definition at line 25 of file Tax.php.

◆ DISPLAY_INCL_DESCR

const DISPLAY_INCL_DESCR = 1

Including FPT and FPT description

Definition at line 30 of file Tax.php.


The documentation for this class was generated from the following file: