merge with master
This commit is contained in:
@@ -93,6 +93,11 @@ class Ability
|
||||
can :index, :home
|
||||
can :show, :home
|
||||
|
||||
#ability for split_bill
|
||||
can :index, :split_bill
|
||||
can :create, :split_bill
|
||||
can :update_sale, :split_bill
|
||||
|
||||
elsif user.role == "cashier"
|
||||
|
||||
# can :overall_void, :void
|
||||
@@ -100,7 +105,7 @@ class Ability
|
||||
can :show, :home
|
||||
can :read, Order
|
||||
can :update, Order
|
||||
can :menage, Booking
|
||||
can :manage, Booking
|
||||
can :manage, OrderQueueStation
|
||||
can :read, Sale
|
||||
can :update, Sale
|
||||
@@ -174,6 +179,11 @@ class Ability
|
||||
can :remove_all_discount, :discount
|
||||
can :member_discount, :discount
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
can :move_dining, :moveroom
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, DiningQueue
|
||||
|
||||
@@ -191,6 +201,11 @@ class Ability
|
||||
|
||||
can :index, :home
|
||||
can :show, :home
|
||||
|
||||
#ability for split_bill
|
||||
can :index, :split_bill
|
||||
can :create, :split_bill
|
||||
can :update_sale, :split_bill
|
||||
elsif user.role == "waiter"
|
||||
can :index, :home
|
||||
can :show, :home
|
||||
|
||||
@@ -7,4 +7,7 @@ class Commissioner < ApplicationRecord
|
||||
|
||||
# validations
|
||||
validates_presence_of :name
|
||||
|
||||
# Commissioner Image Uploader
|
||||
mount_uploader :image_path, CommissionerImageUploader
|
||||
end
|
||||
|
||||
@@ -2,6 +2,9 @@ class Customer < ApplicationRecord
|
||||
|
||||
#self.primary_key = :customer_id
|
||||
|
||||
# Customer Image Uploader
|
||||
mount_uploader :image_path, CustomerImageUploader
|
||||
|
||||
before_create :generate_custom_id
|
||||
has_many :orders
|
||||
has_many :sales
|
||||
@@ -31,7 +34,7 @@ class Customer < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
@@ -68,7 +71,7 @@ class Customer < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -121,7 +124,7 @@ class Customer < ApplicationRecord
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
})
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false, message: "Server Time out" }
|
||||
@@ -198,7 +201,7 @@ class Customer < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status": false , "message": "Connect To" }
|
||||
@@ -274,7 +277,7 @@ class Customer < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status": false , "message": "Connect To" }
|
||||
@@ -309,7 +312,7 @@ class Customer < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
|
||||
5
app/models/display_image.rb
Normal file
5
app/models/display_image.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class DisplayImage < ApplicationRecord
|
||||
mount_uploader :image, DisplayImageUploader
|
||||
belongs_to :shop
|
||||
|
||||
end
|
||||
@@ -8,6 +8,9 @@ class Employee < ApplicationRecord
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||
|
||||
# Employee Image Uploader
|
||||
mount_uploader :image_path, EmployeeImageUploader
|
||||
|
||||
def self.all_emp_except_waiter
|
||||
Employee.where('role!=?','waiter')
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.find_product_in_inventory(item)
|
||||
product = InventoryDefinition.find_by_item_code(item.product_code)
|
||||
product = InventoryDefinition.find_by_item_code(item.item_instance_code)
|
||||
if product.nil?
|
||||
return false, nil
|
||||
else
|
||||
@@ -21,7 +21,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.check_balance(item,inventory_definition) # item => saleItemOBj
|
||||
stock = StockJournal.where('item_code=?', item.product_code).order('created_at desc').take
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order('created_at desc').take
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class License
|
||||
include HTTParty
|
||||
|
||||
base_uri "connect.smartsales.dev/api"
|
||||
base_uri "connect.smartsales.asia/api"
|
||||
|
||||
attr_accessor :name, :address_1, :address_2, :township, :city, :country, :email, :phone, :fax, :logo, :subdomain,
|
||||
:plan_activation_date, :plan_next_renewal_date, :plan_max_products,:plan_max_customers, :plan_active_connections,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Menu < ApplicationRecord
|
||||
|
||||
require 'spreadsheet'
|
||||
has_many :menu_categories, dependent: :destroy
|
||||
|
||||
validates_presence_of :name, :valid_days, :valid_time_from, :valid_time_to
|
||||
@@ -31,4 +33,120 @@ class Menu < ApplicationRecord
|
||||
menu.destroy
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def self.to_csv
|
||||
m_attributes = %w{name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
|
||||
CSV.generate(headers: true, row_sep: "\r\n") do |csv|
|
||||
csv << m_attributes
|
||||
menu = Menu.all
|
||||
menu.each do |user|
|
||||
csv << m_attributes.map{ |attr| user.send(attr)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.import(file)
|
||||
|
||||
spreadsheet = open_spreadsheet(file)
|
||||
sheet_count = spreadsheet.sheets.count-1
|
||||
for i in 0..sheet_count do
|
||||
header = spreadsheet.sheet(i).row(1)
|
||||
sheet_name = spreadsheet.sheets[i]
|
||||
|
||||
(2..spreadsheet.sheet(i).last_row).each do |ii|
|
||||
row = Hash[[header,spreadsheet.sheet(i).row(ii)].transpose]
|
||||
if sheet_name == "Account"
|
||||
# Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||
account = Account.find_by_id(row["id"])
|
||||
if account
|
||||
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||
else
|
||||
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||
end
|
||||
elsif sheet_name == "Item Set"
|
||||
# ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||
item_set = ItemSet.find_by_id(row["id"])
|
||||
if item_set
|
||||
ItemSet.create( name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||
else
|
||||
ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||
end
|
||||
elsif sheet_name == "Menu Item Options"
|
||||
# MenuItemOption.create(id:row["id"], option_type: row["option_type"],name: row["name"],value: row["value"])
|
||||
item_options = MenuItemOption.find_by_id(row["id"])
|
||||
if item_options
|
||||
MenuItemOption.create( option_type: row["option_type"],name: row["name"],value: row["value"])
|
||||
else
|
||||
MenuItemOption.create(id:row["id"], option_type: row["option_type"],name: row["name"],value: row["value"])
|
||||
end
|
||||
elsif sheet_name == "Menu Item Attributes"
|
||||
# MenuItemAttribute.create(id:row["id"], attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
|
||||
item_attributes = MenuItemAttribute.find_by_id(row["id"])
|
||||
if item_attributes
|
||||
MenuItemAttribute.create( attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
|
||||
else
|
||||
MenuItemAttribute.create(id:row["id"], attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
|
||||
end
|
||||
elsif sheet_name == "Menu"
|
||||
menu = Menu.find_by_id(row["id"])
|
||||
if menu
|
||||
Menu.create(name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
|
||||
else
|
||||
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
|
||||
end
|
||||
elsif sheet_name == "Menu Category"
|
||||
# MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||
menu_category = MenuCategory.find_by_id(row["id"])
|
||||
if menu_category
|
||||
MenuCategory.create(menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||
else
|
||||
MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||
end
|
||||
elsif sheet_name == "Menu Item"
|
||||
# MenuItem.create(id:row["id"], item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: row["item_attributes"], item_options: row["item_options"], account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
|
||||
menu_item = MenuItem.find_by_id(row["id"])
|
||||
if menu_item
|
||||
MenuItem.create(item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: JSON.parse(row["item_attributes"]), item_options: JSON.parse(row["item_options"]), account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
|
||||
else
|
||||
MenuItem.create(id:row["id"], item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: JSON.parse(row["item_attributes"]), item_options: JSON.parse(row["item_options"]), account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
|
||||
end
|
||||
elsif sheet_name == "Menu Item Instance"
|
||||
# MenuItemInstance.create(id:row["id"], menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: row["item_attributes"], price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
|
||||
item_instance = MenuItemInstance.find_by_id(row["id"])
|
||||
if item_instance
|
||||
MenuItemInstance.create(menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: JSON.parse(row["item_attributes"]), price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
|
||||
else
|
||||
MenuItemInstance.create(id:row["id"], menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: JSON.parse(row["item_attributes"]), price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
|
||||
end
|
||||
elsif sheet_name == "Menu Instance Item Set"
|
||||
# MenuInstanceItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
|
||||
menu_instance_set = MenuInstanceItemSet.find_by_id(row["id"])
|
||||
if menu_instance_set
|
||||
MenuInstanceItemSet.create(item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
|
||||
else
|
||||
MenuInstanceItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
|
||||
end
|
||||
elsif sheet_name == "Menu Item Set"
|
||||
# MenuItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
|
||||
menu_item_set = MenuItemSet.find_by_id(row["id"])
|
||||
if menu_item_set
|
||||
MenuItemSet.create(item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
|
||||
else
|
||||
MenuItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.open_spreadsheet(file)
|
||||
case File.extname(file.original_filename)
|
||||
when ".csv" then Roo::CSV.new(file.path,nil,:ignore)
|
||||
when ".xls" then Roo::Excel.new(file.path,nil,:ignore)
|
||||
when ".xlsx" then Roo::Excelx.new(file.path,nil,:ignore)
|
||||
else raise "Unknown File type: #{original_filename}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
class MenuCategory < ApplicationRecord
|
||||
# before_create :generate_menu_category_code
|
||||
|
||||
belongs_to :menu
|
||||
belongs_to :menu
|
||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||
has_many :menu_items
|
||||
@@ -83,4 +83,19 @@ class MenuCategory < ApplicationRecord
|
||||
# def generate_menu_category_code
|
||||
# self.code = SeedGenerator.generate_code(self.class.name, "C")
|
||||
# end
|
||||
|
||||
def self.to_csv
|
||||
|
||||
mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << mc_attributes
|
||||
|
||||
csv << mc_attributes
|
||||
MenuCategory.all.each do |user|
|
||||
puts user
|
||||
csv << mc_attributes.map{ |attr| user.send(attr)}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,9 +71,9 @@ class Order < ApplicationRecord
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
|
||||
|
||||
#Send order to queue one it done!
|
||||
if self.source != "quick_service"
|
||||
# if self.source != "quick_service"
|
||||
process_order_queue
|
||||
end
|
||||
# end
|
||||
|
||||
#send order to broadcast job
|
||||
send_order_broadcast(booking)
|
||||
@@ -135,7 +135,7 @@ class Order < ApplicationRecord
|
||||
|
||||
#loop to add all items to order
|
||||
ordered_list.each do |item|
|
||||
|
||||
|
||||
menu_item = MenuItem.search_by_item_code(item[:item_instance_code])
|
||||
|
||||
# For Product while item code not in menu item
|
||||
@@ -152,7 +152,7 @@ class Order < ApplicationRecord
|
||||
item[:sub_items].each do |si|
|
||||
# Retrive instance's Price
|
||||
set_item = MenuItem.search_by_item_code(si[:item_instance_code])
|
||||
set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity], "price"=>set_item[:price]})
|
||||
set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price], "options"=>si[:options]})
|
||||
end
|
||||
end
|
||||
set_order_items = set_order_items.to_json
|
||||
@@ -290,14 +290,14 @@ class Order < ApplicationRecord
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||
|
||||
|
||||
if print_status
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, self.table_id)
|
||||
oqs.process_order(order, self.table_id, self.source)
|
||||
end
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
@@ -313,7 +313,7 @@ class Order < ApplicationRecord
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, self.table_id)
|
||||
oqs.process_order(order, self.table_id, self.source)
|
||||
end
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
@@ -326,7 +326,7 @@ class Order < ApplicationRecord
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, self.table_id)
|
||||
oqs.process_order(order, self.table_id, self.source)
|
||||
end
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
@@ -339,17 +339,17 @@ class Order < ApplicationRecord
|
||||
#Process order items and send to order queue
|
||||
def self.pay_process_order_queue(id,table_id)
|
||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(id, table_id)
|
||||
else
|
||||
order = Order.find(id)
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id)
|
||||
end
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
end
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(id, table_id)
|
||||
else
|
||||
order = Order.find(id)
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id)
|
||||
end
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
end
|
||||
end
|
||||
|
||||
def check_cup_status(status)
|
||||
|
||||
@@ -5,7 +5,8 @@ class OrderItem < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
|
||||
#Associations
|
||||
belongs_to :order, autosave: true
|
||||
belongs_to :order, autosave: true
|
||||
# belongs_to :order, counter_cache: true
|
||||
|
||||
#Validation
|
||||
validates_presence_of :item_code, :item_name, :qty
|
||||
|
||||
@@ -13,7 +13,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
# validations
|
||||
validates_presence_of :station_name, :printer_name
|
||||
|
||||
def process_order (order, table_id)
|
||||
def process_order (order, table_id, order_source = nil)
|
||||
|
||||
oqs_stations = OrderQueueStation.active
|
||||
|
||||
@@ -55,7 +55,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
if oqs.auto_print
|
||||
if oqs.auto_print && order_source != "quick_service"
|
||||
if oqs_order_items.length > 0
|
||||
print_slip(oqs, order, oqs_order_items)
|
||||
is_auto_printed = true
|
||||
@@ -90,7 +90,81 @@ class OrderQueueStation < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
if oqs.auto_print
|
||||
if oqs.auto_print && order_source != "quick_service"
|
||||
if oqs_order_items.length > 0
|
||||
print_slip(oqs, order, oqs_order_items)
|
||||
is_auto_printed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end #end else
|
||||
end
|
||||
|
||||
def pay_process_order_queue (order_id, table_id)
|
||||
|
||||
oqs_stations = OrderQueueStation.active
|
||||
|
||||
order = Order.find(order_id)
|
||||
order_items = order.order_items
|
||||
|
||||
if table_id.to_i > 0
|
||||
# get dining
|
||||
dining = DiningFacility.find(table_id)
|
||||
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
|
||||
# ToDo per item per printer
|
||||
|
||||
oqs_by_zones.each do |oqpbz|
|
||||
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 (order_item.qty > 0)
|
||||
oqs_order_items.push(order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
else
|
||||
oqs_stations.each do |oqs|
|
||||
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 (order_item.qty > 0)
|
||||
oqs_order_items.push(order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if oqs.auto_print
|
||||
if oqs_order_items.length > 0
|
||||
print_slip(oqs, order, oqs_order_items)
|
||||
is_auto_printed = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class PrintSetting < ApplicationRecord
|
||||
# validations
|
||||
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
|
||||
validates_presence_of :name, :unique_code, :printer_name, :brand_name, :api_settings, :page_width, :page_height, :print_copies
|
||||
|
||||
def self.get_precision_delimiter
|
||||
PrintSetting.find_by_unique_code("ReceiptBillPdf")
|
||||
|
||||
@@ -24,6 +24,11 @@ class Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
|
||||
# Options from printer name
|
||||
def self.printer_options(printer_name)
|
||||
Cups.options_for(printer_name)
|
||||
end
|
||||
|
||||
def self.printers()
|
||||
Cups.show_destinations
|
||||
end
|
||||
|
||||
@@ -176,7 +176,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
@@ -202,14 +202,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
begin
|
||||
if count == 1
|
||||
filename = "/receipts/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file filename
|
||||
if printed_status != 'Paid'
|
||||
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
else
|
||||
filename = "/receipts/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
pdf.render_file filename
|
||||
if printed_status != 'Paid'
|
||||
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
@@ -262,11 +262,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
def print_receipt_pdf(filename,receipt_no,print_copies,printer_name)
|
||||
count = print_copies.to_i
|
||||
# if count == 0
|
||||
# self.print("public"+filename, printer_name)
|
||||
# self.print(filename, printer_name)
|
||||
# else
|
||||
begin
|
||||
if count == 1
|
||||
self.print("public"+filename, printer_name)
|
||||
self.print(filename, printer_name)
|
||||
else
|
||||
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
|
||||
self.print(filename, printer_name)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,8 @@ class SaleItem < ApplicationRecord
|
||||
sale_item.product_alt_name = item.product_alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.status = type
|
||||
if type == "foc" || type == "promotion" || type == "void"
|
||||
sale_item.remark = type
|
||||
if type == "foc" || type == "promotion" || type == "void" || type == "waste" || type == "spoile"
|
||||
sale_item.qty = qty * (-1)
|
||||
else
|
||||
sale_item.qty = qty
|
||||
|
||||
@@ -11,6 +11,7 @@ class SalePayment < ApplicationRecord
|
||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
self.payment_reference = remark
|
||||
amount_due = invoice.grand_total
|
||||
|
||||
#get all payment for this invoices
|
||||
@@ -48,8 +49,15 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = paypar_payment
|
||||
when "foc"
|
||||
payment_status = foc_payment
|
||||
<<<<<<< HEAD
|
||||
when "paymal"
|
||||
payment_status = paymal_payment
|
||||
=======
|
||||
when "JunctionPay"
|
||||
payment_status = junction_pay_payment
|
||||
when "alipay"
|
||||
payment_status = external_terminal_card_payment(:alipay)
|
||||
>>>>>>> 996392a041cb5f92a3b2985cbd0379210132d829
|
||||
else
|
||||
puts "it was something else"
|
||||
end
|
||||
@@ -87,7 +95,7 @@ class SalePayment < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
@@ -135,7 +143,7 @@ class SalePayment < ApplicationRecord
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -261,8 +269,7 @@ class SalePayment < ApplicationRecord
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -284,7 +291,7 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = false
|
||||
self.payment_method = method
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.card_payment_reference
|
||||
# self.payment_reference = self.card_payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
@@ -353,6 +360,7 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
def paymal_payment
|
||||
payment_status = false
|
||||
|
||||
@@ -378,6 +386,20 @@ class SalePayment < ApplicationRecord
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
=======
|
||||
def junction_pay_payment
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
self.payment_method = "JunctionPay"
|
||||
self.payment_amount = self.received_amount
|
||||
# self.payment_reference = self.payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
>>>>>>> 996392a041cb5f92a3b2985cbd0379210132d829
|
||||
return payment_status
|
||||
|
||||
end
|
||||
@@ -391,6 +413,7 @@ class SalePayment < ApplicationRecord
|
||||
sObj = Sale.find(self.sale_id)
|
||||
is_credit = 0
|
||||
is_foc = 0
|
||||
method_status = false
|
||||
sObj.sale_payments.each do |spay|
|
||||
all_received_amount += spay.payment_amount.to_f
|
||||
if spay.payment_method == "creditnote"
|
||||
@@ -399,8 +422,12 @@ class SalePayment < ApplicationRecord
|
||||
if spay.payment_method == "foc"
|
||||
is_foc = 1
|
||||
end
|
||||
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote"
|
||||
method_status = true
|
||||
end
|
||||
end
|
||||
if (self.sale.grand_total <= all_received_amount)
|
||||
|
||||
if (self.sale.grand_total <= all_received_amount) && method_status
|
||||
if is_credit == 0
|
||||
self.sale.payment_status = "paid"
|
||||
else
|
||||
@@ -440,11 +467,15 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
self.sale.save!
|
||||
table_update_status(sObj)
|
||||
|
||||
if check_foc
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
elsif method_status && paid_amount.to_f == 0
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
end
|
||||
end
|
||||
@@ -476,7 +507,7 @@ class SalePayment < ApplicationRecord
|
||||
bookings.each do |tablebooking|
|
||||
if tablebooking.booking_status != 'moved'
|
||||
if tablebooking.sale_id
|
||||
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
|
||||
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste'
|
||||
status = false
|
||||
sale_count += 1
|
||||
else
|
||||
@@ -540,7 +571,7 @@ class SalePayment < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status": false , "message": " Connection timeout" }
|
||||
@@ -585,7 +616,8 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
rebate_arr.push(data)
|
||||
end
|
||||
|
||||
Rails.logger.debug "Rebage Response"
|
||||
Rails.logger.debug rebate_arr.to_json
|
||||
total_amount = rebate_prices - payparcost - overall_dis
|
||||
|
||||
if credit == 1
|
||||
@@ -616,7 +648,7 @@ class SalePayment < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status": false , "message": "Connect To" }
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
class Shop < ApplicationRecord
|
||||
ShopDetail = Shop.find_by_id(1)
|
||||
|
||||
# Shop Image Uploader
|
||||
mount_uploader :logo, ShopImageUploader
|
||||
|
||||
has_many :display_images
|
||||
accepts_nested_attributes_for :display_images
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class StockJournal < ApplicationRecord
|
||||
balance = calculate_balance(balance, item.qty)
|
||||
|
||||
journal = StockJournal.new
|
||||
journal.item_code = item.product_code
|
||||
journal.item_code = item.item_instance_code
|
||||
journal.inventory_definition_id = inventory_definition.id
|
||||
journal.debit = item.qty
|
||||
journal.balance = balance
|
||||
@@ -36,12 +36,16 @@ class StockJournal < ApplicationRecord
|
||||
journal.save
|
||||
end
|
||||
|
||||
def self.inventory_balances(today,from,to)
|
||||
def self.inventory_balances(today,from,to,from_time,to_time)
|
||||
if !from.nil? && !to.nil?
|
||||
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")
|
||||
.where("stock_journals.created_at between '#{from}' and '#{to}'")
|
||||
.group("mii.item_instance_name")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'")
|
||||
else
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'")
|
||||
end
|
||||
query = query.group("mii.item_instance_name")
|
||||
.order("mii.item_instance_name ASC")
|
||||
else
|
||||
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||
|
||||
@@ -1,2 +1,17 @@
|
||||
class Survey < ApplicationRecord
|
||||
|
||||
def self.search(filter,from,to)
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
else
|
||||
keyword = "dining_name LIKE ?","%#{filter}%"
|
||||
end
|
||||
|
||||
if from.present? && to.present?
|
||||
survey = Survey.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ?", from,to)
|
||||
query = survey.where(keyword)
|
||||
else
|
||||
where("dining_name LIKE ?", "%#{filter}%")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class TaxProfile < ApplicationRecord
|
||||
default_scope { order('order_by asc') }
|
||||
# validations
|
||||
validates_presence_of :name, :rate
|
||||
validates_presence_of :name, :rate, :group_type
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user