77
88use Magento \Framework \Pricing \PriceCurrencyInterface ;
99use Magento \Tax \Model \Calculation as TaxCalculation ;
10+ use Magento \Sales \Model \Order ;
1011
1112/**
1213 * Order creditmemo shipping total calculation model
@@ -115,25 +116,26 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
115116 /**
116117 * Checks if shipping provided incl tax, tax applied after discount, and discount applied on shipping excl tax
117118 *
118- * @param \Magento\Sales\Model\ Order $order
119+ * @param Order $order
119120 * @return bool
120121 */
121- private function isShippingIncludeTaxWithTaxAfterDiscountOnExcl ( $ order ): bool
122+ private function isShippingIncludeTaxWithTaxAfterDiscount ( Order $ order ): bool
122123 {
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 );
126128 }
127129
128130 /**
129131 * Get allowed shipping amount to refund based on tax settings
130132 *
131- * @param \Magento\Sales\Model\ Order $order
133+ * @param Order $order
132134 * @return float
133135 */
134- private function getAllowedAmountInclTax (\ Magento \ Sales \ Model \ Order $ order ): float
136+ private function getAllowedAmountInclTax (Order $ order ): float
135137 {
136- if ($ this ->isShippingIncludeTaxWithTaxAfterDiscountOnExcl ($ order )) {
138+ if ($ this ->isShippingIncludeTaxWithTaxAfterDiscount ($ order )) {
137139 $ result = $ order ->getShippingInclTax ();
138140 foreach ($ order ->getCreditmemosCollection () as $ creditmemo ) {
139141 $ result -= $ creditmemo ->getShippingInclTax ();
@@ -155,7 +157,7 @@ private function getAllowedAmountInclTax(\Magento\Sales\Model\Order $order): flo
155157 private function getBaseAllowedAmountInclTax (\Magento \Sales \Model \Order $ order ): float
156158 {
157159 $ result = $ order ->getBaseShippingInclTax ();
158- if ($ this ->isShippingIncludeTaxWithTaxAfterDiscountOnExcl ($ order )) {
160+ if ($ this ->isShippingIncludeTaxWithTaxAfterDiscount ($ order )) {
159161 foreach ($ order ->getCreditmemosCollection () as $ creditmemo ) {
160162 $ result -= $ creditmemo ->getBaseShippingInclTax ();
161163 }
0 commit comments