Skip to content

Commit f090960

Browse files
committed
Merge remote-tracking branch 'local/ACP2E-1076' into PR_25_NOV_2022
2 parents 84e7dfa + 6e36f59 commit f090960

File tree

6 files changed

+125
-5
lines changed

6 files changed

+125
-5
lines changed

app/code/Magento/Quote/Model/Quote/TotalsCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function collectAddressTotals(
269269
'total' => $total
270270
]
271271
);
272-
272+
$total->setBaseSubtotalTotalInclTax($total->getBaseSubtotalInclTax());
273273
$address->addData($total->getData());
274274
$address->setAppliedTaxes($total->getAppliedTaxes());
275275
return $total;

app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ protected function processProductItems(
627627
$address = $shippingAssignment->getShipping()->getAddress();
628628
$address->setBaseTaxAmount($baseTax);
629629
$address->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
630+
$address->setSubtotalInclTax($subtotalInclTax);
630631
$address->setSubtotal($total->getSubtotal());
631632
$address->setBaseSubtotal($total->getBaseSubtotal());
632633

app/code/Magento/Weee/Model/Total/Quote/Weee.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class Weee extends AbstractTotal
2525
/**
2626
* Constant for weee item code prefix
2727
*/
28-
const ITEM_CODE_WEEE_PREFIX = 'weee';
28+
public const ITEM_CODE_WEEE_PREFIX = 'weee';
2929
/**
3030
* Constant for weee item type
3131
*/
32-
const ITEM_TYPE = 'weee';
32+
public const ITEM_TYPE = 'weee';
3333

3434
/**
3535
* @var WeeHelper
@@ -42,7 +42,7 @@ class Weee extends AbstractTotal
4242
protected $_store;
4343

4444
/**
45-
* Counter
45+
* Counter to keep track of count for weee
4646
*
4747
* @var int
4848
*/
@@ -245,6 +245,7 @@ protected function process(
245245

246246
$this->processTotalAmount(
247247
$total,
248+
$address,
248249
$totalRowValueExclTax,
249250
$baseTotalRowValueExclTax,
250251
$totalRowValueInclTax,
@@ -258,6 +259,7 @@ protected function process(
258259
* Process row amount based on FPT total amount configuration setting
259260
*
260261
* @param Total $total
262+
* @param Address $address
261263
* @param float $rowValueExclTax
262264
* @param float $baseRowValueExclTax
263265
* @param float $rowValueInclTax
@@ -266,6 +268,7 @@ protected function process(
266268
*/
267269
protected function processTotalAmount(
268270
$total,
271+
$address,
269272
$rowValueExclTax,
270273
$baseRowValueExclTax,
271274
$rowValueInclTax,
@@ -284,6 +287,8 @@ protected function processTotalAmount(
284287
$total->setBaseSubtotalInclTax(
285288
$total->getBaseSubtotalInclTax() + $this->priceCurrency->round($baseRowValueInclTax)
286289
);
290+
$address->setBaseSubtotalTotalInclTax($total->getBaseSubtotalInclTax());
291+
$address->setSubtotalInclTax($total->getSubtotalInclTax());
287292
return $this;
288293
}
289294

app/code/Magento/Weee/Model/Total/Quote/WeeeTax.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function collect(
3030
Total $total
3131
) {
3232
AbstractTotal::collect($quote, $shippingAssignment, $total);
33+
$address = $shippingAssignment->getShipping()->getAddress();
3334
$this->_store = $quote->getStore();
3435
if (!$this->weeeData->isEnabled($this->_store)) {
3536
return $this;
@@ -47,7 +48,7 @@ public function collect(
4748
$weeeBaseTotal = $total->getWeeeBaseTotalExclTax();
4849

4950
//Add to appropriate 'subtotal' or 'weee' accumulators
50-
$this->processTotalAmount($total, $weeeTotal, $weeeBaseTotal, $weeeTotal, $weeeBaseTotal);
51+
$this->processTotalAmount($total, $address, $weeeTotal, $weeeBaseTotal, $weeeTotal, $weeeBaseTotal);
5152
return $this;
5253
}
5354

@@ -141,6 +142,7 @@ public function collect(
141142

142143
$this->processTotalAmount(
143144
$total,
145+
$address,
144146
$totalRowValueExclTax,
145147
$baseTotalRowValueExclTax,
146148
$totalRowValueInclTax,
@@ -204,6 +206,7 @@ protected function createItemToWeeeCodeMapping($weeeCodeToItemMap)
204206
* Process row amount based on FPT total amount configuration setting
205207
*
206208
* @param Total $total
209+
* @param Address $address
207210
* @param float $rowValueExclTax
208211
* @param float $baseRowValueExclTax
209212
* @param float $rowValueInclTax
@@ -212,6 +215,7 @@ protected function createItemToWeeeCodeMapping($weeeCodeToItemMap)
212215
*/
213216
protected function processTotalAmount(
214217
$total,
218+
$address,
215219
$rowValueExclTax,
216220
$baseRowValueExclTax,
217221
$rowValueInclTax,
@@ -227,6 +231,8 @@ protected function processTotalAmount(
227231

228232
$total->setSubtotalInclTax($total->getSubtotalInclTax() + $rowValueInclTax);
229233
$total->setBaseSubtotalInclTax($total->getBaseSubtotalInclTax() + $baseRowValueInclTax);
234+
$address->setBaseSubtotalTotalInclTax($total->getBaseSubtotalInclTax());
235+
$address->setSubtotalInclTax($total->getSubtotalInclTax());
230236
return $this;
231237
}
232238

app/code/Magento/Weee/Test/Mftf/Section/StorefrontCheckoutCartItemWeeeSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="productWeeePriceExcludingTaxByName" type="text" selector="//a[contains(text(),'{{productName}}')]/ancestor::tr//td[contains(@class, 'price')]//span[contains(@class,'price-excluding-tax')]//span[contains(@class,'weee')]" parameterized="true"/>
1515
<element name="productWeeeSubtotalExcludingTaxByName" type="text" selector="//a[contains(text(),'{{productName}}')]/ancestor::tr//td[contains(@class, 'subtotal')]//span[contains(@class,'price-excluding-tax')]//span[contains(@class,'weee')]" parameterized="true"/>
1616
<element name="productWeeeSubtotalIncludingTax" type="text" selector="//span[@class='cart-tax-total']/span[@class='weee']/span[@class='price']"/>
17+
<element name="subtotalIncludingTaxPrice" type="text" selector=".//div[@class='cart-totals']//tr[@class='totals sub incl']//td[@class='amount']/span"/>
1718
</section>
1819
</sections>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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="StorefrontFPTTaxDiscountInShoppingCartTest">
12+
<annotations>
13+
<stories value="Discount (Cart price rules) ignore Weee tax amount included in subtotal cart"/>
14+
<title value="Discount (Cart price rules) ignore Weee tax amount included in subtotal cart"/>
15+
<description value="Discount (Cart price rules) ignore Weee tax amount included in subtotal including tax cart"/>
16+
<severity value="CRITICAL"/>
17+
<useCaseId value="ACP2E-1076"/>
18+
<testCaseId value="AC-6663"/>
19+
<group value="SalesRule"/>
20+
</annotations>
21+
22+
<before>
23+
<!-- Step 1: Simple product is created -->
24+
<createData entity="_defaultProduct" stepKey="createSimpleProduct"/>
25+
<!-- Step 2: Create a cart price rule for $10 Fixed amount discount -->
26+
<createData entity="ActiveSalesRuleCoupon50" stepKey="createCartPriceRule"/>
27+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
28+
<requiredEntity createDataKey="createCartPriceRule"/>
29+
</createData>
30+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
31+
<!-- Step 3: Store>Configuration; Sales>Tax FPT Enable -->
32+
<createData entity="WeeeConfigEnable" stepKey="enableFPT"/>
33+
<!-- update display price and display subtotal with 'Including and Excluding Tax' -->
34+
<magentoCLI command="config:set tax/cart_display/price 3" stepKey="setPrice"/>
35+
<magentoCLI command="config:set tax/cart_display/subtotal 3" stepKey="setSubtotal"/>
36+
<!-- Step 4: Fixed Product Tax attribute is created and added to default attribute set -->
37+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
38+
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
39+
<requiredEntity createDataKey="createProductFPTAttribute"/>
40+
</createData>
41+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openProductEditPage">
42+
<argument name="productId" value="$$createSimpleProduct.id$$"/>
43+
</actionGroup>
44+
<!-- Step 5: FPT United States/California/100 -->
45+
<actionGroup ref="AdminProductAddFPTValueActionGroup" stepKey="addFPTValue1">
46+
<argument name="FPTAttributeCode" value="$createProductFPTAttribute.attribute_code$"/>
47+
<argument name="stateForFPT" value="California"/>
48+
<argument name="valueForFPT" value="100"/>
49+
</actionGroup>
50+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
51+
<magentoCron groups="index" stepKey="reindexBrokenIndices"/>
52+
</before>
53+
54+
<after>
55+
<magentoCLI command="config:set tax/cart_display/price 1" stepKey="setPrice"/>
56+
<magentoCLI command="config:set tax/cart_display/subtotal 1" stepKey="setSubtotal"/>
57+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteSalesRule"/>
58+
<deleteData createDataKey="createProductFPTAttribute" stepKey="deleteProductFPTAttribute"/>
59+
<createData entity="WeeeConfigDisable" stepKey="disableFPT"/>
60+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
61+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
62+
<magentoCron groups="index" stepKey="reindexBrokenIndices"/>
63+
</after>
64+
65+
<!-- Search and update cart price rule page -->
66+
<actionGroup ref="AdminOpenCartPriceRulesPageActionGroup" stepKey="goToCartPriceRulePage"/>
67+
<actionGroup ref="AdminFilterCartPriceRuleActionGroup" stepKey="filterCartPriceRule">
68+
<argument name="ruleName" value="$$createCartPriceRule.name$$"/>
69+
</actionGroup>
70+
<click selector="{{PriceRuleConditionsSection.conditionsTab}}" stepKey="expandConditions"/>
71+
<!-- Scroll down -->
72+
<scrollTo selector="{{PriceRuleConditionsSection.conditionsTab}}" stepKey="scrollToConditionsTab"/>
73+
<click selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="clickNewRule"/>
74+
<selectOption selector="{{PriceRuleConditionsSection.rulesDropdown}}" userInput="Subtotal (Incl. Tax)" stepKey="selectProductAttributes"/>
75+
<waitForPageLoad stepKey="waitForConditions"/>
76+
<click selector="{{PriceRuleConditionsSection.ruleParamLink('1', '1', '1')}}" stepKey="startEditOperator"/>
77+
<selectOption selector="{{PriceRuleConditionsSection.operatorByIndex('1', '1')}}" userInput="equals or less than" stepKey="fillOperator"/>
78+
<click selector="{{PriceRuleConditionsSection.ruleParamLink('1', '1', '2')}}" stepKey="startEditValue"/>
79+
<fillField selector="{{PriceRuleConditionsSection.valueByIndex('1', '1')}}" userInput="2000" stepKey="fillValue"/>
80+
<click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/>
81+
<see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
82+
<!-- Step 6: Add the product to the cart -->
83+
<amOnPage url="{{StorefrontProductPage.url($createSimpleProduct.custom_attributes[url_key]$)}}" stepKey="amOnSimpleProductPage1"/>
84+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
85+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="8" stepKey="fillQuantity"/>
86+
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage"/>
87+
<!-- Step 7: Go to Shopping Cart -->
88+
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart1"/>
89+
<!-- Step 8: Open Estimate Shipping and Tax section -->
90+
<actionGroup ref="StorefrontCheckoutCartFillEstimateShippingAndTaxActionGroup" stepKey="setEstimateShippingAndTaxInitialAddressToUnitedStates">
91+
<argument name="country" value="United States"/>
92+
<argument name="state" value="California"/>
93+
<argument name="postcode" value="*"/>
94+
</actionGroup>
95+
<!-- Step 9: Add the same product to the cart again ($2230.00 subtotal incl tax) -->
96+
<amOnPage url="{{StorefrontProductPage.url($createSimpleProduct.custom_attributes[url_key]$)}}" stepKey="amOnSimpleProductPage"/>
97+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
98+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="2" stepKey="fillQuantity2"/>
99+
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage2"/>
100+
<!-- Step 10: Go to Shopping Cart -->
101+
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart"/>
102+
<!-- Step 11: Should not see the discount because we have exceeded $2000 -->
103+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/>
104+
<see selector="{{StorefrontCheckoutCartItemWeeeSection.subtotalIncludingTaxPrice}}" userInput="$2,230.00" stepKey="seeNewPriceSide"/>
105+
<dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/>
106+
</test>
107+
</tests>

0 commit comments

Comments
 (0)