delete shop scope in model
This commit is contained in:
@@ -223,7 +223,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
@pdf_view = @lookup_pdf.value
|
@pdf_view = @lookup_pdf.value
|
||||||
end
|
end
|
||||||
|
|
||||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,current_shop)
|
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||||
@kbz_pay_amount += amount.to_f
|
@kbz_pay_amount += amount.to_f
|
||||||
|
|
||||||
#for changable on/off
|
#for changable on/off
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class HomeController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@inventories = StockJournal.inventory_balances(@from,@to, current_shop).sum(:balance)
|
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
|
||||||
|
|
||||||
@total_trans = Sale.total_trans(current_user,@from,@to)
|
@total_trans = Sale.total_trans(current_user,@from,@to)
|
||||||
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
|||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
|
|
||||||
StockJournal.delete_stock_journal(inventory.item_code,current_shop)
|
StockJournal.delete_stock_journal(inventory.item_code)
|
||||||
StockCheckItem.delete_stock_check_item(inventory.item_code,current_shop)
|
StockCheckItem.delete_stock_check_item(inventory.item_code)
|
||||||
if !inventory.nil?
|
if !inventory.nil?
|
||||||
inventory.destroy
|
inventory.destroy
|
||||||
flash[:message] = 'Inventory was successfully destroyed.'
|
flash[:message] = 'Inventory was successfully destroyed.'
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
|||||||
item_list = JSON.parse(params[:stock_item])
|
item_list = JSON.parse(params[:stock_item])
|
||||||
reason = params[:reason]
|
reason = params[:reason]
|
||||||
check = StockCheck.new
|
check = StockCheck.new
|
||||||
@check = check.create(current_user, reason, item_list,current_shop)
|
@check = check.create(current_user, reason, item_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -33,7 +33,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
|||||||
check = params[:data]
|
check = params[:data]
|
||||||
stockCheck = StockCheck.find_by_id(check)
|
stockCheck = StockCheck.find_by_id(check)
|
||||||
stockCheck.stock_check_items.each do |item|
|
stockCheck.stock_check_items.each do |item|
|
||||||
StockJournal.from_stock_check(item,current_shop)
|
StockJournal.from_stock_check(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
|
|
||||||
|
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
@occupied_table = DiningFacility.where("status='occupied'").shop.count
|
@occupied_table = DiningFacility.where("status='occupied'").count
|
||||||
@shift = ShiftSale.current_open_shift(current_user)
|
@shift = ShiftSale.current_open_shift(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@pdf_view = @lookup_pdf.value
|
@pdf_view = @lookup_pdf.value
|
||||||
end
|
end
|
||||||
|
|
||||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user, current_shop)
|
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||||
@kbz_pay_amount += amount.to_f
|
@kbz_pay_amount += amount.to_f
|
||||||
|
|
||||||
#for changable on/off
|
#for changable on/off
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class Settings::MenusController < ApplicationController
|
|||||||
|
|
||||||
def import
|
def import
|
||||||
if params[:file]
|
if params[:file]
|
||||||
status = Menu.import(params[:file], current_user.name,current_shop)
|
status = Menu.import(params[:file], current_user.name)
|
||||||
redirect_to settings_menus_path, notice: status
|
redirect_to settings_menus_path, notice: status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ class Transactions::CreditNotesController < ApplicationController
|
|||||||
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||||
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
||||||
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
|
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
|
||||||
THEN NULL ELSE payment_method='creditnote' END)").shop
|
THEN NULL ELSE payment_method='creditnote' END)")
|
||||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||||
else
|
else
|
||||||
sale = Sale.search_credit_sales(customer,filter,from,to,order_source).shop
|
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
|
||||||
if !sale.nil?
|
if !sale.nil?
|
||||||
@credit_notes = sale
|
@credit_notes = sale
|
||||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ class Transactions::SalesController < ApplicationController
|
|||||||
|
|
||||||
if receipt_no.nil? && from.nil? && to.nil?
|
if receipt_no.nil? && from.nil? && to.nil?
|
||||||
if @shift.blank?
|
if @shift.blank?
|
||||||
@sales = Sale.where("NOT sale_status='new'").shop.order("sale_id desc")
|
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
|
||||||
else
|
else
|
||||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").shop.order("sale_id desc")
|
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
|
||||||
end
|
end
|
||||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||||
else
|
else
|
||||||
sale = Sale.search(receipt_no,from,to,@shift).shop
|
sale = Sale.search(receipt_no,from,to,@shift)
|
||||||
if sale.count > 0
|
if sale.count > 0
|
||||||
@sales = sale
|
@sales = sale
|
||||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class Booking < ApplicationRecord
|
|||||||
joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
|
joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
|
||||||
.where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
|
.where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
|
||||||
end
|
end
|
||||||
.shop.order("sale_id DESC")
|
.order("sale_id DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_sync_data(sale_id)
|
def self.get_sync_data(sale_id)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ class DiningFacility < ApplicationRecord
|
|||||||
ROOM_TYPE = "Room"
|
ROOM_TYPE = "Room"
|
||||||
|
|
||||||
default_scope { order('order_by asc') }
|
default_scope { order('order_by asc') }
|
||||||
scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) }
|
|
||||||
|
|
||||||
scope :active, -> {where(is_active: true)}
|
scope :active, -> {where(is_active: true)}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ class Menu < ApplicationRecord
|
|||||||
#Default Scope to pull the active version only
|
#Default Scope to pull the active version only
|
||||||
default_scope { order("created_at asc") }
|
default_scope { order("created_at asc") }
|
||||||
scope :active, -> {where("is_active = true")}
|
scope :active, -> {where("is_active = true")}
|
||||||
scope :shop, -> { where("menus.shop_code=?",Shop.current_shop.shop_code) }
|
|
||||||
|
|
||||||
def self.current_menu
|
def self.current_menu
|
||||||
today = DateTime.now
|
today = DateTime.now
|
||||||
@@ -47,7 +46,7 @@ class Menu < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.import(file, created_by,shop)
|
def self.import(file, created_by)
|
||||||
status = ""
|
status = ""
|
||||||
spreadsheet = open_spreadsheet(file)
|
spreadsheet = open_spreadsheet(file)
|
||||||
if spreadsheet.sheets.count > 1
|
if spreadsheet.sheets.count > 1
|
||||||
|
|||||||
@@ -791,7 +791,7 @@ def self.daily_sales_list(from,to)
|
|||||||
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
||||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||||
.along_with_sale_payments_except_void_between(from, to)
|
.along_with_sale_payments_except_void_between(from, to)
|
||||||
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to).shop
|
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
|
||||||
.group("sale_id").to_sql
|
.group("sale_id").to_sql
|
||||||
|
|
||||||
daily_total = connection.select_all("SELECT
|
daily_total = connection.select_all("SELECT
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_kbz_pay_amount(sale_id, current_user,shop)
|
def self.get_kbz_pay_amount(sale_id, current_user)
|
||||||
amount = 0
|
amount = 0
|
||||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||||
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
|
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
class StockCheck < ApplicationRecord
|
class StockCheck < ApplicationRecord
|
||||||
has_many :stock_check_items
|
has_many :stock_check_items
|
||||||
|
|
||||||
def create(user, reason, item_list,shop)
|
def create(user, reason, item_list)
|
||||||
self.reason = reason
|
self.reason = reason
|
||||||
self.check_by = user.id
|
self.check_by = user.id
|
||||||
self.check_start = Time.now
|
self.check_start = Time.now
|
||||||
self.check_end = Time.now
|
self.check_end = Time.now
|
||||||
self.shop_code = shop.shop_code
|
|
||||||
save
|
save
|
||||||
item_list.each do |item|
|
item_list.each do |item|
|
||||||
stockItem = StockCheckItem.new
|
stockItem = StockCheckItem.new
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class StockCheckItem < ApplicationRecord
|
|||||||
return query
|
return query
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_stock_check_item(item_code,shop)
|
def self.delete_stock_check_item(item_code)
|
||||||
self.where("item_code=?", item_code).delete_all
|
self.where("item_code=?", item_code).delete_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class StockJournal < ApplicationRecord
|
|||||||
return balance.to_i - qty.to_i
|
return balance.to_i - qty.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_stock_check(item,shop)
|
def self.from_stock_check(item)
|
||||||
stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first
|
stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first
|
||||||
if stock_journal.nil?
|
if stock_journal.nil?
|
||||||
old_blance = 0
|
old_blance = 0
|
||||||
@@ -57,7 +57,7 @@ class StockJournal < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.inventory_balances(from,to, current_shop)
|
def self.inventory_balances(from,to)
|
||||||
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||||
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
||||||
.group("mii.item_instance_name")
|
.group("mii.item_instance_name")
|
||||||
@@ -76,7 +76,7 @@ class StockJournal < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_stock_journal(item_code,shop)
|
def self.delete_stock_journal(item_code)
|
||||||
self.where("item_code=?", item_code).delete_all
|
self.where("item_code=?", item_code).delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ class Zone < ApplicationRecord
|
|||||||
has_many :order_queue_stations
|
has_many :order_queue_stations
|
||||||
has_many :cashier_terminals
|
has_many :cashier_terminals
|
||||||
|
|
||||||
scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) }
|
|
||||||
|
|
||||||
# validations
|
# validations
|
||||||
validates_presence_of :name, :created_by
|
validates_presence_of :name, :created_by
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<%= f.input :is_currently_login %>
|
<%= f.input :is_currently_login %>
|
||||||
<%= f.input :auto_print_receipt %>
|
<%= f.input :auto_print_receipt %>
|
||||||
<%= f.label "Select Zones", :class => 'control-label' %>
|
<%= f.label "Select Zones", :class => 'control-label' %>
|
||||||
<%= f.collection_check_boxes :zone_ids , Zone.shop, :id, :name , :class => 'checkbox form-group'%>
|
<%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox form-group'%>
|
||||||
<% if(@server_mode != 'cloud') %>
|
<% if(@server_mode != 'cloud') %>
|
||||||
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
|
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ div.form-inputs span{
|
|||||||
<%= f.input :print_copy %>
|
<%= f.input :print_copy %>
|
||||||
<%= f.hidden_field :processing_items %>
|
<%= f.hidden_field :processing_items %>
|
||||||
<%= f.label "Select Zones", :class => 'control-label' %>
|
<%= f.label "Select Zones", :class => 'control-label' %>
|
||||||
<%= f.collection_check_boxes :zone_ids , Zone.shop, :id, :name , :class => 'checkbox'%>
|
<%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox'%>
|
||||||
<%= f.input :cut_per_item %>
|
<%= f.input :cut_per_item %>
|
||||||
<%= f.input :use_alternate_name %>
|
<%= f.input :use_alternate_name %>
|
||||||
<%= f.input :processing_items, as: :hidden %>
|
<%= f.input :processing_items, as: :hidden %>
|
||||||
|
|||||||
Reference in New Issue
Block a user