feat: 新增改性剂计算

This commit is contained in:
han0
2024-07-11 18:14:17 +08:00
parent fa029882a2
commit 44c8e8c096
10 changed files with 79 additions and 1295 deletions

View File

@@ -23,18 +23,13 @@ class AsphaltImportedModifierCalculator(Calculator):
if not asphalt.price_recommend:
return 0, 0
query = AsphaltModifier.get_query(self.year, self.month)
modifier_current = query.first()
query = AsphaltModifier.get_query(*Helper.get_last_month(self.year, self.month))
modifier_previous = query.first()
if modifier_current and modifier_previous:
fluctuating_2 = int((modifier_current.price - modifier_previous.price) * 5 / 100)
else:
fluctuating_2 = 0
query = PriceResult.get_query(self.year, self.month, name='改性剂')
modifier = query.first()
fluctuating_2 = int(modifier.fluctuating_recommend * 5 / 100) if modifier else 0
previous_price = int(getattr(self.previous_prices, 'price_recommend', 0))
if not previous_price:
previous_price = asphalt.price_recommend + modifier_current.price * 5 / 100
previous_price = asphalt.price_recommend + modifier.price_recommend * 5 / 100
price = previous_price + fluctuating_1 + fluctuating_2
price = round(price / 10) * 10