summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/promotion
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-01-04 02:27:45 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-01-04 02:27:45 +0000
commit63abd2dc32f952af7234f3d6a7774cbb8c7bcb47 (patch)
treeb4cee127fc7d467b33cef4ffae9218f8acb9aeaa /indoteknik_custom/models/promotion
parent13b31fc3d89957d23582efb2c51ab143ca1d425a (diff)
parent717cb3b43c729e265603b3df61234c0b430742a7 (diff)
Merged in change/feature/promotion-program (pull request #133)
Change/feature/promotion program
Diffstat (limited to 'indoteknik_custom/models/promotion')
-rw-r--r--indoteknik_custom/models/promotion/promotion_program.py1
-rw-r--r--indoteknik_custom/models/promotion/promotion_program_line.py10
2 files changed, 8 insertions, 3 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_program.py b/indoteknik_custom/models/promotion/promotion_program.py
index 29aaa753..1a1ee6bf 100644
--- a/indoteknik_custom/models/promotion/promotion_program.py
+++ b/indoteknik_custom/models/promotion/promotion_program.py
@@ -6,6 +6,7 @@ class PromotionProgram(models.Model):
name = fields.Char(string="Name")
banner = fields.Binary(string="Banner")
+ image = fields.Binary(string="Image")
icon = fields.Binary(string="Icon", help="Image 1:1 ratio")
icon_top = fields.Binary(string="Icon Top", help="Icon ini ditampilkan sebagai atribut pada atas gambar di product card pada website")
icon_bottom = fields.Binary(string="Icon Bottom", help="Icon ini ditampilkan sebagai atribut pada bawah gambar di product card pada website")
diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py
index 34a0fbb2..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,16 +95,21 @@ 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)
-
+
+ # 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,
'remaining_qty': remaining_qty,
'used_percentage': percent_remaining,
+ 'package_price': package_price,
'price': {
'price': self.price,
'price_discount': self.price,