Skip to content

Commit f54bd5f

Browse files
committed
MC-20244: Pricing :: FPT calculation
- fix static failures
1 parent a102fd3 commit f54bd5f

File tree

6 files changed

+36
-23
lines changed

6 files changed

+36
-23
lines changed

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ type Price @doc(description: "Price is deprecated, replaced by ProductPrice. The
2121
adjustments: [PriceAdjustment] @deprecated(reason: "Price is deprecated, use ProductPrice.") @doc(description: "An array that provides information about tax, weee, or weee_tax adjustments.")
2222
}
2323

24-
type PriceAdjustment @doc(description: "The PricedAdjustment object defines the amount of money to apply as an adjustment, the type of adjustment to apply, and whether the item is included or excluded from the adjustment.") {
24+
type PriceAdjustment @doc(description: "PriceAdjustment is deprecated. Taxes will be included or excluded in the price. The PricedAdjustment object defines the amount of money to apply as an adjustment, the type of adjustment to apply, and whether the item is included or excluded from the adjustment.") {
2525
amount: Money @doc(description: "The amount of the price adjustment and its currency code.")
26-
code: PriceAdjustmentCodesEnum @doc(description: "Indicates whether the adjustment involves tax, weee, or weee_tax.")
27-
description: PriceAdjustmentDescriptionEnum @doc(description: "Indicates whether the entity described by the code attribute is included or excluded from the adjustment.")
26+
code: PriceAdjustmentCodesEnum @deprecated(reason: "PriceAdjustment is deprecated.") @doc(description: "Indicates whether the adjustment involves tax, weee, or weee_tax.")
27+
description: PriceAdjustmentDescriptionEnum @deprecated(reason: "PriceAdjustment is deprecated.") @doc(description: "Indicates whether the entity described by the code attribute is included or excluded from the adjustment.")
2828
}
2929

30-
enum PriceAdjustmentCodesEnum @doc(description: "Note: This enumeration contains values defined in modules other than the Catalog module.") {
30+
enum PriceAdjustmentCodesEnum @doc(description: "PriceAdjustmentCodesEnum is deprecated. This enumeration contains values defined in modules other than the Catalog module.") {
3131
}
3232

33-
enum PriceAdjustmentDescriptionEnum @doc(description: "This enumeration states whether a price adjustment is included or excluded.") {
33+
enum PriceAdjustmentDescriptionEnum @doc(description: "PriceAdjustmentDescriptionEnum is deprecated. This enumeration states whether a price adjustment is included or excluded.") {
3434
INCLUDED
3535
EXCLUDED
3636
}

app/code/Magento/Weee/Model/ResourceModel/Tax.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
*/
66
namespace Magento\Weee\Model\ResourceModel;
77

8-
use Magento\Catalog\Model\Product;
9-
use Magento\Catalog\Model\Product\Condition\ConditionInterface;
10-
118
/**
129
* Wee tax resource model
1310
*
@@ -51,7 +48,7 @@ protected function _construct()
5148
}
5249

5350
/**
54-
* Fetch one
51+
* Fetch one calculated weee attribute from a select criteria
5552
*
5653
* @param \Magento\Framework\DB\Select|string $select
5754
* @return string
@@ -62,6 +59,8 @@ public function fetchOne($select)
6259
}
6360

6461
/**
62+
* Is there a weee attribute available for the location provided
63+
*
6564
* @param int $countryId
6665
* @param int $regionId
6766
* @param int $websiteId
@@ -96,6 +95,8 @@ public function isWeeeInLocation($countryId, $regionId, $websiteId)
9695
}
9796

9897
/**
98+
* Fetch calculated weee attributes by location, store and entity
99+
*
99100
* @param int $countryId
100101
* @param int $regionId
101102
* @param int $websiteId

app/code/Magento/Weee/Model/Tax.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Magento\Catalog\Model\Product\Type;
1414

1515
/**
16+
* Weee tax model
17+
*
1618
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1719
* @api
1820
* @since 100.0.2
@@ -144,6 +146,8 @@ protected function _construct()
144146
}
145147

146148
/**
149+
* Get the weee amount
150+
*
147151
* @param Product $product
148152
* @param null|false|\Magento\Framework\DataObject $shipping
149153
* @param null|false|\Magento\Framework\DataObject $billing
@@ -173,6 +177,8 @@ public function getWeeeAmount(
173177
}
174178

175179
/**
180+
* Get the weee amount excluding tax
181+
*
176182
* @param Product $product
177183
* @param null|false|\Magento\Framework\DataObject $shipping
178184
* @param null|false|\Magento\Framework\DataObject $billing
@@ -203,6 +209,8 @@ public function getWeeeAmountExclTax(
203209
}
204210

205211
/**
212+
* Get the weee attribute codes
213+
*
206214
* @param bool $forceEnabled
207215
* @return array
208216
*/
@@ -214,8 +222,8 @@ public function getWeeeAttributeCodes($forceEnabled = false)
214222
/**
215223
* Retrieve Wee tax attribute codes
216224
*
217-
* @param null|string|bool|int|Store $store
218-
* @param bool $forceEnabled
225+
* @param null|string|bool|int|Store $store
226+
* @param bool $forceEnabled
219227
* @return array
220228
*/
221229
public function getWeeeTaxAttributeCodes($store = null, $forceEnabled = false)
@@ -231,6 +239,8 @@ public function getWeeeTaxAttributeCodes($store = null, $forceEnabled = false)
231239
}
232240

233241
/**
242+
* Retrieve the relevant wee tax attributes assigned to a product by location
243+
*
234244
* @param Product $product
235245
* @param null|false|\Magento\Quote\Model\Quote\Address $shipping
236246
* @param null|false|\Magento\Quote\Model\Quote\Address $billing
@@ -241,6 +251,7 @@ public function getWeeeTaxAttributeCodes($store = null, $forceEnabled = false)
241251
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
242252
* @SuppressWarnings(PHPMD.NPathComplexity)
243253
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
254+
* phpcs:disable Generic.Metrics.NestingLevel
244255
*/
245256
public function getProductWeeeAttributes(
246257
$product,
@@ -283,7 +294,7 @@ public function getProductWeeeAttributes(
283294
return $result;
284295
}
285296

286-
/** @var \Magento\Tax\Model\Calculation $calculator */
297+
/** @var Calculation $calculator */
287298
$calculator = $this->_calculationFactory->create();
288299

289300
$customerId = $this->_customerSession->getCustomerId();
@@ -332,7 +343,7 @@ public function getProductWeeeAttributes(
332343
$amount = $value;
333344
$amountExclTax = $value;
334345
if ($calculateTax && $this->weeeConfig->isTaxable($store)) {
335-
/** @var \Magento\Tax\Model\Calculation $calculator */
346+
/** @var Calculation $calculator */
336347
$defaultPercent = $calculator->getRate(
337348
$defaultRateRequest->setProductClassId($product->getTaxClassId())
338349
);
@@ -392,6 +403,8 @@ public function getProductWeeeAttributes(
392403
}
393404

394405
/**
406+
* Is there a weee attribute available for the location provided
407+
*
395408
* @param int $countryId
396409
* @param int $regionId
397410
* @param int $websiteId

app/code/Magento/WeeeGraphQl/Model/Resolver/FptResolver.php renamed to app/code/Magento/WeeeGraphQl/Model/Resolver/FixedProductTax.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
/**
2020
* Resolver for FixedProductTax object that retrieves an array of FPT attributes with prices
2121
*/
22-
class FptResolver implements ResolverInterface
22+
class FixedProductTax implements ResolverInterface
2323
{
24-
2524
/**
2625
* @var Data
2726
*/

app/code/Magento/WeeeGraphQl/composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"type": "magento2-module",
55
"require": {
66
"php": "~7.1.3||~7.2.0||~7.3.0",
7-
"magento/framework": "*"
8-
},
9-
"suggest": {
7+
"magento/framework": "*",
108
"magento/module-store": "*",
119
"magento/module-tax": "*",
12-
"magento/module-weee": "*",
10+
"magento/module-weee": "*"
11+
},
12+
"suggest": {
1313
"magento/module-catalog-graph-ql": "*"
1414
},
1515
"license": [

app/code/Magento/WeeeGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Copyright © Magento, Inc. All rights reserved.
22
# See COPYING.txt for license details.
33

4-
enum PriceAdjustmentCodesEnum {
5-
WEEE
6-
WEEE_TAX
4+
enum PriceAdjustmentCodesEnum @doc(description: "PriceAdjustmentCodesEnum is deprecated, use ProductPrice.") {
5+
WEEE @deprecated(reason: "WEEE is deprecated, use fixed_product_taxes.label")
6+
WEEE_TAX @deprecated(reason: "WEEE_TAX is deprecated, use fixed_product_taxes. Tax is included or excluded in the amount")
77
}
88

99
type ProductPrice {
10-
fixed_product_taxes: [FixedProductTax] @doc(description: "The multiple FPTs that can be applied to a product price.") @resolver(class: "Magento\\WeeeGraphQl\\Model\\Resolver\\FptResolver")
10+
fixed_product_taxes: [FixedProductTax] @doc(description: "The multiple FPTs that can be applied to a product price.") @resolver(class: "Magento\\WeeeGraphQl\\Model\\Resolver\\FixedProductTax")
1111
}
1212

1313
type FixedProductTax @doc(description: "A single FPT that can be applied to a product price.") {

0 commit comments

Comments
 (0)