diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-07-27 04:18:27 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-07-27 04:18:27 +0000 |
| commit | e64105b97b5da3218e3dfbe5db4456b31f08ca73 (patch) | |
| tree | 332eadffa49d97696aa53dc9c10bfd1cc0537e74 /indoteknik_api | |
| parent | 591617f043789ef66a76b7e97e6886b3412369e4 (diff) | |
| parent | 421ff67560201e8155d03cbe4ff7029cd6b667a4 (diff) | |
Merged in production (pull request #74)
Production
Diffstat (limited to 'indoteknik_api')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 21 | ||||
| -rw-r--r-- | indoteknik_api/models/product_product.py | 11 |
2 files changed, 24 insertions, 8 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 7ec6459b..e08ec97b 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -29,6 +29,12 @@ class Product(controller.Controller): qty = 0 sla_date = '-' + # Qty Stock Vendor + qty_vendor = stock_vendor.quantity + qty_vendor -= int(qty_vendor * 0.1) + qty_vendor = math.ceil(float(qty_vendor)) + total_excell = qty_vendor + is_altama_product = product.x_manufacture.id in [10,122,89] if is_altama_product: try: @@ -37,11 +43,7 @@ class Product(controller.Controller): qty_altama -= int(qty_altama * 0.1) qty_altama = math.ceil(float(qty_altama)) total_adem = qty_altama - # Qty Stock Vendor - qty_vendor = stock_vendor.quantity - qty_vendor -= int(qty_vendor * 0.1) - qty_vendor = math.ceil(float(qty_vendor)) - total_excell = qty_vendor + if qty_available > 0: qty = qty_available + total_adem + total_excell sla_date = '1 Hari' @@ -53,8 +55,13 @@ class Product(controller.Controller): except: print('error') else: - qty = qty_available - sla_date = product_sla.sla or '-' + if qty_available > 0: + qty = qty_available + sla_date = product_sla.sla or '-' + elif qty_vendor > 0: + qty = total_excell + sla_date = '2-4 Hari' + data = { 'qty': qty, diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 334b58c5..fb485bae 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -31,6 +31,8 @@ class ProductProduct(models.Model): def v2_api_single_response(self, product_product): product_template = product_product.product_tmpl_id + stock = product_product.qty_stock_vendor + stock = 1 if stock == 0 else stock data = { 'id': product_product.id, 'parent': { @@ -41,7 +43,7 @@ class ProductProduct(models.Model): 'code': product_product.default_code or '', 'name': product_product.display_name, 'price': product_product.calculate_website_price(), - 'stock': product_product.qty_stock_vendor, + 'stock': stock, 'weight': product_product.weight, 'attributes': [x.name for x in product_product.product_template_attribute_value_ids], 'manufacture' : self.api_manufacture(product_product) @@ -82,6 +84,13 @@ class ProductProduct(models.Model): if price[discount_key] > 0: discount_percentage = price[discount_key] if price[price_key] > 0: price_discount = price[price_key] + flashsale = self._get_flashsale_price() + flashsale_price = flashsale['flashsale_price'] + flashsale_discount = flashsale['flashsale_discount'] + if flashsale_price > 0 and flashsale_price < price_discount: + price_discount = flashsale_price + discount_percentage = flashsale_discount + return { 'price': self._get_website_price_exclude_tax(), 'discount_percentage': discount_percentage, |
