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

Public Member Functions

 __construct (WeeeHelper $weeeHelper, TaxHelper $taxHelper, PriceCurrencyInterface $priceCurrency, $sortOrder=null)
 
 getAdjustmentCode ()
 
 isIncludedInBasePrice ()
 
 isIncludedInDisplayPrice ()
 
 extractAdjustment ($amount, SaleableInterface $saleableItem, $context=[])
 
 applyAdjustment ($amount, SaleableInterface $saleableItem, $context=[])
 
 isExcludedWith ($adjustmentCode)
 
 getSortOrder ()
 

Data Fields

const ADJUSTMENT_CODE = 'weee_tax'
 

Protected Member Functions

 getAmount (SaleableInterface $saleableItem)
 

Protected Attributes

 $weeeHelper
 
 $taxHelper
 
 $sortOrder
 
 $priceCurrency
 

Detailed Description

Weee tax pricing adjustment

Definition at line 19 of file TaxAdjustment.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( WeeeHelper  $weeeHelper,
TaxHelper  $taxHelper,
PriceCurrencyInterface  $priceCurrency,
  $sortOrder = null 
)

Constructor

Parameters
WeeeHelper$weeeHelper
TaxHelper$taxHelper
PriceCurrencyInterface$priceCurrency
int$sortOrder

Definition at line 58 of file TaxAdjustment.php.

63  {
64  $this->weeeHelper = $weeeHelper;
65  $this->taxHelper = $taxHelper;
66  $this->priceCurrency = $priceCurrency;
67  $this->sortOrder = $sortOrder;
68  }

Member Function Documentation

◆ applyAdjustment()

applyAdjustment (   $amount,
SaleableInterface  $saleableItem,
  $context = [] 
)

Apply adjustment amount and return result value

Parameters
float$amount
SaleableInterface$saleableItem
null | array$context
Returns
float

Implements AdjustmentInterface.

Definition at line 132 of file TaxAdjustment.php.

133  {
135  return $amount;
136  }
137  return $amount + $this->getAmount($saleableItem);
138  }
getAmount(SaleableInterface $saleableItem)
$amount
Definition: order.php:14

◆ extractAdjustment()

extractAdjustment (   $amount,
SaleableInterface  $saleableItem,
  $context = [] 
)

Extract adjustment amount from the given amount value

Parameters
float$amount
SaleableInterface$saleableItem
null | array$context
Returns
float @SuppressWarnings(PHPMD.UnusedFormalParameter)

Implements AdjustmentInterface.

Definition at line 119 of file TaxAdjustment.php.

120  {
121  return 0;
122  }

◆ getAdjustmentCode()

getAdjustmentCode ( )

Get adjustment code

Returns
string

Implements AdjustmentInterface.

Definition at line 75 of file TaxAdjustment.php.

76  {
77  return self::ADJUSTMENT_CODE;
78  }

◆ getAmount()

getAmount ( SaleableInterface  $saleableItem)
protected

Obtain amount

Parameters
SaleableInterface$saleableItem
Returns
float

Definition at line 158 of file TaxAdjustment.php.

159  {
160  $weeeTaxAmount = 0;
161  $attributes = $this->weeeHelper->getProductWeeeAttributes($saleableItem, null, null, null, true, false);
162  if ($attributes != null) {
163  foreach ($attributes as $attribute) {
164  $weeeTaxAmount += $attribute->getData('tax_amount');
165  }
166  }
167  $weeeTaxAmount = $this->priceCurrency->convert($weeeTaxAmount);
168  return $weeeTaxAmount;
169  }
$attributes
Definition: matrix.phtml:13

◆ getSortOrder()

getSortOrder ( )

Return sort order position

Returns
int

Implements AdjustmentInterface.

Definition at line 176 of file TaxAdjustment.php.

177  {
178  return $this->sortOrder;
179  }

◆ isExcludedWith()

isExcludedWith (   $adjustmentCode)

Check if adjustment should be excluded from calculations along with the given adjustment

Parameters
string$adjustmentCode
Returns
bool

Implements AdjustmentInterface.

Definition at line 146 of file TaxAdjustment.php.

147  {
148  return (($adjustmentCode == self::ADJUSTMENT_CODE) ||
149  ($adjustmentCode == \Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE));
150  }

◆ isIncludedInBasePrice()

isIncludedInBasePrice ( )

Define if adjustment is included in base price (FPT is excluded from base price)

Returns
bool

Implements AdjustmentInterface.

Definition at line 86 of file TaxAdjustment.php.

87  {
88  return false;
89  }

◆ isIncludedInDisplayPrice()

isIncludedInDisplayPrice ( )

Define if adjustment is included in display price

Returns
bool

Implements AdjustmentInterface.

Definition at line 96 of file TaxAdjustment.php.

97  {
98  if ($this->taxHelper->displayPriceExcludingTax()) {
99  return false;
100  }
101  if ($this->weeeHelper->isEnabled() == true &&
102  $this->weeeHelper->isTaxable() == true &&
103  $this->weeeHelper->typeOfDisplay([\Magento\Weee\Model\Tax::DISPLAY_EXCL]) == false) {
104  return true;
105  } else {
106  return false;
107  }
108  }

Field Documentation

◆ $priceCurrency

$priceCurrency
protected

Definition at line 48 of file TaxAdjustment.php.

◆ $sortOrder

$sortOrder
protected

Definition at line 43 of file TaxAdjustment.php.

◆ $taxHelper

$taxHelper
protected

Definition at line 36 of file TaxAdjustment.php.

◆ $weeeHelper

$weeeHelper
protected

Definition at line 31 of file TaxAdjustment.php.

◆ ADJUSTMENT_CODE

const ADJUSTMENT_CODE = 'weee_tax'

Adjustment code weee

Definition at line 24 of file TaxAdjustment.php.


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