fix order model invoice genrator

This commit is contained in:
Parsa Nazer
2026-01-04 12:45:44 +03:30
parent 9e0cba4c2b
commit 0e0a6ccc24
3 changed files with 106 additions and 41 deletions
+19 -1
View File
@@ -250,7 +250,25 @@ class OrderItemModel(models.Model):
def __str__(self):
return f'({self.product}) - ({self.order.user})'
# @property
def total_price_before_discount(self):
return self.price * self.quantity
# @property
def total_product_discount_amount(self):
if self.discount_percent > 0:
return int((self.price * self.quantity) * (self.discount_percent / 100))
return 0
# @property
def price_after_special_discount(self):
all_discounts = (self.special_discount_amount or 0) + self.total_product_discount_amount()
print(all_discounts)
return self.total_price_before_discount() - all_discounts
def unit_price(self):
return self.price
class ShopOrderModel(models.Model):
"""Represents the portion of a customer Order that belongs to a single Shop.