shop code missing

This commit is contained in:
Nweni
2019-12-03 20:19:42 +06:30
parent 15361fe4e1
commit ca92a07919
5 changed files with 25 additions and 24 deletions

View File

@@ -73,7 +73,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
# FOr Sale Audit # FOr Sale Audit
action_by = current_user.name action_by = current_user.name
if access_code != "null" && current_user.role == "cashier" if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name action_by = Employee.find_by_emp_id_and_shop_code(access_code,Shop.current_shop.shop_code).name
end end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
@@ -116,7 +116,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
# get member information # get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer) member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -124,7 +124,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
current_balance = 0 current_balance = 0
end end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") printer = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -139,13 +139,13 @@ class Foodcourt::VoidController < BaseFoodcourtController
end end
end end
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -6,7 +6,7 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile if check_mobile
@webview = true @webview = true
end end
@shop = Shop.current_shop
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') @all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
@@ -19,6 +19,7 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile if check_mobile
@webview = true @webview = true
end end
@shop = Shop.current_shop
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
if !display_type.nil? && display_type.value.to_i ==2 if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value @display_type = display_type.value
@@ -224,7 +225,7 @@ class Origami::AddordersController < BaseOrigamiController
def process_order_queue(order_id,table_id,order_source) def process_order_queue(order_id,table_id,order_source)
print_status = nil print_status = nil
cup_status = nil cup_status = nil
@shop = Shop.current_shop
#Send to background job for processing #Send to background job for processing
order = Order.find(order_id) order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code) sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)

View File

@@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController
def index def index
@webview = check_mobile @webview = check_mobile
@shop = Shop.current_shop
@tables = Table.unscope(:order).all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@rooms = Room.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier") @complete = Sale.completed_sale("cashier")
@@ -21,7 +21,7 @@ class Origami::HomeController < BaseOrigamiController
# get printer info # get printer info
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile @webview = check_mobile
@shop = Shop.current_shop
@tables = Table.unscope(:order).all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@rooms = Room.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier") @complete = Sale.completed_sale("cashier")

View File

@@ -2057,13 +2057,13 @@ end
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}") query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}")
.group("bookings.booking_id") .group("bookings.booking_id")
end end
def self.completed_sale(type,shop_code) def self.completed_sale(type)
if type == "cashier" if type == "cashier"
type = "and orders.source = 'emenu' or orders.source = 'cashier'" type = "and orders.source = 'emenu' or orders.source = 'cashier'"
else else
type = "and orders.source = '#{type}'" type = "and orders.source = '#{type}'"
end end
query = Sale.where("sales.shop_code='#{shop_code}'") query = Sale.where("sales.shop_code='#{Shop.current_shop.shop_code}'")
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
.joins("join orders as orders on orders.order_id = sale_orders.order_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id")
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}")
@@ -2456,7 +2456,7 @@ private
def update_stock_journal def update_stock_journal
if self.sale_status == "void" && self.sale_status_before_last_save != "void" if self.sale_status == "void" && self.sale_status_before_last_save != "void"
self.sale_items.each do |item| self.sale_items.each do |item|
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code) found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
if found if found
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
unless stock.nil? unless stock.nil?
@@ -2469,7 +2469,7 @@ private
end end
elsif self.sale_status == "waste" || self.sale_status == "spoile" || (self.payment_status == "foc" && self.payment_status_was != "foc") elsif self.sale_status == "waste" || self.sale_status == "spoile" || (self.payment_status == "foc" && self.payment_status_was != "foc")
self.bookings.first.order_items.each do |item| self.bookings.first.order_items.each do |item|
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code) found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
if found if found
if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id) if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id)
if self.payment_status == "foc" && self.payment_status_was != "foc" if self.payment_status == "foc" && self.payment_status_was != "foc"

View File

@@ -1,11 +1,11 @@
application_path="#{File.expand_path("../..", __FILE__)}" # application_path="#{File.expand_path("../..", __FILE__)}"
directory application_path # directory application_path
#environment ENV.fetch("RAILS_ENV") { "production" } # #environment ENV.fetch("RAILS_ENV") { "production" }
environment "production" # environment "production"
pidfile "#{application_path}/tmp/puma/pid" # pidfile "#{application_path}/tmp/puma/pid"
state_path "#{application_path}/tmp/puma/state" # state_path "#{application_path}/tmp/puma/state"
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" # stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
port ENV.fetch("PORT") { 62158 } # port ENV.fetch("PORT") { 62158 }
workers 2 # workers 2
preload_app! # preload_app!
threads 1,1 # threads 1,1