8
8
use Magento \Tax \Model \Config ;
9
9
10
10
/**
11
- * Class allows to show admin notification about possible issues related to tax calculation and display settings .
11
+ * Class allows to show admin notification about possible issues related to "Apply Discount On Prices" setting .
12
12
*
13
- * For the case when prices under "Calculation Settings" are set to "Excluding Tax"
14
- * and at the same time some of price display settings are set to "Including Tax"
13
+ * Warning is displayed in case when "Catalog Prices" = "Excluding Tax"
14
+ * AND "Apply Discount On Prices" = "Including Tax"
15
+ * AND "Apply Customer Tax" = "After Discount"
15
16
*/
16
- class AdminPriceExcludingTax implements \Magento \Tax \Model \System \Message \NotificationInterface
17
+ class ApplyDiscountOnPrices implements \Magento \Tax \Model \System \Message \NotificationInterface
17
18
{
18
19
/**
19
20
* @var \Magento\Store\Model\StoreManagerInterface
@@ -58,15 +59,15 @@ public function __construct(
58
59
*/
59
60
public function getIdentity ()
60
61
{
61
- return 'TAX_NOTIFICATION_PRICE_EXCLUDING_TAX ' ;
62
+ return 'TAX_NOTIFICATION_APPLY_DISCOUNT ' ;
62
63
}
63
64
64
65
/**
65
66
* {@inheritdoc}
66
67
*/
67
68
public function isDisplayed ()
68
69
{
69
- if (!$ this ->taxConfig ->isWrongPriceExcludingTaxSettingsIgnored () && $ this ->getStoresWithWrongSettings ()) {
70
+ if (!$ this ->taxConfig ->isWrongApplyDiscountSettingIgnored () && $ this ->getStoresWithWrongSettings ()) {
70
71
return true ;
71
72
}
72
73
return false ;
@@ -81,14 +82,14 @@ public function getText()
81
82
82
83
if ($ this ->isDisplayed ()) {
83
84
$ messageDetails .= '<strong> ' ;
84
- $ messageDetails .= __ ('Current tax configuration can result in rounding errors and discount calculation errors . ' );
85
+ $ messageDetails .= __ ('If you want to apply discount on prices including tax and apply customer tax after discount, you must set Catalog Prices to “Including Price” . ' );
85
86
$ messageDetails .= '</strong><p> ' ;
86
87
$ messageDetails .= __ ('Store(s) affected: ' );
87
88
$ messageDetails .= implode (', ' , $ this ->getStoresWithWrongSettings ());
88
89
$ messageDetails .= '</p><p> ' ;
89
90
$ messageDetails .= __ (
90
91
'Click on the link to <a href="%1">ignore this notification</a> ' ,
91
- $ this ->urlBuilder ->getUrl ('tax/tax/ignoreTaxNotification ' , ['section ' => 'price_excluding_tax ' ])
92
+ $ this ->urlBuilder ->getUrl ('tax/tax/ignoreTaxNotification ' , ['section ' => 'apply_discount ' ])
92
93
);
93
94
$ messageDetails .= "</p> " ;
94
95
}
@@ -106,7 +107,7 @@ public function getSeverity()
106
107
}
107
108
108
109
/**
109
- * Return list of store names which have incompatible tax calculation and tax display settings.
110
+ * Return list of store names which have invalid settings.
110
111
*
111
112
* @return array
112
113
*/
@@ -127,56 +128,15 @@ private function getStoresWithWrongSettings()
127
128
}
128
129
129
130
/**
130
- * Check if tax calculation and tax display settings are compatible .
131
+ * Check if settings are valid .
131
132
*
132
133
* @param null|int|bool|string|\Magento\Store\Model\Store $store $store
133
134
* @return bool false if settings are incorrect
134
135
*/
135
136
private function checkSettings ($ store = null )
136
137
{
137
- $ adminCatalogPricesExcludeTax = !$ this ->taxConfig ->priceIncludesTax ($ store )
138
- || !$ this ->taxConfig ->shippingPriceIncludesTax ($ store );
139
- $ displayPricesWhichIncludeTax = $ this ->hasCatalogDisplaySettingsWhichIncludeTax ($ store )
140
- || $ this ->hasCartDisplaySettingsWhichIncludeTax ($ store )
141
- || $ this ->hasSalesDisplaySettingsWhichIncludeTax ($ store );
142
- return !($ adminCatalogPricesExcludeTax && $ displayPricesWhichIncludeTax );
143
- }
144
-
145
- /**
146
- * Check if there are any price display settings for catalog with values other than "Excluding tax"
147
- *
148
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
149
- * @return bool
150
- */
151
- private function hasCatalogDisplaySettingsWhichIncludeTax ($ store = null )
152
- {
153
- return $ this ->taxConfig ->getPriceDisplayType ($ store ) !== Config::DISPLAY_TYPE_EXCLUDING_TAX
154
- || $ this ->taxConfig ->getShippingPriceDisplayType ($ store ) !== Config::DISPLAY_TYPE_EXCLUDING_TAX ;
155
- }
156
-
157
- /**
158
- * Check if there are any price display settings for cart with values other than "Excluding tax"
159
- *
160
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
161
- * @return bool
162
- */
163
- private function hasCartDisplaySettingsWhichIncludeTax ($ store = null )
164
- {
165
- return !$ this ->taxConfig ->displayCartPricesExclTax ($ store )
166
- || !$ this ->taxConfig ->displayCartSubtotalExclTax ($ store )
167
- || !$ this ->taxConfig ->displayCartShippingExclTax ($ store );
168
- }
169
-
170
- /**
171
- * Check if there are any price display settings for orders, invoices, credit memos with values not "Excluding tax"
172
- *
173
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
174
- * @return bool
175
- */
176
- private function hasSalesDisplaySettingsWhichIncludeTax ($ store = null )
177
- {
178
- return !$ this ->taxConfig ->displaySalesPricesExclTax ($ store )
179
- || !$ this ->taxConfig ->displaySalesSubtotalExclTax ($ store )
180
- || !$ this ->taxConfig ->displaySalesShippingExclTax ($ store );
138
+ return $ this ->taxConfig ->priceIncludesTax ($ store )
139
+ || !$ this ->taxConfig ->applyTaxAfterDiscount ($ store )
140
+ || !$ this ->taxConfig ->discountTax ($ store );
181
141
}
182
142
}
0 commit comments