Skip to content

Commit 4e751b6

Browse files
author
Yu Tang
committed
Merge remote-tracking branch 'origin/FearlessKiwis-MAGETWO-43291-YT' into FearlessKiwis-develop-no-refactoring
2 parents 0b5d877 + 867552e commit 4e751b6

File tree

24 files changed

+675
-152
lines changed

24 files changed

+675
-152
lines changed

app/code/Magento/Bundle/Pricing/Adjustment/BundleCalculatorInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ interface BundleCalculatorInterface extends CalculatorInterface
1717
/**
1818
* @param float|string $amount
1919
* @param Product $saleableItem
20-
* @param null|bool $exclude
20+
* @param null|bool|string|array $exclude
2121
* @return \Magento\Framework\Pricing\Amount\AmountInterface
2222
*/
2323
public function getMaxAmount($amount, Product $saleableItem, $exclude = null);
2424

2525
/**
2626
* @param float|string $amount
2727
* @param Product $saleableItem
28-
* @param null|bool $exclude
28+
* @param null|bool|string|array $exclude
2929
* @return \Magento\Framework\Pricing\Amount\AmountInterface
3030
*/
3131
public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = null);
3232

3333
/**
3434
* @param float|string $amount
3535
* @param Product $saleableItem
36-
* @param null|bool $exclude
36+
* @param null|bool|string|array $exclude
3737
* @return \Magento\Framework\Pricing\Amount\AmountInterface
3838
*/
3939
public function getMinRegularAmount($amount, Product $saleableItem, $exclude = null);
@@ -42,7 +42,7 @@ public function getMinRegularAmount($amount, Product $saleableItem, $exclude = n
4242
* Option amount calculation for saleable item
4343
*
4444
* @param Product $saleableItem
45-
* @param null|string $exclude
45+
* @param null|bool|string|array $exclude
4646
* @param bool $searchMin
4747
* @param \Magento\Framework\Pricing\Amount\AmountInterface|null $bundleProductAmount
4848
* @return \Magento\Framework\Pricing\Amount\AmountInterface
@@ -60,7 +60,7 @@ public function getOptionsAmount(
6060
* @param float $basePriceValue
6161
* @param Product $bundleProduct
6262
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
63-
* @param null|string $exclude code of adjustment that has to be excluded
63+
* @param null|bool|string|array $exclude code of adjustment that has to be excluded
6464
* @return \Magento\Framework\Pricing\Amount\AmountInterface
6565
*/
6666
public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null);

app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct(
7777
*
7878
* @param float|string $amount
7979
* @param SaleableInterface $saleableItem
80-
* @param null|string $exclude
80+
* @param null|bool|string|array $exclude
8181
* @param null|array $context
8282
* @return \Magento\Framework\Pricing\Amount\AmountInterface
8383
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -92,7 +92,7 @@ public function getAmount($amount, SaleableInterface $saleableItem, $exclude = n
9292
*
9393
* @param float $amount
9494
* @param Product $saleableItem
95-
* @param null|string $exclude
95+
* @param null|bool|string|array $exclude
9696
* @return \Magento\Framework\Pricing\Amount\AmountInterface
9797
*/
9898
public function getMinRegularAmount($amount, Product $saleableItem, $exclude = null)
@@ -105,7 +105,7 @@ public function getMinRegularAmount($amount, Product $saleableItem, $exclude = n
105105
*
106106
* @param float $amount
107107
* @param Product $saleableItem
108-
* @param null|string $exclude
108+
* @param null|bool|string|array $exclude
109109
* @return \Magento\Framework\Pricing\Amount\AmountInterface
110110
*/
111111
public function getMaxAmount($amount, Product $saleableItem, $exclude = null)
@@ -118,7 +118,7 @@ public function getMaxAmount($amount, Product $saleableItem, $exclude = null)
118118
*
119119
* @param float $amount
120120
* @param Product $saleableItem
121-
* @param null|string $exclude
121+
* @param null|bool|string|array $exclude
122122
* @return \Magento\Framework\Pricing\Amount\AmountInterface
123123
*/
124124
public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = null)
@@ -130,7 +130,7 @@ public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = n
130130
* Option amount calculation for bundle product
131131
*
132132
* @param Product $saleableItem
133-
* @param null|string $exclude
133+
* @param null|bool|string|array $exclude
134134
* @param bool $searchMin
135135
* @param float $baseAmount
136136
* @param bool $useRegularPrice
@@ -260,7 +260,7 @@ protected function getBundleOptions(Product $saleableItem)
260260
* @param float $basePriceValue
261261
* @param Product $bundleProduct
262262
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
263-
* @param null|string $exclude
263+
* @param null|bool|string|array $exclude
264264
* @return \Magento\Framework\Pricing\Amount\AmountInterface
265265
*/
266266
public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null)
@@ -278,7 +278,7 @@ public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectio
278278
* @param float $basePriceValue
279279
* @param Product $bundleProduct
280280
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
281-
* @param null|string $exclude
281+
* @param null|bool|string|arrayy $exclude
282282
* @return \Magento\Framework\Pricing\Amount\AmountInterface
283283
*/
284284
protected function calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude)
@@ -297,7 +297,7 @@ protected function calculateFixedBundleAmount($basePriceValue, $bundleProduct, $
297297
* @param float $basePriceValue
298298
* @param Product $bundleProduct
299299
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
300-
* @param null|string $exclude
300+
* @param null|bool|string|array $exclude
301301
* @return \Magento\Framework\Pricing\Amount\AmountInterface
302302
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
303303
*/
@@ -340,9 +340,18 @@ protected function calculateDynamicBundleAmount($basePriceValue, $bundleProduct,
340340
}
341341
}
342342
}
343-
if ($exclude && isset($adjustments[$exclude])) {
344-
$fullAmount -= $adjustments[$exclude];
345-
unset($adjustments[$exclude]);
343+
if (is_array($exclude) == false) {
344+
if ($exclude && isset($adjustments[$exclude])) {
345+
$fullAmount -= $adjustments[$exclude];
346+
unset($adjustments[$exclude]);
347+
}
348+
} else {
349+
foreach ($exclude as $oneExclusion) {
350+
if ($oneExclusion && isset($adjustments[$oneExclusion])) {
351+
$fullAmount -= $adjustments[$oneExclusion];
352+
unset($adjustments[$oneExclusion]);
353+
}
354+
}
346355
}
347356
return $this->amountFactory->create($fullAmount, $adjustments);
348357
}

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BundleSelectionPrice extends AbstractPrice
6868
* @param ManagerInterface $eventManager
6969
* @param DiscountCalculator $discountCalculator
7070
* @param bool $useRegularPrice
71-
* @param string $excludeAdjustment
71+
* @param array $excludeAdjustment
7272
*/
7373
public function __construct(
7474
Product $saleableItem,

app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CustomOptionPrice extends AbstractPrice implements CustomOptionPriceInterf
4141
* @param float $quantity
4242
* @param CalculatorInterface $calculator
4343
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
44-
* @param string $excludeAdjustment
44+
* @param array $excludeAdjustment
4545
*/
4646
public function __construct(
4747
SaleableInterface $saleableItem,
@@ -113,7 +113,7 @@ public function getValue()
113113

114114
/**
115115
* @param float $amount
116-
* @param null|bool|string $exclude
116+
* @param null|bool|string|array $exclude
117117
* @param null|array $context
118118
* @return AmountInterface|bool|float
119119
*/

app/code/Magento/Tax/Pricing/Render/Adjustment.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ public function displayBothPrices()
9191
*/
9292
public function getDisplayAmountExclTax($exclude = null, $includeContainer = false)
9393
{
94+
//If exclude is not supplied, use the default
95+
if ($exclude === null) {
96+
$exclude = $this->getDefaultExclusions();
97+
}
98+
9499
return $this->formatCurrency(
95100
$this->getRawAmount($exclude),
96101
$includeContainer

app/code/Magento/Weee/Helper/Data.php

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/**
1414
* WEEE data helper
15+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
1516
*/
1617
class Data extends \Magento\Framework\App\Helper\AbstractHelper
1718
{
@@ -195,7 +196,7 @@ public function displayTotalsInclTax($store = null)
195196
* @param mixed $website
196197
* @return float
197198
*/
198-
public function getAmount($product, $website = null)
199+
public function getAmountExclTax($product, $website = null)
199200
{
200201
if (!$product->hasData($this->cacheProductWeeeAmount)) {
201202
/** @var \Magento\Store\Model\Store $store */
@@ -207,7 +208,7 @@ public function getAmount($product, $website = null)
207208

208209
$amount = 0;
209210
if ($this->isEnabled($store)) {
210-
$amount = $this->_weeeTax->getWeeeAmount($product, null, null, $website);
211+
$amount = $this->_weeeTax->getWeeeAmountExclTax($product, null, null, $website);
211212
}
212213

213214
$product->setData($this->cacheProductWeeeAmount, $amount);
@@ -269,26 +270,29 @@ public function typeOfDisplay(
269270
/**
270271
* Proxy for \Magento\Weee\Model\Tax::getProductWeeeAttributes()
271272
*
272-
* @param \Magento\Catalog\Model\Product $product
273-
* @param null|false|\Magento\Framework\DataObject $shipping
274-
* @param null|false|\Magento\Framework\DataObject $billing
275-
* @param Website $website
276-
* @param bool $calculateTaxes
273+
* @param \Magento\Catalog\Model\Product $product
274+
* @param null|false|\Magento\Framework\DataObject $shipping
275+
* @param null|false|\Magento\Framework\DataObject $billing
276+
* @param Website $website
277+
* @param bool $calculateTaxes
278+
* @param bool $round
277279
* @return \Magento\Framework\DataObject[]
278280
*/
279281
public function getProductWeeeAttributes(
280282
$product,
281283
$shipping = null,
282284
$billing = null,
283285
$website = null,
284-
$calculateTaxes = false
286+
$calculateTaxes = false,
287+
$round = true
285288
) {
286289
return $this->_weeeTax->getProductWeeeAttributes(
287290
$product,
288291
$shipping,
289292
$billing,
290293
$website,
291-
$calculateTaxes
294+
$calculateTaxes,
295+
$round
292296
);
293297
}
294298

@@ -397,7 +401,8 @@ public function getProductWeeeAttributesForDisplay($product)
397401
$store = $product->getStore();
398402

399403
if ($this->isEnabled($store)) {
400-
return $this->getProductWeeeAttributes($product, null, null, null, $this->typeOfDisplay(1));
404+
$calculateTax = ($this->typeOfDisplay(1) || $this->typeOfDisplay(2)) ? 1 : 0;
405+
return $this->getProductWeeeAttributes($product, null, null, null, $calculateTax, false);
401406
}
402407
return [];
403408
}
@@ -438,45 +443,6 @@ public function getProductWeeeAttributesForRenderer(
438443
return [];
439444
}
440445

441-
/**
442-
* Returns amount to display
443-
*
444-
* @param \Magento\Catalog\Model\Product $product
445-
* @return int
446-
*/
447-
public function getAmountForDisplay($product)
448-
{
449-
/** @var \Magento\Store\Model\Store $store */
450-
$store = $product->getStore();
451-
452-
if ($this->isEnabled($store)) {
453-
return $this->_weeeTax->getWeeeAmount($product, null, null, null, $this->typeOfDisplay(1));
454-
}
455-
return 0;
456-
}
457-
458-
/**
459-
* Returns all summed WEEE taxes with all local taxes applied
460-
*
461-
* @param \Magento\Framework\DataObject[] $attributes Result from getProductWeeeAttributes()
462-
* @return float
463-
* @throws \Magento\Framework\Exception\LocalizedException
464-
*/
465-
public function getAmountInclTaxes($attributes)
466-
{
467-
if (!is_array($attributes)) {
468-
throw new \Magento\Framework\Exception\LocalizedException(__('$attributes must be an array'));
469-
}
470-
471-
$amount = 0;
472-
foreach ($attributes as $attribute) {
473-
/* @var $attribute \Magento\Framework\DataObject */
474-
$amount += $attribute->getAmountInclTax();
475-
}
476-
477-
return (float) $amount;
478-
}
479-
480446
/**
481447
* Get the weee tax including tax
482448
*
@@ -798,6 +764,17 @@ public function isDisplayExcl($storeId = null)
798764
);
799765
}
800766

767+
/**
768+
* Get tax price display settings
769+
*
770+
* @param null|string|bool|int|Store $store
771+
* @return int
772+
*/
773+
public function getTaxDisplayConfig($store = null)
774+
{
775+
return $this->_taxData->getPriceDisplayType($store);
776+
}
777+
801778
/**
802779
* Return an array of FPT attributes for a bundle product
803780
*

0 commit comments

Comments
 (0)