current shop

This commit is contained in:
Nweni
2019-12-03 13:43:26 +06:30
parent 417d64ecae
commit e0b912bfa0
18 changed files with 98 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
class BaseFoodcourtController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
layout "foodcourt"
before_action :check_user

View File

@@ -25,16 +25,16 @@ module LoginVerification
end
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
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
# Get current Cashiers
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
@@ -45,7 +45,7 @@ module LoginVerification
#check order reservation used
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
if !order_reserve.empty?
order_reserve.each do |order|
@@ -61,7 +61,7 @@ module LoginVerification
#check bank integration used
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
if !bank_integration.empty?
bank_integration.each do |bank|
@@ -86,7 +86,7 @@ module LoginVerification
if (token)
#@current_user = User.find_by(api_key: token)
#Rails.logger.debug "token - " + token.to_s
@user = Employee.authenticate_by_token(token,@current_shop)
@user = Employee.authenticate_by_token(token)
if @user
return true
#Maybe log - login?
@@ -94,21 +94,6 @@ module LoginVerification
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
redirect_to root_path
end

View File

@@ -136,7 +136,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
@order.new_booking = true
@order.waiters = 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.extra_time = extra_time

View File

@@ -102,7 +102,7 @@ class Foodcourt::DashboardController < BaseFoodcourtController
end
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_options = MenuItemOption.all.load
end

View File

@@ -17,14 +17,15 @@ class Foodcourt::FoodCourtController < ApplicationController
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# 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
@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')
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@cashier_type = "food_court"
#checked quick_service only
@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?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"

View File

@@ -19,7 +19,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#shop_detail = Shop.first
# rounding adjustment
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)
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
@@ -63,7 +63,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
# For Print
# 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"
print_settings = PrintSetting.all
if !print_settings.nil?
@@ -91,7 +91,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
customer= Customer.find(saleObj.customer_id)
# 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')
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)
# 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
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)
other_amount = SaleItem.calculate_other_charges(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_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
@@ -170,7 +170,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
end
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
@display_type = display_type.value
else
@@ -190,7 +190,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
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
if Sale.exists?(sale_id)
@@ -215,17 +215,17 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
@dining = ''
@other_payment = 0.0
@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?
@pdf_view = @lookup_pdf.value
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
#for changable on/off
@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?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
@@ -267,7 +267,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#end rounding adjustment
# rounding adjustment
if @shop.is_rounding_adj
if Shop.current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
@@ -293,7 +293,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# 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 =[]
@tax_arr =[]
accounts.each do |acc|
@@ -307,7 +307,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
@account_arr.push(sale_tax)
end
end
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
rebate = MembershipSetting.find_by_rebate(1)
# get member information
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
@@ -469,7 +469,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
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 = {
:status => true,
@@ -544,7 +544,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#shop detail
#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"
if !printer.empty?
@@ -559,7 +559,7 @@ class Foodcourt::PaymentsController < 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(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)
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 = {
:status => true,
:filepath => filename,
@@ -603,7 +603,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj
if Shop.current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#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"
unique_code = "ReceiptBillOrderPdf"
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"
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
@@ -651,7 +651,7 @@ class Foodcourt::PaymentsController < 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)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)

View File

@@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
@cashier_type = params[:type]
@shift = ShiftSale.current_open_shift(current_user)
#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
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
@@ -16,7 +16,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
def new
@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
def create
@@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
cashier_terminal.save
#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?
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?
# @close_cashier_print = close_cashier_print[0][1]
# 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"
if !close_cashier_pdf.empty?
@@ -92,13 +92,13 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
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
@sale_items = Sale.get_shift_sale_items(@shift.id)
other_charges = Sale.get_other_charges()
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
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_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card
@@ -129,7 +129,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
end
end
end
Employee.logout(@shop,session[:session_token])
Employee.logout(session[:session_token])
session[:session_token] = nil
end
@@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
if @shift
#get tax
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 = ShiftSale.get_by_shift_other_payment(@shift)

View File

@@ -18,8 +18,9 @@ class HomeController < ApplicationController
def index
# @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")
@roles = Employee.where("shop_code='#{@current_shop.shop_code}'").distinct.pluck(:role)
shop = Shop.current_shop
@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
# @roles = Lookup.collection_of("employee_roles")
@@ -52,7 +53,7 @@ class HomeController < ApplicationController
@login_form = LoginForm.new()
@login_form.emp_id = params[:login_form][:emp_id]
@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.is_active
@@ -169,7 +170,7 @@ class HomeController < ApplicationController
def destroy
# clear in employee session
Employee.logout(current_shop,session[:session_token])
Employee.logout(session[:session_token])
session[:session_token] = nil
# redirect_to root_path
render :json => {:status=> "Success", :url => root_path }.to_json

View File

@@ -131,7 +131,7 @@ class Origami::AddordersController < BaseOrigamiController
@order.new_booking = true
@order.waiters = 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.extra_time = extra_time

View File

@@ -17,14 +17,15 @@ class Origami::FoodCourtController < ApplicationController
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# 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
@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')
@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')
@cashier_type = "food_court"
#checked quick_service only
@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?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"

View File

@@ -32,7 +32,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
# 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
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
@@ -63,7 +63,7 @@ class Origami::PaymentsController < BaseOrigamiController
# customer= Customer.where('customer_id=' +.customer_id)
customer = Customer.find(sale_data.customer_id)
# rounding adjustment
if @shop.is_rounding_adj
if Shop.current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(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
@@ -76,14 +76,14 @@ class Origami::PaymentsController < BaseOrigamiController
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 )
# 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
# member_info = Customer.get_member_account(customer)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
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)
# find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
@@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController
#TODO :: KBZPAY ( QR )
# On/Off setting ( show or not qr )
# 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
qr = nil
@@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
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 = {
:filepath => filename,
@@ -144,7 +144,7 @@ class Origami::PaymentsController < BaseOrigamiController
#shop_detail = Shop.current_shop
# rounding adjustment
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)
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
@@ -198,7 +198,7 @@ class Origami::PaymentsController < BaseOrigamiController
# For Print
# 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"
print_settings = PrintSetting.all
if !print_settings.nil?
@@ -226,7 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id)
# 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')
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)
# 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(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(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_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
@@ -313,7 +313,7 @@ class Origami::PaymentsController < BaseOrigamiController
# end
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
@display_type = display_type.value
else
@@ -333,7 +333,7 @@ class Origami::PaymentsController < BaseOrigamiController
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
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
if Sale.exists?(sale_id)
@@ -358,17 +358,17 @@ class Origami::PaymentsController < BaseOrigamiController
@dining = ''
@other_payment = 0.0
@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?
@pdf_view = @lookup_pdf.value
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
#for changable on/off
@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?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
@@ -410,7 +410,7 @@ class Origami::PaymentsController < BaseOrigamiController
#end rounding adjustment
# rounding adjustment
if @shop.is_rounding_adj
if Shop.current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
@@ -436,7 +436,7 @@ class Origami::PaymentsController < BaseOrigamiController
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# 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 =[]
@tax_arr =[]
accounts.each do |acc|
@@ -450,7 +450,7 @@ class Origami::PaymentsController < BaseOrigamiController
@account_arr.push(sale_tax)
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
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
@@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController
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 = {
:status => true,
@@ -703,7 +703,7 @@ class Origami::PaymentsController < BaseOrigamiController
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(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)
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 = {
:status => true,
:filepath => filename,
@@ -747,7 +747,7 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj
if Shop.current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#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"
unique_code = "ReceiptBillOrderPdf"
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"
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
@@ -795,7 +795,7 @@ class Origami::PaymentsController < BaseOrigamiController
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)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)

View File

@@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController
# GET /settings/cashier_terminals
# GET /settings/cashier_terminals.json
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
# GET /settings/cashier_terminals/1

View File

@@ -3,6 +3,7 @@ class Employee < ApplicationRecord
has_many :commissioners
has_many :shit_sales
belongs_to :order_queue_station
validates_presence_of :name, :role
validates_presence_of :password, :on => [:create]
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] }
end
def self.login(shop,emp_id, password)
user = Employee.find_by_emp_id_and_shop_code(emp_id,shop.shop_code)
expiry_time = login_expiry_time(shop)
def self.login(emp_id, password)
user = Employee.find_by_emp_id(emp_id)
expiry_time = login_expiry_time
if (user)
#user.authenticate(password)
if (user.authenticate(password))
@@ -36,10 +37,10 @@ class Employee < ApplicationRecord
end
def self.authenticate_by_token(session_token,shop)
def self.authenticate_by_token(session_token)
if (session_token)
user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
expiry_time = login_expiry_time(shop)
user = Employee.find_by_token_session(session_token)
expiry_time = login_expiry_time
if user && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
@@ -54,9 +55,9 @@ class Employee < ApplicationRecord
return false
end
def self.logout(shop,session_token)
def self.logout(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
user.token_session = nil
@@ -72,9 +73,9 @@ class Employee < ApplicationRecord
retry
end
def self.login_expiry_time(shop)
def self.login_expiry_time
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?
login_expiry.each do |exp_time|
if exp_time[0].downcase == "login"

View File

@@ -25,8 +25,8 @@ class InventoryDefinition < ApplicationRecord
def self.find_product_in_inventory(item)
if product = InventoryDefinition.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_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.current_shop.shop_code)
return true, product
end
end

View File

@@ -1585,7 +1585,6 @@ end
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")
.completed
.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")
.joins(:sale_payments)
.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
if payment_method == 'card'

View File

@@ -20,11 +20,11 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.current_shop.shop_code.nil?
# if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
# else
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
# end
end
# def cache_dir

View File

@@ -68,7 +68,7 @@
<div class="row">
<div class="col-lg-12_ col-md-12 col-sm-12 col-xs-12 text-center">
<div class="current-shop-name">
<span><%= @current_shop.name %></span>
<span><%= Shop.current_shop.name rescue "" %></span>
</div>
</div>
</div>

BIN
dump.rdb

Binary file not shown.