This commit is contained in:
yarzar_code
2020-01-12 20:07:28 +06:30
parent 314cc507a3
commit dff2c69627
89 changed files with 492 additions and 469 deletions

View File

@@ -1,6 +1,5 @@
class Api::AuthenticateController < Api::ApiController class Api::AuthenticateController < Api::ApiController
skip_before_action :authenticate skip_before_action :authenticate
# before_action :find_shop
def create def create
emp_id = params[:emp_id] emp_id = params[:emp_id]
@@ -67,8 +66,5 @@ class Api::AuthenticateController < Api::ApiController
params.permit(:emp_id, :password, :session_token) params.permit(:emp_id, :password, :session_token)
end end
private
def find_shop
@shop = Shop.find_by_shop_code(params[:shop_code])
end
end end

View File

@@ -18,7 +18,7 @@ module LoginVerification
def current_shop def current_shop
begin begin
return @shop return Shop.current_shop
rescue rescue
return nil return nil
end end
@@ -40,7 +40,7 @@ module LoginVerification
#Shop Name in Navbor #Shop Name in Navbor
def shop_detail def shop_detail
@shop = current_shop @shop ||= current_shop
end end
#check order reservation used #check order reservation used

View File

@@ -12,8 +12,7 @@ module MultiTenancy
shop_code = request.subdomain.partition('-').last shop_code = request.subdomain.partition('-').last
@shop = Shop.find_by(shop_code: shop_code) @shop = Shop.find_by(shop_code: shop_code)
else else
# @shop = Shop.first @shop = Shop.first
@shop = Shop.find_by(shop_code: '262')
end end
set_current_tenant(@shop) set_current_tenant(@shop)
end end

View File

@@ -9,15 +9,25 @@ class Crm::CustomersController < BaseCrmController
filter = params[:filter] filter = params[:filter]
filter_card_no = params[:filter_card_no] filter_card_no = params[:filter_card_no]
type = params[:type] type = params[:type]
puts "type :"
puts type
puts "filter :"
puts filter
puts "filter card no"
puts filter_card_no
@customer_update_phone_email_membertype =false @customer_update_phone_email_membertype =false
if filter_card_no=="" if filter_card_no==""
@crm_customers = Customer.all @crm_customers = Customer.all
puts "Filter card no"
elsif !filter_card_no.nil? elsif !filter_card_no.nil?
@crm_customers=Customer.where("card_no=?",filter_card_no) @crm_customers=Customer.where("card_no=?",filter_card_no)
puts "Null filter card no"
elsif filter.nil? || filter_card_no=="" elsif filter.nil? || filter_card_no==""
@crm_customers = Customer.all @crm_customers = Customer.all
puts "filter null filter card no nulll"
else else
@crm_customers = Customer.search(filter) @crm_customers = Customer.search(filter)
puts "else"
# paymal_customer = Customer.search_paypar_account_no(filter) # paymal_customer = Customer.search_paypar_account_no(filter)
# search account no from paypar # search account no from paypar
if type == "card" if type == "card"

View File

@@ -22,7 +22,7 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
end end
@member_discount = MembershipSetting.find_by_discount(1) @member_discount = MembershipSetting.find_by_discount(1)
@accounts = Account.where("shop_code='#{@shop.shop_code}'") @accounts = Account.all
end end
#discount page show from origami index with selected order #discount page show from origami index with selected order

View File

@@ -74,7 +74,7 @@ class Foodcourt::FoodCourtController < ApplicationController
end end
def get_all_product() def get_all_product()
@product = Product.where("shop_code='#{@shop.shop_code}'") @product = Product.all
end end
# render json for http status code # render json for http status code

View File

@@ -4,13 +4,13 @@ class Foodcourt::HomeController < BaseFoodcourtController
def index def index
@webview = check_mobile @webview = check_mobile
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier") @complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count @occupied_table = DiningFacility.where("status='occupied'").count
@shift = ShiftSale.current_open_shift(current_user) @shift = ShiftSale.current_open_shift(current_user)
end end
@@ -19,10 +19,10 @@ class Foodcourt::HomeController < BaseFoodcourtController
# get printer info # get printer info
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile @webview = check_mobile
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier") @complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@shift = ShiftSale.current_open_shift(current_user) @shift = ShiftSale.current_open_shift(current_user)
@@ -30,8 +30,8 @@ class Foodcourt::HomeController < BaseFoodcourtController
@status_sale = "" @status_sale = ""
@sale_array = Array.new @sale_array = Array.new
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code) @membership = MembershipSetting.all
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") @payment_methods = PaymentMethodSetting.all
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'") #@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
@order_items = Array.new @order_items = Array.new
@@ -103,16 +103,16 @@ class Foodcourt::HomeController < BaseFoodcourtController
end end
#for bank integration #for bank integration
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') @checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time') @checkout_alert_time = Lookup.collection_of('checkout_alert_time')
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC") accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
@tax_arr =[] @tax_arr =[]
accounts.each do |acc| accounts.each do |acc|
@tax_arr.push(acc.name) @tax_arr.push(acc.name)
end end
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0 @split_bill = 0
if !lookup_spit_bill[0].nil? if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1] @split_bill = lookup_spit_bill[0][1]
@@ -120,7 +120,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
#for edit order on/off #for edit order on/off
@edit_order_origami = true @edit_order_origami = true
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order') lookup_edit_order = Lookup.collection_of('edit_order')
if !lookup_edit_order.empty? if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order| lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami" if edit_order[0].downcase == "editorderorigami"
@@ -133,7 +133,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
#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"

View File

@@ -71,7 +71,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
.joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq .where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',Date.today).order("bookings.created_at desc").uniq
end end
def completed def completed
customer =Customer.find_by_customer_id(params[:customer_id]) customer =Customer.find_by_customer_id(params[:customer_id])

View File

@@ -547,7 +547,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.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -562,7 +562,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(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)
@@ -631,7 +631,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
else else
receipt_bill_a5_pdf = Lookup.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.all
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'
@@ -654,7 +654,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(unique_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)

View File

@@ -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.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]
@@ -15,8 +15,8 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
end end
def new def new
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code) @float = Lookup.where('lookup_type=?','float_value')
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'") @terminal = CashierTerminal.available
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('bank_integration')
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.collection_of("print_settings")
unique_code = "CloseCashierPdf" unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty? if !close_cashier_pdf.empty?
@@ -98,7 +98,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
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='')
@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
@@ -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='')
#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)

View File

@@ -18,8 +18,8 @@ class Foodcourt::SurveysController < BaseFoodcourtController
if @booking.dining_facility_id.to_i>0 if @booking.dining_facility_id.to_i>0
@dining_facility = DiningFacility.find(@booking.dining_facility_id) @dining_facility = DiningFacility.find(@booking.dining_facility_id)
@table_type = @dining_facility.type @table_type = @dining_facility.type
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code) @survey_data = Survey.find_by_dining_name(@dining_facility.name)
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code) survey_process = Survey.find_by_receipt_no(@receipt_no)
if !survey_process.nil? if !survey_process.nil?
@survey_data = survey_process @survey_data = survey_process
end end
@@ -33,7 +33,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController
@table_type = @dining_facility.type @table_type = @dining_facility.type
@receipt_no = nil @receipt_no = nil
@grand_total = nil @grand_total = nil
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code) @survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
end end
end end
@@ -46,7 +46,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id) # cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) # shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier # set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift current_shift = ShiftSale.current_shift
current_shift_user =Employee.find_by_id(current_user.employee_id) current_shift_user =Employee.find_by_id(current_user.employee_id)
if open_cashier.count>0 if open_cashier.count>0

View File

@@ -64,7 +64,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
# FOr Sale Audit # FOr Sale Audit
action_by = current_user.name action_by = current_user.name
if access_code != "null" && current_user.role == "cashier" if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name action_by = Employee.find_by_emp_id(access_code).name
end end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
@@ -111,7 +111,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
current_balance = 0 current_balance = 0
end end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") printer = PrintSetting.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -126,7 +126,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
end end
end end
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -54,7 +54,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
# FOr Sale Audit # FOr Sale Audit
action_by = current_user.name action_by = current_user.name
if access_code != "null" && current_user.role == "cashier" if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name action_by = Employee.find_by_emp_id(access_code).name
end end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark ) sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
@@ -88,7 +88,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
# get member information # get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer) member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -96,7 +96,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
current_balance = 0 current_balance = 0
end end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") printer = PrintSetting.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -112,7 +112,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
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(unique_code)
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -18,8 +18,8 @@ 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='#{@shop.shop_code}' and is_active = true").order("name asc") @employees = Employee.all.where("is_active = true").order("name asc")
@roles = Employee.where("shop_code='#{@shop.shop_code}'").distinct.pluck(:role) @roles = Employee.distinct.pluck(:role)
# byebug # byebug
# @roles = Lookup.collection_of("employee_roles") # @roles = Lookup.collection_of("employee_roles")

View File

@@ -3,14 +3,14 @@ class Inventory::InventoryController < BaseInventoryController
def index def index
filter = params[:filter] filter = params[:filter]
@inventory_definitions = InventoryDefinition.get_by_category(@shop,filter) @inventory_definitions = InventoryDefinition.get_by_category(filter)
end end
def show def show
inventory_definition_id = params[:inventory_definition_id] inventory_definition_id = params[:inventory_definition_id]
inventory = InventoryDefinition.find_by_id_and_shop_code(inventory_definition_id,@shop.shop_code) inventory = InventoryDefinition.find_by_id(inventory_definition_id)
@stock_journals = StockJournal.where("item_code=? and shop_code='#{@shop.shop_code}'",inventory.item_code).order("id DESC") @stock_journals = StockJournal.where("item_code=?",inventory.item_code).order("id DESC")
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20) @stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
respond_to do |format| respond_to do |format|

View File

@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions # GET /inventory_definitions
# GET /inventory_definitions.json # GET /inventory_definitions.json
def index def index
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'") @inventory_definitions = InventoryDefinition.all
end end
# GET /inventory_definitions/1 # GET /inventory_definitions/1
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions/new # GET /inventory_definitions/new
def new def new
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc') @menus = Menu.order('created_at asc')
@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')
@inventory_definition = InventoryDefinition.new @inventory_definition = InventoryDefinition.new
end end
@@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions # POST /inventory_definitions
# POST /inventory_definitions.json # POST /inventory_definitions.json
def create def create
inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code) inventory = InventoryDefinition.find_by_item_code(params[:item_code])
if inventory.nil? if inventory.nil?
@inventory_definition = InventoryDefinition.new @inventory_definition = InventoryDefinition.new
@@ -84,7 +84,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# DELETE /inventory_definitions/1 # DELETE /inventory_definitions/1
# DELETE /inventory_definitions/1.json # DELETE /inventory_definitions/1.json
def destroy def destroy
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code) inventory = InventoryDefinition.find_by_id(params[:id])
@inventory_definition.destroy @inventory_definition.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' } format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
@@ -107,7 +107,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_inventory_definition def set_inventory_definition
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code) @inventory_definition = InventoryDefinition.find_by_id(params[:id])
end end
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -8,7 +8,6 @@ class Inventory::StockChecksController < BaseInventoryController
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" + .joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" + " JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ") " JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.where("inventory_definitions.shop_code='#{@shop.shop_code}'")
.group("mi.menu_category_id") .group("mi.menu_category_id")
.order("mi.menu_category_id desc") .order("mi.menu_category_id desc")
unless !@category.nil? unless !@category.nil?
@@ -24,7 +23,7 @@ class Inventory::StockChecksController < BaseInventoryController
end end
def show def show
@check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code) @check = StockCheck.find_by_id(params[:id])
@stock_check_items = StockCheckItem.get_items_with_category(params[:id]) @stock_check_items = StockCheckItem.get_items_with_category(params[:id])

View File

@@ -6,8 +6,8 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status true # Query for OQS with delivery status true
# @tables = DiningFacility.all.active.order('status desc') # @tables = DiningFacility.all.active.order('status desc')
@tables = DiningFacility.all.active.where("type = 'Table' and shop_code='#{@shop.shop_code}' ").order('status desc') @tables = DiningFacility.all.active.where("type = 'Table'").order('status desc')
@rooms = DiningFacility.all.active.where("type = 'Room' and shop_code='#{@shop.shop_code}' ").order('status desc') @rooms = DiningFacility.all.active.where("type = 'Room'").order('status desc')
@filter = params[:filter] @filter = params[:filter]
@@ -232,7 +232,7 @@ class Oqs::HomeController < BaseOqsController
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") .where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
query = query.where("df.shop_code='#{@shop.shop_code}' and df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("odt.order_items_id") .group("odt.order_items_id")
.order("assigned_order_items.created_at desc") .order("assigned_order_items.created_at desc")

View File

@@ -19,7 +19,7 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile if check_mobile
@webview = true @webview = true
end end
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

View File

@@ -21,7 +21,7 @@ class Origami::CashInsController < BaseOrigamiController
shift = shift shift = shift
else else
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0 if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0]) shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -16,7 +16,7 @@ class Origami::CashOutsController < BaseOrigamiController
if shift != nil if shift != nil
shift = shift shift = shift
else else
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0 if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0]) shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -92,12 +92,12 @@ class Origami::CustomersController < BaseOrigamiController
# if flash["errors"] # if flash["errors"]
# @crm_customer.valid? # @crm_customer.valid?
# end # end
@membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type") @membership_types = Lookup.collection_of("member_group_type")
#get paypar accountno #get paypar accountno
@paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no") @paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no")
#for create customer on/off #for create customer on/off
@create_flag = true @create_flag = true
lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings') lookup_customer = Lookup.collection_of('customer_settings')
if !lookup_customer.empty? if !lookup_customer.empty?
lookup_customer.each do |create_setting| lookup_customer.each do |create_setting|
if create_setting[0].downcase == "create" if create_setting[0].downcase == "create"
@@ -168,9 +168,9 @@ class Origami::CustomersController < BaseOrigamiController
sale = Sale.find_by_receipt_no(receipt_no) sale = Sale.find_by_receipt_no(receipt_no)
@out = [] @out = []
action_by = current_user.name action_by = current_user.name
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url if member_actions.gateway_url
@campaign_type_id = nil @campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s

View File

@@ -47,21 +47,21 @@ class Origami::DashboardController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
@current_user = current_user @current_user = current_user
#dine-in cashier #dine-in cashier
dinein_cashier = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dinein_cashier') dinein_cashier = Lookup.collection_of('dinein_cashier')
@dinein_cashier = 0 @dinein_cashier = 0
if !dinein_cashier[0].nil? if !dinein_cashier[0].nil?
@dinein_cashier = dinein_cashier[0][1] @dinein_cashier = dinein_cashier[0][1]
end end
#quick service #quick service
quick_service = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('quick_service') quick_service = Lookup.collection_of('quick_service')
@quick_service = 0 @quick_service = 0
if !quick_service[0].nil? if !quick_service[0].nil?
@quick_service = quick_service[0][1] @quick_service = quick_service[0][1]
end end
#fourt court #fourt court
food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court') food_court = Lookup.collection_of('food_court')
@food_court = 0 @food_court = 0
@food_court_name = nil @food_court_name = nil
if !food_court[0].nil? if !food_court[0].nil?
@@ -70,7 +70,7 @@ class Origami::DashboardController < BaseOrigamiController
end end
#order reservation #order reservation
order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation') order_reservation = Lookup.collection_of('order_reservation')
@order_reservation = 0 @order_reservation = 0
if !order_reservation.empty? if !order_reservation.empty?
order_reservation.each do |order_reserve| order_reservation.each do |order_reserve|
@@ -81,7 +81,7 @@ class Origami::DashboardController < BaseOrigamiController
end end
#dashboard settings on/off for supervisor and cashier #dashboard settings on/off for supervisor and cashier
dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings') dashboard_settings = Lookup.collection_of('dashboard_settings')
@setting_flag = true @setting_flag = true
if !dashboard_settings.empty? if !dashboard_settings.empty?
dashboard_settings.each do |setting| dashboard_settings.each do |setting|
@@ -92,7 +92,7 @@ class Origami::DashboardController < BaseOrigamiController
end end
#reservation #reservation
reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation') reservation = Lookup.collection_of('reservation')
@reservation = 0 @reservation = 0
if !reservation.empty? if !reservation.empty?
reservation.each do |reserve| reservation.each do |reserve|

View File

@@ -21,8 +21,8 @@ class Origami::DiscountsController < BaseOrigamiController
end end
end end
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) @member_discount = MembershipSetting.find_by_discount(1)
@accounts = Account.where("shop_code='#{@shop.shop_code}'") @accounts = Account.all
end end
#discount page show from origami index with selected order #discount page show from origami index with selected order

View File

@@ -17,10 +17,10 @@ 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") @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"
display_type = Lookup.find_by_lookup_type("display_type") 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
@@ -31,7 +31,7 @@ class Origami::FoodCourtController < ApplicationController
#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"
@@ -160,7 +160,7 @@ class Origami::FoodCourtController < ApplicationController
end end
def get_all_product() def get_all_product()
@product = Product..where("shop_code='#{@shop.shop_code}'") @product = Product.all
end end
# render json for http status code # render json for http status code

View File

@@ -73,16 +73,16 @@ class Origami::HomeController < BaseOrigamiController
end end
#for bank integration #for bank integration
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') @checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time') @checkout_alert_time = Lookup.collection_of('checkout_alert_time')
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC") accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
@tax_arr =[] @tax_arr =[]
accounts.each do |acc| accounts.each do |acc|
@tax_arr.push(acc.name) @tax_arr.push(acc.name)
end end
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0 @split_bill = 0
if !lookup_spit_bill[0].nil? if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1] @split_bill = lookup_spit_bill[0][1]
@@ -90,7 +90,7 @@ class Origami::HomeController < BaseOrigamiController
#for edit order on/off #for edit order on/off
@edit_order_origami = true @edit_order_origami = true
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order') lookup_edit_order = Lookup.collection_of('edit_order')
if !lookup_edit_order.empty? if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order| lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami" if edit_order[0].downcase == "editorderorigami"
@@ -103,7 +103,7 @@ class Origami::HomeController < BaseOrigamiController
#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"

View File

@@ -98,12 +98,12 @@ class Origami::OrderReservationController < BaseOrigamiController
end end
def get_order_info def get_order_info
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{current_shop.shop_code}'").count() order_reservation = OrderReservation.where("status = 'new'").count()
render :json => order_reservation render :json => order_reservation
end end
def check_receipt_bill def check_receipt_bill
receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation") receipt_bill = Lookup.collection_of("order_reservation")
status = 0 status = 0
if !receipt_bill.nil? if !receipt_bill.nil?

View File

@@ -32,9 +32,9 @@ class Origami::PaymalController < BaseOrigamiController
if customer_data if customer_data
@membership_id = customer_data.membership_id @membership_id = customer_data.membership_id
if !@membership_id.nil? if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url if member_actions.gateway_url
@campaign_type_id = nil @campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s

View File

@@ -65,7 +65,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_detail, "Frt",current_balance,nil,other_amount,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, "Frt", current_balance, nil, other_amount, nil, nil, nil)
result = { result = {
:filepath => filename, :filepath => filename,
@@ -202,7 +202,7 @@ class Origami::PaymentsController < BaseOrigamiController
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_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) 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)
#end #end
end end
@@ -225,7 +225,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("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
@@ -245,7 +245,7 @@ class Origami::PaymentsController < BaseOrigamiController
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount") @sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
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)
@@ -270,7 +270,7 @@ 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("ReceiptPdfView")
if !@lookup_pdf.nil? if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value @pdf_view = @lookup_pdf.value
end end
@@ -280,7 +280,7 @@ class Origami::PaymentsController < BaseOrigamiController
#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"
@@ -348,7 +348,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 = ?",@cashier_type).order("order_by ASC")
@account_arr =[] @account_arr =[]
@tax_arr =[] @tax_arr =[]
accounts.each do |acc| accounts.each do |acc|
@@ -362,7 +362,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(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)
@@ -613,7 +613,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(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)
@@ -680,9 +680,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.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.all
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'

View File

@@ -30,8 +30,8 @@ class Origami::RoomsController < BaseOrigamiController
@status_order = "" @status_order = ""
@status_sale = "" @status_sale = ""
@sale_array = Array.new @sale_array = Array.new
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code) @membership = MembershipSetting.all
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code) @payment_methods = PaymentMethodSetting.all
@membership = MembershipSetting::MembershipSetting @membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all @payment_methods = PaymentMethodSetting.all
@dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") @dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")

View File

@@ -15,7 +15,7 @@ class Origami::ShiftsController < BaseOrigamiController
end end
def new def new
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code) @float = Lookup.where('lookup_type=?','float_value')
@terminal = CashierTerminal.available @terminal = CashierTerminal.available
end end
@@ -56,7 +56,7 @@ class Origami::ShiftsController < BaseOrigamiController
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('bank_integration')
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 Origami::ShiftsController < BaseOrigamiController
# 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.collection_of("print_settings")
unique_code = "CloseCashierPdf" unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty? if !close_cashier_pdf.empty?
@@ -97,7 +97,7 @@ class Origami::ShiftsController < BaseOrigamiController
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='')
@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
@@ -144,7 +144,7 @@ class Origami::ShiftsController < BaseOrigamiController
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='')
#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)

View File

@@ -18,8 +18,8 @@ class Origami::SurveysController < BaseOrigamiController
if @booking.dining_facility_id.to_i>0 if @booking.dining_facility_id.to_i>0
@dining_facility = DiningFacility.find(@booking.dining_facility_id) @dining_facility = DiningFacility.find(@booking.dining_facility_id)
@table_type = @dining_facility.type @table_type = @dining_facility.type
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code) @survey_data = Survey.find_by_dining_name(@dining_facility.name)
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code) survey_process = Survey.find_by_receipt_no(@receipt_no)
if !survey_process.nil? if !survey_process.nil?
@survey_data = survey_process @survey_data = survey_process
end end
@@ -46,7 +46,7 @@ class Origami::SurveysController < BaseOrigamiController
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id) # cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) # shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier # set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift current_shift = ShiftSale.current_shift
current_shift_user =Employee.find_by_id(current_user.employee_id) current_shift_user =Employee.find_by_id(current_user.employee_id)
if open_cashier.count>0 if open_cashier.count>0

View File

@@ -39,7 +39,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
@status_sale = 'sale' @status_sale = 'sale'
@customer = @sale.customer @customer = @sale.customer
#for split bill #for split bill
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0 @split_bill = 0
if !lookup_spit_bill[0].nil? if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1] @split_bill = lookup_spit_bill[0][1]

View File

@@ -72,7 +72,7 @@ class Origami::VoidController < BaseOrigamiController
# FOr Sale Audit # FOr Sale Audit
action_by = current_user.name action_by = current_user.name
if access_code != "null" && current_user.role == "cashier" if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name action_by = Employee.find_by_emp_id(access_code).name
end end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
@@ -114,7 +114,7 @@ class Origami::VoidController < BaseOrigamiController
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
# get member information # get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer) member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -122,7 +122,7 @@ class Origami::VoidController < BaseOrigamiController
current_balance = 0 current_balance = 0
end end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") printer = PrintSetting.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -137,7 +137,7 @@ class Origami::VoidController < 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(unique_code)
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -54,7 +54,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
# FOr Sale Audit # FOr Sale Audit
action_by = current_user.name action_by = current_user.name
if access_code != "null" && current_user.role == "cashier" if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name action_by = Employee.find_by_emp_id(access_code).name
end end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark ) sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
@@ -87,7 +87,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
# unique_code = "ReceiptBillPdf" # unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
# get member information # get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer) member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -95,7 +95,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
current_balance = 0 current_balance = 0
end end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") printer = PrintSetting.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -111,7 +111,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
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(unique_code)
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -6,7 +6,7 @@ class Reports::CommissionController < BaseReportController
commissioner = params[:commissioner].to_i commissioner = params[:commissioner].to_i
@com_id = commissioner @com_id = commissioner
@commissioner = Commissioner.active.where("shop_code='#{@shop.shop_code}'") @commissioner = Commissioner.active
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner) @transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
@@ -23,7 +23,7 @@ class Reports::CommissionController < BaseReportController
def show def show
from, to = get_date_range_from_params from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|

View File

@@ -5,16 +5,16 @@ authorize_resource :class => false
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
from, to = get_date_range_from_params from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = '' @shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end

View File

@@ -7,7 +7,7 @@ class Reports::DailysaleController < BaseReportController
@tax = SaleTax.get_tax(from,to) @tax = SaleTax.get_tax(from,to)
@from = from @from = from
@to = to @to = to
@payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code=?",@shop.shop_code).pluck("payment_method") @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# get printer info # get printer info
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format| respond_to do |format|

View File

@@ -1,7 +1,7 @@
class Reports::HourlySaleitemController < BaseReportController class Reports::HourlySaleitemController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@account = Account.where("shop_code='#{@shop.shop_code}'") @account = Account.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
@start_time = params[:start_time] @start_time = params[:start_time]
@@ -12,16 +12,16 @@ class Reports::HourlySaleitemController < BaseReportController
shift = '' shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
if shift_sale.shift_closed_at.blank? if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
end end
@@ -31,7 +31,7 @@ class Reports::HourlySaleitemController < BaseReportController
@type = params[:sale_type] @type = params[:sale_type]
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,filter,@start_time,@end_time) @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,filter,@start_time,@end_time)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'") @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
@account_cate_count = Hash.new {|hash, key| hash[key] = 0} @account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}

View File

@@ -1,20 +1,20 @@
class Reports::IndutyController < BaseReportController class Reports::IndutyController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@commissioners = Commissioner.where("shop_code='#{@shop.shop_code}'") #.where("is_active='1'") @commissioners = Commissioner.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = '' @shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
@@ -43,7 +43,7 @@ class Reports::IndutyController < BaseReportController
def show def show
from, to = get_date_range_from_params from, to = get_date_range_from_params
@induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@commissioner = params[:commissioner] @commissioner = params[:commissioner]
date_arr = Array.new date_arr = Array.new

View File

@@ -11,16 +11,16 @@ class Reports::OrderReservationController < BaseReportController
@shift = '' @shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
if shift_sale.shift_closed_at.blank? if shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
end end

View File

@@ -15,9 +15,9 @@ class Reports::PaymentMethodController < BaseReportController
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
@payment_type = params[:payment_type] @payment_type = params[:payment_type]

View File

@@ -2,7 +2,7 @@ class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
@payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") @payment_method = PaymentMethodSetting.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
@shift_sale_range = '' @shift_sale_range = ''
@@ -14,17 +14,17 @@ authorize_resource :class => false
@shift_sale = ShiftSale.find(params[:shift_name]) @shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at)
else else
if @shift_sale.shift_closed_at.blank? if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end end
end end
end end
@lookup = Lookup.find_by_lookup_type_and_shop_code('reprint_receipt',@shop.shop_code) @lookup = Lookup.find_by_lookup_type('reprint_receipt')
if @lookup.nil? if @lookup.nil?
@lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code) @lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code)
end end
@@ -32,7 +32,7 @@ authorize_resource :class => false
payment_type = params[:payment_type] payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
@tax_profiles = TaxProfile.where("shop_code='#{@shop.shop_code}'").group('name').order('order_by asc') #.limit(2) @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@from = from @from = from
@to = to @to = to

View File

@@ -2,7 +2,7 @@ class Reports::ReceiptNoDetailController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
@payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") @payment_method = PaymentMethodSetting.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
@shift_sale_range = '' @shift_sale_range = ''
@@ -17,9 +17,9 @@ authorize_resource :class => false
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else else
if @shift_sale.shift_closed_at.blank? if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end end
end end
end end

View File

@@ -1,7 +1,7 @@
class Reports::SaleitemController < BaseReportController class Reports::SaleitemController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@account = Account.where("shop_code='#{@shop.shop_code}'") @account = Account.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
shift_sale_range = '' shift_sale_range = ''
@@ -13,12 +13,12 @@ class Reports::SaleitemController < BaseReportController
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
if shift_sale.shift_closed_at.blank? if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
end end
@@ -92,16 +92,16 @@ class Reports::SaleitemController < BaseReportController
shift_name = 'All Shift' shift_name = 'All Shift'
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
if shift_sale.shift_closed_at.blank? if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'" ,shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL" ,shift_sale.shift_started_at)
else else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
@@ -117,14 +117,14 @@ class Reports::SaleitemController < BaseReportController
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code) @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
other_charges = Sale.get_other_charges() other_charges = Sale.get_other_charges()
if shift.present? if shift.present?
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",shift.to_a) @total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
else else
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",from,to) @total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end end
# get printer info # get printer info
print_settings = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsPdf',@shop.shop_code) # SaleItemsPdf print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
print_settings_star = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsStarPdf',@shop.shop_code) print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
if print_settings.nil? if print_settings.nil?
if !print_settings_star.nil? if !print_settings_star.nil?

View File

@@ -58,7 +58,7 @@ class Reports::ShiftsaleController < BaseReportController
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") close_cashier_pdf = Lookup.collection_of("print_settings")
unique_code = "CloseCashierPdf" unique_code = "CloseCashierPdf"
@@ -93,7 +93,7 @@ class Reports::ShiftsaleController < BaseReportController
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments @total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
# 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)
printer = Printer::CashierStationPrinter.new(print_settings) printer = Printer::CashierStationPrinter.new(print_settings)
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) # printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)

View File

@@ -2,7 +2,7 @@ class Reports::StaffMealController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@account = Account.where("shop_code='#{@shop.shop_code}'") @account = Account.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
shift_sale_range = '' shift_sale_range = ''
@@ -10,16 +10,16 @@ class Reports::StaffMealController < BaseReportController
shift = '' shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
if shift_sale.shift_closed_at.blank? if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end
end end

View File

@@ -12,9 +12,9 @@ class Reports::StockCheckController < BaseReportController
# end # end
from_date, to_date = get_date_range_from_params from_date, to_date = get_date_range_from_params
@item_code = params[:item_code] @item_code = params[:item_code]
@inventory_definitions = InventoryDefinition.active.where("shop_code='#{@shop.shop_code}'") @inventory_definitions = InventoryDefinition.active
@transaction = StockCheckItem.where("shop_code='#{@shop.shop_code}'").get_transaction(from_date, to_date, @item_code) @transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
@from = from_date @from = from_date
@to = to_date @to = to_date
# get printer info # get printer info

View File

@@ -9,10 +9,10 @@ authorize_resource :class => false
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end end
end end

View File

@@ -6,7 +6,7 @@ class Settings::AccountsController < ApplicationController
# GET /settings/accounts.json # GET /settings/accounts.json
def index def index
@settings_accounts = Account.all.where("shop_code='#{@shop.shop_code}'") @settings_accounts = Account.all
end end
# GET /settings/accounts/1 # GET /settings/accounts/1

View File

@@ -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.all
end end
# GET /settings/cashier_terminals/1 # GET /settings/cashier_terminals/1

View File

@@ -31,7 +31,7 @@ class Settings::EmployeesController < ApplicationController
# POST /employees.json # POST /employees.json
def create def create
@employee = Employee.new(employee_params) @employee = Employee.new(employee_params)
@employee.shop_code =current_shop.shop_code @employee.shop_code =@shop.shop_code
respond_to do |format| respond_to do |format|
if @employee.save if @employee.save
format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' } format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' }

View File

@@ -25,7 +25,7 @@ class Settings::LookupsController < ApplicationController
# POST /settings/lookups.json # POST /settings/lookups.json
def create def create
@settings_lookup = Lookup.new(settings_lookup_params) @settings_lookup = Lookup.new(settings_lookup_params)
@settings_lookup.shop_code = current_shop.shop_code @settings_lookup.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_lookup.save if @settings_lookup.save
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' } format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' }

View File

@@ -6,7 +6,7 @@ class Settings::MenusController < ApplicationController
# GET /settings/menus.json # GET /settings/menus.json
def index def index
@settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) @settings_menus = Menu.all.page(params[:page]).per(10)
respond_to do |format| respond_to do |format|
format.html format.html
format.xlsx format.xlsx
@@ -77,7 +77,7 @@ class Settings::MenusController < ApplicationController
def export def export
@settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) @settings_menus = Menu.all.page(params[:page]).per(10)
menu = Menu.find(params[:id]) menu = Menu.find(params[:id])
p = Axlsx::Package.new p = Axlsx::Package.new

View File

@@ -6,7 +6,7 @@ class Settings::OrderQueueStationsController < ApplicationController
# GET /settings/order_queue_stations # GET /settings/order_queue_stations
# GET /settings/order_queue_stations.json # GET /settings/order_queue_stations.json
def index def index
@settings_order_queue_stations = OrderQueueStation.where("shop_code=?",@shop.shop_code) @settings_order_queue_stations = OrderQueueStation.all
@settings_order_queue_stations = Kaminari.paginate_array(@settings_order_queue_stations).page(params[:page]).per(50) @settings_order_queue_stations = Kaminari.paginate_array(@settings_order_queue_stations).page(params[:page]).per(50)
end end

View File

@@ -7,7 +7,7 @@ class Settings::OutOfStockController < ApplicationController
end end
def new def new
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc') @menus = Menu.order('created_at asc')
@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

View File

@@ -6,7 +6,7 @@ class Settings::ZonesController < ApplicationController
# GET /settings/zones.json # GET /settings/zones.json
def index def index
@settings_zones = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") @settings_zones = Zone.all.where("is_active= true")
end end
# GET /settings/zones/1 # GET /settings/zones/1

View File

@@ -9,7 +9,7 @@ class Transactions::BookingsController < ApplicationController
to = params[:to] to = params[:to]
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
@bookings = Booking.where("shop_code=?",@shop.shop_code).order("sale_id desc") @bookings = Booking.order("sale_id desc")
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20) @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
else else
booking = Booking.search(filter,from,to) booking = Booking.search(filter,from,to)

View File

@@ -13,11 +13,11 @@ class Transactions::OrderReservationsController < ApplicationController
if from.nil? && to.nil? if from.nil? && to.nil?
@order_reservations = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee") @order_reservations = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id") .joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
.where("NOT order_reservation_status='new' and order_reservations.shop_code='#{@shop.shop_code}'") .where("NOT order_reservation_status='new'")
.order("order_reservation_id desc") .order("order_reservation_id desc")
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20) @order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)
else else
order_reservation = OrderReservation.search(filter,from,to).where("order_reservations.shop_code='#{@shop.shop_code}'") order_reservation = OrderReservation.search(filter,from,to)
if order_reservation.length > 0 if order_reservation.length > 0
@order_reservations = order_reservation @order_reservations = order_reservation
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20) @order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)

View File

@@ -9,9 +9,9 @@ class Transactions::OrdersController < ApplicationController
to = params[:to] to = params[:to]
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
orders = Order.where("shop_code='#{@shop.shop_code}'").order("order_id desc") orders = Order.order("order_id desc")
else else
orders = Order.search(filter,from,to).where("orders.shop_code='#{@shop.shop_code}'") orders = Order.search(filter,from,to)
end end
if !orders.nil? if !orders.nil?

View File

@@ -89,7 +89,7 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales/1 # GET /transactions/sales/1
# GET /transactions/sales/1.json # GET /transactions/sales/1.json
def show def show
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code) @membership = MembershipSetting.all
@payment_methods = PaymentMethodSetting.where("is_active='1'") @payment_methods = PaymentMethodSetting.where("is_active='1'")
@sale = Sale.find(params[:id]) @sale = Sale.find(params[:id])

View File

@@ -11,10 +11,10 @@ class Transactions::ShiftSalesController < ApplicationController
to = params[:to] to = params[:to]
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
@shift_sales = ShiftSale.where("shop_code='#{@shop.shop_code}'").order("id desc") @shift_sales = ShiftSale.order("id desc")
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
else else
shift_sale = ShiftSale.search(filter,from,to).where("shift_sales.shop_code='#{@shop.shop_code}'") shift_sale = ShiftSale.search(filter,from,to)
if shift_sale.count > 0 if shift_sale.count > 0
@shift_sales = shift_sale @shift_sales = shift_sale
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)

View File

@@ -6,9 +6,9 @@ class Transactions::SurveysController < ApplicationController
to = params[:to] to = params[:to]
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
@surveys = Survey.where("shop_code='#{@shop.shop_code}'") @surveys = Survey.all
else else
@surveys = Survey.search(filter,from,to).where("shop_code='#{@shop.shop_code}'") @surveys = Survey.search(filter,from,to)
end end
@filter = filter @filter = filter

View File

@@ -54,7 +54,7 @@ class DiningFacility < ApplicationRecord
def get_checkout_booking def get_checkout_booking
booking = self.current_reserved_booking booking = self.current_reserved_booking
if booking if booking
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time") lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0 free_time_min = 0
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
now = Time.now.utc now = Time.now.utc
@@ -95,7 +95,7 @@ class DiningFacility < ApplicationRecord
bookings = self.current_checkin_booking bookings = self.current_checkin_booking
arr_booking = Array.new arr_booking = Array.new
if bookings if bookings
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time") lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0 free_time_min = 0
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
now = Time.now.utc now = Time.now.utc

View File

@@ -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.current_shop.shop_code) if product = InventoryDefinition.find_by_item_code(item.item_instance_code)
if stock_check_item = StockCheckItem.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(item.item_instance_code)
return true, product return true, product
end end
end end
@@ -34,7 +34,7 @@ class InventoryDefinition < ApplicationRecord
def self.check_balance(item, inventory_definition) # item => saleItemOBj def self.check_balance(item, inventory_definition) # item => saleItemOBj
stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first stock = StockJournal.where("item_code=?", item.item_instance_code).order("id DESC").first
unless stock.nil? unless stock.nil?
modify_balance(item, stock, inventory_definition) modify_balance(item, stock, inventory_definition)
else else
@@ -99,7 +99,7 @@ class InventoryDefinition < ApplicationRecord
" JOIN menu_items mi ON mi.id = mii.menu_item_id" + " JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ") " JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.joins(" JOIN accounts acc ON acc.id = mi.account_id") .joins(" JOIN accounts acc ON acc.id = mi.account_id")
.where("inventory_definitions.shop_code='#{shop.shop_code}' and (inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ? .where("(inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ?
OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ? OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ?
OR mii.item_instance_name LIKE ? OR mc.name LIKE ?)","%#{filter}%","%#{filter}%","%#{filter}%", OR mii.item_instance_name LIKE ? OR mc.name LIKE ?)","%#{filter}%","%#{filter}%","%#{filter}%",
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") "%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")

View File

@@ -86,7 +86,7 @@ class Lookup < ApplicationRecord
end end
def self.save_shift_sale_items_settings(val,shop_code) def self.save_shift_sale_items_settings(val,shop_code)
@lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last @lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil? if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code) @lookup = Lookup.create_shift_sale_lookup(shop_code)
end end
@@ -95,7 +95,7 @@ class Lookup < ApplicationRecord
end end
def self.shift_sale_items_lookup_value(shop_code) def self.shift_sale_items_lookup_value(shop_code)
@lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last @lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil? if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code) @lookup = Lookup.create_shift_sale_lookup(shop_code)
end end

View File

@@ -212,7 +212,7 @@ class Order < ApplicationRecord
def self.pay_process_order_queue(id,table_id) def self.pay_process_order_queue(id,table_id)
# if ENV["SERVER_MODE"] != 'cloud' # if ENV["SERVER_MODE"] != 'cloud'
order = Order.find(id) order = Order.find(id)
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",order.shop_code) sidekiq = Lookup.find_by_lookup_type("sidekiq")
if !sidekiq.nil? if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(id, table_id) OrderQueueProcessorJob.perform_later(id, table_id)
else else

View File

@@ -153,23 +153,36 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# Query for OQS with status # Query for OQS with status
def print_query(type, id) def print_query(type, id)
query = OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
.joins("left join orders ON orders.order_id = order_items.order_id")
.joins("left join booking_orders AS bo ON bo.order_id=order_items.order_id")
.joins("left join bookings AS b ON b.booking_id = bo.booking_id")
.joins("left join dining_facilities AS df ON df.id = b.dining_facility_id")
.joins("left join customers as cus ON cus.customer_id = orders.customer_id")
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
if type == "order_item" if type == "order_item"
query.where("order_items.order_items_id = ?", id) OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
.group("order_items.item_code") .joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("order_items.order_items_id = '#{ id }'")
.group("order_items.item_code")
elsif type == "order_summary" elsif type == "order_summary"
query.where("orders.order_id = ?", id) OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
.group("order_items.order_items_id") .joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("orders.order_id = '#{ id }'")
.group("order_items.order_items_id")
else else
# order summary for booking # order summary for booking
query.where("b.booking_id = ?", id) OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("b.booking_id = '#{ id }'")
end end
end end

View File

@@ -42,17 +42,17 @@ class Printer::PrinterWorker
end end
def print(file_path, printer_destination = nil ) def print(file_path, printer_destination = nil )
if printer_destination.nil? # if printer_destination.nil?
printer_destination = self.printer_destination # printer_destination = self.printer_destination
end # end
copy = self.print_copies # copy = self.print_copies
#Print only when printer information is not null # #Print only when printer information is not null
if !self.printer_destination.nil? # if !self.printer_destination.nil?
(1..copy).each do # (1..copy).each do
page = Cups::PrintJob.new(file_path, printer_destination) # page = Cups::PrintJob.new(file_path, printer_destination)
page.print # page.print
end # end
end # end
end end
end end

View File

@@ -35,7 +35,7 @@ class ProductCommission < ApplicationRecord
def self.edit_product_commission(saleItemObj,shop_code) def self.edit_product_commission(saleItemObj,shop_code)
menu_item = MenuItem.find_by_item_code(saleItemObj.product_code) menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
commission = Commission.where("shop_code='#{shop_code}' and product_code = ? AND is_active = ?", menu_item.id, true).take commission = Commission.where("product_code = ? AND is_active = ?", menu_item.id, true).take
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take
if !product_commission.nil? if !product_commission.nil?

View File

@@ -849,9 +849,9 @@ end
def self.get_by_shiftsales(from,to,shift,shop_code) def self.get_by_shiftsales(from,to,shift,shop_code)
if !shift.blank? if !shift.blank?
query = ShiftSale.where("shift_sales.id =? and shop_code='#{shop_code}'",shift.id) query = ShiftSale.where("shift_sales.id =?",shift.id)
else else
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? ) and shop_code='#{shop_code}'", from, to, from, to) query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end end
shift_sale_data = Hash.new shift_sale_data = Hash.new
@@ -1127,13 +1127,13 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
# end # end
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
sale_cash.each do |s_c| sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f total_card_amount += s_c.card_amount.to_f
@@ -1144,20 +1144,20 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else else
query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to) query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to)
# if type.nil? || type == 'all' || type == "other" # if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) # other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
# end # end
product = product.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to) product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
sale_cash.each do |s_c| sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f total_card_amount += s_c.card_amount.to_f
@@ -1263,8 +1263,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
CONCAT(DATE_FORMAT(CONVERT_TZ(shift_sales.shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_sales.shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p')) as credit_payment_shift_name") CONCAT(DATE_FORMAT(CONVERT_TZ(shift_sales.shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_sales.shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p')) as credit_payment_shift_name")
.joins(:sale_audit) .joins(:sale_audit)
.joins(:sale => :shift_sale) .joins(:sale => :shift_sale)
.joins(:sale => :cashier) .joins(:sale => :cashier).to_sql
.where("sales.shop_code='#{shop_code}'").to_sql
credits = SalePayment.select(" credits = SalePayment.select("
sale_payments.sale_payment_id, sale_payments.sale_payment_id,
@@ -1315,7 +1314,6 @@ end
sale_arr = Array.new sale_arr = Array.new
query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment") query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
.where("sales.shop_code='#{shop_code}'")
# .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id") # .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
# .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? # .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
# OR sh.shift_closed_at between ? and ? )", from ,to, from, to) # OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
@@ -1488,7 +1486,7 @@ 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)
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")
.group("SUBSTRING_INDEX(product_name, ' - ', 1)") .group("SUBSTRING_INDEX(product_name, ' - ', 1)")
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
@@ -1600,7 +1598,7 @@ end
query = SalePayment.credits query = SalePayment.credits
.joins(:sale) .joins(:sale)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sale_payments.sale_id") .joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sale_payments.sale_id")
.where("sale_payments.payment_method= ? AND sales.sale_status = ? AND sales.shop_code=?", 'creditnote', 'completed',current_shop.shop_code) .where("sale_payments.payment_method= ? AND sales.sale_status = ?", 'creditnote', 'completed')
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.merge(Sale.receipt_date_between(from, to)) query = query.merge(Sale.receipt_date_between(from, to))
@@ -1818,7 +1816,6 @@ end
query = Sale.select("count(distinct sale_orders.order_id) as total_order") query = Sale.select("count(distinct sale_orders.order_id) as total_order")
.joins(:sale_orders) .joins(:sale_orders)
.where("shop_code='#{current_shop.shop_code}'")
.completed .completed
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
@@ -2357,8 +2354,8 @@ def self.get_check_sale_data(transaction_date)
.group("sales.receipt_no,sales.sale_status") .group("sales.receipt_no,sales.sale_status")
end end
def paymal_payment_void def paymal_payment_void
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.shop_code) membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_actions_data = MembershipAction.find_by_membership_type_and_shop_code("void",self.shop_code) membership_actions_data = MembershipAction.find_by_membership_type("void")
if !membership_actions_data.nil? if !membership_actions_data.nil?
sale_payments =self.sale_payments.where("payment_reference is not null") sale_payments =self.sale_payments.where("payment_reference is not null")
if !sale_payments.empty? if !sale_payments.empty?

View File

@@ -36,7 +36,7 @@ class SalePayment < ApplicationRecord
def self.get_kbz_pay_amount(sale_id, current_user,shop) def self.get_kbz_pay_amount(sale_id, current_user,shop)
amount = 0 amount = 0
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).last
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
if !sale_payment.nil? and !kbz_pay_method.nil? if !sale_payment.nil? and !kbz_pay_method.nil?
if sale_payment.payment_status == 'pending' if sale_payment.payment_status == 'pending'
@@ -295,7 +295,7 @@ class SalePayment < ApplicationRecord
def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id) def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("create_payment"); # membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
sale_data = Sale.find_by_sale_id(sale_id) sale_data = Sale.find_by_sale_id(sale_id)
membership_actions_data = PaymentMethodSetting.find_by_payment_method_and_shop_code(payment_type,sale_data.shop_code) membership_actions_data = PaymentMethodSetting.find_by_payment_method(payment_type)
customer_data = Customer.find_by_customer_id(sale_data.customer_id) customer_data = Customer.find_by_customer_id(sale_data.customer_id)
if !membership_actions_data.nil? if !membership_actions_data.nil?
@@ -530,7 +530,7 @@ class SalePayment < ApplicationRecord
#Next time - validate if the vochure number is valid - within #Next time - validate if the vochure number is valid - within
account_no = self.payment_reference account_no = self.payment_reference
# self.sale.customer.update_attributes(paypar_account_no: ) # self.sale.customer.update_attributes(paypar_account_no: )
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.sale.shop_code) membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id) membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit #record an payment in sale-audit
@@ -783,8 +783,8 @@ class SalePayment < ApplicationRecord
overall_dis = sObj.total_discount overall_dis = sObj.total_discount
if credit != 1 if credit != 1
membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code) membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type_and_shop_code("get_member_campaign",sObj.shop_code) memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"] campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s auth_token = memberaction.auth_token.to_s
@@ -868,8 +868,8 @@ class SalePayment < ApplicationRecord
if total_amount >= 0 if total_amount >= 0
receipt_no = sObj.receipt_no receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code) membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type_and_shop_code("rebate",sObj.shop_code) memberaction = MembershipAction.find_by_membership_type("rebate")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"] campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s auth_token = memberaction.auth_token.to_s

View File

@@ -31,7 +31,7 @@ class SaleTax < ApplicationRecord
def self.get_tax(from,to) def self.get_tax(from,to)
query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount") query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount")
.joins("join sales on sales.sale_id = sale_taxes.sale_id") .joins("join sales on sales.sale_id = sale_taxes.sale_id")
.where("sales.shop_code=? and sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0",Shop.current_shop.shop_code, 'completed', from, to) .where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0", 'completed', from, to)
.group("sale_taxes.tax_name") .group("sale_taxes.tax_name")
end end

View File

@@ -28,7 +28,7 @@ class ShiftSale < ApplicationRecord
#find open shift where is open today and is not closed and login by current cashier #find open shift where is open today and is not closed and login by current cashier
#DATE(shift_started_at)=? and #DATE(shift_started_at)=? and
today_date = DateTime.now.strftime("%Y-%m-%d") today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("shop_code='#{current_user.shop_code}' and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take
return shift return shift
#end #end
end end

View File

@@ -68,6 +68,6 @@ class StockCheckItem < ApplicationRecord
end end
def self.delete_stock_check_item(item_code,shop) def self.delete_stock_check_item(item_code,shop)
self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all self.where("item_code=?", item_code).delete_all
end end
end end

View File

@@ -36,7 +36,7 @@ class StockJournal < ApplicationRecord
end end
def self.from_stock_check(item,shop) def self.from_stock_check(item,shop)
stock_journal = StockJournal.where("shop_code='#{shop.shop_code}' and item_code=?", item.item_code).order("id DESC").first stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first
if stock_journal.nil? if stock_journal.nil?
old_blance = 0 old_blance = 0
inventory_definition_id = InventoryDefinition.find_by_item_code_and_shop_code(item.item_code,shop.shop_code).id inventory_definition_id = InventoryDefinition.find_by_item_code_and_shop_code(item.item_code,shop.shop_code).id
@@ -79,7 +79,7 @@ class StockJournal < ApplicationRecord
end end
def self.delete_stock_journal(item_code,shop) def self.delete_stock_journal(item_code,shop)
self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all self.where("item_code=?", item_code).delete_all
end end
end end

View File

@@ -31,7 +31,7 @@ class OrderSummaryPdf < Prawn::Document
end end
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"z
if order[0].source =='app' if order[0].source =='app'
text "Mobile Order", :size => self.header_font_size,:align => :left text "Mobile Order", :size => self.header_font_size,:align => :left
move_down 1 move_down 1

View File

@@ -5,7 +5,7 @@ class ReceiptBillPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_account, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref) def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_account, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil, shop_details, printed_status, current_balance, card_data, other_charges_amount, latest_order_no, card_balance_amount, transaction_ref)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -72,6 +72,8 @@ class ReceiptBillPdf < Prawn::Document
else else
customer(customer_account,nil) customer(customer_account,nil)
end end
puts "Card data = >" +card_data
puts "Printed =>" + printed_status
#start card sale trans data #start card sale trans data
if card_data != nil if card_data != nil
card_sale_data(card_data) card_sale_data(card_data)

View File

@@ -308,6 +308,8 @@
$("#type").val("card"); $("#type").val("card");
} }
} }
$("#sxModal").hide();
//$("#filter_form").submit();
} }
} }

View File

@@ -175,8 +175,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
$("#filter_form").submit();
},100); },100);
}); });

View File

@@ -375,7 +375,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
},100); },100);
} }
}); });
@@ -395,7 +394,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val(); customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){ if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -497,6 +495,7 @@
$("#type").val("card"); $("#type").val("card");
} }
} }
$("#sxModal").hide();
} }
} }

View File

@@ -248,19 +248,29 @@
// Read Card Reader // Read Card Reader
$(".btn_member").on('click', function(){ $(".btn_member").on('click', function(){
var cardNo = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || "";
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#used_amount").text());
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide(); },100);
customer_mamber_card_no = $("#paypar_account_no").val(); });
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || "";
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#used_amount").text());
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) { if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0; customer_mamber_card_no = $("#membership_id").text() || 0;
} }
@@ -316,18 +326,7 @@
}else{ }else{
swal("Opp","Please Check Member","warning") swal("Opp","Please Check Member","warning")
} }
},100); $("#sxModal").hide();
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
} }
} }

View File

@@ -1150,43 +1150,172 @@ $(document).ready(function(){
// Read Card Reader // Read Card Reader
$(".btn_member").on('click', function(){ $(".btn_member").on('click', function(){
var cardNo = ""; $("#is_memberModal").hide();
$("#sxModal").attr('data-for', 'member');
$("#sxModal").show();
setTimeout(function(){
getCardNo();
},100);
});
function pay_with_card(cardNo) {
var sale_id = $("#sale_id").text() || 0;
var receipt_no = "";
if(($("#receipt_no").html() != undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#grand_total").text());
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/send_account" ,
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
$("#loading_wrapper").hide();
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
type: "POST",
url: "<%=foodcourt_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
success: function(result){
if(result.status == true){
swal({
title: "Information!",
text: result.message,
type: 'success',
html: true,
closeOnConfirm: true,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
$('.confirm').attr("disabled","disabled");
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
window.location.href = "<%= foodcourt_food_court_path %>";
}
});
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: data.message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
function member_card(cardNo) {
var customer_id = ''; var customer_id = '';
var customer_name = ''; var customer_name = '';
var membership_id = ''; var membership_id = '';
var membership_type = ''; var membership_type = '';
var sale_id = $("#sale_id").text() || 0; var sale_id = $("#sale_id").text() || 0;
var customer_mamber_card_no = 0;
$("#is_memberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
if(sale_id != 0 && cardNo != 0){
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/get_customer" ,
data: { filter : cardNo ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
} }
});
} }
},100); });
}); }
}
// Read NFC card no from java // Read NFC card no from java
function getCardNo(){ function getCardNo(){
@@ -1197,8 +1326,15 @@ $(document).ready(function(){
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
if ($("#sxModal").attr("data-for") == 'member') {
member_card(cardNo);
} else if ($("#sxModal").attr('data-for') == 'payment') {
pay_with_card(cardNo);
}
$("#sxModal").hide();
} }
} }
@@ -1460,138 +1596,13 @@ $(document).ready(function(){
// Read Card Reader - Paymal payment for FoodCourt // Read Card Reader - Paymal payment for FoodCourt
$(".btn_paymal_member").on('click', function (){ $(".btn_paymal_member").on('click', function (){
var cardNo = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#grand_total").text());
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
$("#sxModal").attr('data-for', 'payment');
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ var cardNo = setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/send_account" ,
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
$("#loading_wrapper").hide();
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
type: "POST",
url: "<%=foodcourt_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
success: function(result){
if(result.status == true){
swal({
title: "Information!",
text: result.message,
type: 'success',
html: true,
closeOnConfirm: true,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
$('.confirm').attr("disabled","disabled");
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
window.location.href = "<%= foodcourt_food_court_path %>";
}
});
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: data.message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
},100); },100);
setCardNo(cardNo);
}); });
// QR Code Reader // QR Code Reader

View File

@@ -396,7 +396,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
},100); },100);
} }
}); });
@@ -416,7 +415,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val(); customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){ if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -518,6 +516,7 @@
$("#type").val("card"); $("#type").val("card");
} }
} }
$("#sxModal").hide();
} }
} }

View File

@@ -265,7 +265,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){ if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -332,6 +331,7 @@
function setCardNo(cardNo){ function setCardNo(cardNo){
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
} }
} }

View File

@@ -259,7 +259,6 @@
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) { if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0; customer_mamber_card_no = $("#membership_id").text() || 0;
@@ -328,6 +327,7 @@
function setCardNo(cardNo){ function setCardNo(cardNo){
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
} }
} }

View File

@@ -1305,7 +1305,6 @@ $(document).ready(function(){
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){ if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -1342,6 +1341,7 @@ $(document).ready(function(){
function setCardNo(cardNo){ function setCardNo(cardNo){
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
} }
} }
@@ -1707,7 +1707,6 @@ $(document).ready(function(){
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ setTimeout(function(){
getCardNo(); getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) { if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0; customer_mamber_card_no = $("#membership_id").text() || 0;

View File

@@ -1,5 +1,5 @@
class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1] # class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1]
def change # def change
add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0 # add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0
end # end
end # end

View File

@@ -1,10 +1,10 @@
class CreateOutOfStocks < ActiveRecord::Migration[5.1] class CreateOutOfStocks < ActiveRecord::Migration[5.1]
def change # def change
create_table :out_of_stocks do |t| # create_table :out_of_stocks do |t|
t.datetime :date # t.datetime :date
t.string :item_instance_code # t.string :item_instance_code
t.timestamps # t.timestamps
end # end
end # end
end end