change stock check report and some structure
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
class Inventory::InventoryController < BaseInventoryController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@products = InventoryDefinition.all.active.order('created_at desc')
|
||||
end
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
(CASE WHEN sj.credit IS NULL THEN '-' ELSE sj.credit END) as credit,
|
||||
(CASE WHEN sj.debit IS NULL THEN '-' ELSE sj.debit END) as debit,
|
||||
(CASE WHEN sj.balance IS NULL THEN '-' ELSE sj.balance END) as balance")
|
||||
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
|
||||
.where("(CASE WHEN sj.balance > 0 THEN sj.balance=(SELECT MIN(balance) FROM stock_journals WHERE stock_journals.item_code = inventory_definitions.item_code ORDER BY created_at DESC) ELSE 1 END)")
|
||||
.group("inventory_definitions.item_code")
|
||||
.order("(CASE WHEN sj.balance > 0 THEN MIN(sj.balance) ELSE NULL END )")
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||
|
||||
@stock_journals = StockJournal.where(item_code: inventory.item_code)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
|
||||
Reference in New Issue
Block a user