delete shop scope in model

This commit is contained in:
Zin Moe
2020-01-13 18:41:37 +06:30
parent a3edbb07fd
commit 270c2a821e
20 changed files with 25 additions and 29 deletions

View File

@@ -135,7 +135,7 @@ class Booking < ApplicationRecord
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}%")
end
.shop.order("sale_id DESC")
.order("sale_id DESC")
end
def self.get_sync_data(sale_id)

View File

@@ -20,7 +20,6 @@ class DiningFacility < ApplicationRecord
ROOM_TYPE = "Room"
default_scope { order('order_by asc') }
scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) }
scope :active, -> {where(is_active: true)}

View File

@@ -8,7 +8,6 @@ class Menu < ApplicationRecord
#Default Scope to pull the active version only
default_scope { order("created_at asc") }
scope :active, -> {where("is_active = true")}
scope :shop, -> { where("menus.shop_code=?",Shop.current_shop.shop_code) }
def self.current_menu
today = DateTime.now
@@ -47,7 +46,7 @@ class Menu < ApplicationRecord
end
end
def self.import(file, created_by,shop)
def self.import(file, created_by)
status = ""
spreadsheet = open_spreadsheet(file)
if spreadsheet.sheets.count > 1

View File

@@ -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='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
.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
daily_total = connection.select_all("SELECT

View File

@@ -34,7 +34,7 @@ class SalePayment < ApplicationRecord
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
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

View File

@@ -1,12 +1,11 @@
class StockCheck < ApplicationRecord
has_many :stock_check_items
def create(user, reason, item_list,shop)
def create(user, reason, item_list)
self.reason = reason
self.check_by = user.id
self.check_start = Time.now
self.check_end = Time.now
self.shop_code = shop.shop_code
save
item_list.each do |item|
stockItem = StockCheckItem.new

View File

@@ -67,7 +67,7 @@ class StockCheckItem < ApplicationRecord
return query
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
end
end

View File

@@ -34,7 +34,7 @@ class StockJournal < ApplicationRecord
return balance.to_i - qty.to_i
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
if stock_journal.nil?
old_blance = 0
@@ -57,7 +57,7 @@ class StockJournal < ApplicationRecord
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")
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
.group("mii.item_instance_name")
@@ -76,7 +76,7 @@ class StockJournal < ApplicationRecord
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
end

View File

@@ -5,7 +5,6 @@ class Zone < ApplicationRecord
has_many :order_queue_stations
has_many :cashier_terminals
scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) }
# validations
validates_presence_of :name, :created_by