Skip to content

Commit c0b4710

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/2.3-develop' into MC-5602
2 parents 583c88a + f032485 commit c0b4710

21 files changed

+368
-67
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
11+
<actionGroup name="AdminOrderBraintreeFillActionGroup">
12+
<!--Select Braintree Payment method on Admin Order Create Page-->
13+
<click stepKey="chooseBraintree" selector="{{NewOrderSection.creditCardBraintree}}"/>
14+
<waitForPageLoad stepKey="waitForBraintreeConfigs" time="5"/>
15+
<click stepKey="openCardTypes" selector="{{NewOrderSection.openCardTypes}}"/>
16+
<waitForPageLoad stepKey="waitForCardTypes" time="3"/>
17+
<click stepKey="chooseCardType" selector="{{NewOrderSection.masterCard}}"/>
18+
<waitForPageLoad stepKey="waitForCardSelected" time="3"/>
19+
20+
<!--Choose Master Card from drop-down list-->
21+
<switchToIFrame stepKey="switchToCardNumber" selector="{{NewOrderSection.cardFrame}}"/>
22+
<fillField stepKey="fillCardNumber" selector="{{NewOrderSection.creditCardNumber}}" userInput="{{PaymentAndShippingInfo.cardNumber}}"/>
23+
<waitForPageLoad stepKey="waitForFillCardNumber" time="1"/>
24+
<switchToIFrame stepKey="switchBackFromCard"/>
25+
26+
<!--Fill expire date-->
27+
<switchToIFrame stepKey="switchToExpirationMonth" selector="{{NewOrderSection.monthFrame}}"/>
28+
<fillField stepKey="fillMonth" selector="{{NewOrderSection.expirationMonth}}" userInput="{{PaymentAndShippingInfo.month}}"/>
29+
<waitForPageLoad stepKey="waitForFillMonth" time="1"/>
30+
<switchToIFrame stepKey="switchBackFromMonth"/>
31+
<switchToIFrame stepKey="switchToExpirationYear" selector="{{NewOrderSection.yearFrame}}"/>
32+
<fillField stepKey="fillYear" selector="{{NewOrderSection.expirationYear}}" userInput="{{PaymentAndShippingInfo.year}}"/>
33+
<waitForPageLoad stepKey="waitForFillYear" time="1"/>
34+
<switchToIFrame stepKey="switchBackFromYear"/>
35+
36+
<!--Fill CVW code-->
37+
<switchToIFrame stepKey="switchToCVV" selector="{{NewOrderSection.cvvFrame}}"/>
38+
<fillField stepKey="fillCVV" selector="{{NewOrderSection.cvv}}" userInput="{{PaymentAndShippingInfo.cvv}}"/>
39+
<wait stepKey="waitForFillCVV" time="1"/>
40+
<switchToIFrame stepKey="switchBackFromCVV"/>
41+
</actionGroup>
42+
</actionGroups>

app/code/Magento/Braintree/Test/Mftf/Data/BraintreeData.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<requiredEntity type="merchant_id">MerchantId</requiredEntity>
4343
<requiredEntity type="public_key">PublicKey</requiredEntity>
4444
<requiredEntity type="private_key">PrivateKey</requiredEntity>
45+
<requiredEntity type="active">Status</requiredEntity>
4546
</entity>
4647
<entity name="BraintreeTitle" type="title">
4748
<data key="value">Credit Card (Braintree)</data>

app/code/Magento/Braintree/Test/Mftf/Section/AdminMenuSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<element name="sales" type="button" selector="//li[@id='menu-magento-sales-sales']"/>
1414
<element name="catalog" type="button" selector="//li[@id='menu-magento-catalog-catalog']"/>
1515
<element name="customers" type="button" selector="//li[@id='menu-magento-customer-customer']"/>
16-
<element name="marketing" type="button" selector="//li[@id='//li[@id='menu-magento-backend-marketing']']"/>
16+
<element name="marketing" type="button" selector="//li[@id='menu-magento-backend-marketing']"/>
1717
<element name="content" type="button" selector="//li[@id='menu-magento-backend-content']"/>
1818
<element name="reports" type="button" selector="//li[@id='menu-magento-reports-report']"/>
1919
<element name="stores" type="button" selector="//li[@id='menu-magento-backend-stores']"/>
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="CreateAdminOrderPayedWithOnlinePaymentIncludingTaxAndDiscount">
12+
<annotations>
13+
<features value="Braintree"/>
14+
<stories value="Get access to a New Credit Memo Page from Invocie for Order payed with online payment via Admin"/>
15+
<title value="Admin should be able to open a New Credit Memo Page from Invoice Page for Order with tax and discount and payed using online payment method"/>
16+
<description value="Admin should be able to open a New Credit Memo Page from Invoice Page for Order with tax and discount and payed using online payment method"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MAGETWO-94472"/>
19+
<group value="braintree"/>
20+
</annotations>
21+
22+
<before>
23+
<!--Create Default Category-->
24+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
25+
26+
<!--Create Simple product-->
27+
<createData entity="_defaultProduct" stepKey="simpleProduct">
28+
<requiredEntity createDataKey="createCategory"/>
29+
</createData>
30+
31+
<!--Create Tax Rule is based on default tax rates (Stores>Tax Rule) US-CA-*-Rate 1 = 8.2500 US-NY-*-Rate 1 = 8.3750 -->
32+
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
33+
34+
<!--Configure Braintree Payment method-->
35+
<createData entity="BraintreeConfig" stepKey="BraintreeConfigurationData"/>
36+
<createData entity="CustomBraintreeConfigurationData" stepKey="enableBraintree"/>
37+
38+
<!--Create Retailer Customer with US_CA address-->
39+
<createData entity="Simple_US_Customer_CA" stepKey="simpleCustomer">
40+
<field key="group_id">3</field>
41+
</createData>
42+
43+
<!--Login as Admin User-->
44+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
45+
</before>
46+
47+
<after>
48+
<!--Delete Cart Price Rule-->
49+
<actionGroup ref="AdminDeleteCartPriceRuleForRetailerActionGroup" stepKey="deleteSalesRule"/>
50+
51+
<!--Set to default configuration Tax Shipping Class-->
52+
<actionGroup ref="setDefaultShippingTaxClass" stepKey="setdefaultClass"/>
53+
54+
<!--Delete Simple Sub Category-->
55+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
56+
57+
<!--Delete Simple Product-->
58+
<deleteData createDataKey="simpleProduct" stepKey="deleteSimpleProduct"/>
59+
60+
<!-- Delete Tax Rule -->
61+
<deleteData createDataKey="createTaxRule" stepKey="deleteTaxRule"/>
62+
63+
<!-- Rollback Braintree to Default -->
64+
<createData entity="RollBackCustomBraintreeConfigurationData" stepKey="rollbackBraintreeConfig"/>
65+
66+
<!--Delete Customer-->
67+
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
68+
69+
<!--Log Out-->
70+
<actionGroup ref="logout" stepKey="logout"/>
71+
</after>
72+
73+
<!-- Create a cart price rule with 10% discount for whole cart -->
74+
<click selector="{{AdminMenuSection.marketing}}" stepKey="clickOnMarketing" />
75+
<waitForPageLoad stepKey="waitForMarketing" time="3"/>
76+
<click selector="{{CartPriceRulesSubmenuSection.cartPriceRules}}" stepKey="clickOnCartPriceRules"/>
77+
<waitForPageLoad stepKey="waitForCartPriceRules" time="3"/>
78+
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
79+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{SimpleSalesRule.name}}" stepKey="fillRuleName"/>
80+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>
81+
<actionGroup ref="selectRetailerCustomerGroup" stepKey="selectRetailerCustomerGroup"/>
82+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/>
83+
<selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Percent of product price discount" stepKey="selectActionType"/>
84+
<fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/>
85+
<click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/>
86+
<waitForPageLoad stepKey="waitForCartRuleLoad" time="3"/>
87+
<see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
88+
89+
<!--Set Taxable Goods for Shipping Tax Class-->
90+
<actionGroup ref="changeShippingTaxClass" stepKey="changeShippingTaxClass"/>
91+
92+
<!--Adding Special price to product-->
93+
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct.id$$)}}" stepKey="openAdminProductEditPage"/>
94+
<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="addSpecialPrice"/>
95+
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
96+
97+
<!--Create New Order-->
98+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer">
99+
<argument name="customer" value="$$simpleCustomer$$"/>
100+
</actionGroup>
101+
102+
<!--Add a product to order-->
103+
<actionGroup ref="addSimpleProductToOrder" stepKey="addProductToOrder">
104+
<argument name="product" value="$$simpleProduct$$"/>
105+
</actionGroup>
106+
107+
<!--Select FlatRate shipping method-->
108+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="orderSelectFlatRateShippingMethod"/>
109+
110+
<!--Select Braintree online Payment method -->
111+
<actionGroup ref="AdminOrderBraintreeFillActionGroup" stepKey="selectCreditCardPayment"/>
112+
113+
<!--Submit Order-->
114+
<click stepKey="submitOrder" selector="{{NewOrderSection.submitOrder}}"/>
115+
<waitForPageLoad stepKey="waitForSubmitOrder" time="5"/>
116+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the order." stepKey="seeOrderSuccessMessage" after="waitForSubmitOrder"/>
117+
118+
<!-- Create New invoice-->
119+
<actionGroup ref="adminFastCreateInvoice" stepKey="createInvoice"/>
120+
121+
<!--Get access to Credit Memo page from Invoice page-->
122+
<click selector="{{AdminInvoiceMainActionsSection.openNewCreditMemoFromInvoice}}" stepKey="clickCreateNewCreditMemo"/>
123+
<waitForPageLoad stepKey="waitForLoadNewCreditMemoPage" time="5"/>
124+
<see selector="{{AdminCreditMemoOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeNewCreditMemo"/>
125+
</test>
126+
</tests>

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
use Magento\Framework\Session\SessionManagerInterface;
2626
use Magento\Framework\View\Element\UiComponent\ContextInterface;
2727
use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool;
28+
use Magento\Ui\Component\Form\Element\Multiline;
2829
use Magento\Ui\Component\Form\Field;
2930
use Magento\Ui\DataProvider\EavValidationRules;
3031

3132
/**
33+
* Supplies the data for the customer UI component
34+
*
3235
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3336
*
3437
* @api
@@ -155,10 +158,11 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
155158
* @param Config $eavConfig
156159
* @param FilterPool $filterPool
157160
* @param FileProcessorFactory $fileProcessorFactory
158-
* @param ContextInterface $context
159161
* @param array $meta
160162
* @param array $data
163+
* @param ContextInterface $context
161164
* @param bool $allowToShowHiddenAttributes
165+
* @throws \Magento\Framework\Exception\LocalizedException
162166
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
163167
*/
164168
public function __construct(
@@ -596,8 +600,14 @@ protected function prepareAddressData($addressId, array &$addresses, array $cust
596600
) {
597601
$addresses[$addressId]['default_shipping'] = $customer['default_shipping'];
598602
}
599-
if (isset($addresses[$addressId]['street']) && !is_array($addresses[$addressId]['street'])) {
600-
$addresses[$addressId]['street'] = explode("\n", $addresses[$addressId]['street']);
603+
604+
foreach ($this->meta['address']['children'] as $attributeName => $attributeMeta) {
605+
if ($attributeMeta['arguments']['data']['config']['dataType'] === Multiline::NAME
606+
&& isset($addresses[$addressId][$attributeName])
607+
&& !is_array($addresses[$addressId][$attributeName])
608+
) {
609+
$addresses[$addressId][$attributeName] = explode("\n", $addresses[$addressId][$attributeName]);
610+
}
601611
}
602612
}
603613

app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,8 @@ public function testGetData()
649649
2 => [
650650
'firstname' => 'firstname',
651651
'lastname' => 'lastname',
652-
'street' => [
653-
'street',
654-
'street',
655-
],
652+
// Won't be an array because it isn't defined as a multiline field in this test
653+
'street' => "street\nstreet",
656654
'default_billing' => 2,
657655
'default_shipping' => 2,
658656
]

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function __construct(
3737
}
3838

3939
/**
40+
* Collects credit memo shipping totals.
41+
*
4042
* @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
4143
* @return $this
4244
* @throws \Magento\Framework\Exception\LocalizedException
@@ -55,12 +57,10 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
5557
$orderShippingInclTax = $order->getShippingInclTax();
5658
$orderBaseShippingInclTax = $order->getBaseShippingInclTax();
5759
$allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded();
58-
$baseAllowedTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded();
5960
$allowedAmountInclTax = $allowedAmount + $allowedTaxAmount;
60-
$baseAllowedAmountInclTax = $baseAllowedAmount + $baseAllowedTaxAmount;
61-
62-
// for the credit memo
63-
$shippingAmount = $baseShippingAmount = $shippingInclTax = $baseShippingInclTax = 0;
61+
$baseAllowedAmountInclTax = $orderBaseShippingInclTax
62+
- $order->getBaseShippingRefunded()
63+
- $order->getBaseShippingTaxRefunded();
6464

6565
// Check if the desired shipping amount to refund was specified (from invoice or another source).
6666
if ($creditmemo->hasBaseShippingAmount()) {
@@ -128,7 +128,6 @@ private function isSuppliedShippingAmountInclTax($order)
128128

129129
/**
130130
* Get the Tax Config.
131-
* In a future release, will become a constructor parameter.
132131
*
133132
* @return \Magento\Tax\Model\Config
134133
*

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
*/
66
namespace Magento\Sales\Model\Order\Creditmemo\Total;
77

8+
/**
9+
* Collects credit memo taxes.
10+
*/
811
class Tax extends AbstractTotal
912
{
1013
/**
14+
* Collects credit memo taxes.
15+
*
1116
* @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
1217
* @return $this
1318
*
@@ -79,18 +84,10 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
7984
$totalDiscountTaxCompensation += $invoice->getShippingDiscountTaxCompensationAmount() * $taxFactor;
8085
$baseTotalDiscountTaxCompensation +=
8186
$invoice->getBaseShippingDiscountTaxCompensationAmnt() * $taxFactor;
82-
$shippingDiscountTaxCompensationAmount =
83-
$invoice->getShippingDiscountTaxCompensationAmount() * $taxFactor;
84-
$baseShippingDiscountTaxCompensationAmount =
85-
$invoice->getBaseShippingDiscountTaxCompensationAmnt() * $taxFactor;
8687
$shippingTaxAmount = $creditmemo->roundPrice($shippingTaxAmount);
8788
$baseShippingTaxAmount = $creditmemo->roundPrice($baseShippingTaxAmount, 'base');
8889
$totalDiscountTaxCompensation = $creditmemo->roundPrice($totalDiscountTaxCompensation);
8990
$baseTotalDiscountTaxCompensation = $creditmemo->roundPrice($baseTotalDiscountTaxCompensation, 'base');
90-
$shippingDiscountTaxCompensationAmount =
91-
$creditmemo->roundPrice($shippingDiscountTaxCompensationAmount);
92-
$baseShippingDiscountTaxCompensationAmount =
93-
$creditmemo->roundPrice($baseShippingDiscountTaxCompensationAmount, 'base');
9491
if ($taxFactor < 1 && $invoice->getShippingTaxAmount() > 0) {
9592
$isPartialShippingRefunded = true;
9693
}

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Sales\Model\Order\Invoice\Total;
77

8+
/**
9+
* Collects invoice taxes.
10+
*/
811
class Tax extends AbstractTotal
912
{
1013
/**
@@ -69,26 +72,31 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
6972
}
7073
}
7174

75+
$taxDiscountCompensationAmt = $totalDiscountTaxCompensation;
76+
$baseTaxDiscountCompensationAmt = $baseTotalDiscountTaxCompensation;
77+
$allowedDiscountTaxCompensation = $order->getDiscountTaxCompensationAmount() -
78+
$order->getDiscountTaxCompensationInvoiced();
79+
$allowedBaseDiscountTaxCompensation = $order->getBaseDiscountTaxCompensationAmount() -
80+
$order->getBaseDiscountTaxCompensationInvoiced();
81+
7282
if ($this->_canIncludeShipping($invoice)) {
7383
$totalTax += $order->getShippingTaxAmount();
7484
$baseTotalTax += $order->getBaseShippingTaxAmount();
7585
$totalDiscountTaxCompensation += $order->getShippingDiscountTaxCompensationAmount();
7686
$baseTotalDiscountTaxCompensation += $order->getBaseShippingDiscountTaxCompensationAmnt();
87+
88+
$allowedDiscountTaxCompensation += $order->getShippingDiscountTaxCompensationAmount() -
89+
$order->getShippingDiscountTaxCompensationInvoiced();
90+
$allowedBaseDiscountTaxCompensation += $order->getBaseShippingDiscountTaxCompensationAmnt() -
91+
$order->getBaseShippingDiscountTaxCompensationInvoiced();
92+
7793
$invoice->setShippingTaxAmount($order->getShippingTaxAmount());
7894
$invoice->setBaseShippingTaxAmount($order->getBaseShippingTaxAmount());
7995
$invoice->setShippingDiscountTaxCompensationAmount($order->getShippingDiscountTaxCompensationAmount());
8096
$invoice->setBaseShippingDiscountTaxCompensationAmnt($order->getBaseShippingDiscountTaxCompensationAmnt());
8197
}
8298
$allowedTax = $order->getTaxAmount() - $order->getTaxInvoiced();
8399
$allowedBaseTax = $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced();
84-
$allowedDiscountTaxCompensation = $order->getDiscountTaxCompensationAmount() +
85-
$order->getShippingDiscountTaxCompensationAmount() -
86-
$order->getDiscountTaxCompensationInvoiced() -
87-
$order->getShippingDiscountTaxCompensationInvoiced();
88-
$allowedBaseDiscountTaxCompensation = $order->getBaseDiscountTaxCompensationAmount() +
89-
$order->getBaseShippingDiscountTaxCompensationAmnt() -
90-
$order->getBaseDiscountTaxCompensationInvoiced() -
91-
$order->getBaseShippingDiscountTaxCompensationInvoiced();
92100

93101
if ($invoice->isLast()) {
94102
$totalTax = $allowedTax;
@@ -107,8 +115,8 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
107115

108116
$invoice->setTaxAmount($totalTax);
109117
$invoice->setBaseTaxAmount($baseTotalTax);
110-
$invoice->setDiscountTaxCompensationAmount($totalDiscountTaxCompensation);
111-
$invoice->setBaseDiscountTaxCompensationAmount($baseTotalDiscountTaxCompensation);
118+
$invoice->setDiscountTaxCompensationAmount($taxDiscountCompensationAmt);
119+
$invoice->setBaseDiscountTaxCompensationAmount($baseTaxDiscountCompensationAmt);
112120

113121
$invoice->setGrandTotal($invoice->getGrandTotal() + $totalTax + $totalDiscountTaxCompensation);
114122
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseTotalTax + $baseTotalDiscountTaxCompensation);

0 commit comments

Comments
 (0)