Pull from master
This commit is contained in:
@@ -10,7 +10,7 @@ class Customer < ApplicationRecord
|
||||
has_many :sales
|
||||
|
||||
validates_presence_of :name, :contact_no, :email #,:card_no
|
||||
validates :contact_no, uniqueness: true, numericality: true
|
||||
validates :contact_no, numericality: true #uniqueness: true,
|
||||
validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
|
||||
# validates :card_no, uniqueness: true
|
||||
# validates :paypar_account_no, uniqueness: true
|
||||
|
||||
@@ -57,9 +57,15 @@ class MenuCategory < ApplicationRecord
|
||||
to = 24
|
||||
to = to * 3600 + to_t.min* 60 + to_t.sec
|
||||
else
|
||||
|
||||
h += 24
|
||||
to = h*3600 + to_t.min* 60 + to_t.sec
|
||||
c = current_t.hour
|
||||
if c < 12
|
||||
|
||||
c +=24
|
||||
current = c*3600 + current_t.min* 60 + current_t.sec
|
||||
|
||||
end
|
||||
end
|
||||
else # (after) noon
|
||||
if h > 12
|
||||
@@ -72,6 +78,7 @@ class MenuCategory < ApplicationRecord
|
||||
day = Date.today.wday
|
||||
dayresult = menu.valid_days.include?(day.to_s)
|
||||
|
||||
|
||||
if current.between?(from, to) && menu.valid_days.include?(day.to_s)
|
||||
return true
|
||||
else
|
||||
@@ -108,3 +115,7 @@ class MenuCategory < ApplicationRecord
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ class OrderReservation < ApplicationRecord
|
||||
else
|
||||
gender = "Male"
|
||||
end
|
||||
customer = Customer.new
|
||||
if params[:customer_id] && !params[:customer_id].nil?
|
||||
customer = Customer.find(params[:customer_id])
|
||||
else
|
||||
customer = Customer.new
|
||||
end
|
||||
customer.name = params[:name]
|
||||
customer.email = params[:email]
|
||||
customer.contact_no = params[:contact_no] ? params[:contact_no] : ''
|
||||
@@ -33,7 +37,6 @@ class OrderReservation < ApplicationRecord
|
||||
customer.customer_type = "Doemal"
|
||||
customer.tax_profiles = ["2"]
|
||||
customer.save
|
||||
|
||||
# unless customer.valid?
|
||||
# render json: {
|
||||
# status: 422,
|
||||
@@ -319,13 +322,10 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
# if ENV["SERVER_MODE"] == 'cloud'
|
||||
# ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code
|
||||
# end
|
||||
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
end
|
||||
end
|
||||
|
||||
@@ -340,13 +340,10 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
# if ENV["SERVER_MODE"] == 'cloud'
|
||||
# ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code
|
||||
# end
|
||||
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
end
|
||||
end
|
||||
|
||||
@@ -361,10 +358,10 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -870,9 +870,9 @@ def self.get_item_query(type)
|
||||
elsif type == "discount"
|
||||
sale_type = "i.status = 'Discount'"
|
||||
elsif type == "foc"
|
||||
sale_type = "i.status = 'foc' and i.qty > 0"
|
||||
sale_type = "i.status = 'foc' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "void"
|
||||
sale_type = "i.status = 'void' and i.qty > 0"
|
||||
sale_type = "i.status = 'void' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "other"
|
||||
sale_type = "i.item_instance_code IS NULL"
|
||||
end
|
||||
@@ -907,12 +907,8 @@ end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
query = self.get_item_query(type)
|
||||
else
|
||||
query = self.get_item_query(type)
|
||||
end
|
||||
|
||||
query = self.get_item_query(type)
|
||||
|
||||
discount_query = 0
|
||||
total_card_amount = 0
|
||||
@@ -921,12 +917,16 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
total_foc_amount = 0
|
||||
total_grand_total = 0
|
||||
|
||||
other_charges = self.get_other_charges()
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
end
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
@@ -947,7 +947,9 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
@@ -968,7 +970,9 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
|
||||
Reference in New Issue
Block a user