Merge branch 'foodcourt' of gitlab.com:code2lab/SXRestaurant into foodcourt

This commit is contained in:
Myat Zin Wai Maw
2019-12-04 13:33:31 +06:30
20 changed files with 118 additions and 129 deletions

View File

@@ -1,7 +1,10 @@
class Api::ApiController < ActionController::API
include MultiTenancy
include TokenVerification
include ActionView::Rendering
include ActionController::MimeResponds
include ActionView::Rendering
before_action :core_allow
helper_method :current_token, :current_login_employee, :get_cashier
@@ -15,6 +18,12 @@ class Api::ApiController < ActionController::API
private
# ActionView::Rendering override render_to_body breaks render :json,
# resulting in an ActionView::MissingTemplate error.
def render_to_body(options)
_render_to_body_with_renderer(options) || super
end
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON

View File

@@ -62,8 +62,8 @@ class Api::OrdersController < Api::ApiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
@shop = Shop.find_by_shop_code(params[:shop_code])
current_shift = ShiftSale.current_shift(@shop.shop_code)
# @shop = Shop.find_by_shop_code(params[:shop_code])
current_shift = ShiftSale.current_shift
if current_shift.nil?
@status = false
@message = "No Current Open Shift for This Employee"

View File

@@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
#before_action :check_installation
protect_from_forgery with: :exception
@@ -17,5 +18,4 @@ class ApplicationController < ActionController::Base
flash[:warning] = exception.message
redirect_to root_path
end
end

View File

@@ -1,5 +1,8 @@
class BaseCrmController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
layout "CRM"
before_action :check_user

View File

@@ -1,5 +1,7 @@
class BaseInventoryController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
layout "inventory"
before_action :check_user

View File

@@ -1,5 +1,8 @@
class BaseOqsController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
layout "OQS"
before_action :check_user

View File

@@ -1,5 +1,7 @@
class BaseOrigamiController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
layout "origami"
before_action :check_user

View File

@@ -1,5 +1,7 @@
class BaseReportController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
layout "application"
before_action :check_user

View File

@@ -1,5 +1,7 @@
class BaseWaiterController < ActionController::Base
include LoginVerification, MultiTenancy
include MultiTenancy
include LoginVerification
layout "waiter"
before_action :check_user

View File

@@ -68,7 +68,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}'").order("bookings.created_at desc").uniq
.where("orders.source='app'").order("bookings.created_at desc").uniq
end
def completed
customer =Customer.find_by_customer_id(params[:customer_id])

View File

@@ -73,7 +73,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
# FOr Sale Audit
action_by = current_user.name
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
# 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)
# 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
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -124,7 +124,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
printer = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
unique_code="ReceiptBillPdf"
if !printer.empty?
@@ -139,13 +139,13 @@ class Foodcourt::VoidController < BaseFoodcourtController
end
end
# 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
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)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
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 = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -6,7 +6,7 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile
@webview = true
end
@shop = Shop.current_shop
@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")
@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
@webview = true
end
@shop = Shop.current_shop
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
@display_type = display_type.value
@@ -224,7 +225,7 @@ class Origami::AddordersController < BaseOrigamiController
def process_order_queue(order_id,table_id,order_source)
print_status = nil
cup_status = nil
@shop = Shop.current_shop
#Send to background job for processing
order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)

View File

@@ -5,8 +5,9 @@ class Origami::HomeController < BaseOrigamiController
def index
@webview = check_mobile
@tables = Table.unscope(:order).all.active.order('status desc')
@rooms = Room.unscope(:order).all.active.order('status desc')
@tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
@rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@@ -22,8 +23,9 @@ class Origami::HomeController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile
@tables = Table.unscope(:order).all.active.order('status desc')
@rooms = Room.unscope(:order).all.active.order('status desc')
@tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
@rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')

View File

@@ -176,14 +176,14 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone
# bookings = Booking.where("sale_id='#{sale_id}'")
bookings = Booking.find_by_sale_id(sale_id)
bookings = saleObj.bookings[0]
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings.dining_facility_id.to_i > 0
table = DiningFacility.find(bookings.dining_facility_id)
table = bookings.dining_facility
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)