From d418bd8dd84b91b9dc031819cfa9a2446e77acd2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 24 Jun 2023 11:22:54 +0700 Subject: Fixing percent remaining on program line --- indoteknik_custom/models/promotion_program_line.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/promotion_program_line.py b/indoteknik_custom/models/promotion_program_line.py index 3ab9b2c0..7aaff4c4 100644 --- a/indoteknik_custom/models/promotion_program_line.py +++ b/indoteknik_custom/models/promotion_program_line.py @@ -131,7 +131,9 @@ class PromotionProgramLine(models.Model): product_price = self.product_id.calculate_website_price() limit_qty = self._res_limit_qty() remaining_qty = self._get_remaining_qty(user) - percent_remaining = (limit_qty['all'] - remaining_qty['all']) / limit_qty['all'] * 100 + percent_remaining = 0 + if limit_qty['all'] > 0: + percent_remaining = (limit_qty['all'] - remaining_qty['all']) / limit_qty['all'] * 100 return { 'id': self.id, 'name': self.name, -- cgit v1.2.3