Skip to content

Commit ae00d48

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-91769' into EPAM-PR-21
2 parents f124dc2 + 1238a5c commit ae00d48

File tree

9 files changed

+193
-7
lines changed

9 files changed

+193
-7
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormActionSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<element name="saveAndClose" type="button" selector="span[title='Save &amp; Close']" timeout="30"/>
1616
<element name="changeStoreButton" type="button" selector="#store-change-button" timeout="10"/>
1717
<element name="selectStoreView" type="button" selector="//ul[@data-role='stores-list']/li/a[normalize-space(.)='{{var1}}']" timeout="10" parameterized="true"/>
18+
<element name="selectTaxClass" type="select" selector="select[name='product[tax_class_id]']"/>
1819
<element name="saveAndDuplicate" type="button" selector="span[id='save_and_duplicate']" timeout="30"/>
1920
</section>
2021
</sections>

app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@
112112

113113
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage"/>
114114
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask3"/>
115+
<!-- Reset admin order filter -->
116+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
117+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask5"/>
115118
<fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="searchOrderNum"/>
116119
<click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/>
117120
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/>

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

Lines changed: 8 additions & 3 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+
* Order credit memo tax total calculation model
10+
*/
811
class Tax extends AbstractTotal
912
{
1013
/**
14+
* Collect credit memo tax total
15+
*
1116
* @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
1217
* @return $this
1318
*
@@ -70,10 +75,11 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
7075
}
7176

7277
$isPartialShippingRefunded = false;
78+
$baseOrderShippingAmount = (float)$order->getBaseShippingAmount();
7379
if ($invoice = $creditmemo->getInvoice()) {
7480
//recalculate tax amounts in case if refund shipping value was changed
75-
if ($order->getBaseShippingAmount() && $creditmemo->getBaseShippingAmount()) {
76-
$taxFactor = $creditmemo->getBaseShippingAmount() / $order->getBaseShippingAmount();
81+
if ($baseOrderShippingAmount && $creditmemo->getBaseShippingAmount() !== null) {
82+
$taxFactor = $creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount;
7783
$shippingTaxAmount = $invoice->getShippingTaxAmount() * $taxFactor;
7884
$baseShippingTaxAmount = $invoice->getBaseShippingTaxAmount() * $taxFactor;
7985
$totalDiscountTaxCompensation += $invoice->getShippingDiscountTaxCompensationAmount() * $taxFactor;
@@ -99,7 +105,6 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
99105
}
100106
} else {
101107
$orderShippingAmount = $order->getShippingAmount();
102-
$baseOrderShippingAmount = $order->getBaseShippingAmount();
103108

104109
$baseOrderShippingRefundedAmount = $order->getBaseShippingRefunded();
105110

app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
<element name="emailCopy" type="checkbox" selector=".order-totals-actions #send_email"/>
2020
<element name="refundStoreCredit" type="checkbox" selector=".order-totals-actions .field-refund-store-credit input[type='checkbox']"/>
2121
<element name="submitRefundOffline" type="button" selector=".order-totals-actions button[data-ui-id='order-items-submit-button']" timeout="30"/>
22+
<element name="creditMemoItem" type="text" selector="#sales_order_view_tabs_order_creditmemos"/>
23+
<element name="viewMemo" type="text" selector="div#sales_order_view_tabs_order_creditmemos_content a.action-menu-item"/>
2224
</section>
2325
</sections>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ public function collectDataProvider()
447447
],
448448
],
449449
'creditmemo_data' => [
450-
'grand_total' => 64.95,
451-
'base_grand_total' => 64.95,
452-
'tax_amount' => 4.95,
453-
'base_tax_amount' => 4.95,
450+
'grand_total' => 64.94,
451+
'base_grand_total' => 64.94,
452+
'tax_amount' => 4.94,
453+
'base_tax_amount' => 4.94,
454454
],
455455
],
456456
];

app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminTaxActionGroup.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@
9595
<see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the configuration."/>
9696
</actionGroup>
9797

98+
<actionGroup name="addCustomTaxRate" extends="addNewTaxRateNoZip">
99+
<remove keyForRemoval="fillZipCode"/>
100+
<remove keyForRemoval="fillRate"/>
101+
<fillField stepKey="fillZipCode" selector="{{AdminTaxRulesSection.zipCode}}" userInput="US-NY-*-Rate 2" after="fillTaxIdentifier"/>
102+
<fillField stepKey="fillRate" selector="{{AdminTaxRulesSection.rate}}" userInput="0" after="selectCountry"/>
103+
</actionGroup>
104+
98105
<!-- Action group to add a tax rate when on a tax rule configuration page -->
99106
<!-- Must already be on a tax rule configuration page or a new tax rule page -->
100107
<actionGroup name="addNewTaxRateNoZip">

app/code/Magento/Tax/Test/Mftf/Section/AdminConfigureTaxSection.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,10 @@
5252
<element name="systemValueDisplayZeroTaxSales" type="checkbox" selector="#row_tax_sales_display_zero_tax input[type='checkbox']"/>
5353
<element name="dropdownDisplayZeroTaxSales" type="checkbox" selector="#row_tax_sales_display_zero_tax select"/>
5454
<element name="fixedProductTaxes" type="block" selector="#tax_weee-head" timeout="30"/>
55+
56+
<element name="taxClassesCondition" type="block" selector="//a[@id='tax_classes-head' and @class='open']" timeout="30"/>
57+
<element name="useSystemValue" type="checkbox" selector="#tax_classes_default_product_tax_class_inherit"/>
58+
<element name="productTaxClass" type="select" selector="#tax_classes_default_product_tax_class"/>
59+
<element name="save" type="button" selector="#save"/>
5560
</section>
5661
</sections>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminProductTaxClassSection">
12+
<element name="additionalSettings" type="text" selector="#details-summarybase_fieldset"/>
13+
<element name="additionalSettingsCond" type="text" selector="//summary[@id='details-summarybase_fieldset' and @aria-expanded='true']"/>
14+
<element name="productTaxClass" type="button" selector="//div[contains(@class, 'field-tax_product_class')]//span[text()='Add New Tax Class']"/>
15+
<element name="TaxClassName" type="block" selector="//div[contains(@class, 'field-tax_product_class')]//input[@class='mselect-input']"/>
16+
<element name="confirm" type="button" selector="//div[contains(@class, 'field-tax_product_class')]//span[@class='mselect-save']"/>
17+
</section>
18+
</sections>
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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="CheckCreditMemoTotalsTest">
12+
<annotations>
13+
<features value="Tax"/>
14+
<stories value="MAGETWO-91769 - Credit Memo - Wrong tax calculation! #10982"/>
15+
<title value="Checking Credit memo Totals"/>
16+
<description value="Checking Credit memo Totals"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MAGETWO-95175"/>
19+
<group value="creditMemo"/>
20+
<group value="tax"/>
21+
</annotations>
22+
<before>
23+
<!--Create category and product-->
24+
<createData entity="_defaultCategory" stepKey="createCategory"/>
25+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
26+
<requiredEntity createDataKey="createCategory"/>
27+
</createData>
28+
<!--Create customer-->
29+
<createData entity="Simple_US_Customer_NY" stepKey="createCustomer"/>
30+
<!--Login as admin-->
31+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
32+
<!--Create tax rule and tax rate-->
33+
<amOnPage url="{{AdminTaxRuleGridPage.url}}" stepKey="goToTaxRulePage"/>
34+
<waitForPageLoad stepKey="waitForTaxRatePage"/>
35+
<click stepKey="addNewTaxRate" selector="{{AdminGridMainControls.add}}"/>
36+
<fillField stepKey="fillRuleName" selector="{{AdminTaxRulesSection.ruleName}}" userInput="SampleRule"/>
37+
<actionGroup ref="addCustomTaxRate" stepKey="addCustomTaxRate">
38+
<argument name="taxCode" value="SimpleTaxNY"/>
39+
</actionGroup>
40+
<click stepKey="expandAdditionalSettings" selector="{{AdminProductTaxClassSection.additionalSettings}}"/>
41+
<waitForPageLoad stepKey="waitForPageLoad"/>
42+
<click selector="{{AdminProductTaxClassSection.productTaxClass}}" stepKey="ClickToAddTaxClass"/>
43+
<fillField selector="{{AdminProductTaxClassSection.TaxClassName}}" userInput="NewTaxClass" stepKey="setName"/>
44+
<click selector="{{AdminProductTaxClassSection.confirm}}" stepKey="ClickToDone"/>
45+
<click stepKey="clickSave" selector="{{AdminStoresMainActionsSection.saveButton}}"/>
46+
<waitForPageLoad stepKey="waitForTaxRatePage1"/>
47+
<see userInput="You saved the tax rule." stepKey="VerifyRuleSaved"/>
48+
<!--Search and edit product to add new created tax rule-->
49+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
50+
<argument name="product" value="$$createSimpleProduct$$"/>
51+
</actionGroup>
52+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="OpenEditProductOnBackend">
53+
<argument name="product" value="$$createSimpleProduct$$"/>
54+
</actionGroup>
55+
<waitForPageLoad stepKey="waitForPageLoad2"/>
56+
<selectOption selector="{{AdminProductFormActionSection.selectTaxClass}}" userInput="NewTaxClass" stepKey="SetNewTaxClass" />
57+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
58+
<!--Set configs-->
59+
<amOnPage url="{{AdminTaxConfigurationPage.url}}" stepKey="goToTaxConfigPage"/>
60+
<conditionalClick stepKey="clickOrdersInvoicesCreditSales" selector="{{AdminConfigureTaxSection.taxClasses}}" dependentSelector="{{AdminConfigureTaxSection.taxClassesCondition}}" visible="false"/>
61+
<click selector="{{AdminConfigureTaxSection.useSystemValue}}" stepKey="UncheckUseSystemValue"/>
62+
<selectOption selector="{{AdminConfigureTaxSection.productTaxClass}}" userInput="NewTaxClass" stepKey="selectClass"/>
63+
<click selector="{{AdminConfigureTaxSection.save}}" stepKey="saveConfig"/>
64+
<!--flash cache-->
65+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
66+
</before>
67+
<after>
68+
<!--Delete category and product-->
69+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
70+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
71+
<!--Delete customer-->
72+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
73+
<!-- Reset admin order filter -->
74+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
75+
<!--Roll Back configuration-->
76+
<amOnPage url="{{AdminTaxConfigurationPage.url}}" stepKey="goToTaxConfigPage"/>
77+
<conditionalClick stepKey="clickOrdersInvoicesCreditSales" selector="{{AdminConfigureTaxSection.taxClasses}}" dependentSelector="{{AdminConfigureTaxSection.taxClassesCondition}}" visible="false"/>
78+
<selectOption selector="{{AdminConfigureTaxSection.productTaxClass}}" userInput="Taxable Goods" stepKey="selectClass"/>
79+
<click selector="{{AdminConfigureTaxSection.save}}" stepKey="saveConfig"/>
80+
<!-- Go to the tax rule page and delete the row we created-->
81+
<amOnPage url="{{AdminTaxRuleGridPage.url}}" stepKey="goToTaxRulesPage"/>
82+
<waitForPageLoad stepKey="waitForRulesPage"/>
83+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteRule">
84+
<argument name="name" value="SampleRule"/>
85+
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
86+
</actionGroup>
87+
<!-- Go to the tax rate page -->
88+
<amOnPage url="{{AdminTaxRateGridPage.url}}" stepKey="goToTaxRatesPage"/>
89+
<waitForPageLoad stepKey="waitForRatesPage"/>
90+
<!-- Delete tax rate that were created -->
91+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteNYRate">
92+
<argument name="name" value="{{SimpleTaxNY.state}}"/>
93+
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
94+
</actionGroup>
95+
<actionGroup ref="deleteProductTaxClass" stepKey="deleteFirstProductTaxClass">
96+
<argument name="taxClassName" value="NewTaxClass"/>
97+
</actionGroup>
98+
<!--logout-->
99+
<actionGroup ref="logout" stepKey="logout"/>
100+
</after>
101+
<!--Create new order-->
102+
<actionGroup stepKey="CreateNewOrder" ref="navigateToNewOrderPageExistingCustomer">
103+
<argument name="customer" value="Simple_US_Customer_NY"/>
104+
</actionGroup>
105+
<!--Add product to order-->
106+
<click stepKey="clickToAddProduct" selector="{{AdminOrderFormItemsSection.addProducts}}"/>
107+
<waitForPageLoad stepKey="waitForProductsOpened"/>
108+
<checkOption selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" stepKey="selectProduct"/>
109+
<click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="clickAddSelectedProducts"/>
110+
<waitForPageLoad stepKey="waitForPageLoad3"/>
111+
<!--Set shipping method-->
112+
<actionGroup stepKey="orderSelectFlatRateShipping" ref="orderSelectFlatRateShipping"/>
113+
<!--Submit order-->
114+
<click stepKey="SubmitOrder" selector="{{AdminOrderFormActionSection.SubmitOrder}}"/>
115+
<waitForPageLoad stepKey="waitForPageLoad4"/>
116+
<grabTextFrom stepKey="getOrderId" selector="|Order # (\d+)|"/>
117+
<!--Open new created order-->
118+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrders"/>
119+
<waitForPageLoad stepKey="waitForPageLoad5"/>
120+
<actionGroup ref="filterOrderGridById" stepKey="filterOrderGridById">
121+
<argument name="orderId" value="$getOrderId"/>
122+
</actionGroup>
123+
<!--Create order invoice-->
124+
<click selector="{{AdminDataGridTableSection.rowViewAction('1')}}" stepKey="clickCreatedOrderInGrid"/>
125+
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceAction"/>
126+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seePageNameNewInvoicePage"/>
127+
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/>
128+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeInvoiceCreateSuccess"/>
129+
<see selector="{{AdminInvoiceOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeOrderProcessing"/>
130+
<!--Create Credit Memo-->
131+
<click selector="{{AdminOrderDetailsMainActionsSection.creditMemo}}" stepKey="clickCreditMemoAction"/>
132+
<fillField selector="{{AdminCreditMemoTotalSection.refundShipping}}" userInput="0" stepKey="setRefundShipping"/>
133+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Memo" stepKey="seeNewMemoInPageTitle"/>
134+
<click selector="{{AdminCreditMemoTotalSection.submitRefundOffline}}" stepKey="clickRefundOffline"/>
135+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the credit memo." stepKey="seeCreditMemoSuccess"/>
136+
<click selector="{{AdminCreditMemoTotalSection.creditMemoItem}}" stepKey="goToCreatedCreditMemo"/>
137+
<waitForPageLoad stepKey="waitForPageLoad6"/>
138+
<!--View created memo and verify tax for product-->
139+
<click selector="{{AdminCreditMemoTotalSection.viewMemo}}" stepKey="ViewMemo"/>
140+
<waitForPageLoad stepKey="waitForPageLoad7"/>
141+
<grabTextFrom selector="{{AdminCreditMemoTotalSection.grandTotal}}" stepKey="getGrandTotal"/>
142+
<assertEquals expected='$123.00' expectedType="string" actual="($getGrandTotal)" stepKey="assertGrandTotalValue"/>
143+
144+
</test>
145+
</tests>

0 commit comments

Comments
 (0)