Skip to content

Instantly share code, notes, and snippets.

@aconfee
Created August 24, 2017 16:48
Show Gist options
  • Save aconfee/1ed1765bf0135e272ec58dcb0355b447 to your computer and use it in GitHub Desktop.
Save aconfee/1ed1765bf0135e272ec58dcb0355b447 to your computer and use it in GitHub Desktop.
var targetPrice = null;
if (priceGuideType === PriceGuideType.Radar && priceEstimate.UseProvisionSetting) {
targetPrice = wrapper.Financials.TargetPricePct;
var method = this.settings[EntitySettingDefinitions.Stocking_TargetPriceCalculationMethod];
if (method.toLowerCase().indexOf("pricingtarget") >= 0) {
var pricingTargets = priceEstimate.PricingTargets;
var defaultRuleSet = pricingTargets.RuleSets.filter(ruleSet => { return ruleSet.Id === pricingTargets.DefaultRuleSetId; })[0];
if (defaultRuleSet) {
if (defaultRuleSet.Type === Models.PricingTargetType.Exact_Days_Supply) {
targetPrice = this.matchTargetPriceBucket(defaultRuleSet, pricingData.ExactDaySupply) || targetPrice;
}
else {
// Provision Setting is Days In Inventory Based
var days = +this.settings[EntitySettingDefinitions.Stocking_TargetPriceTargetDaysInInventory];
targetPrice = this.matchTargetPriceBucket(defaultRuleSet, days) || targetPrice;
}
} else {
console.error("No default rule set selected by user.");
}
}
}
var targetPrice = null;
if (priceGuideType === PriceGuideType.Radar && priceEstimate.UseProvisionSetting) {
//vAuto reccommended and fallback for PricingTarget method
targetPrice = wrapper.Financials.TargetPricePct;
var method = this.settings[EntitySettingDefinitions.Stocking_TargetPriceCalculationMethod];
//PricingTarget means we need to match to a pricing bucket
if (/pricingtarget/i.test(method)) {
var pricingTargets = priceEstimate.PricingTargets;
var defaultRuleSet: Models.IPricingTargetRuleSet = null;
var bucketPercent = null;
pricingTargets.RuleSets.some((ruleSet) => {
defaultRuleSet = ruleSet;
return ruleSet.Id === pricingTargets.DefaultRuleSetId;
});
// Provision Setting is MDS based
if (defaultRuleSet.Type === Models.PricingTargetType.Exact_Days_Supply) {
bucketPercent = this.matchTargetPriceBucket(defaultRuleSet, pricingData.ExactDaySupply);
targetPrice = bucketPercent ? bucketPercent : targetPrice;
} else {
// Provision Setting is Days In Inventory Based
var days = +this.settings[EntitySettingDefinitions.Stocking_TargetPriceTargetDaysInInventory];
bucketPercent = this.matchTargetPriceBucket(defaultRuleSet, days);
targetPrice = bucketPercent ? bucketPercent : targetPrice;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment