7
7
8
8
use Magento \Framework \Pricing \PriceCurrencyInterface ;
9
9
use Magento \Tax \Model \Calculation as TaxCalculation ;
10
+ use Magento \Sales \Model \Order ;
10
11
11
12
/**
12
13
* Order creditmemo shipping total calculation model
@@ -115,25 +116,26 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
115
116
/**
116
117
* Checks if shipping provided incl tax, tax applied after discount, and discount applied on shipping excl tax
117
118
*
118
- * @param \Magento\Sales\Model\ Order $order
119
+ * @param Order $order
119
120
* @return bool
120
121
*/
121
- private function isShippingIncludeTaxWithTaxAfterDiscountOnExcl ( $ order ): bool
122
+ private function isShippingIncludeTaxWithTaxAfterDiscount ( Order $ order ): bool
122
123
{
123
- return $ this ->getTaxConfig ()->getCalculationSequence ($ order ->getStoreId ())
124
- === TaxCalculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL &&
125
- $ this ->isSuppliedShippingAmountInclTax ($ order );
124
+ $ calculationSequence = $ this ->getTaxConfig ()->getCalculationSequence ($ order ->getStoreId ());
125
+ return ($ calculationSequence === TaxCalculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL
126
+ || $ calculationSequence === TaxCalculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL )
127
+ && $ this ->isSuppliedShippingAmountInclTax ($ order );
126
128
}
127
129
128
130
/**
129
131
* Get allowed shipping amount to refund based on tax settings
130
132
*
131
- * @param \Magento\Sales\Model\ Order $order
133
+ * @param Order $order
132
134
* @return float
133
135
*/
134
- private function getAllowedAmountInclTax (\ Magento \ Sales \ Model \ Order $ order ): float
136
+ private function getAllowedAmountInclTax (Order $ order ): float
135
137
{
136
- if ($ this ->isShippingIncludeTaxWithTaxAfterDiscountOnExcl ($ order )) {
138
+ if ($ this ->isShippingIncludeTaxWithTaxAfterDiscount ($ order )) {
137
139
$ result = $ order ->getShippingInclTax ();
138
140
foreach ($ order ->getCreditmemosCollection () as $ creditmemo ) {
139
141
$ result -= $ creditmemo ->getShippingInclTax ();
@@ -155,7 +157,7 @@ private function getAllowedAmountInclTax(\Magento\Sales\Model\Order $order): flo
155
157
private function getBaseAllowedAmountInclTax (\Magento \Sales \Model \Order $ order ): float
156
158
{
157
159
$ result = $ order ->getBaseShippingInclTax ();
158
- if ($ this ->isShippingIncludeTaxWithTaxAfterDiscountOnExcl ($ order )) {
160
+ if ($ this ->isShippingIncludeTaxWithTaxAfterDiscount ($ order )) {
159
161
foreach ($ order ->getCreditmemosCollection () as $ creditmemo ) {
160
162
$ result -= $ creditmemo ->getBaseShippingInclTax ();
161
163
}
0 commit comments