Skip to content

Commit

Permalink
Merge pull request #1270 from magento-south/PRS
Browse files Browse the repository at this point in the history
MAGETWO-69029: Remove obsolete link "Show more" on Dashboard page on Advance Reporting block
MAGETWO-60352: [Github] Wrong error message in cart after entering invalid discount code #7230
MAGETWO-66510: Javascript error prevents adding/removing categories from existing catalog price rule condition
MAGETWO-59207: Checkbox return to stock doesn't work if Automatically Return Credit Memo Item to Stock Yes
MAGETWO-70201: Update Readme for Analytics modules. Final
MAGETWO-57835: [Github] Cannot save customer dob attribute if admin interface locale is en_GB #6323
  • Loading branch information
rganin authored Jul 5, 2017
2 parents d6bb4de + 5c25a27 commit f7b5f3b
Show file tree
Hide file tree
Showing 32 changed files with 451 additions and 881 deletions.
791 changes: 18 additions & 773 deletions app/code/Magento/Analytics/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
<div class="dashboard-advanced-reports-content">
<?= $block->escapeHtml(__('Gain new insights and take command of your business\' performance,' .
' using our dynamic product, order, and customer reports tailored to your customer data.')) ?>
<a href="<?= $block->escapeUrl($block->getUrl('analytics/reports/show')) ?>"
target="_blank"
data-index="analytics-service-info-link">
<?= $block->escapeHtml(__('View details')) ?>
</a>
</div>
</div>
<div class="dashboard-advanced-reports-actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ protected function setUp()
->getMock();

$this->dataProviderMock = $this->getMockForAbstractClass(DataProviderInterface::class);

$this->contextMock->expects($this->any())
->method('getNamespace')
->willReturn(DateRange::NAME);
$this->contextMock->expects($this->any())
->method('addComponentDefinition')
->with(DateRange::NAME, ['extends' => DateRange::NAME]);

$this->contextMock->expects($this->any())
->method('getDataProvider')
->willReturn($this->dataProviderMock);
}

/**
Expand All @@ -84,29 +95,15 @@ protected function setUp()
*/
public function testPrepare($name, $filterData, $expectedCondition)
{
/** @var FormDate PHPUnit_Framework_MockObject_MockObject|$uiComponent */
$uiComponent = $this->getMockBuilder(FormDate::class)
->disableOriginalConstructor()
->getMock();

$uiComponent->expects($this->any())
->method('getContext')
->willReturn($this->contextMock);

$this->contextMock->expects($this->any())
->method('getNamespace')
->willReturn(DateRange::NAME);
$this->contextMock->expects($this->any())
->method('addComponentDefinition')
->with(DateRange::NAME, ['extends' => DateRange::NAME]);

$this->contextMock->expects($this->any())
->method('getFiltersParams')
->willReturn($filterData);

$this->contextMock->expects($this->any())
->method('getDataProvider')
->willReturn($this->dataProviderMock);
$uiComponent = $this->getMockBuilder(FormDate::class)->disableOriginalConstructor()->getMock();

$uiComponent->expects($this->any())
->method('getContext')
->willReturn($this->contextMock);

if ($expectedCondition !== null) {
if (is_string($filterData[$name])) {
Expand All @@ -118,11 +115,11 @@ public function testPrepare($name, $filterData, $expectedCondition)
$uiComponent->method('convertDate')
->willReturnMap([
[
$filterData[$name]['from'], 0, 0, 0,
$filterData[$name]['from'],
new \DateTime($filterData[$name]['from'], new \DateTimeZone('UTC'))
],
[
$filterData[$name]['to'], 23, 59, 59,
$filterData[$name]['to'],
new \DateTime($filterData[$name]['to'] . ' 23:59:00', new \DateTimeZone('UTC'))
],
]);
Expand Down Expand Up @@ -161,6 +158,23 @@ public function testPrepare($name, $filterData, $expectedCondition)
->with($filterMock);
break;
}
} else {
$uiComponent->method('convertDate')
->willReturnMap([
[
$filterData[$name]['from'],
new \DateTime($filterData[$name]['from'], new \DateTimeZone('UTC'))
],
[
$filterData[$name]['to'],
new \DateTime($filterData[$name]['to'] . ' 23:59:00', new \DateTimeZone('UTC'))
],
]);

$filterMock = $this->getFilterMockWithoutExpectedCondition();
$this->dataProviderMock->expects(static::exactly(2))
->method('addFilter')
->with($filterMock);
}

$this->uiComponentFactory->expects($this->any())
Expand Down Expand Up @@ -212,6 +226,31 @@ private function getFilterMock($name, $expectedType, $expectedDate, &$i)
return $filterMock;
}

/**
* Gets Filter mock without expected condition
*
* @return Filter|\PHPUnit_Framework_MockObject_MockObject
*/
private function getFilterMockWithoutExpectedCondition()
{
$this->filterBuilderMock->expects(static::exactly(2))
->method('setConditionType')
->willReturnSelf();
$this->filterBuilderMock->expects(static::exactly(2))
->method('setField')
->willReturnSelf();
$this->filterBuilderMock->expects(static::exactly(2))
->method('setValue')
->willReturnSelf();

$filterMock = $this->getMock(Filter::class);
$this->filterBuilderMock->expects(static::exactly(2))
->method('create')
->willReturn($filterMock);

return $filterMock;
}

/**
* @return array
*/
Expand Down
5 changes: 2 additions & 3 deletions app/code/Magento/CatalogAnalytics/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## Overview
# Magento_CatalogAnalytics module

The Magento_CatalogAnalytics module provides products data for integration with
[Magento Business Intelligence](https://magento.com/products/business-intelligence).
The Magento_CatalogAnalytics module configures data definitions for a data collection related to the Catalog module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html).
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Backend\Block\Widget\Form;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Ui\Component\Layout\Tabs\TabInterface;
use Magento\Rule\Model\Condition\AbstractCondition;

class Conditions extends Generic implements TabInterface
{
Expand Down Expand Up @@ -146,14 +147,16 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('rule_');

$conditionsFieldSetId = $model->getConditionsFieldSetId($formName);

$newChildUrl = $this->getUrl(
'catalog_rule/promo_catalog/newConditionHtml/form/' . $model->getConditionsFieldSetId($formName),
'catalog_rule/promo_catalog/newConditionHtml/form/' . $conditionsFieldSetId,
['form_namespace' => $formName]
);

$renderer = $this->_rendererFieldset->setTemplate('Magento_CatalogRule::promo/fieldset.phtml')
->setNewChildUrl($newChildUrl)
->setFieldSetId($model->getConditionsFieldSetId($formName));
->setFieldSetId($conditionsFieldSetId);

$fieldset = $form->addFieldset(
$fieldsetId,
Expand All @@ -175,22 +178,24 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
->setRenderer($this->_conditions);

$form->setValues($model->getData());
$this->setConditionFormName($model->getConditions(), $formName);
$this->setConditionFormName($model->getConditions(), $formName, $conditionsFieldSetId);
return $form;
}

/**
* @param \Magento\Rule\Model\Condition\AbstractCondition $conditions
* @param AbstractCondition $conditions
* @param string $formName
* @param string $jsFormName
* @return void
*/
private function setConditionFormName(\Magento\Rule\Model\Condition\AbstractCondition $conditions, $formName)
private function setConditionFormName(AbstractCondition $conditions, $formName, $jsFormName)
{
$conditions->setFormName($formName);
$conditions->setJsFormObject($formName);
$conditions->setJsFormObject($jsFormName);

if ($conditions->getConditions() && is_array($conditions->getConditions())) {
foreach ($conditions->getConditions() as $condition) {
$this->setConditionFormName($condition, $formName);
$this->setConditionFormName($condition, $formName, $jsFormName);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Checkout/Controller/Cart/CouponPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public function execute()
$escaper->escapeHtml($couponCode)
)
);
$this->cart->save();
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
<settings>
<timezone>false</timezone>
<dateFormat>MMM d, y</dateFormat>
<skipTime>true</skipTime>
<filter>dateRange</filter>
<dataType>date</dataType>
<label translate="true">Date of Birth</label>
Expand Down
5 changes: 2 additions & 3 deletions app/code/Magento/CustomerAnalytics/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## Overview
# Magento_CustomerAnalytics module

The Magento_CustomerAnalytics module provides customers data for integration with
[Magento Business Intelligence](https://magento.com/products/business-intelligence).
The Magento_CustomerAnalytics module configures data definitions for a data collection related to the Customer module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html).
5 changes: 2 additions & 3 deletions app/code/Magento/QuoteAnalytics/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## Overview
# Magento_QuoteAnalytics

The Magento_QuoteAnalytics module provides quotes data for integration with
[Magento Business Intelligence](https://magento.com/products/business-intelligence).
The Magento_QuoteAnalytics module configures data definitions for a data collection related to the Quote module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html).
5 changes: 2 additions & 3 deletions app/code/Magento/ReviewAnalytics/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## Overview
# Magento_ReviewAnalytics module

The Magento_ReviewAnalytics module provides reviews data for integration with
[Magento Business Intelligence](https://magento.com/products/business-intelligence).
The Magento_ReviewAnalytics module configures data definitions for a data collection related to the Review module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html).
5 changes: 2 additions & 3 deletions app/code/Magento/SalesAnalytics/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## Overview
# Magento_SalesAnalytics module

The Magento_SalesAnalytics module provides orders data for integration with
[Magento Business Intelligence](https://magento.com/products/business-intelligence).
The Magento_SalesAnalytics module configures data definitions for a data collection related to the Sales module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html).
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ public function afterExecute(
\Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment = null,
\Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface $arguments = null
) {
if ($this->stockConfiguration->isAutoReturnEnabled()) {
return $resultEntityId;
}

$invoice = $this->invoiceRepository->get($invoiceId);
$order = $this->orderRepository->get($invoice->getOrderId());

Expand All @@ -95,10 +91,11 @@ public function afterExecute(
) {
$returnToStockItems = $arguments->getExtensionAttributes()->getReturnToStockItems();
}

$creditmemo = $this->creditmemoRepository->get($resultEntityId);
$this->returnProcessor->execute($creditmemo, $order, $returnToStockItems);

$isAutoReturn = $this->stockConfiguration->isAutoReturnEnabled();
if ($isAutoReturn || !empty($returnToStockItems)) {
$creditmemo = $this->creditmemoRepository->get($resultEntityId);
$this->returnProcessor->execute($creditmemo, $order, $returnToStockItems, $isAutoReturn);
}
return $resultEntityId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public function afterExecute(
\Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment = null,
\Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface $arguments = null
) {
if ($this->stockConfiguration->isAutoReturnEnabled()) {
return $resultEntityId;
}

$order = $this->orderRepository->get($orderId);

$returnToStockItems = [];
Expand All @@ -91,10 +87,11 @@ public function afterExecute(
) {
$returnToStockItems = $arguments->getExtensionAttributes()->getReturnToStockItems();
}

$creditmemo = $this->creditmemoRepository->get($resultEntityId);
$this->returnProcessor->execute($creditmemo, $order, $returnToStockItems);

$isAutoReturn = $this->stockConfiguration->isAutoReturnEnabled();
if ($isAutoReturn || !empty($returnToStockItems)) {
$creditmemo = $this->creditmemoRepository->get($resultEntityId);
$this->returnProcessor->execute($creditmemo, $order, $returnToStockItems, $isAutoReturn);
}
return $resultEntityId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ public function execute(EventObserver $observer)
$returnToStockItems[] = $item->getOrderItemId();
}
}
$this->returnProcessor->execute(
$creditmemo,
$order,
$returnToStockItems,
$this->stockConfiguration->isAutoReturnEnabled()
);
if (!empty($returnToStockItems)) {
$this->returnProcessor->execute($creditmemo, $order, $returnToStockItems);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public function testRefundOrderInventory()
{
$ids = ['1', '14'];
$items = [];
$isAutoReturnEnabled = true;

$creditMemo = $this->getMock(\Magento\Sales\Model\Order\Creditmemo::class, [], [], '', false);

Expand All @@ -168,11 +167,6 @@ public function testRefundOrderInventory()
$creditMemo->expects($this->once())
->method('getItems')
->will($this->returnValue($items));

$this->stockConfiguration->expects($this->any())
->method('isAutoReturnEnabled')
->will($this->returnValue($isAutoReturnEnabled));

$this->event->expects($this->once())
->method('getCreditmemo')
->will($this->returnValue($creditMemo));
Expand All @@ -183,7 +177,7 @@ public function testRefundOrderInventory()

$this->returnProcessorMock->expects($this->once())
->method('execute')
->with($creditMemo, $this->orderMock, $ids, $isAutoReturnEnabled);
->with($creditMemo, $this->orderMock, $ids);

$this->observer->execute($this->eventObserver);
}
Expand Down
19 changes: 17 additions & 2 deletions app/code/Magento/Ui/Component/Filters/Type/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Ui\Component\Filters\Type;

use Magento\Ui\Component\Form\Element\DataType\Date as DataTypeDate;
Expand Down Expand Up @@ -78,12 +79,26 @@ protected function applyFilter()
}

if (is_array($value)) {
$dateFrom = null;
$dateTo = null;

if (isset($value['from'])) {
$this->applyFilterByType('gteq', $this->wrappedComponent->convertDate($value['from']));
$dateFrom = $this->wrappedComponent->convertDate($value['from']);
if ($this->getData('config/skipTime')) {
$dateFrom->setTime(0, 0, 0);
}
$this->applyFilterByType('gteq', $dateFrom);
}

if (isset($value['to'])) {
$this->applyFilterByType('lteq', $this->wrappedComponent->convertDate($value['to'], 23, 59, 59));
$dateTo = $this->wrappedComponent->convertDate($value['to']);
if ($this->getData('config/skipTime')) {
$dateTo->setTime(0, 0, 0);
}
if ($dateFrom == $dateTo) {
$dateTo->setTime(23, 59, 59);
}
$this->applyFilterByType('lteq', $dateTo);
}
} else {
$this->applyFilterByType('eq', $this->wrappedComponent->convertDate($value));
Expand Down
Loading

0 comments on commit f7b5f3b

Please sign in to comment.