current shop
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class BaseFoodcourtController < ActionController::Base
|
class BaseFoodcourtController < ActionController::Base
|
||||||
include LoginVerification
|
include LoginVerification, MultiTenancy
|
||||||
layout "foodcourt"
|
layout "foodcourt"
|
||||||
|
|
||||||
before_action :check_user
|
before_action :check_user
|
||||||
|
|||||||
@@ -25,16 +25,16 @@ module LoginVerification
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_login_employee
|
def current_login_employee
|
||||||
@employee = Employee.find_by_token_session_and_shop_code(session[:session_token],@current_shop.shop_code)
|
@employee = Employee.find_by_token_session(session[:session_token])
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
@current_user ||= Employee.find_by_token_session_and_shop_code(session[:session_token],@current_shop.shop_code) if session[:session_token]
|
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get current Cashiers
|
# Get current Cashiers
|
||||||
def get_cashier
|
def get_cashier
|
||||||
@cashier = Employee.where("shop_code='#{@current_shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ module LoginVerification
|
|||||||
|
|
||||||
#check order reservation used
|
#check order reservation used
|
||||||
def order_reservation
|
def order_reservation
|
||||||
order_reserve = Lookup.where("shop_code='#{@current_shop.shop_code}'").collection_of('order_reservation')
|
order_reserve = Lookup.collection_of('order_reservation')
|
||||||
status = false
|
status = false
|
||||||
if !order_reserve.empty?
|
if !order_reserve.empty?
|
||||||
order_reserve.each do |order|
|
order_reserve.each do |order|
|
||||||
@@ -61,7 +61,7 @@ module LoginVerification
|
|||||||
|
|
||||||
#check bank integration used
|
#check bank integration used
|
||||||
def bank_integration
|
def bank_integration
|
||||||
bank_integration = Lookup.where("shop_code='#{@current_shop.shop_code}'").collection_of('bank_integration')
|
bank_integration = Lookup.collection_of('bank_integration')
|
||||||
status = false
|
status = false
|
||||||
if !bank_integration.empty?
|
if !bank_integration.empty?
|
||||||
bank_integration.each do |bank|
|
bank_integration.each do |bank|
|
||||||
@@ -86,7 +86,7 @@ module LoginVerification
|
|||||||
if (token)
|
if (token)
|
||||||
#@current_user = User.find_by(api_key: token)
|
#@current_user = User.find_by(api_key: token)
|
||||||
#Rails.logger.debug "token - " + token.to_s
|
#Rails.logger.debug "token - " + token.to_s
|
||||||
@user = Employee.authenticate_by_token(token,@current_shop)
|
@user = Employee.authenticate_by_token(token)
|
||||||
if @user
|
if @user
|
||||||
return true
|
return true
|
||||||
#Maybe log - login?
|
#Maybe log - login?
|
||||||
@@ -94,21 +94,6 @@ module LoginVerification
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_session_token
|
|
||||||
shop_code = 262
|
|
||||||
if (shop_code)
|
|
||||||
#@current_user = User.find_by(api_key: token)
|
|
||||||
#Rails.logger.debug "token - " + token.to_s
|
|
||||||
@current_shop = Shop.find_by_shop_code(shop_code)
|
|
||||||
if @current_shop
|
|
||||||
return true
|
|
||||||
#Maybe log - login?
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@current_shop = Shop.first
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_unauthorized
|
def render_unauthorized
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
|||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
@order.waiters = current_login_employee.name
|
@order.waiters = current_login_employee.name
|
||||||
@order.employee_name = current_login_employee.name
|
@order.employee_name = current_login_employee.name
|
||||||
@order.shop_code =@shop.shop_code
|
@order.shop_code = Shop.current_shop.shop_code
|
||||||
@order.is_extra_time = is_extra_time
|
@order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = extra_time
|
@order.extra_time = extra_time
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class Foodcourt::DashboardController < BaseFoodcourtController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_all_menu
|
def get_all_menu
|
||||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'")
|
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all
|
||||||
@item_attributes = MenuItemAttribute.all.load
|
@item_attributes = MenuItemAttribute.all.load
|
||||||
@item_options = MenuItemOption.all.load
|
@item_options = MenuItemOption.all.load
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,14 +17,15 @@ class Foodcourt::FoodCourtController < ApplicationController
|
|||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
shop = Shop.current_shop
|
||||||
|
@zone = Zone.all.where("is_active= true")
|
||||||
@customer = Customer.all
|
@customer = Customer.all
|
||||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
@tables = Table.all.active.order('status desc')
|
||||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
@rooms = Room.all.active.order('status desc')
|
||||||
@cashier_type = "food_court"
|
@cashier_type = "food_court"
|
||||||
#checked quick_service only
|
#checked quick_service only
|
||||||
@quick_service_only = true
|
@quick_service_only = true
|
||||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||||
if !lookup_dine_in.empty?
|
if !lookup_dine_in.empty?
|
||||||
lookup_dine_in.each do |dine_in|
|
lookup_dine_in.each do |dine_in|
|
||||||
if dine_in[0].downcase == "dineincashier"
|
if dine_in[0].downcase == "dineincashier"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
#shop_detail = Shop.first
|
#shop_detail = Shop.first
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if !path.include? ("credit_payment")
|
if !path.include? ("credit_payment")
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||||
rounding_adj = new_total - saleObj.grand_total
|
rounding_adj = new_total - saleObj.grand_total
|
||||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||||
@@ -63,7 +63,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
|
|
||||||
# For Print
|
# For Print
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
print_settings = PrintSetting.all
|
print_settings = PrintSetting.all
|
||||||
if !print_settings.nil?
|
if !print_settings.nil?
|
||||||
@@ -91,7 +91,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.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)
|
||||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||||
|
|
||||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||||
@@ -146,14 +146,14 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||||
|
|
||||||
# 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(unique_code)
|
||||||
# Calculate Food and Beverage Total
|
# Calculate Food and Beverage Total
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
other_amount = SaleItem.calculate_other_charges(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_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||||
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
@@ -170,7 +170,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
display_type = Lookup.find_by_lookup_type("display_type")
|
||||||
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
|
||||||
else
|
else
|
||||||
@@ -190,7 +190,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
@membership_rebate_balance=0
|
@membership_rebate_balance=0
|
||||||
|
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
@@ -215,17 +215,17 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
@dining = ''
|
@dining = ''
|
||||||
@other_payment = 0.0
|
@other_payment = 0.0
|
||||||
@pdf_view = nil
|
@pdf_view = nil
|
||||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||||
if !@lookup_pdf.nil?
|
if !@lookup_pdf.nil?
|
||||||
@pdf_view = @lookup_pdf.value
|
@pdf_view = @lookup_pdf.value
|
||||||
end
|
end
|
||||||
|
|
||||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,Shop.current_shop)
|
||||||
@kbz_pay_amount += amount.to_f
|
@kbz_pay_amount += amount.to_f
|
||||||
|
|
||||||
#for changable on/off
|
#for changable on/off
|
||||||
@changable_tax = true
|
@changable_tax = true
|
||||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||||
if !lookup_changable_tax.empty?
|
if !lookup_changable_tax.empty?
|
||||||
lookup_changable_tax.each do |changable_tax|
|
lookup_changable_tax.each do |changable_tax|
|
||||||
if changable_tax[0].downcase == "change"
|
if changable_tax[0].downcase == "change"
|
||||||
@@ -267,7 +267,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
b = saleObj.grand_total / 25 # Division
|
b = saleObj.grand_total / 25 # Division
|
||||||
#not calculate rounding if modulus is 0 and division is even
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
@@ -293,7 +293,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(@sale_data.customer_id)
|
@customer = Customer.find(@sale_data.customer_id)
|
||||||
# accounts = @customer.tax_profiles
|
# accounts = @customer.tax_profiles
|
||||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||||
@account_arr =[]
|
@account_arr =[]
|
||||||
@tax_arr =[]
|
@tax_arr =[]
|
||||||
accounts.each do |acc|
|
accounts.each do |acc|
|
||||||
@@ -307,7 +307,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
@account_arr.push(sale_tax)
|
@account_arr.push(sale_tax)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
# get member information
|
# get member information
|
||||||
if @customer.membership_id != nil && rebate
|
if @customer.membership_id != nil && rebate
|
||||||
response = Customer.get_member_account(@customer)
|
response = Customer.get_member_account(@customer)
|
||||||
@@ -469,7 +469,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
:status => true,
|
:status => true,
|
||||||
@@ -544,7 +544,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
|
|
||||||
#shop detail
|
#shop detail
|
||||||
#shop_detail = Shop.first
|
#shop_detail = Shop.first
|
||||||
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?
|
||||||
@@ -559,7 +559,7 @@ class Foodcourt::PaymentsController < 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(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
@@ -568,7 +568,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
|
|
||||||
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,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:status => true,
|
:status => true,
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
@@ -603,7 +603,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
|
|
||||||
saleObj = Sale.find(params[:sale_id])
|
saleObj = Sale.find(params[:sale_id])
|
||||||
|
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
b = saleObj.grand_total / 25 # Division
|
b = saleObj.grand_total / 25 # Division
|
||||||
#not calculate rounding if modulus is 0 and division is even
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
@@ -626,9 +626,9 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
|||||||
if cashier_type.strip.downcase == "doemal_order"
|
if cashier_type.strip.downcase == "doemal_order"
|
||||||
unique_code = "ReceiptBillOrderPdf"
|
unique_code = "ReceiptBillOrderPdf"
|
||||||
else
|
else
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||||
if !print_settings.nil?
|
if !print_settings.nil?
|
||||||
print_settings.each do |setting|
|
print_settings.each do |setting|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
if setting.unique_code == 'ReceiptBillPdf'
|
||||||
@@ -651,7 +651,7 @@ class Foodcourt::PaymentsController < 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)
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
@shift = ShiftSale.current_open_shift(current_user)
|
@shift = ShiftSale.current_open_shift(current_user)
|
||||||
#for bank integration
|
#for bank integration
|
||||||
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
|
bank_integration = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('bank_integration')
|
||||||
@bank_integration = 0
|
@bank_integration = 0
|
||||||
if !bank_integration[0].nil?
|
if !bank_integration[0].nil?
|
||||||
@bank_integration = bank_integration[0][1]
|
@bank_integration = bank_integration[0][1]
|
||||||
@@ -16,7 +16,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@float = Lookup.where('lookup_type=?','float_value')
|
@float = Lookup.where('lookup_type=?','float_value')
|
||||||
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
|
@terminal = CashierTerminal.available.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
cashier_terminal.save
|
cashier_terminal.save
|
||||||
|
|
||||||
#add shift_sale_id to card_settle_trans
|
#add shift_sale_id to card_settle_trans
|
||||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
|
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',Shop.current_shop.shop_code)
|
||||||
if !bank_integration.nil?
|
if !bank_integration.nil?
|
||||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
# if !close_cashier_print[0].nil?
|
# if !close_cashier_print[0].nil?
|
||||||
# @close_cashier_print = close_cashier_print[0][1]
|
# @close_cashier_print = close_cashier_print[0][1]
|
||||||
# end
|
# end
|
||||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
close_cashier_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings")
|
||||||
unique_code = "CloseCashierPdf"
|
unique_code = "CloseCashierPdf"
|
||||||
|
|
||||||
if !close_cashier_pdf.empty?
|
if !close_cashier_pdf.empty?
|
||||||
@@ -92,13 +92,13 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
#get tax
|
#get tax
|
||||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||||
sale_items = ''
|
sale_items = ''
|
||||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
@lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code)
|
||||||
if @lookup.to_i == 1
|
if @lookup.to_i == 1
|
||||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||||
other_charges = Sale.get_other_charges()
|
other_charges = Sale.get_other_charges()
|
||||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||||
end
|
end
|
||||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{Shop.current_shop.shop_code}'")
|
||||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||||
#other payment details for mpu or visa like card
|
#other payment details for mpu or visa like card
|
||||||
@@ -129,7 +129,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Employee.logout(@shop,session[:session_token])
|
Employee.logout(session[:session_token])
|
||||||
session[:session_token] = nil
|
session[:session_token] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
|||||||
if @shift
|
if @shift
|
||||||
#get tax
|
#get tax
|
||||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{Shop.current_shop.shop_code}'")
|
||||||
#other payment details for mpu or visa like card
|
#other payment details for mpu or visa like card
|
||||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ class HomeController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||||
@employees = Employee.all.where("shop_code='#{@current_shop.shop_code}' and is_active = true").order("name asc")
|
shop = Shop.current_shop
|
||||||
@roles = Employee.where("shop_code='#{@current_shop.shop_code}'").distinct.pluck(:role)
|
@employees = Employee.all.where("shop_code='#{shop.shop_code}' and is_active = true").order("name asc")
|
||||||
|
@roles = Employee.where("shop_code='#{shop.shop_code}'").distinct.pluck(:role)
|
||||||
|
|
||||||
# byebug
|
# byebug
|
||||||
# @roles = Lookup.collection_of("employee_roles")
|
# @roles = Lookup.collection_of("employee_roles")
|
||||||
@@ -52,7 +53,7 @@ class HomeController < ApplicationController
|
|||||||
@login_form = LoginForm.new()
|
@login_form = LoginForm.new()
|
||||||
@login_form.emp_id = params[:login_form][:emp_id]
|
@login_form.emp_id = params[:login_form][:emp_id]
|
||||||
@login_form.password = params[:login_form][:password]
|
@login_form.password = params[:login_form][:password]
|
||||||
@employee = Employee.login(current_shop,@login_form.emp_id, @login_form.password)
|
@employee = Employee.login(@login_form.emp_id, @login_form.password)
|
||||||
|
|
||||||
if @employee != nil
|
if @employee != nil
|
||||||
if @employee.is_active
|
if @employee.is_active
|
||||||
@@ -169,7 +170,7 @@ class HomeController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
# clear in employee session
|
# clear in employee session
|
||||||
Employee.logout(current_shop,session[:session_token])
|
Employee.logout(session[:session_token])
|
||||||
session[:session_token] = nil
|
session[:session_token] = nil
|
||||||
# redirect_to root_path
|
# redirect_to root_path
|
||||||
render :json => {:status=> "Success", :url => root_path }.to_json
|
render :json => {:status=> "Success", :url => root_path }.to_json
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
@order.waiters = current_login_employee.name
|
@order.waiters = current_login_employee.name
|
||||||
@order.employee_name = current_login_employee.name
|
@order.employee_name = current_login_employee.name
|
||||||
@order.shop_code =@shop.shop_code
|
@order.shop_code = Shop.current_shop.shop_code
|
||||||
@order.is_extra_time = is_extra_time
|
@order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = extra_time
|
@order.extra_time = extra_time
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,15 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
shop = Shop.current_shop
|
||||||
|
@zone = Zone.all.where("shop_code='#{shop.shop_code}' and is_active= true")
|
||||||
@customer = Customer.all
|
@customer = Customer.all
|
||||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
@tables = Table.all.active.where("shop_code='#{shop.shop_code}'").order('status desc')
|
||||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
@rooms = Room.all.active.where("shop_code='#{shop.shop_code}'").order('status desc')
|
||||||
@cashier_type = "food_court"
|
@cashier_type = "food_court"
|
||||||
#checked quick_service only
|
#checked quick_service only
|
||||||
@quick_service_only = true
|
@quick_service_only = true
|
||||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
lookup_dine_in = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('dinein_cashier')
|
||||||
if !lookup_dine_in.empty?
|
if !lookup_dine_in.empty?
|
||||||
lookup_dine_in.each do |dine_in|
|
lookup_dine_in.each do |dine_in|
|
||||||
if dine_in[0].downcase == "dineincashier"
|
if dine_in[0].downcase == "dineincashier"
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
# Print for First Bill to Customer
|
# Print for First Bill to Customer
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
print_settings = PrintSetting.all
|
print_settings = PrintSetting.all
|
||||||
@@ -63,7 +63,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
# customer= Customer.where('customer_id=' +.customer_id)
|
||||||
customer = Customer.find(sale_data.customer_id)
|
customer = Customer.find(sale_data.customer_id)
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||||
rounding_adj = new_total - sale_data.grand_total
|
rounding_adj = new_total - sale_data.grand_total
|
||||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||||
@@ -76,14 +76,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
||||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code)
|
||||||
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)
|
||||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
current_balance = 0
|
current_balance = 0
|
||||||
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)
|
||||||
|
|
||||||
# find order id by sale id
|
# find order id by sale id
|
||||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||||
@@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#TODO :: KBZPAY ( QR )
|
#TODO :: KBZPAY ( QR )
|
||||||
# On/Off setting ( show or not qr )
|
# On/Off setting ( show or not qr )
|
||||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last
|
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => Shop.current_shop.shop_code).last
|
||||||
|
|
||||||
status = false
|
status = false
|
||||||
qr = nil
|
qr = nil
|
||||||
@@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, Shop.current_shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
@@ -144,7 +144,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#shop_detail = Shop.current_shop
|
#shop_detail = Shop.current_shop
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if !path.include? ("credit_payment")
|
if !path.include? ("credit_payment")
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||||
rounding_adj = new_total - saleObj.grand_total
|
rounding_adj = new_total - saleObj.grand_total
|
||||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||||
@@ -198,7 +198,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
# For Print
|
# For Print
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
print_settings = PrintSetting.all
|
print_settings = PrintSetting.all
|
||||||
if !print_settings.nil?
|
if !print_settings.nil?
|
||||||
@@ -226,7 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.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_and_shop_code(1,Shop.current_shop.shop_code)
|
||||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||||
|
|
||||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||||
@@ -281,14 +281,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||||
|
|
||||||
# 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(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
other_amount = SaleItem.calculate_other_charges(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_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||||
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
@@ -313,7 +313,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
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.current_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
|
||||||
else
|
else
|
||||||
@@ -333,7 +333,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,Shop.current_shop.shop_code)
|
||||||
@membership_rebate_balance=0
|
@membership_rebate_balance=0
|
||||||
|
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
@@ -358,17 +358,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@dining = ''
|
@dining = ''
|
||||||
@other_payment = 0.0
|
@other_payment = 0.0
|
||||||
@pdf_view = nil
|
@pdf_view = nil
|
||||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",Shop.current_shop.shop_code)
|
||||||
if !@lookup_pdf.nil?
|
if !@lookup_pdf.nil?
|
||||||
@pdf_view = @lookup_pdf.value
|
@pdf_view = @lookup_pdf.value
|
||||||
end
|
end
|
||||||
|
|
||||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,Shop.current_shop)
|
||||||
@kbz_pay_amount += amount.to_f
|
@kbz_pay_amount += amount.to_f
|
||||||
|
|
||||||
#for changable on/off
|
#for changable on/off
|
||||||
@changable_tax = true
|
@changable_tax = true
|
||||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
lookup_changable_tax = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('changable_tax')
|
||||||
if !lookup_changable_tax.empty?
|
if !lookup_changable_tax.empty?
|
||||||
lookup_changable_tax.each do |changable_tax|
|
lookup_changable_tax.each do |changable_tax|
|
||||||
if changable_tax[0].downcase == "change"
|
if changable_tax[0].downcase == "change"
|
||||||
@@ -410,7 +410,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
# rounding adjustment
|
# rounding adjustment
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
b = saleObj.grand_total / 25 # Division
|
b = saleObj.grand_total / 25 # Division
|
||||||
#not calculate rounding if modulus is 0 and division is even
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
@@ -436,7 +436,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(@sale_data.customer_id)
|
@customer = Customer.find(@sale_data.customer_id)
|
||||||
# accounts = @customer.tax_profiles
|
# accounts = @customer.tax_profiles
|
||||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
accounts = TaxProfile.where("group_type = ? and shop_code='#{Shop.current_shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||||
@account_arr =[]
|
@account_arr =[]
|
||||||
@tax_arr =[]
|
@tax_arr =[]
|
||||||
accounts.each do |acc|
|
accounts.each do |acc|
|
||||||
@@ -450,7 +450,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@account_arr.push(sale_tax)
|
@account_arr.push(sale_tax)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code)
|
||||||
# get member information
|
# get member information
|
||||||
if @customer.membership_id != nil && rebate
|
if @customer.membership_id != nil && rebate
|
||||||
response = Customer.get_member_account(@customer)
|
response = Customer.get_member_account(@customer)
|
||||||
@@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
:status => true,
|
:status => true,
|
||||||
@@ -703,7 +703,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
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(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
@@ -712,7 +712,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
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,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:status => true,
|
:status => true,
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
@@ -747,7 +747,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
saleObj = Sale.find(params[:sale_id])
|
saleObj = Sale.find(params[:sale_id])
|
||||||
|
|
||||||
if @shop.is_rounding_adj
|
if Shop.current_shop.is_rounding_adj
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
b = saleObj.grand_total / 25 # Division
|
b = saleObj.grand_total / 25 # Division
|
||||||
#not calculate rounding if modulus is 0 and division is even
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
@@ -770,9 +770,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
if cashier_type.strip.downcase == "doemal_order"
|
if cashier_type.strip.downcase == "doemal_order"
|
||||||
unique_code = "ReceiptBillOrderPdf"
|
unique_code = "ReceiptBillOrderPdf"
|
||||||
else
|
else
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||||
if !print_settings.nil?
|
if !print_settings.nil?
|
||||||
print_settings.each do |setting|
|
print_settings.each do |setting|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
if setting.unique_code == 'ReceiptBillPdf'
|
||||||
@@ -795,7 +795,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
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)
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController
|
|||||||
# GET /settings/cashier_terminals
|
# GET /settings/cashier_terminals
|
||||||
# GET /settings/cashier_terminals.json
|
# GET /settings/cashier_terminals.json
|
||||||
def index
|
def index
|
||||||
@settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code)
|
@settings_cashier_terminals = CashierTerminal.where("shop_code=?",Shop.current_shop.shop_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /settings/cashier_terminals/1
|
# GET /settings/cashier_terminals/1
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ class Employee < ApplicationRecord
|
|||||||
has_many :commissioners
|
has_many :commissioners
|
||||||
has_many :shit_sales
|
has_many :shit_sales
|
||||||
belongs_to :order_queue_station
|
belongs_to :order_queue_station
|
||||||
|
|
||||||
validates_presence_of :name, :role
|
validates_presence_of :name, :role
|
||||||
validates_presence_of :password, :on => [:create]
|
validates_presence_of :password, :on => [:create]
|
||||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||||
@@ -19,9 +20,9 @@ class Employee < ApplicationRecord
|
|||||||
Employee.select("id, name").map { |e| [e.name, e.id] }
|
Employee.select("id, name").map { |e| [e.name, e.id] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.login(shop,emp_id, password)
|
def self.login(emp_id, password)
|
||||||
user = Employee.find_by_emp_id_and_shop_code(emp_id,shop.shop_code)
|
user = Employee.find_by_emp_id(emp_id)
|
||||||
expiry_time = login_expiry_time(shop)
|
expiry_time = login_expiry_time
|
||||||
if (user)
|
if (user)
|
||||||
#user.authenticate(password)
|
#user.authenticate(password)
|
||||||
if (user.authenticate(password))
|
if (user.authenticate(password))
|
||||||
@@ -36,10 +37,10 @@ class Employee < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.authenticate_by_token(session_token,shop)
|
def self.authenticate_by_token(session_token)
|
||||||
if (session_token)
|
if (session_token)
|
||||||
user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
|
user = Employee.find_by_token_session(session_token)
|
||||||
expiry_time = login_expiry_time(shop)
|
expiry_time = login_expiry_time
|
||||||
|
|
||||||
if user && user.session_expiry.utc > DateTime.now.utc
|
if user && user.session_expiry.utc > DateTime.now.utc
|
||||||
#Extend the login time each time authenticatation take place
|
#Extend the login time each time authenticatation take place
|
||||||
@@ -54,9 +55,9 @@ class Employee < ApplicationRecord
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.logout(shop,session_token)
|
def self.logout(session_token)
|
||||||
if (session_token)
|
if (session_token)
|
||||||
user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
|
user = Employee.find_by_token_session(session_token)
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user.token_session = nil
|
user.token_session = nil
|
||||||
@@ -72,9 +73,9 @@ class Employee < ApplicationRecord
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.login_expiry_time(shop)
|
def self.login_expiry_time
|
||||||
expiry_time = 30
|
expiry_time = 30
|
||||||
login_expiry = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('expiry_time')
|
login_expiry = Lookup.collection_of('expiry_time')
|
||||||
if !login_expiry.empty?
|
if !login_expiry.empty?
|
||||||
login_expiry.each do |exp_time|
|
login_expiry.each do |exp_time|
|
||||||
if exp_time[0].downcase == "login"
|
if exp_time[0].downcase == "login"
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class InventoryDefinition < ApplicationRecord
|
|||||||
|
|
||||||
|
|
||||||
def self.find_product_in_inventory(item)
|
def self.find_product_in_inventory(item)
|
||||||
if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code)
|
||||||
if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code)
|
||||||
return true, product
|
return true, product
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1585,7 +1585,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
def self.top_bottom_products(current_user,from,to,type,current_shop)
|
def self.top_bottom_products(current_user,from,to,type,current_shop)
|
||||||
puts @current_shop
|
|
||||||
query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
|
query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
|
||||||
.completed
|
.completed
|
||||||
.where("qty > 0 AND price > 0 AND shop_code='#{current_shop.shop_code}'")
|
.where("qty > 0 AND price > 0 AND shop_code='#{current_shop.shop_code}'")
|
||||||
@@ -1768,7 +1767,6 @@ end
|
|||||||
query = Sale.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount")
|
query = Sale.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount")
|
||||||
.joins(:sale_payments)
|
.joins(:sale_payments)
|
||||||
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
|
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
|
||||||
.where("sales.shop_code='#{shop.shop_code}'")
|
|
||||||
.completed
|
.completed
|
||||||
|
|
||||||
if payment_method == 'card'
|
if payment_method == 'card'
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def filename
|
def filename
|
||||||
if Shop.current_shop.shop_code.nil?
|
# if Shop.current_shop.shop_code.nil?
|
||||||
"#{original_filename}" if original_filename.present?
|
"#{original_filename}" if original_filename.present?
|
||||||
else
|
# else
|
||||||
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
|
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
# def cache_dir
|
# def cache_dir
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12_ col-md-12 col-sm-12 col-xs-12 text-center">
|
<div class="col-lg-12_ col-md-12 col-sm-12 col-xs-12 text-center">
|
||||||
<div class="current-shop-name">
|
<div class="current-shop-name">
|
||||||
<span><%= @current_shop.name %></span>
|
<span><%= Shop.current_shop.name rescue "" %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user