feat: Enhance admin permissions and improve product currency handling
This commit is contained in:
@@ -146,14 +146,9 @@ class DollorModel(models.Model):
|
||||
price = int(data["lastTradePrice"])
|
||||
price_in_usd = price / 10.0
|
||||
print('\n\nprice from api \n\n')
|
||||
except:
|
||||
if self.price:
|
||||
print('\n\nprice from last price \n\n')
|
||||
return self.price
|
||||
except Exception as e:
|
||||
return self.defualt_price
|
||||
|
||||
else:
|
||||
print('\n\nprice from defualt price \n\n')
|
||||
return self.defualt_price
|
||||
return price_in_usd
|
||||
|
||||
class Meta:
|
||||
@@ -379,7 +374,6 @@ class ProductVariant(models.Model):
|
||||
currency_type = (
|
||||
('dollor', 'دلار'),
|
||||
('toman', 'تومان'),
|
||||
('derham', 'درهم')
|
||||
)
|
||||
in_pack_items = models.ManyToManyField(
|
||||
InPackItems, blank=True, verbose_name='ایتم های داخل پک')
|
||||
@@ -454,14 +448,11 @@ class ProductVariant(models.Model):
|
||||
raise ValidationError(
|
||||
{"dollor_price": "The 'dollor_price' must be provided in the context for dollar pricing."})
|
||||
|
||||
dollar_to_dirham = 0.27
|
||||
|
||||
if self.currency == 'toman':
|
||||
toman_price = self.input_price
|
||||
elif self.currency == 'dollor':
|
||||
toman_price = self.input_price * dollor_price
|
||||
elif self.currency == 'derham':
|
||||
toman_price = self.input_price * dollor_price * dollar_to_dirham
|
||||
else:
|
||||
toman_price = self.input_price
|
||||
|
||||
|
||||
Reference in New Issue
Block a user