110 \
Magento\Eav\Model\Entity\AttributeFactory $attributeFactory,
112 \
Magento\
Tax\Model\CalculationFactory $calculationFactory,
113 \
Magento\Customer\Model\Session $customerSession,
122 $this->_attributeFactory = $attributeFactory;
124 $this->_calculationFactory = $calculationFactory;
125 $this->_customerSession = $customerSession;
127 $this->_taxData = $taxData;
156 $calculateTax =
false 196 $amountExclTax +=
$attribute->getAmountExclTax();
199 return $amountExclTax;
220 if (!$forceEnabled && !$this->weeeConfig->isEnabled(
$store)) {
224 if ($this->_allAttributes ===
null) {
225 $this->_allAttributes = $this->_attributeFactory->create()->getAttributeCodesByFrontendType(
'weee');
242 public function getProductWeeeAttributes(
247 $calculateTax =
null,
261 $websiteObject = $this->_storeManager->getWebsite(
$website);
263 $store = $websiteObject->getDefaultGroup()->getDefaultStore();
272 $calculator = $this->_calculationFactory->create();
274 $customerId = $this->_customerSession->getCustomerId();
275 if ($shipping && $shipping->getCountryId()) {
280 $shipping = $this->accountManagement->getDefaultShippingAddress(
$customerId);
281 $billing = $this->accountManagement->getDefaultBillingAddress(
$customerId);
284 $shippingAddressArray = $this->_customerSession->getDefaultTaxShippingAddress();
285 $billingAddressArray = $this->_customerSession->getDefaultTaxBillingAddress();
286 if (!empty($billingAddressArray)) {
287 $billing = new \Magento\Framework\DataObject($billingAddressArray);
289 if (!empty($shippingAddressArray)) {
290 $shipping = new \Magento\Framework\DataObject($shippingAddressArray);
296 $rateRequest = $calculator->getRateRequest(
303 $defaultRateRequest = $calculator->getDefaultRateRequest(
$store);
305 $productAttributes = $this->
getResource()->fetchWeeeTaxCalculationsByEntity(
306 $rateRequest->getCountryId(),
307 $rateRequest->getRegionId(),
319 if ($calculateTax && $this->weeeConfig->isTaxable(
$store)) {
321 $defaultPercent = $calculator->getRate(
322 $defaultRateRequest->setProductClassId(
$product->getTaxClassId())
324 $currentPercent = $calculator->getRate(
325 $rateRequest->setProductClassId(
$product->getTaxClassId())
327 if ($this->_taxData->priceIncludesTax(
$store)) {
328 $amountInclTax =
$value / (100 + $defaultPercent) * (100 + $currentPercent);
330 $amountInclTax = $this->priceCurrency->round($amountInclTax);
332 $taxAmount = $amountInclTax - $amountInclTax / (100 + $currentPercent) * 100;
338 $appliedRates = $this->_calculationFactory->create()->getAppliedRates($rateRequest);
339 if (is_array($appliedRates) && count($appliedRates) > 1) {
341 foreach ($appliedRates as $appliedRate) {
352 $value * $currentPercent / 100
361 $one = new \Magento\Framework\DataObject();
367 ->setAmountExclTax($amountExclTax)
getWeeeAmountExclTax( $product, $shipping=null, $billing=null, $website=null)
getWeeeTaxAttributeCodes($store=null, $forceEnabled=false)
isWeeeInLocation($countryId, $regionId, $websiteId)
getWeeeAttributeCodes($forceEnabled=false)
const DISPLAY_EXCL_DESCR_INCL
getWeeeAmount( $product, $shipping=null, $billing=null, $website=null, $calculateTax=false)
__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=[])