Skip to content

Commit 59a60e5

Browse files
merge magento/2.3-develop into magento-honey-badgers/MC-23091-2.3.5
2 parents 0c93e0e + 54bd0d8 commit 59a60e5

File tree

24 files changed

+1370
-26
lines changed

24 files changed

+1370
-26
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,7 @@ public function execute($entity, $arguments = [])
9696
$productId = (int)$entity->getData($identifierField);
9797

9898
// prepare original data to compare
99-
$origPrices = [];
100-
$originalId = $entity->getOrigData($identifierField);
101-
if (empty($originalId) || $entity->getData($identifierField) == $originalId) {
102-
$origPrices = $entity->getOrigData($attribute->getName());
103-
}
104-
99+
$origPrices = $entity->getOrigData($attribute->getName());
105100
$old = $this->prepareOldTierPriceToCompare($origPrices);
106101
// prepare data for save
107102
$new = $this->prepareNewDataForSave($priceRows, $isGlobal);

app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function testExecute(): void
108108
];
109109
$linkField = 'entity_id';
110110
$productId = 10;
111+
$originalProductId = 11;
111112

112113
/** @var \PHPUnit_Framework_MockObject_MockObject $product */
113114
$product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
@@ -124,7 +125,7 @@ public function testExecute(): void
124125
->willReturnMap(
125126
[
126127
['tier_price', $originalTierPrices],
127-
['entity_id', $productId]
128+
['entity_id', $originalProductId]
128129
]
129130
);
130131
$product->expects($this->atLeastOnce())->method('getStoreId')->willReturn(0);

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ public function setShippingMethods($methods)
625625
$addressId = $address->getId();
626626
if (isset($methods[$addressId])) {
627627
$address->setShippingMethod($methods[$addressId]);
628+
$address->setCollectShippingRates(true);
628629
} elseif (!$address->getShippingMethod()) {
629630
throw new \Magento\Framework\Exception\LocalizedException(
630631
__('Set shipping methods for all addresses. Verify the shipping methods and try again.')

app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,16 @@ public function testSetShippingMethods()
420420
$methodsArray = [1 => 'flatrate_flatrate', 2 => 'tablerate_bestway'];
421421
$addressId = 1;
422422
$addressMock = $this->getMockBuilder(QuoteAddress::class)
423-
->setMethods(['getId', 'setShippingMethod'])
423+
->setMethods(['getId', 'setShippingMethod', 'setCollectShippingRates'])
424424
->disableOriginalConstructor()
425425
->getMock();
426426

427427
$addressMock->expects($this->once())->method('getId')->willReturn($addressId);
428428
$this->quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([$addressMock]);
429429
$addressMock->expects($this->once())->method('setShippingMethod')->with($methodsArray[$addressId]);
430+
$addressMock->expects($this->once())
431+
->method('setCollectShippingRates')
432+
->with(true);
430433
$this->quoteMock->expects($this->once())
431434
->method('__call')
432435
->with('setTotalsCollectedFlag', [false])

app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
4141
$baseOrderItemTax = (double)$orderItem->getBaseTaxInvoiced();
4242
$orderItemQty = (double)$orderItem->getQtyInvoiced();
4343

44-
if ($orderItemTax && $orderItemQty) {
44+
if ($orderItemQty) {
4545
/**
4646
* Check item tax amount
4747
*/

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php

Lines changed: 148 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,18 @@ public function testCollect($orderData, $creditmemoData, $expectedResults)
100100
}
101101
$this->creditmemo->expects($this->any())
102102
->method('roundPrice')
103-
->will($this->returnCallback(
104-
function ($price, $type) use (&$roundingDelta) {
105-
if (!isset($roundingDelta[$type])) {
106-
$roundingDelta[$type] = 0;
103+
->will(
104+
$this->returnCallback(
105+
function ($price, $type) use (&$roundingDelta) {
106+
if (!isset($roundingDelta[$type])) {
107+
$roundingDelta[$type] = 0;
108+
}
109+
$roundedPrice = round($price + $roundingDelta[$type], 2);
110+
$roundingDelta[$type] = $price - $roundedPrice;
111+
return $roundedPrice;
107112
}
108-
$roundedPrice = round($price + $roundingDelta[$type], 2);
109-
$roundingDelta[$type] = $price - $roundedPrice;
110-
return $roundedPrice;
111-
}
112-
));
113+
)
114+
);
113115

114116
$this->model->collect($this->creditmemo);
115117

@@ -610,6 +612,143 @@ public function collectDataProvider()
610612
],
611613
];
612614

615+
// scenario 6: 2 items, 2 invoiced, price includes tax, full discount, free shipping
616+
// partial credit memo, make sure that discount tax compensation (with 100 % discount) is calculated correctly
617+
$result['collect_with_full_discount_product_price'] = [
618+
'order_data' => [
619+
'data_fields' => [
620+
'discount_amount' => -200.00,
621+
'discount_invoiced' => -200.00,
622+
'subtotal' => 181.82,
623+
'subtotal_incl_tax' => 200,
624+
'base_subtotal' => 181.82,
625+
'base_subtotal_incl_tax' => 200,
626+
'subtotal_invoiced' => 181.82,
627+
'discount_tax_compensation_amount' => 18.18,
628+
'discount_tax_compensation_invoiced' => 18.18,
629+
'base_discount_tax_compensation_amount' => 18.18,
630+
'base_discount_tax_compensation_invoiced' => 18.18,
631+
'grand_total' => 0,
632+
'base_grand_total' => 0,
633+
'shipping_tax_amount' => 0,
634+
'base_shipping_tax_amount' => 0,
635+
'shipping_discount_tax_compensation_amount' => 0,
636+
'base_shipping_discount_tax_compensation_amount' => 0,
637+
'tax_amount' => 0,
638+
'base_tax_amount' => 0,
639+
'tax_invoiced' => 0,
640+
'base_tax_invoiced' => 0,
641+
'tax_refunded' => 0,
642+
'base_tax_refunded' => 0,
643+
'base_shipping_amount' => 0,
644+
],
645+
],
646+
'creditmemo_data' => [
647+
'items' => [
648+
'item_1' => [
649+
'order_item' => [
650+
'qty_invoiced' => 1,
651+
'tax_amount' => 0,
652+
'tax_invoiced' => 0,
653+
'tax_refunded' => null,
654+
'base_tax_amount' => 0,
655+
'base_tax_invoiced' => 0,
656+
'base_tax_refunded' => 0,
657+
'tax_percent' => 10,
658+
'qty_refunded' => 0,
659+
'discount_percent' => 100,
660+
'discount_amount' => 100,
661+
'base_discount_amount' => 100,
662+
'discount_invoiced' => 100,
663+
'base_discount_invoiced' => 100,
664+
'row_total' => 90.91,
665+
'base_row_total' => 90.91,
666+
'row_invoiced' => 90.91,
667+
'base_row_invoiced' => 90.91,
668+
'price_incl_tax' => 100,
669+
'base_price_incl_tax' => 100,
670+
'row_total_incl_tax' => 100,
671+
'base_row_total_incl_tax' => 100,
672+
'discount_tax_compensation_amount' => 9.09,
673+
'base_discount_tax_compensation_amount' => 9.09,
674+
'discount_tax_compensation_invoiced' => 9.09,
675+
'base_discount_tax_compensation_invoiced' => 9.09,
676+
],
677+
'is_last' => true,
678+
'qty' => 1,
679+
],
680+
'item_2' => [
681+
'order_item' => [
682+
'qty_invoiced' => 1,
683+
'tax_amount' => 0,
684+
'tax_invoiced' => 0,
685+
'tax_refunded' => null,
686+
'base_tax_amount' => 0,
687+
'base_tax_invoiced' => 0,
688+
'base_tax_refunded' => null,
689+
'tax_percent' => 10,
690+
'qty_refunded' => 0,
691+
'discount_percent' => 100,
692+
'discount_amount' => 100,
693+
'base_discount_amount' => 100,
694+
'discount_invoiced' => 100,
695+
'base_discount_invoiced' => 100,
696+
'row_total' => 90.91,
697+
'base_row_total' => 90.91,
698+
'row_invoiced' => 90.91,
699+
'base_row_invoiced' => 90.91,
700+
'price_incl_tax' => 100,
701+
'base_price_incl_tax' => 100,
702+
'row_total_incl_tax' => 100,
703+
'base_row_total_incl_tax' => 100,
704+
'discount_tax_compensation_amount' => 9.09,
705+
'base_discount_tax_compensation_amount' => 9.09,
706+
'discount_tax_compensation_invoiced' => 9.09,
707+
'base_discount_tax_compensation_invoiced' => 9.09,
708+
],
709+
'is_last' => false,
710+
'qty' => 0,
711+
],
712+
],
713+
'is_last' => false,
714+
'data_fields' => [
715+
'grand_total' => -9.09,
716+
'base_grand_total' => -9.09,
717+
'base_shipping_amount' => 0,
718+
'tax_amount' => 0,
719+
'base_tax_amount' => 0,
720+
'invoice' => new MagentoObject(
721+
[
722+
'shipping_tax_amount' => 0,
723+
'base_shipping_tax_amount' => 0,
724+
'shipping_discount_tax_compensation_amount' => 0,
725+
'base_shipping_discount_tax_compensation_amount' => 0,
726+
]
727+
),
728+
],
729+
],
730+
'expected_results' => [
731+
'creditmemo_items' => [
732+
'item_1' => [
733+
'tax_amount' => 0,
734+
'base_tax_amount' => 0,
735+
],
736+
'item_2' => [
737+
'tax_amount' => 0,
738+
'base_tax_amount' => 0,
739+
],
740+
],
741+
'creditmemo_data' => [
742+
'grand_total' => 0,
743+
'base_grand_total' => 0,
744+
'tax_amount' => 0,
745+
'base_tax_amount' => 0,
746+
'shipping_tax_amount' => 0,
747+
'base_shipping_tax_amount' => 0,
748+
],
749+
],
750+
];
751+
613752
return $result;
614753
}
615754

app/code/Magento/Sitemap/Model/Sitemap.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\DataObject;
1212
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Filesystem;
1314
use Magento\Framework\UrlInterface;
1415
use Magento\Robots\Model\Config\Value;
1516
use Magento\Sitemap\Model\ItemProvider\ItemProviderInterface;
@@ -191,6 +192,16 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel implements \Magento
191192
*/
192193
private $lastModMinTsVal;
193194

195+
/**
196+
* @var Filesystem
197+
*/
198+
private $filesystem;
199+
200+
/**
201+
* @var DocumentRoot
202+
*/
203+
private $documentRoot;
204+
194205
/**
195206
* Initialize dependencies.
196207
*
@@ -238,8 +249,9 @@ public function __construct(
238249
) {
239250
$this->_escaper = $escaper;
240251
$this->_sitemapData = $sitemapData;
241-
$documentRoot = $documentRoot ?: ObjectManager::getInstance()->get(DocumentRoot::class);
242-
$this->_directory = $filesystem->getDirectoryWrite($documentRoot->getPath());
252+
$this->documentRoot = $documentRoot ?: ObjectManager::getInstance()->get(DocumentRoot::class);
253+
$this->filesystem = $filesystem;
254+
$this->_directory = $filesystem->getDirectoryWrite($this->documentRoot->getPath());
243255
$this->_categoryFactory = $categoryFactory;
244256
$this->_productFactory = $productFactory;
245257
$this->_cmsFactory = $cmsFactory;
@@ -727,8 +739,8 @@ protected function _getFormattedLastmodDate($date)
727739
*/
728740
protected function _getDocumentRoot()
729741
{
730-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
731-
return realpath($this->_request->getServer('DOCUMENT_ROOT'));
742+
return $this->filesystem->getDirectoryRead($this->documentRoot->getPath())
743+
->getAbsolutePath();
732744
}
733745

734746
/**

0 commit comments

Comments
 (0)