diff --git a/web/calculators/__init__.py b/web/calculators/__init__.py index f297547..baa7dc5 100644 --- a/web/calculators/__init__.py +++ b/web/calculators/__init__.py @@ -190,11 +190,16 @@ class Calculator: return getattr(self.previous_prices, 'price_recommend', 0) def _get_calculate_price(self, round_dit=2): - prices = (self.price_ftb, self.price_ss, self.price_fhb, self.price_network, self.price_survey, self.price_last_month) - total = sum(float(i) for i in prices) - if total == 0: + prices = [ + self.price_ftb * self.weight_ftb, + self.price_ss * self.weight_ss, + self.price_fhb * self.weight_fhb, + self.price_network * self.weight_network, + self.price_survey * self.weight_survey, + ] + if sum(prices) == 0: return 0 - result = total / len([i for i in prices if i != 0]) + result = sum(prices) / sum([self.weight_ftb, self.weight_ss, self.weight_fhb, self.weight_network, self.weight_survey]) result = round(result, round_dit) return result