Merge branch 'adminbsb_material_ui'
This commit is contained in:
@@ -3,7 +3,7 @@ module LoginVerification
|
||||
|
||||
included do
|
||||
before_action :authenticate_session_token
|
||||
helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration
|
||||
helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration
|
||||
end
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
@@ -17,6 +17,14 @@ module LoginVerification
|
||||
end
|
||||
end
|
||||
|
||||
def current_shop
|
||||
begin
|
||||
return Shop.first
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
|
||||
@@ -1,45 +1,13 @@
|
||||
class Inventory::InventoryController < BaseInventoryController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
|
||||
THEN (SELECT 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
|
||||
WHERE stock_journals.item_code = inventory_definitions.item_code
|
||||
ORDER BY stock_journals.created_at DESC LIMIT 1"
|
||||
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
||||
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
|
||||
(#{least_stock}) as balance,"+
|
||||
"acc.title as account_name,mi.name as item_name,
|
||||
mii.item_instance_name as instance_name," +
|
||||
"mc.name as menu_category_name,mc.id as menu_category_id "
|
||||
)
|
||||
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
|
||||
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
.group("mi.menu_category_id,inventory_definitions.item_code")
|
||||
.order("acc.title desc,mi.menu_category_id desc,balance ASC")
|
||||
filter = params[:filter]
|
||||
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(filter)
|
||||
|
||||
end
|
||||
|
||||
# def self.get_item_query(type)
|
||||
|
||||
# query = Sale.select("acc.title as account_name,mi.name as item_name,mii.item_instance_name as instance_name" +
|
||||
# "mc.name as menu_category_name,mc.id as menu_category_id ")
|
||||
|
||||
# query = query.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||
# " JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
# " JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
# query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
# query = query.group("acc.title,mi.account_id,mi.menu_category_id")
|
||||
# .order("acc.title desc, mi.account_id desc, mi.menu_category_id desc")
|
||||
# end
|
||||
|
||||
|
||||
def show
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||
|
||||
@@ -41,7 +41,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
member_info = nil
|
||||
unique_code = 'StockCheckPdf'
|
||||
|
||||
shop_details = Shop.find(1)
|
||||
shop_details = current_shop
|
||||
checker = Employee.find(stockcheck.check_by)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
if !print_settings.nil?
|
||||
@@ -66,7 +66,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
@shop = current_shop
|
||||
end
|
||||
|
||||
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
@@ -109,7 +109,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
shop_details = current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
|
||||
@@ -90,7 +90,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
shop_details = current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
|
||||
@@ -59,11 +59,11 @@ class Settings::ShopsController < ApplicationController
|
||||
File.delete(delete_path)
|
||||
end
|
||||
end
|
||||
save_path = Rails.root.join("public/#{Shop.find(1).shop_code}_#{a.original_filename}")
|
||||
save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}")
|
||||
File.open(save_path, 'wb') do |f|
|
||||
f.write a.read
|
||||
end
|
||||
audio_name = "#{Shop.find(1).shop_code}_#{a.original_filename}"
|
||||
audio_name = "#{current_shop.shop_code}_#{a.original_filename}"
|
||||
@settings_shop.display_images.where(:name => "order_audio").destroy_all
|
||||
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user