From ad127a4dc2bfb81d9c99ba78ab41a49eefeb0dd2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 22 Dec 2023 11:20:45 +0700 Subject: update promotion program feature --- indoteknik_custom/models/promotion/promotion_program_line.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/promotion/promotion_program_line.py') diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 34a0fbb2..d9095c75 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -96,7 +96,11 @@ class PromotionProgramLine(models.Model): weight = 0 if not any(x['package_weight'] == 0 for x in merged_products): weight = sum(x['package_weight'] for x in merged_products) - + + products_total = sum(x['price']['price_discount'] * x['qty'] for x in products) + free_products_total = sum(x['price']['price_discount'] * x['qty'] for x in free_products) + package_price = products_total + free_products_total + response = { 'id': self.id, 'name': self.name, @@ -106,6 +110,7 @@ class PromotionProgramLine(models.Model): 'limit_qty': limit_qty, 'remaining_qty': remaining_qty, 'used_percentage': percent_remaining, + 'package_price': package_price, 'price': { 'price': self.price, 'price_discount': self.price, -- cgit v1.2.3 From 717cb3b43c729e265603b3df61234c0b430742a7 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 4 Jan 2024 09:25:14 +0700 Subject: update promotion program feature --- indoteknik_custom/models/promotion/promotion_program_line.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models/promotion/promotion_program_line.py') diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index d9095c75..d77123ce 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -13,7 +13,6 @@ class PromotionProgramLine(models.Model): ("discount_loading", "Discount Loading"), ("merchandise", "Merchandise") ], 'Type') - image = fields.Binary(string="Image") package_limit = fields.Integer('Package limit') package_limit_user = fields.Integer('Package limit / user') @@ -96,15 +95,15 @@ class PromotionProgramLine(models.Model): weight = 0 if not any(x['package_weight'] == 0 for x in merged_products): weight = sum(x['package_weight'] for x in merged_products) - - products_total = sum(x['price']['price_discount'] * x['qty'] for x in products) - free_products_total = sum(x['price']['price_discount'] * x['qty'] for x in free_products) + + # Sum of products and free products in 1 package quantity + products_total = sum(x['price']['price_discount'] * x['qty'] / qty for x in products) + free_products_total = sum(x['price']['price_discount'] * x['qty'] / qty for x in free_products) package_price = products_total + free_products_total response = { 'id': self.id, 'name': self.name, - 'image': ir_attachment.api_image(self._name, 'image', self.id), 'remaining_time': self._get_remaining_time(), 'promotion_type': self._res_promotion_type(), 'limit_qty': limit_qty, -- cgit v1.2.3