Skip to content

Commit 6030506

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #11707: UPS Option to include TAX in rate (by @gwharton) - magento-engcom/magento2ce#1134: #12205: Stock inventory reindex bug. (by @p-bystritsky) - #14156: Add website- and storeview-code in stores admin grid (by @aschrammel) Fixed GitHub Issues: - #12205: Stock inventory reindex bug (reported by @Nix-id) has been fixed in magento-engcom/magento2ce#1134 by @p-bystritsky in 2.2-develop branch Related commits: 1. 20d7afb 2. 8c44db2
2 parents 5afa7d3 + 79687fc commit 6030506

File tree

19 files changed

+2138
-12
lines changed

19 files changed

+2138
-12
lines changed

app/code/Magento/Backend/Block/System/Store/Grid/Render/Group.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function render(\Magento\Framework\DataObject $row)
2727
$this->getUrl('adminhtml/*/editGroup', ['group_id' => $row->getGroupId()]) .
2828
'">' .
2929
$this->escapeHtml($row->getData($this->getColumn()->getIndex())) .
30-
'</a>';
30+
'</a><br />'
31+
. '(' . __('Code') . ': ' . $row->getGroupCode() . ')';
3132
}
3233
}

app/code/Magento/Backend/Block/System/Store/Grid/Render/Store.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function render(\Magento\Framework\DataObject $row)
2727
$this->getUrl('adminhtml/*/editStore', ['store_id' => $row->getStoreId()]) .
2828
'">' .
2929
$this->escapeHtml($row->getData($this->getColumn()->getIndex())) .
30-
'</a>';
30+
'</a><br />' .
31+
'(' . __('Code') . ': ' . $row->getStoreCode() . ')';
3132
}
3233
}

app/code/Magento/Backend/Block/System/Store/Grid/Render/Website.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function render(\Magento\Framework\DataObject $row)
2424
$this->getUrl('adminhtml/*/editWebsite', ['website_id' => $row->getWebsiteId()]) .
2525
'">' .
2626
$this->escapeHtml($row->getData($this->getColumn()->getIndex())) .
27-
'</a>';
27+
'</a><br />' .
28+
'(' . __('Code') . ': ' . $row->getCode() . ')';
2829
}
2930
}

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ protected function _prepareIndexTable($entityIds = null)
288288
*/
289289
protected function _updateIndex($entityIds)
290290
{
291+
$this->deleteOldRecords($entityIds);
291292
$connection = $this->getConnection();
292293
$select = $this->_getStockStatusSelect($entityIds, true);
293294
$select = $this->getQueryProcessorComposite()->processQuery($select, $entityIds, true);
@@ -310,7 +311,6 @@ protected function _updateIndex($entityIds)
310311
}
311312
}
312313

313-
$this->deleteOldRecords($entityIds);
314314
$this->_updateIndexTable($data);
315315

316316
return $this;

app/code/Magento/Store/Model/ResourceModel/Website/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ public function joinGroupAndStore()
138138
$this->getSelect()->joinLeft(
139139
['group_table' => $this->getTable('store_group')],
140140
'main_table.website_id = group_table.website_id',
141-
['group_id' => 'group_id', 'group_title' => 'name']
141+
['group_id' => 'group_id', 'group_title' => 'name', 'group_code' => 'code']
142142
)->joinLeft(
143143
['store_table' => $this->getTable('store')],
144144
'group_table.group_id = store_table.group_id',
145-
['store_id' => 'store_id', 'store_title' => 'name']
145+
['store_id' => 'store_id', 'store_title' => 'name', 'store_code' => 'code']
146146
);
147147
$this->addOrder('group_table.name', \Magento\Framework\DB\Select::SQL_ASC) // store name
148148
->addOrder(

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,9 @@ protected function _getXmlQuotes()
727727
if ($this->getConfigFlag('negotiated_active')) {
728728
$xmlParams .= "<RateInformation><NegotiatedRatesIndicator/></RateInformation>";
729729
}
730+
if ($this->getConfigFlag('include_taxes')) {
731+
$xmlParams .= "<TaxInformationIndicator/>";
732+
}
730733

731734
$xmlParams .= <<<XMLRequest
732735
</Shipment>
@@ -795,6 +798,8 @@ private function mapCurrencyCode($code)
795798
* @param mixed $xmlResponse
796799
* @return Result
797800
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
801+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
802+
* @SuppressWarnings(PHPMD.ElseExpression)
798803
*/
799804
protected function _parseXmlResponse($xmlResponse)
800805
{
@@ -821,17 +826,45 @@ protected function _parseXmlResponse($xmlResponse)
821826
foreach ($arr as $shipElement) {
822827
$code = (string)$shipElement->Service->Code;
823828
if (in_array($code, $allowedMethods)) {
829+
//The location of tax information is in a different place depending on whether we are using negotiated rates or not
824830
if ($negotiatedActive) {
825-
$cost = $shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue;
831+
$includeTaxesArr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment/NegotiatedRates/NetSummaryCharges/TotalChargesWithTaxes");
832+
$includeTaxesActive = $this->getConfigFlag(
833+
'include_taxes'
834+
) && !empty($includeTaxesArr);
835+
if ($includeTaxesActive) {
836+
$cost = $shipElement->NegotiatedRates->NetSummaryCharges->TotalChargesWithTaxes->MonetaryValue;
837+
$responseCurrencyCode = $this->mapCurrencyCode(
838+
(string)$shipElement->NegotiatedRates->NetSummaryCharges->TotalChargesWithTaxes->CurrencyCode
839+
);
840+
}
841+
else {
842+
$cost = $shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue;
843+
$responseCurrencyCode = $this->mapCurrencyCode(
844+
(string)$shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->CurrencyCode
845+
);
846+
}
826847
} else {
827-
$cost = $shipElement->TotalCharges->MonetaryValue;
848+
$includeTaxesArr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment/TotalChargesWithTaxes");
849+
$includeTaxesActive = $this->getConfigFlag(
850+
'include_taxes'
851+
) && !empty($includeTaxesArr);
852+
if ($includeTaxesActive) {
853+
$cost = $shipElement->TotalChargesWithTaxes->MonetaryValue;
854+
$responseCurrencyCode = $this->mapCurrencyCode(
855+
(string)$shipElement->TotalChargesWithTaxes->CurrencyCode
856+
);
857+
}
858+
else {
859+
$cost = $shipElement->TotalCharges->MonetaryValue;
860+
$responseCurrencyCode = $this->mapCurrencyCode(
861+
(string)$shipElement->TotalCharges->CurrencyCode
862+
);
863+
}
828864
}
829865

830866
//convert price with Origin country currency code to base currency code
831867
$successConversion = true;
832-
$responseCurrencyCode = $this->mapCurrencyCode(
833-
(string)$shipElement->TotalCharges->CurrencyCode
834-
);
835868
if ($responseCurrencyCode) {
836869
if (in_array($responseCurrencyCode, $allowedCurrencies)) {
837870
$cost = (double)$cost * $this->_getBaseCurrencyRate($responseCurrencyCode);

0 commit comments

Comments
 (0)