Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -65,7 +65,7 @@ class HomeController < ApplicationController
|
|||||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||||
|
|
||||||
@top_products = Sale.top_products(today)
|
@top_products = Sale.top_products(today)
|
||||||
@hourly_sales = Sale.hourly_sales(today)
|
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
||||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||||
# .sum(:grand_total)
|
# .sum(:grand_total)
|
||||||
@employee_sales = Sale.employee_sales(today).sum(:grand_total)
|
@employee_sales = Sale.employee_sales(today).sum(:grand_total)
|
||||||
|
|||||||
@@ -21,43 +21,78 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||||
|
|
||||||
#Assign OQS id to order Items
|
#Assign OQS id to order Items
|
||||||
oqs_stations.each do |oqs|
|
# oqs_stations.each do |oqs|
|
||||||
is_auto_printed = false
|
# is_auto_printed = false
|
||||||
oqs_order_items = []
|
# oqs_order_items = []
|
||||||
#Get List of items -
|
# #Get List of items -
|
||||||
pq_items = JSON.parse(oqs.processing_items)
|
# pq_items = JSON.parse(oqs.processing_items)
|
||||||
|
|
||||||
#Loop through the processing items
|
# #Loop through the processing items
|
||||||
pq_items.each do |pq_item|
|
# pq_items.each do |pq_item|
|
||||||
#Processing through the looping items
|
# #Processing through the looping items
|
||||||
order_items.each do |order_item|
|
# order_items.each do |order_item|
|
||||||
if (pq_item == order_item.item_code)
|
# if (pq_item == order_item.item_code)
|
||||||
# if oqs.id == oqpbz.order_queue_station_id
|
# # if oqs.id == oqpbz.order_queue_station_id
|
||||||
# #Same Order_items can appear in two location.
|
# # #Same Order_items can appear in two location.
|
||||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
# # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
# else
|
# # else
|
||||||
|
|
||||||
if (order_item.price != 0)
|
# if (order_item.price != 0)
|
||||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
oqs_order_items.push(order_item)
|
# oqs_order_items.push(order_item)
|
||||||
end
|
# end
|
||||||
# end
|
# # end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
# Auto Printing
|
|
||||||
# ToDo per item per printer
|
# ToDo per item per printer
|
||||||
|
|
||||||
OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").find_each do |oqpbz|
|
OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").find_each do |oqpbz|
|
||||||
if oqs.id == oqpbz.order_queue_station_id
|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
|
||||||
|
is_auto_printed = false
|
||||||
|
oqs_order_items = []
|
||||||
|
|
||||||
|
if oqs.is_active
|
||||||
|
#Get List of items -
|
||||||
|
pq_items = JSON.parse(oqs.processing_items)
|
||||||
|
#Loop through the processing items
|
||||||
|
pq_items.each do |pq_item|
|
||||||
|
#Processing through the looping items
|
||||||
|
order_items.each do |order_item|
|
||||||
|
if (pq_item == order_item.item_code)
|
||||||
|
# if oqs.id == oqpbz.order_queue_station_id
|
||||||
|
# #Same Order_items can appear in two location.
|
||||||
|
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
|
# else
|
||||||
|
|
||||||
|
if (order_item.price != 0)
|
||||||
|
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
|
oqs_order_items.push(order_item)
|
||||||
|
end
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if oqs.auto_print
|
if oqs.auto_print
|
||||||
if oqs_order_items.length > 0
|
if oqs_order_items.length > 0
|
||||||
print_slip(oqs, order, oqs_order_items)
|
print_slip(oqs, order, oqs_order_items)
|
||||||
is_auto_printed = true
|
is_auto_printed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# if oqs.id == oqpbz.order_queue_station_id
|
||||||
|
# # Auto Printing
|
||||||
|
# if oqs.auto_print
|
||||||
|
# if oqs_order_items.length > 0
|
||||||
|
# print_slip(oqs, order, oqs_order_items)
|
||||||
|
# is_auto_printed = true
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -854,7 +854,9 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.hourly_sales(today)
|
def self.hourly_sales(today)
|
||||||
query= Sale.select("grand_total").where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
query= Sale.select("grand_total")
|
||||||
|
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
.group("date_format(receipt_date, '%I %p')")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.employee_sales(today)
|
def self.employee_sales(today)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class SeedGenerator < ApplicationRecord
|
|||||||
# Generate ID for Tables
|
# Generate ID for Tables
|
||||||
def self.generate_id(model, prefix)
|
def self.generate_id(model, prefix)
|
||||||
seed = SeedGenerator.find_by_model(model)
|
seed = SeedGenerator.find_by_model(model)
|
||||||
|
next_no = seed.next
|
||||||
new_receipt_no = 0
|
new_receipt_no = 0
|
||||||
|
|
||||||
if (seed.nil?)
|
if (seed.nil?)
|
||||||
@@ -9,38 +10,33 @@ class SeedGenerator < ApplicationRecord
|
|||||||
seed.model = model
|
seed.model = model
|
||||||
new_receipt_no = seed.next
|
new_receipt_no = seed.next
|
||||||
seed.save
|
seed.save
|
||||||
|
|
||||||
else
|
else
|
||||||
current_no = seed.next
|
# current_no = seed.next
|
||||||
seed.next = seed.next + seed.increase_by
|
# seed.next = seed.next + seed.increase_by
|
||||||
seed.current = current_no
|
# seed.current = current_no
|
||||||
seed.save
|
# seed.save
|
||||||
|
cur_val, next_val = self.update_seed(model, seed.next, seed.increase_by)
|
||||||
|
|
||||||
|
if next_no == cur_val
|
||||||
|
puts "SSS"
|
||||||
|
puts next_val
|
||||||
|
cur_val2, next_val2 = self.update_seed(model, next_val, seed.increase_by)
|
||||||
|
puts next_val2
|
||||||
|
padding_len = 15 - prefix.length
|
||||||
|
saleOrderId = prefix +"-"+ cur_val2.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||||
|
puts saleOrderId
|
||||||
|
return saleOrderId
|
||||||
|
end
|
||||||
|
|
||||||
|
padding_len = 15 - prefix.length
|
||||||
|
saleOrderId = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||||
|
return saleOrderId
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
padding_len = 15 - prefix.length
|
padding_len = 15 - prefix.length
|
||||||
saleOrderId = prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
saleOrderId = prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||||
return saleOrderId
|
return saleOrderId
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Generate Receipt No
|
|
||||||
def self.new_receipt_no
|
|
||||||
seed = SeedGenerator.find_by_model("sale")
|
|
||||||
new_receipt_no = 0
|
|
||||||
if (seed.nil?)
|
|
||||||
seed = SeedGenerator.new()
|
|
||||||
seed.model = "sale"
|
|
||||||
new_receipt_no = seed.next
|
|
||||||
seed.save
|
|
||||||
|
|
||||||
else
|
|
||||||
current_no = seed.next
|
|
||||||
seed.next = seed.next
|
|
||||||
seed.current = current_no
|
|
||||||
seed.save
|
|
||||||
end
|
|
||||||
|
|
||||||
return seed.current
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate for 4 digit Code
|
# Generate for 4 digit Code
|
||||||
@@ -71,4 +67,24 @@ class SeedGenerator < ApplicationRecord
|
|||||||
next_code = prefix + seed.current.to_s.to_s.rjust((count)+1,'0')
|
next_code = prefix + seed.current.to_s.to_s.rjust((count)+1,'0')
|
||||||
return next_code
|
return next_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.update_seed(model, current, inc)
|
||||||
|
cur_val = 0
|
||||||
|
next_val = 0
|
||||||
|
nex = current + inc
|
||||||
|
|
||||||
|
update_sql = "update seed_generators set current= #{current}, next= #{nex} where model='#{model}';";
|
||||||
|
select_sql = "select * from seed_generators where model='#{model}';"
|
||||||
|
update_result = ActiveRecord::Base.connection.execute(update_sql);
|
||||||
|
|
||||||
|
select_result = ActiveRecord::Base.connection.execute(select_sql);
|
||||||
|
|
||||||
|
select_result.each do |row|
|
||||||
|
p row
|
||||||
|
cur_val = row [3]
|
||||||
|
next_val = row[4]
|
||||||
|
end
|
||||||
|
|
||||||
|
return cur_val, next_val
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module SXRestaurants
|
|||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
# Application configuration should go into files in config/initializers
|
# Application configuration should go into files in config/initializers
|
||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
config.i18n.default_locale = :'mm'
|
config.i18n.default_locale = :'en'
|
||||||
|
|
||||||
config.active_record.time_zone_aware_types = [:datetime, :time]
|
config.active_record.time_zone_aware_types = [:datetime, :time]
|
||||||
config.active_job.queue_adapter = :sidekiq
|
config.active_job.queue_adapter = :sidekiq
|
||||||
|
|||||||
Reference in New Issue
Block a user