order list view and serilaizer
This commit is contained in:
+11
-9
@@ -59,21 +59,23 @@ class OrderModel(models.Model):
|
||||
print('didnt send')
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def total_with_discount(self):
|
||||
total_with_item_discount = sum(item.total_with_discount() for item in self.items.all())
|
||||
if self.discount_code:
|
||||
if not self.discount_code.is_valid():
|
||||
raise DiscountNotAvailableError('این کد تخفیف دیگر معتبر نیست')
|
||||
discount_percent = self.discount_code.percent
|
||||
return total_with_item_discount * ((100 - discount_percent) / 100)
|
||||
return total_with_item_discount
|
||||
def discount(self):
|
||||
pass
|
||||
# total_with_item_discount = sum(item.total_with_discount() for item in self.items.all())
|
||||
# if self.discount_code:
|
||||
# if not self.discount_code.is_valid():
|
||||
# raise DiscountNotAvailableError('این کد تخفیف دیگر معتبر نیست')
|
||||
# discount_percent = self.discount_code.percent
|
||||
# return total_with_item_discount * ((100 - discount_percent) / 100)
|
||||
# return total_with_item_discount
|
||||
|
||||
|
||||
def tax(self):
|
||||
return self.total_without_tax() * 0.2
|
||||
|
||||
def total(self):
|
||||
return self.total_with_discount() + self.tax()
|
||||
pass
|
||||
# return self.total_with_discount() + self.tax()
|
||||
|
||||
def remove_order_item(self, item_pk, quantity):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user