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

@@ -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)