public decimal CalculateOfferLocalContentPreference(LocalContentPreferenceModel data) { if (data.currentOfferPrice != 0) { var result = (((data.lowestOfferPrice / data.currentOfferPrice) * data.priceWeight) + ((((data.supplierLocalContentPercentage / 100) * (data.localContentTargetWeight / 100)) + ((data.supplierBaselinePercentage / 100) * (data.baselineWeight / 100)) + (data.isIncludedInMarket ? (data.includedInMarketWeight / 100) : 0)) * data.localContentWeight)); return(Math.Round(result, 2)); } throw new BusinessRuleException("يجب ان تكون قيمة العرض المراد حسابه اكبر من 0"); }
public void ShouldCalculateOfferLocalContentPreference_ThrowError() { LocalContentPreferenceModel localContentPreferenceModel = new LocalContentPreferenceModel() { currentOfferPrice = 0, lowestOfferPrice = 900, supplierLocalContentPercentage = 25, supplierBaselinePercentage = 10, priceWeight = 60, localContentTargetWeight = 50, baselineWeight = 50, includedInMarketWeight = 5, localContentWeight = 40, isIncludedInMarket = true, }; var result = Assert.Throws <BusinessRuleException>(() => _sut.CalculateOfferLocalContentPreference(localContentPreferenceModel)); Assert.Equal("يجب ان تكون قيمة العرض المراد حسابه اكبر من 0", result.Message); }
public void ShouldCalculateOfferLocalContentPreference_SuccessLowestOffer() { LocalContentPreferenceModel localContentPreferenceModel = new LocalContentPreferenceModel() { currentOfferPrice = 900, lowestOfferPrice = 900, supplierLocalContentPercentage = 25, supplierBaselinePercentage = 10, priceWeight = 60, localContentTargetWeight = 50, baselineWeight = 50, includedInMarketWeight = 5, localContentWeight = 40, isIncludedInMarket = true, }; var result = _sut.CalculateOfferLocalContentPreference(localContentPreferenceModel); Assert.Equal("69.00", result.ToString()); }