Skip to content

Commit f7226f8

Browse files
author
Tang, Yu(ytang1)
committed
Merge pull request #246 from magento-fearless-kiwis/develop
[FearlessKiwis] Bug Fixes
2 parents 3f148f9 + b895ea1 commit f7226f8

File tree

29 files changed

+326
-495
lines changed

29 files changed

+326
-495
lines changed

app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ require([
5050
showTime: false,
5151
showHour: false,
5252
showMinute: false,
53-
localTimezone: <?php /* @escapeNotVerified */ echo $block->getTimezoneOffsetSeconds() ?>,
54-
serverTimezoneSeconds:<?php /* @escapeNotVerified */ echo $block->getStoreTimestamp() ?>,
5553
yearRange: '<?php /* @escapeNotVerified */ echo $block->getYearRange() ?>'
5654
}
5755
});

app/code/Magento/Weee/Block/Item/Price/Renderer.php

100644100755
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ public function getUnitDisplayPriceExclTax()
196196
*/
197197
public function getBaseUnitDisplayPriceExclTax()
198198
{
199-
$basePriceExclTax = $this->getItem()->getBasePrice();
199+
$orderItem = $this->getItem();
200+
if ($orderItem instanceof InvoiceItem || $orderItem instanceof CreditMemoItem) {
201+
$orderItem = $orderItem->getOrderItem();
202+
}
203+
204+
$qty = $orderItem->getQtyOrdered();
205+
$basePriceExclTax = $orderItem->getBaseRowTotal() / $qty;
200206

201207
if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
202208
return $basePriceExclTax;
@@ -338,7 +344,13 @@ public function getFinalUnitDisplayPriceExclTax()
338344
*/
339345
public function getBaseFinalUnitDisplayPriceExclTax()
340346
{
341-
$basePriceExclTax = $this->getItem()->getBasePrice();
347+
$orderItem = $this->getItem();
348+
if ($orderItem instanceof InvoiceItem || $orderItem instanceof CreditMemoItem) {
349+
$orderItem = $orderItem->getOrderItem();
350+
}
351+
352+
$qty = $orderItem->getQtyOrdered();
353+
$basePriceExclTax = $orderItem->getBaseRowTotal() / $qty;
342354

343355
if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
344356
return $basePriceExclTax;

app/code/Magento/Weee/Block/Sales/Order/Totals.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ public function initTotals()
4848
$store = $this->getSource()->getStore();
4949

5050
$weeeTotal = $this->weeeData->getTotalAmounts($items, $store);
51+
$weeeBaseTotal = $this->weeeData->getBaseTotalAmounts($items, $store);
5152
if ($weeeTotal) {
5253
// Add our total information to the set of other totals
5354
$total = new \Magento\Framework\DataObject(
5455
[
5556
'code' => $this->getNameInLayout(),
5657
'label' => __('FPT'),
5758
'value' => $weeeTotal,
59+
'base_value' => $weeeBaseTotal
5860
]
5961
);
6062
if ($this->getBeforeCondition()) {

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

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,27 @@ public function getTotalAmounts($items, $store = null)
704704
return $weeeTotal;
705705
}
706706

707+
/**
708+
* Returns the base total amount of FPT across all items. Used for displaying the FPT totals line item.
709+
*
710+
* @param \Magento\Quote\Model\Quote\Item\AbstractItem[] $items
711+
* @param null|string|bool|int|Store $store
712+
* @return float
713+
*/
714+
public function getBaseTotalAmounts($items, $store = null)
715+
{
716+
$baseWeeeTotal = 0;
717+
$displayTotalsInclTax = $this->displayTotalsInclTax($store);
718+
foreach ($items as $item) {
719+
if ($displayTotalsInclTax) {
720+
$baseWeeeTotal += $this->getBaseRowWeeeTaxInclTax($item);
721+
} else {
722+
$baseWeeeTotal += $item->getBaseWeeeTaxAppliedRowAmount();
723+
}
724+
}
725+
return $baseWeeeTotal;
726+
}
727+
707728
/**
708729
* Get FPT DISPLAY_INCL setting
709730
*
@@ -791,19 +812,33 @@ public function getWeeeAttributesForBundle($product)
791812
$typeInstance->getOptionsIds($product),
792813
$product
793814
);
794-
$insertedWeeCodesArray = [];
815+
$insertedWeeeCodesArray = [];
795816
foreach ($selectionCollection as $selectionItem) {
796-
$weeAttributes = $this->getProductWeeeAttributes(
817+
$weeeAttributes = $this->getProductWeeeAttributes(
797818
$selectionItem,
798819
null,
799820
null,
800-
$product->getStore()->getWebsiteId()
821+
$product->getStore()->getWebsiteId(),
822+
true,
823+
false
801824
);
802-
foreach ($weeAttributes as $weeAttribute) {
803-
$insertedWeeCodesArray[$selectionItem->getId()][$weeAttribute->getCode()]=$weeAttribute;
825+
$priceTaxDisplay = $this->getTaxDisplayConfig();
826+
$priceIncludesTax = $this->displayTotalsInclTax();
827+
foreach ($weeeAttributes as $weeeAttribute) {
828+
if ($priceTaxDisplay == \Magento\Tax\Model\Config::DISPLAY_TYPE_INCLUDING_TAX ||
829+
$priceTaxDisplay == \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH) {
830+
if ($priceIncludesTax == false) {
831+
$weeeAttribute['amount'] = $weeeAttribute['amount_excl_tax'] + $weeeAttribute['tax_amount'];
832+
}
833+
} else if ($priceTaxDisplay == \Magento\Tax\Model\Config::DISPLAY_TYPE_EXCLUDING_TAX) {
834+
if ($priceIncludesTax == true) {
835+
$weeeAttribute['amount'] = $weeeAttribute['amount_excl_tax'];
836+
}
837+
}
838+
$insertedWeeeCodesArray[$selectionItem->getId()][$weeeAttribute->getCode()] = $weeeAttribute;
804839
}
805840
}
806-
return $insertedWeeCodesArray;
841+
return $insertedWeeeCodesArray;
807842
}
808843
return [];
809844
}

app/code/Magento/Weee/Observer/GetPriceConfigurationObserver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ private function insertWeeePrice($holder, $key, $weeeAttributesForBundle)
124124
$weeeSum = 0;
125125
foreach ($weeeAttributesForBundle[$holder['optionId']] as $weeeAttribute) {
126126
$holder[$key]['weeePrice' . $weeeAttribute->getCode()] =
127-
['amount' => (float)$weeeAttribute->getAmountExclTax()];
128-
$weeeSum += (float)$weeeAttribute->getAmountExclTax();
127+
['amount' => (float)$weeeAttribute->getAmount()];
128+
$weeeSum += (float)$weeeAttribute->getAmount();
129129
}
130130
$holder[$key]['weeePrice']['amount'] += (float)$weeeSum;
131131
} else {

app/code/Magento/Weee/Observer/Total/Webapi/ItemObserver.php

Lines changed: 0 additions & 164 deletions
This file was deleted.

app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ protected function setUp()
7171
'getBaseWeeeTaxAppliedAmount',
7272
'getBaseWeeeTaxInclTax',
7373
'getBasePriceInclTax',
74+
'getQtyOrdered'
7475
])
7576
->getMock();
7677

@@ -314,9 +315,13 @@ public function testGetBaseUnitDisplayPriceExclTax(
314315
->will($this->returnValue($baseWeeeTaxExclTax));
315316

316317
$this->item->expects($this->once())
317-
->method('getBasePrice')
318+
->method('getBaseRowTotal')
318319
->will($this->returnValue($basePriceExclTax));
319320

321+
$this->item->expects($this->once())
322+
->method('getQtyOrdered')
323+
->will($this->returnValue(1));
324+
320325
$this->weeeHelper->expects($this->any())
321326
->method('typeOfDisplay')
322327
->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
@@ -610,9 +615,13 @@ public function testGetBaseFinalUnitDisplayPriceExclTax(
610615
->will($this->returnValue($baseWeeeTaxExclTax));
611616

612617
$this->item->expects($this->once())
613-
->method('getBasePrice')
618+
->method('getBaseRowTotal')
614619
->will($this->returnValue($basePriceExclTax));
615620

621+
$this->item->expects($this->once())
622+
->method('getQtyOrdered')
623+
->will($this->returnValue(1));
624+
616625
$this->assertEquals($expectedValue, $this->renderer->getBaseFinalUnitDisplayPriceExclTax());
617626
}
618627

0 commit comments

Comments
 (0)