update mobilepayment

This commit is contained in:
Myat Zin Wai Maw
2019-06-21 14:21:03 +06:30
parent 3716cbdda7
commit efd2e84bcc
3 changed files with 24 additions and 137 deletions

View File

@@ -35,7 +35,7 @@ class InventoryDefinition < ApplicationRecord
end
def self.check_balance(item,inventory_definition) # item => saleItemOBj
stock = StockJournal.where('item_code=?', item.item_instance_code).order('created_at desc').take
stock = StockJournal.where('item_code=?', item.item_instance_code).last
unless stock.nil?
modify_balance(item, stock, inventory_definition)
else
@@ -77,7 +77,7 @@ class InventoryDefinition < ApplicationRecord
def self.get_by_category(filter)
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
THEN (SELECT balance FROM stock_journals
THEN (SELECT min(balance) FROM stock_journals
WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals