Show percentage of discount in cart (Z#23176955) (#4719)

* Show percentage of discount in cart (Z#23176955)

* Fix computation
This commit is contained in:
Raphael Michel
2025-01-21 16:35:15 +01:00
committed by GitHub
parent 00b4622afa
commit ffdc73e0a3
2 changed files with 22 additions and 4 deletions

View File

@@ -3218,6 +3218,12 @@ class CartPosition(AbstractPosition):
self.tax_code = line_price.code
self.save(update_fields=['line_price_gross', 'tax_rate'])
@property
def discount_percentage(self):
if not self.line_price_gross:
return 0
return (self.line_price_gross - self.price) / self.line_price_gross * 100
@property
def addons_without_bundled(self):
addons = [op for op in self.addons.all() if not op.is_bundled]