summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-01-07 17:02:06 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-01-07 17:02:06 +0700
commit7ac434ec0fcf75cb6eefe1892118b7c18b3db53a (patch)
tree2aaf7a6b409248acec3bcf58dbcb31999d4fef5f /indoteknik_api/controllers/api_v1
parent60f54931f8eac477ab737abab1710789e0a2aaf4 (diff)
sla
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/product.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py
index 32362582..2573d7a8 100644
--- a/indoteknik_api/controllers/api_v1/product.py
+++ b/indoteknik_api/controllers/api_v1/product.py
@@ -35,7 +35,7 @@ class Product(controller.Controller):
return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')])
@http.route(prefix + 'product_variant/<id>/stock', auth='public', methods=['GET', 'OPTIONS'])
- @controller.Controller.must_authorized()
+ @controller.Controller.must_authorized()
def get_product_template_stock_by_id(self, **kw):
id = int(kw.get('id'))
date_7_days_ago = datetime.now() - timedelta(days=7)
@@ -47,12 +47,19 @@ class Product(controller.Controller):
('product_variant_id', '=', id),
('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S"))
], limit=1)
+
+ include_instant = False
qty_available = product.qty_free_bandengan
-
- if qty_available < 0:
- qty_available = 0
-
+
+
+ if qty_available > 0 :
+ include_instant = True
+ else :
+ qty_available = 0
+ if product_sla.sla_vendor_id.unit == 'jam':
+ include_instant = True
+
qty = 0
sla_date = '-'
@@ -74,9 +81,10 @@ class Product(controller.Controller):
if qty_available > 0:
qty = qty_available + total_adem + total_excell
+ sla_date = product_sla.sla or 1
elif qty_altama > 0 or qty_vendor > 0:
qty = total_adem if qty_altama > 0 else total_excell
- sla_date = '2-4 Hari'
+ sla_date = product.sla
else:
sla_date = '3-7 Hari'
except:
@@ -84,7 +92,7 @@ class Product(controller.Controller):
else:
if qty_available > 0:
qty = qty_available
- sla_date = product_sla.sla or '-'
+ sla_date = product_sla.sla or 'Indent'
elif qty_vendor > 0:
qty = total_excell
sla_date = '2-4 Hari'
@@ -92,6 +100,7 @@ class Product(controller.Controller):
data = {
'qty': qty,
'sla_date': sla_date,
+ 'can_instant': include_instant
}
return self.response(data, headers=[('Cache-Control', 'max-age=600, private')])