change query and some func: in inv:

This commit is contained in:
phyusin
2018-08-17 17:57:13 +06:30
parent b91ad06f35
commit dee3c89ad3
2 changed files with 11 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ class Inventory::InventoryController < BaseInventoryController
least_stock = "SELECT (CASE WHEN SIGN(MIN(stock_journals.balance)) > 0
THEN MIN(stock_journals.balance) WHEN stock_journals.remark NOT LIKE '%out of stock%'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code AND balance > 0
WHERE item_code = inventory_definitions.item_code
AND remark NOT LIKE '%out of stock%'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals