Skip to content

Commit 4541825

Browse files
committed
Merge branch 'develop' of https://github.corp.ebay.com/magento-firedrakes/magento2ce into MAGETWO-32081-2
Conflicts: dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Product.php dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php
2 parents 63a8666 + 1bba5fe commit 4541825

File tree

66 files changed

+3120
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3120
-263
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ protected function calculateDynamicBundleAmount($basePriceValue, $bundleProduct,
314314

315315
/** @var Store $store */
316316
$store = $bundleProduct->getStore();
317-
$roundingMethod = $this->taxHelper->getCalculationAgorithm($store);
317+
$roundingMethod = $this->taxHelper->getCalculationAlgorithm($store);
318318
foreach ($amountList as $amountInfo) {
319319
/** @var \Magento\Framework\Pricing\Amount\AmountInterface $itemAmount */
320320
$itemAmount = $amountInfo['amount'];

app/code/Magento/Catalog/Model/Product.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,10 @@ public function afterSave()
777777
*/
778778
public function setQty($qty)
779779
{
780-
$this->setData('qty', $qty);
781-
$this->reloadPriceInfo();
780+
if ($this->getData('qty') != $qty) {
781+
$this->setData('qty', $qty);
782+
$this->reloadPriceInfo();
783+
}
782784
return $this;
783785
}
784786

app/code/Magento/Checkout/Controller/Cart/Configure.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ public function execute()
4444
{
4545
// Extract item and product to configure
4646
$id = (int)$this->getRequest()->getParam('id');
47+
$productId = (int)$this->getRequest()->getParam('product_id');
4748
$quoteItem = null;
4849
if ($id) {
4950
$quoteItem = $this->cart->getQuote()->getItemById($id);
5051
}
5152

52-
if (!$quoteItem) {
53-
$this->messageManager->addError(__("We can't find the quote item."));
54-
$this->_redirect('checkout/cart');
55-
return;
56-
}
57-
5853
try {
54+
if (!$quoteItem || $productId != $quoteItem->getProduct()->getId()) {
55+
$this->messageManager->addError(__("We can't find the quote item."));
56+
$this->_redirect('checkout/cart');
57+
return;
58+
}
59+
5960
$params = new \Magento\Framework\Object();
6061
$params->setCategoryId(false);
6162
$params->setConfigureMode(true);

app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_success.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
9+
<head>
10+
<title>Success Page</title>
11+
</head>
912
<body>
1013
<referenceBlock name="page.main.title">
1114
<block class="Magento\Checkout\Block\Onepage\Success" name="checkout.success.print.button" template="button.phtml"/>

app/code/Magento/Directory/Model/PriceCurrency.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,12 @@ public function convert($amount, $scope = null, $currency = null)
5858
}
5959

6060
/**
61-
* Convert and round price value for specified store or passed currency
62-
*
63-
* @param float $amount
64-
* @param null|string|bool|int|\Magento\Store\Model\Store $store
65-
* @param Currency|string|null $currency
66-
* @param int $precision
67-
* @return float
61+
* {@inheritdoc}
6862
*/
69-
public function convertAndRound($amount, $store = null, $currency = null, $precision = self::DEFAULT_PRECISION)
63+
public function convertAndRound($amount, $scope = null, $currency = null, $precision = self::DEFAULT_PRECISION)
7064
{
71-
$currentCurrency = $this->getCurrency($store, $currency);
72-
$convertedValue = $this->getStore($store)->getBaseCurrency()->convert($amount, $currentCurrency);
65+
$currentCurrency = $this->getCurrency($scope, $currency);
66+
$convertedValue = $this->getStore($scope)->getBaseCurrency()->convert($amount, $currentCurrency);
7367
return round($convertedValue, $precision);
7468
}
7569

app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_success.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
99
<update handle="multishipping_checkout"/>
10+
<head>
11+
<title>Success Page</title>
12+
</head>
1013
<body>
1114
<referenceBlock name="page.main.title">
1215
<action method="setPageTitle">

app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,15 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
3737

3838
$allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced();
3939
$baseAllowedSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced();
40-
$allowedSubtotalInclTax = $allowedSubtotal +
41-
$order->getHiddenTaxAmount() +
42-
$order->getTaxAmount() -
43-
$order->getTaxInvoiced() -
44-
$order->getHiddenTaxInvoiced();
45-
$baseAllowedSubtotalInclTax = $baseAllowedSubtotal +
46-
$order->getBaseHiddenTaxAmount() +
47-
$order->getBaseTaxAmount() -
48-
$order->getBaseTaxInvoiced() -
49-
$order->getBaseHiddenTaxInvoiced();
50-
51-
/**
52-
* Check if shipping tax calculation is included to current invoice.
53-
*/
54-
$includeShippingTax = true;
55-
foreach ($invoice->getOrder()->getInvoiceCollection() as $previousInvoice) {
56-
if ($previousInvoice->getShippingAmount() && !$previousInvoice->isCanceled()) {
57-
$includeShippingTax = false;
58-
break;
59-
}
60-
}
61-
62-
if ($includeShippingTax) {
63-
$allowedSubtotalInclTax -= $order->getShippingTaxAmount();
64-
$baseAllowedSubtotalInclTax -= $order->getBaseShippingTaxAmount();
65-
} else {
66-
$allowedSubtotalInclTax += $order->getShippingHiddenTaxAmount();
67-
$baseAllowedSubtotalInclTax += $order->getBaseShippingHiddenTaxAmount();
68-
}
40+
//Note: The $subtotalInclTax and $baseSubtotalInclTax are not adjusted from those provide by the line items
41+
//because the "InclTax" is displayed before any tax adjustments based on discounts, shipping, etc.
6942

7043
if ($invoice->isLast()) {
7144
$subtotal = $allowedSubtotal;
7245
$baseSubtotal = $baseAllowedSubtotal;
73-
$subtotalInclTax = $allowedSubtotalInclTax;
74-
$baseSubtotalInclTax = $baseAllowedSubtotalInclTax;
7546
} else {
7647
$subtotal = min($allowedSubtotal, $subtotal);
7748
$baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal);
78-
$subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax);
79-
$baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax);
8049
}
8150

8251
$invoice->setSubtotal($subtotal);

app/code/Magento/SalesRule/Model/Rule/Action/Discount/ByPercent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ protected function _calculate($rule, $item, $qty, $rulePercent)
5757
$discountData->setAmount(($qty * $itemPrice - $item->getDiscountAmount()) * $_rulePct);
5858
$discountData->setBaseAmount(($qty * $baseItemPrice - $item->getBaseDiscountAmount()) * $_rulePct);
5959
$discountData->setOriginalAmount(($qty * $itemOriginalPrice - $item->getDiscountAmount()) * $_rulePct);
60-
$discountData->setBaseOriginalAmount(($qty * $baseItemOriginalPrice - $item->getDiscountAmount()) * $_rulePct);
60+
$discountData->setBaseOriginalAmount(
61+
($qty * $baseItemOriginalPrice - $item->getBaseDiscountAmount()) * $_rulePct
62+
);
6163

6264
if (!$rule->getDiscountQty() || $rule->getDiscountQty() > $qty) {
6365
$discountPercent = min(100, $item->getDiscountPercent() + $rulePercent);

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public function getCalculationSequence($store = null)
629629
* @param null|string|bool|int|Store $store
630630
* @return string
631631
*/
632-
public function getCalculationAgorithm($store = null)
632+
public function getCalculationAlgorithm($store = null)
633633
{
634634
return $this->_config->getAlgorithm($store);
635635
}
@@ -797,23 +797,6 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
797797

798798
$orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getId());
799799

800-
// Apply any taxes for shipping
801-
$shippingTaxAmount = $salesItem->getShippingTaxAmount();
802-
$originalShippingTaxAmount = $order->getShippingTaxAmount();
803-
if ($shippingTaxAmount && $originalShippingTaxAmount &&
804-
$shippingTaxAmount != 0 && floatval($originalShippingTaxAmount)
805-
) {
806-
//An invoice or credit memo can have a different qty than its order
807-
$shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount;
808-
$itemTaxDetails = $orderTaxDetails->getItems();
809-
foreach ($itemTaxDetails as $itemTaxDetail) {
810-
//Aggregate taxable items associated with shipping
811-
if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
812-
$taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
813-
}
814-
}
815-
}
816-
817800
// Apply any taxes for the items
818801
/** @var $item \Magento\Sales\Model\Order\Invoice\Item|\Magento\Sales\Model\Order\Creditmemo\Item */
819802
foreach ($salesItem->getItems() as $item) {
@@ -845,6 +828,23 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
845828
}
846829
}
847830

831+
// Apply any taxes for shipping
832+
$shippingTaxAmount = $salesItem->getShippingTaxAmount();
833+
$originalShippingTaxAmount = $order->getShippingTaxAmount();
834+
if ($shippingTaxAmount && $originalShippingTaxAmount &&
835+
$shippingTaxAmount != 0 && floatval($originalShippingTaxAmount)
836+
) {
837+
//An invoice or credit memo can have a different qty than its order
838+
$shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount;
839+
$itemTaxDetails = $orderTaxDetails->getItems();
840+
foreach ($itemTaxDetails as $itemTaxDetail) {
841+
//Aggregate taxable items associated with shipping
842+
if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
843+
$taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
844+
}
845+
}
846+
}
847+
848848
return $taxClassAmount;
849849
}
850850
}

app/code/Magento/Tax/Model/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function getNeedUseShippingExcludeTax()
270270
}
271271

272272
/**
273-
* Get defined tax calculation agorithm
273+
* Get defined tax calculation algorithm
274274
*
275275
* @param null|string|bool|int|Store $store
276276
* @return string

0 commit comments

Comments
 (0)