Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, Config $taxConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory $classesFactory, \Magento\Tax\Model\ResourceModel\Calculation $resource, CustomerAccountManagement $customerAccountManagement, CustomerGroupManagement $customerGroupManagement, CustomerGroupRepository $customerGroupRepository, CustomerRepository $customerRepository, PriceCurrencyInterface $priceCurrency, SearchCriteriaBuilder $searchCriteriaBuilder, FilterBuilder $filterBuilder, TaxClassRepositoryInterface $taxClassRepository, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[]) | |
getDefaultCustomerTaxClass ($store=null) | |
deleteByRuleId ($ruleId) | |
getRates ($ruleId) | |
getCustomerTaxClasses ($ruleId) | |
getProductTaxClasses ($ruleId) | |
getRate ($request) | |
getStoreRate ($request, $store=null) | |
getDefaultRateRequest ($store=null, $customerId=null) | |
getRateRequest ( $shippingAddress=null, $billingAddress=null, $customerTaxClass=null, $store=null, $customerId=null) | |
getAppliedRates ($request) | |
reproduceProcess ($rates) | |
calcTaxAmount ($price, $taxRate, $priceIncludeTax=false, $round=true) | |
round ($price) | |
getTaxRates ($billingAddress, $shippingAddress, $customerTaxClassId) | |
![]() | |
__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 () | |
![]() | |
__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 | CALC_TAX_BEFORE_DISCOUNT_ON_EXCL = '0_0' |
const | CALC_TAX_BEFORE_DISCOUNT_ON_INCL = '0_1' |
const | CALC_TAX_AFTER_DISCOUNT_ON_EXCL = '1_0' |
const | CALC_TAX_AFTER_DISCOUNT_ON_INCL = '1_1' |
const | CALC_UNIT_BASE = 'UNIT_BASE_CALCULATION' |
const | CALC_ROW_BASE = 'ROW_BASE_CALCULATION' |
const | CALC_TOTAL_BASE = 'TOTAL_BASE_CALCULATION' |
Protected Member Functions | |
_construct () | |
_formCalculationProcess () | |
_getRequestCacheKey ($request) | |
getRateOriginRequest ($store=null) | |
_isCrossBorderTradeEnabled ($store=null) | |
![]() | |
_construct () | |
_init ($resourceModel) | |
_setResourceModel ($resourceName, $collectionName=null) | |
_getResource () | |
_getEventData () | |
_beforeLoad ($modelId, $field=null) | |
_afterLoad () | |
_hasModelChanged () | |
_getValidatorBeforeSave () | |
_createValidatorBeforeSave () | |
_getValidationRulesBeforeSave () | |
_clearReferences () | |
_clearData () | |
![]() | |
_getData ($key) | |
_underscore ($name) | |
Protected Attributes | |
$_rates = [] | |
$_ctc = [] | |
$_ptc = [] | |
$_rateCache = [] | |
$_rateCalculationProcess = [] | |
$_customer | |
$_defaultCustomerTaxClass | |
$_scopeConfig | |
$_storeManager | |
$_customerSession | |
$_customerFactory | |
$_classesFactory | |
$_config | |
$customerAccountManagement | |
$customerGroupManagement | |
$customerGroupRepository | |
$customerRepository | |
$priceCurrency | |
$filterBuilder | |
$searchCriteriaBuilder | |
$taxClassRepository | |
![]() | |
$_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 = [] | |
![]() | |
$_data = [] | |
Additional Inherited Members | |
![]() | |
static | $_underscoreCache = [] |
Tax Calculation Model @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Definition at line 27 of file Calculation.php.
__construct | ( | \Magento\Framework\Model\Context | $context, |
\Magento\Framework\Registry | $registry, | ||
\Magento\Framework\App\Config\ScopeConfigInterface | $scopeConfig, | ||
Config | $taxConfig, | ||
\Magento\Store\Model\StoreManagerInterface | $storeManager, | ||
\Magento\Customer\Model\Session | $customerSession, | ||
\Magento\Customer\Model\CustomerFactory | $customerFactory, | ||
\Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory | $classesFactory, | ||
\Magento\Tax\Model\ResourceModel\Calculation | $resource, | ||
CustomerAccountManagement | $customerAccountManagement, | ||
CustomerGroupManagement | $customerGroupManagement, | ||
CustomerGroupRepository | $customerGroupRepository, | ||
CustomerRepository | $customerRepository, | ||
PriceCurrencyInterface | $priceCurrency, | ||
SearchCriteriaBuilder | $searchCriteriaBuilder, | ||
FilterBuilder | $filterBuilder, | ||
TaxClassRepositoryInterface | $taxClassRepository, | ||
\Magento\Framework\Data\Collection\AbstractDb | $resourceCollection = null , |
||
array | $data = [] |
||
) |
\Magento\Framework\Model\Context | $context | |
\Magento\Framework\Registry | $registry | |
\Magento\Framework\App\Config\ScopeConfigInterface | $scopeConfig | |
Config | $taxConfig | |
\Magento\Store\Model\StoreManagerInterface | $storeManager | |
\Magento\Customer\Model\Session | $customerSession | |
\Magento\Customer\Model\CustomerFactory | $customerFactory | |
\Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory | $classesFactory | |
\Magento\Tax\Model\ResourceModel\Calculation | $resource | |
CustomerAccountManagement | $customerAccountManagement | |
CustomerGroupManagement | $customerGroupManagement | |
CustomerGroupRepository | $customerGroupRepository | |
CustomerRepository | $customerRepository | |
PriceCurrencyInterface | $priceCurrency | |
SearchCriteriaBuilder | $searchCriteriaBuilder | |
FilterBuilder | $filterBuilder | |
TaxClassRepositoryInterface | $taxClassRepository | |
\Magento\Framework\Data\Collection\AbstractDb | $resourceCollection | |
array | $data | @SuppressWarnings(PHPMD.ExcessiveParameterList) |
Definition at line 213 of file Calculation.php.
|
protected |
|
protected |
|
protected |
Get cache key value for specific tax rate request
\Magento\Framework\DataObject | $request |
Definition at line 387 of file Calculation.php.
|
protected |
Return whether cross border trade is enabled or not
null | int | string | Store | $store |
Definition at line 477 of file Calculation.php.
calcTaxAmount | ( | $price, | |
$taxRate, | |||
$priceIncludeTax = false , |
|||
$round = true |
|||
) |
Calculate rated tax amount based on price and tax rate. If you are using price including tax $priceIncludeTax should be true.
float | $price | |
float | $taxRate | |
boolean | $priceIncludeTax | |
boolean | $round |
Definition at line 661 of file Calculation.php.
deleteByRuleId | ( | $ruleId | ) |
Delete calculation settings by rule id
int | $ruleId |
Definition at line 281 of file Calculation.php.
getAppliedRates | ( | $request | ) |
Get information about tax rates applied to request
\Magento\Framework\DataObject | $request |
Definition at line 627 of file Calculation.php.
getCustomerTaxClasses | ( | $ruleId | ) |
Get allowed customer tax classes by rule id
int | $ruleId |
Definition at line 307 of file Calculation.php.
getDefaultCustomerTaxClass | ( | $store = null | ) |
Fetch default customer tax class
null | Store | string | int | $store |
Definition at line 265 of file Calculation.php.
getDefaultRateRequest | ( | $store = null , |
|
$customerId = null |
|||
) |
Return the default rate request. It can be either based on store address or customer address
null | int | string | Store | $store | |
int | $customerId |
Definition at line 461 of file Calculation.php.
getProductTaxClasses | ( | $ruleId | ) |
Get allowed product tax classes by rule id
int | $ruleId |
Definition at line 321 of file Calculation.php.
getRate | ( | $request | ) |
Get calculation tax rate by specific request
\Magento\Framework\DataObject | $request |
Definition at line 356 of file Calculation.php.
|
protected |
Get request object for getting tax rate based on store shipping original address
null | string | bool | int | Store | $store |
Definition at line 425 of file Calculation.php.
getRateRequest | ( | $shippingAddress = null , |
|
$billingAddress = null , |
|||
$customerTaxClass = null , |
|||
$store = null , |
|||
$customerId = null |
|||
) |
Get request object with information necessary for getting tax rate
Request object contain: country_id (->getCountryId()) region_id (->getRegionId()) postcode (->getPostcode()) customer_class_id (->getCustomerClassId()) store (->getStore())
null | bool | \Magento\Framework\DataObject | CustomerAddress | $shippingAddress | |
null | bool | \Magento\Framework\DataObject | CustomerAddress | $billingAddress | |
null | int | $customerTaxClass | |
null | int | \Magento\Store\Model\Store | $store | |
int | $customerId |
Definition at line 502 of file Calculation.php.
getRates | ( | $ruleId | ) |
Get calculation rates by rule id
int | $ruleId |
Definition at line 293 of file Calculation.php.
getStoreRate | ( | $request, | |
$store = null |
|||
) |
Get tax rate based on store shipping origin address settings This rate can be used for conversion store price including tax to store price excluding tax
\Magento\Framework\DataObject | $request | |
null | string | bool | int | Store | $store |
Definition at line 413 of file Calculation.php.
getTaxRates | ( | $billingAddress, | |
$shippingAddress, | |||
$customerTaxClassId | |||
) |
array | $billingAddress | |
array | $shippingAddress | |
int | $customerTaxClassId |
Definition at line 695 of file Calculation.php.
reproduceProcess | ( | $rates | ) |
Gets the calculation process
array | $rates |
Definition at line 646 of file Calculation.php.
round | ( | $price | ) |
Round tax amount
float | $price |
Definition at line 684 of file Calculation.php.
|
protected |
Definition at line 136 of file Calculation.php.
|
protected |
Definition at line 143 of file Calculation.php.
|
protected |
Definition at line 76 of file Calculation.php.
|
protected |
Definition at line 104 of file Calculation.php.
|
protected |
Definition at line 131 of file Calculation.php.
|
protected |
Definition at line 126 of file Calculation.php.
|
protected |
Definition at line 109 of file Calculation.php.
|
protected |
Definition at line 83 of file Calculation.php.
|
protected |
Definition at line 90 of file Calculation.php.
|
protected |
Definition at line 97 of file Calculation.php.
|
protected |
Definition at line 69 of file Calculation.php.
|
protected |
Definition at line 116 of file Calculation.php.
|
protected |
Definition at line 121 of file Calculation.php.
|
protected |
Definition at line 148 of file Calculation.php.
|
protected |
Definition at line 153 of file Calculation.php.
|
protected |
Definition at line 158 of file Calculation.php.
|
protected |
Definition at line 163 of file Calculation.php.
|
protected |
Definition at line 175 of file Calculation.php.
|
protected |
Definition at line 168 of file Calculation.php.
|
protected |
Definition at line 182 of file Calculation.php.
|
protected |
Definition at line 189 of file Calculation.php.
const CALC_ROW_BASE = 'ROW_BASE_CALCULATION' |
Identifier constant for row based calculation
Definition at line 57 of file Calculation.php.
const CALC_TAX_AFTER_DISCOUNT_ON_EXCL = '1_0' |
Identifier constant for Tax calculation after discount excluding TAX
Definition at line 42 of file Calculation.php.
const CALC_TAX_AFTER_DISCOUNT_ON_INCL = '1_1' |
Identifier constant for Tax calculation after discount including TAX
Definition at line 47 of file Calculation.php.
const CALC_TAX_BEFORE_DISCOUNT_ON_EXCL = '0_0' |
Identifier constant for Tax calculation before discount excluding TAX
Definition at line 32 of file Calculation.php.
const CALC_TAX_BEFORE_DISCOUNT_ON_INCL = '0_1' |
Identifier constant for Tax calculation before discount including TAX
Definition at line 37 of file Calculation.php.
const CALC_TOTAL_BASE = 'TOTAL_BASE_CALCULATION' |
Identifier constant for total based calculation
Definition at line 62 of file Calculation.php.
const CALC_UNIT_BASE = 'UNIT_BASE_CALCULATION' |
Identifier constant for unit based calculation
Definition at line 52 of file Calculation.php.