only count paid orders
This commit is contained in:
parent
41467447a8
commit
21b479e253
|
@ -397,7 +397,8 @@ class ProductCategory(CreatedUpdatedModel, UUIDModel):
|
||||||
class ProductStatsManager(models.Manager):
|
class ProductStatsManager(models.Manager):
|
||||||
def with_ticket_stats(self):
|
def with_ticket_stats(self):
|
||||||
return (
|
return (
|
||||||
self.annotate(total_units_sold=Sum("orderproductrelation__quantity"))
|
self.filter(orderproductrelation__order__paid=True)
|
||||||
|
.annotate(total_units_sold=Sum("orderproductrelation__quantity"))
|
||||||
.annotate(profit=F("price") - F("cost"))
|
.annotate(profit=F("price") - F("cost"))
|
||||||
.annotate(total_revenue=F("price") * F("total_units_sold"))
|
.annotate(total_revenue=F("price") * F("total_units_sold"))
|
||||||
.annotate(total_cost=F("cost") * F("total_units_sold"))
|
.annotate(total_cost=F("cost") * F("total_units_sold"))
|
||||||
|
|
Loading…
Reference in a new issue