Created
April 17, 2015 08:03
-
-
Save ducdigital/19a2d5b4073a51fd541d to your computer and use it in GitHub Desktop.
Maping price to a priceIndex
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
var index, pppClient, currencyPrice; | |
pppClient = _.find(menu.fixedPriceMapClient, function (price) { | |
return price.from <= 6 && price.to >= 6; | |
}); | |
currencyPrice = menuPrices[menu.currency]; | |
if (!!pppClient) { | |
index = _.findIndex(currencyPrice, function (v,index) { | |
if (typeof currencyPrice[index+1] === 'undefined') { | |
return false; | |
} | |
return this <= (currencyPrice[index] + (currencyPrice[index+1] - currencyPrice[index])/2); | |
}, pppClient.ppp); | |
} | |
if (menu.freePPP) { | |
index = -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment