diff --git a/bruno/price/Price Add.bru b/bruno/price/Price Add.bru index 392803b..523bb67 100644 --- a/bruno/price/Price Add.bru +++ b/bruno/price/Price Add.bru @@ -12,10 +12,10 @@ post { body:json { { - "item":2, + "sku":"TEST-001", "type":"sell", "currency":"IDR", - "value":3600000, + "value":36000, "periods":"2025-01-01 18:32:35" } } diff --git a/bruno/price/Price Detail.bru b/bruno/price/Price Detail.bru index 352ce30..85a9b79 100644 --- a/bruno/price/Price Detail.bru +++ b/bruno/price/Price Detail.bru @@ -11,5 +11,5 @@ post { } body:json { - {"id":5} + {"id":1} } diff --git a/bruno/price/Price Edit.bru b/bruno/price/Price Edit.bru index 0576c03..e840477 100644 --- a/bruno/price/Price Edit.bru +++ b/bruno/price/Price Edit.bru @@ -12,11 +12,11 @@ post { body:json { { - "id":5, - "item":2, - "type":"sell", + "id":1, + "sku":"TEST-001", + "type":"buy", "currency":"IDR", - "value":999999, + "value":20000, "periods":"2025-01-01 18:32:35" } } diff --git a/bruno/price/Price Remove.bru b/bruno/price/Price Remove.bru index 33590c0..f9a5ae4 100644 --- a/bruno/price/Price Remove.bru +++ b/bruno/price/Price Remove.bru @@ -12,6 +12,6 @@ post { body:json { { - "id":5 + "id":1 } } diff --git a/modules/api/price.py b/modules/api/price.py index 653ad0b..715f049 100644 --- a/modules/api/price.py +++ b/modules/api/price.py @@ -14,7 +14,7 @@ class price: response = {} self.cursor.execute("BEGIN;") try: - self.cursor.execute("SELECT `id`, `item`, `type`, `currency`, `value`, DATE_FORMAT(`periods`, '%Y-%m-%d %H:%i:%S') AS `periods` FROM `item_price` ORDER BY periods DESC, id DESC;") + self.cursor.execute("SELECT `id`, `sku`, `type`, `currency`, `value`, DATE_FORMAT(`periods`, '%Y-%m-%d %H:%i:%S') AS `periods` FROM `item_price` ORDER BY periods DESC, id DESC;") ls = self.cursor.fetchall() loggorilla.prcss(APIADDR, "Giving response") response["status" ] = "success" @@ -39,7 +39,7 @@ class price: id = params["id"] self.cursor.execute("BEGIN;") try: - self.cursor.execute("SELECT `id`, `item`, `type`, `currency`, `value`, DATE_FORMAT(`periods`, '%Y-%m-%d %H:%i:%S') AS `periods` FROM `item_price` WHERE id= %s ORDER BY periods DESC, id DESC;", (id,)) + self.cursor.execute("SELECT `id`, `sku`, `type`, `currency`, `value`, DATE_FORMAT(`periods`, '%Y-%m-%d %H:%i:%S') AS `periods` FROM `item_price` WHERE id= %s ORDER BY periods DESC, id DESC;", (id,)) data = self.cursor.fetchone() loggorilla.prcss(APIADDR, "Giving response") response["status" ] = "success" @@ -61,7 +61,7 @@ class price: APIADDR = "/api/invlab/price/add" response = {} loggorilla.prcss(APIADDR, "Define parameters") - item = params["item" ] + sku = params["sku" ] type = params["type" ] currency = params["currency" ] value = params["value" ] @@ -69,7 +69,7 @@ class price: self.cursor.execute("BEGIN;") try: loggorilla.prcss(APIADDR, "Inserting") - self.cursor.execute("INSERT INTO `item_price` VALUES (DEFAULT, %s, %s, %s, %s, %s) ;", (item, type, currency, value, periods) ) + self.cursor.execute("INSERT INTO `item_price` VALUES (DEFAULT, %s, %s, %s, %s, %s) ;", (sku, type, currency, value, periods) ) loggorilla.prcss(APIADDR, "Giving response") response["status" ] = "success" response["desc" ] = "data added" @@ -78,7 +78,7 @@ class price: loggorilla.error(APIADDR, str(e) ) loggorilla.prcss(APIADDR, "Giving response") response["status" ] = "failed" - response["desc" ] = "Internal Server Error. Please contact us if you still have an error." + response["desc" ] = "Internal Server Error. Please contact us if you still have an error." finally: self.cursor.execute("COMMIT;") self.cursor.close() @@ -90,7 +90,7 @@ class price: response = {} loggorilla.prcss(APIADDR, "Define parameters") key = params["id" ] - item = params["item" ] + sku = params["sku" ] type = params["type" ] currency = params["currency" ] value = params["value" ] @@ -98,7 +98,7 @@ class price: self.cursor.execute("BEGIN;") try: loggorilla.prcss(APIADDR, "Updating") - self.cursor.execute("UPDATE `item_price` SET `item` = %s,`type` = %s,`currency` = %s,`value` = %s,`periods` = %s WHERE `id` = %s ;", (item, type, currency, value, periods, key) ) + self.cursor.execute("UPDATE `item_price` SET `sku` = %s,`type` = %s,`currency` = %s,`value` = %s,`periods` = %s WHERE `id` = %s ;", (sku, type, currency, value, periods, key) ) loggorilla.prcss(APIADDR, "Giving response") response["status" ] = "success" response["desc" ] = "data change"