fixed inventroy item balance
This commit is contained in:
@@ -82,7 +82,9 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_by_category(filter)
|
||||
least_stock = StockJournal.select(:balance).joins("JOIN inventory_definitions ON stock_journals.item_code = inventory_definitions.item_code").order(:id => :desc).limit(1).to_sql
|
||||
least_stock = StockJournal.select(:balance)
|
||||
.where('stock_journals.updated_at = (SELECT MAX(stock_journals.updated_at) FROM stock_journals WHERE (stock_journals.item_code = inventory_definitions.item_code))')
|
||||
.order(:id => :desc).to_sql
|
||||
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
||||
|
||||
Reference in New Issue
Block a user