diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-06-23 11:20:52 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-06-23 11:20:52 +0700 |
| commit | 23014336a1fe1fe5ef54fad30cf6c3d9cc59b2d8 (patch) | |
| tree | 3b1ee79d1e73b6e02f943411c5a2715c7f16e2f3 /indoteknik_api/controllers/api_v1 | |
| parent | ae998f145e4f8b4a0939a97c02e70564ef758e73 (diff) | |
Update response price di product promotion API, Membuat fungsi calculate price promotion, Refactor promotion homepage, Refactor fungsi calculate product price
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product_variant.py | 3 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/promotion.py | 9 |
2 files changed, 3 insertions, 9 deletions
diff --git a/indoteknik_api/controllers/api_v1/product_variant.py b/indoteknik_api/controllers/api_v1/product_variant.py index cec54fda..06ce5d3c 100644 --- a/indoteknik_api/controllers/api_v1/product_variant.py +++ b/indoteknik_api/controllers/api_v1/product_variant.py @@ -26,9 +26,10 @@ class ProductVariant(controller.Controller): def get_product_variant_promotions(self, product_id): product_id = int(product_id) user_data = self.verify_user_token() + pricelist = self.user_pricelist() program_line = request.env['promotion.program.line'] program_lines = program_line.get_active_promotions(product_id) - program_lines = program_line.res_format(program_lines, user_data) + program_lines = program_lines.res_format(user=user_data, pricelist=pricelist) return self.response(program_lines) diff --git a/indoteknik_api/controllers/api_v1/promotion.py b/indoteknik_api/controllers/api_v1/promotion.py index 948681fd..a3dbf0ba 100644 --- a/indoteknik_api/controllers/api_v1/promotion.py +++ b/indoteknik_api/controllers/api_v1/promotion.py @@ -73,20 +73,13 @@ class Promotion(controller.Controller): 'image': product['parent']['image'], 'name': product['parent']['name'], 'variant_total': len(product_template.product_variant_ids), - 'lowest_price': product['price'], + 'lowest_price': line.calculate_price(product['price']), 'stock_total': product['stock'], 'icon': { 'top': request.env['ir.attachment'].api_image('promotion.program', 'icon_top', line.program_id.id), 'bottom': request.env['ir.attachment'].api_image('promotion.program', 'icon_bottom', line.program_id.id) } }) - price = product['lowest_price']['price'] - if line.discount_type == 'percentage': - product['lowest_price']['discount_percentage'] = line.discount_amount - product['lowest_price']['price_discount'] = price - (price * line.discount_amount / 100) - if line.discount_type == 'fixed_price': - product['lowest_price']['price_discount'] = line.discount_amount - product['lowest_price']['discount_percentage'] = round((price - line.discount_amount) / price * 100) product.pop('parent', None) product.pop('price', None) |
