Created
December 15, 2020 20:05
-
-
Save HunterLarco/f421a0b4eac320508ceebddfecb2c8fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/helpers/order/OrderHelper.js b/src/helpers/order/OrderHelper.js | |
index 274299a..f5df7fa 100644 | |
--- a/src/helpers/order/OrderHelper.js | |
+++ b/src/helpers/order/OrderHelper.js | |
@@ -703,19 +703,10 @@ export async function advancedCheckout(account, id, params) { | |
return Promise.reject("INSUFFICIENT_POINTS"); | |
} | |
- prices.sort((a, b) => a - b); | |
- | |
- redeemed = prices.pop(); | |
- | |
- let item = completeOrder.ITEMS.find((item) => item.PRICE === redeemed); | |
- let maxRedeem = parseInt(settings.MOBILE_REWARD_MAX_REDEEM); | |
- if (redeemed > maxRedeem) { | |
- total -= maxRedeem; | |
- taxes -= Math.floor(maxRedeem * (location.TAX_RATE / 100)); | |
- } else { | |
- total -= redeemed; | |
- taxes -= Math.round(redeemed * (location.TAX_RATE / 100)); | |
- } | |
+ const mostExpensiveItem = Math.max(prices); | |
+ const redemption = Math.min(mostExpensiveItem, parseInt(settings.MOBILE_REWARD_MAX_REDEEM)); | |
+ total -= redemption; | |
+ taxes -= Math.floor(redemption * (location.TAX_RATE / 100)); | |
} catch (e) { | |
console.dir(e); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment