shop code
This commit is contained in:
@@ -25,7 +25,7 @@ class Api::AuthenticateController < Api::ApiController
|
||||
@employee = Employee.login(emp_id, password)
|
||||
if @employee && @employee.role == "cashier"
|
||||
if @employee.is_active
|
||||
shift = ShiftSale.current_open_shift(@employee.id)
|
||||
shift = ShiftSale.current_open_shift(@employee)
|
||||
if !shift.nil?
|
||||
@status = true
|
||||
@shift_id = shift.id
|
||||
|
||||
@@ -6,7 +6,7 @@ class Api::BillController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "Order ID or Booking ID is require to request for a bill."
|
||||
# if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||
if !ShiftSale.current_shift.nil?
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if (params[:booking_id])
|
||||
@@ -161,7 +161,7 @@ class Api::BillController < Api::ApiController
|
||||
@status, @booking = @order.generate
|
||||
|
||||
if @status && @booking
|
||||
shift = ShiftSale.current_open_shift(current_login_employee.id)
|
||||
shift = ShiftSale.current_open_shift(current_login_employee)
|
||||
if !shift.nil?
|
||||
cashier = Employee.find(shift.employee_id)
|
||||
if (@booking.booking_id)
|
||||
|
||||
@@ -18,17 +18,17 @@ class Api::CallWaitersController < ActionController::API
|
||||
# CallWaiterJob.perform_later(@table,@time)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids
|
||||
end
|
||||
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids
|
||||
# get printer info
|
||||
@shop = Shop.first
|
||||
unique_code = "CallWaiterPdf"
|
||||
# @shop = Shop.first
|
||||
unique_code = "CallWaiterPdf"
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class Api::OrdersController < Api::ApiController
|
||||
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||
# end
|
||||
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
puts "Hello world"
|
||||
puts @shop.to_json
|
||||
return @shop.to_json
|
||||
|
||||
@@ -14,11 +14,11 @@ class Api::Payment::MobilepaymentController < Api::ApiController
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
shop_detail = Shop.first
|
||||
# shop_detail = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if shop_detail.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
|
||||
@@ -19,14 +19,15 @@ class Api::SurveyController < Api::ApiController
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# puts params.to_json
|
||||
# set cashier
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
current_shift_user =Employee.find_by_id(current_shift.employee_id)
|
||||
if open_cashier.count>0
|
||||
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0])
|
||||
else
|
||||
shift_by_terminal = ShiftSale.current_open_shift(current_shift.employee_id)
|
||||
shift_by_terminal = ShiftSale.current_open_shift(current_shift_user)
|
||||
end
|
||||
|
||||
|
||||
if params[:survey][:id]>0
|
||||
survey = Survey.find(params[:survey][:id])
|
||||
else
|
||||
@@ -50,8 +51,8 @@ class Api::SurveyController < Api::ApiController
|
||||
|
||||
# private
|
||||
# def survey_params
|
||||
# params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner,
|
||||
# params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner,
|
||||
# :dining_name,:created_by,:total_customer,:total_amount)
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :order_reservation, :bank_integration
|
||||
helper_method :shop_detail,:order_reservation, :bank_integration
|
||||
# lookup domain for db from provision
|
||||
# before_action :set_locale
|
||||
# helper_method :current_company,:current_login_employee,:current_user
|
||||
@@ -17,4 +17,5 @@ class ApplicationController < ActionController::Base
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class BaseOrigamiController < ActionController::Base
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :current_token
|
||||
|
||||
@@ -15,16 +15,16 @@ class BaseOrigamiController < ActionController::Base
|
||||
redirect_to origami_dashboard_path
|
||||
end
|
||||
|
||||
def check_user
|
||||
if check_mobile
|
||||
def check_user
|
||||
if check_mobile
|
||||
if current_user.nil?
|
||||
return render status: 401, json: {
|
||||
message: "User using other device!"
|
||||
message: "User using other device!"
|
||||
}.to_json
|
||||
end
|
||||
else
|
||||
else
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -33,21 +33,22 @@ class BaseOrigamiController < ActionController::Base
|
||||
# CheckinJob.set(wait: 1.minute).perform_later()
|
||||
# end
|
||||
|
||||
##already in LoginVerification
|
||||
# Get current Cashier
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
# def get_cashier
|
||||
# @cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
# end
|
||||
|
||||
#check webview
|
||||
def check_mobile
|
||||
status = false
|
||||
authenticate_with_http_token do |token, options|
|
||||
authenticate_with_http_token do |token, options|
|
||||
if token
|
||||
session[:webview] = true
|
||||
session[:session_token] = token
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
|
||||
status = true
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ module LoginVerification
|
||||
|
||||
def current_shop
|
||||
begin
|
||||
shop_code ='262'
|
||||
shop_code ='263'
|
||||
@shop =Shop.find_by_shop_code(shop_code)
|
||||
return @shop
|
||||
rescue
|
||||
@@ -27,28 +27,29 @@ module LoginVerification
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = @shop.employees.find_by_token_session(session[:session_token])
|
||||
@employee = Employee.find_by_token_session_and_shop_code(session[:session_token],@shop.shop_code)
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= @shop.employees.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
@current_user ||= Employee.find_by_token_session_and_shop_code(session[:session_token],@shop.shop_code) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashiers
|
||||
def get_cashier
|
||||
@cashier = @shop.employees.where("role = 'cashier' AND token_session <> ''")
|
||||
@cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
shop_code ='262'
|
||||
shop_code ='263'
|
||||
@shop = Shop.find_by_shop_code(shop_code)
|
||||
return @shop
|
||||
end
|
||||
|
||||
#check order reservation used
|
||||
def order_reservation
|
||||
order_reserve = @shop.lookups.collection_of('order_reservation')
|
||||
order_reserve = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
|
||||
status = false
|
||||
if !order_reserve.empty?
|
||||
order_reserve.each do |order|
|
||||
@@ -64,7 +65,7 @@ module LoginVerification
|
||||
|
||||
#check bank integration used
|
||||
def bank_integration
|
||||
bank_integration = @shop.lookups.collection_of('bank_integration')
|
||||
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
|
||||
status = false
|
||||
if !bank_integration.empty?
|
||||
bank_integration.each do |bank|
|
||||
|
||||
@@ -21,7 +21,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
# paymal_customer = Customer.search_paypar_account_no(filter)
|
||||
# search account no from paypar
|
||||
if type == "card"
|
||||
|
||||
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if !@crm_customers.present?
|
||||
if response["status"] == true
|
||||
@@ -38,6 +38,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.shop_code = @shop.shop_code
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
flash[:member_notice]='Customer was successfully created.'
|
||||
@@ -70,7 +71,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
else
|
||||
flash[:member_error]="Need to press sync button "
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -95,7 +96,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
lookup_customer = Lookup.collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
||||
@create_flag = false
|
||||
end
|
||||
@@ -134,8 +135,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
params[:type] = nil
|
||||
params[:customer_id] = params[:id]
|
||||
@credit_sales = SalePayment.get_credit_sales(params)
|
||||
|
||||
@credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(params[:id])
|
||||
@response = Customer.get_membership_transactions(@customer)
|
||||
@@ -159,7 +160,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
def sync
|
||||
@customer = Customer.find(params[:id])
|
||||
@customer = Customer.find(params[:id])
|
||||
respond_to do |format|
|
||||
name = @customer.name
|
||||
phone = @customer.contact_no
|
||||
@@ -170,8 +171,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
card_no = @customer.card_no
|
||||
paypar_account_no = @customer.paypar_account_no
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = @customer.membership_type
|
||||
if !id.present? && !member_group_id.nil?
|
||||
member_group_id = @customer.membership_type
|
||||
if !id.present? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
@@ -179,7 +180,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
@@ -221,7 +222,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
Rails.logger.debug "--------Sync Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
@@ -252,14 +253,14 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
def create
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
def create
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
@checked_contact = Customer.find_by_contact_no(customer_params[:contact_no])
|
||||
if @checked_contact.nil?
|
||||
respond_to do |format|
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
|
||||
@crm_customers.shop_code = @shop.shop_code
|
||||
if @crm_customers.save
|
||||
# update tax profile
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
@@ -272,7 +273,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
nrc = customer_params[:nrc_no]
|
||||
card_no = customer_params[:card_no]
|
||||
paypar_account_no = customer_params[:paypar_account_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
if member_group_id.present?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -282,7 +283,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
@@ -333,7 +334,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
@@ -399,7 +400,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
# PATCH/PUT /crm/customers/1
|
||||
# PATCH/PUT /crm/customers/1.json
|
||||
def update
|
||||
# Remove "" default first
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
@checked_contact = nil
|
||||
@existed_contact = Customer.find_by_customer_id_and_contact_no(customer_params[:id], customer_params[:contact_no])
|
||||
@@ -409,7 +410,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
if !@existed_contact.nil? || @checked_contact.nil?
|
||||
respond_to do |format|
|
||||
if @crm_customer.update(customer_params)
|
||||
# update tax profile
|
||||
# update tax profile
|
||||
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
@@ -420,7 +421,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
card_no = customer_params[:card_no]
|
||||
paypar_account_no = customer_params[:paypar_account_no]
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = params[:member_group_id]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
if !id.present? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -430,7 +431,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
@@ -471,7 +472,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
Rails.logger.debug "--------Update Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
@@ -496,7 +497,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
@@ -601,7 +602,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
flash[:member_notice]='Membership was successfully updated'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -617,6 +618,5 @@ class Crm::CustomersController < BaseCrmController
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
class Crm::DiningQueuesController < BaseCrmController
|
||||
load_and_authorize_resource
|
||||
before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
|
||||
# GET /crm/dining_queues
|
||||
# GET /crm/dining_queues.json
|
||||
def index
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
|
||||
@complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
|
||||
|
||||
@dining_queues = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
|
||||
@complete_queue = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
|
||||
|
||||
if params[:term]
|
||||
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
|
||||
else
|
||||
@customer = Customer.all
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @customer.to_json }
|
||||
end
|
||||
end
|
||||
@@ -41,16 +41,16 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
def create
|
||||
puts dining_queue_params
|
||||
@dining_queue = DiningQueue.new(dining_queue_params)
|
||||
|
||||
@dining_queue.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @dining_queue.save
|
||||
|
||||
# unique_code = "QueueNoPdf"
|
||||
|
||||
# unique_code = "QueueNoPdf"
|
||||
|
||||
# # get printer info
|
||||
# print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer.print_queue_no(print_settings,@dining_queue)
|
||||
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' }
|
||||
@@ -88,7 +88,7 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
|
||||
def assign
|
||||
@queue = DiningQueue.find(params[:id])
|
||||
@tables = DiningFacility.where("status = 'available' ")
|
||||
@tables = DiningFacility.where("status = 'available' and shop_code='#{@shop.shop_code}' and type!='HotelRoom'")
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
@@ -105,42 +105,46 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
# type = "RoomBooking"
|
||||
# end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:table_id],:type => type,
|
||||
:checkin_at => Time.now.utc,:customer_id => queue.customer_id,:booking_status => "assign" })
|
||||
booking = Booking.create({:dining_facility_id => params[:table_id],
|
||||
:type => type,
|
||||
:checkin_at => Time.now.utc,
|
||||
:customer_id => queue.customer_id,
|
||||
:booking_status => "assign",
|
||||
:shop_code => @shop.shop_code})
|
||||
booking.save!
|
||||
|
||||
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
|
||||
# status = DiningFacility.find(table_id).update_attributes(status: "occupied")
|
||||
|
||||
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def cancel_queue
|
||||
queue = DiningQueue.find(params[:id])
|
||||
|
||||
status = queue.update_attributes(id: params[:id],status:"Cancel")
|
||||
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully canceled .'})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_queue
|
||||
@dining_queue = DiningQueue.find(params[:id])
|
||||
@dining_queue = DiningQueue.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_queue_params
|
||||
params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -18,8 +18,9 @@ class HomeController < ApplicationController
|
||||
|
||||
def index
|
||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
@employees = @shop.employees.all.where("is_active = true").order("name asc")
|
||||
@roles = @shop.employees.distinct.pluck(:role)
|
||||
@employees = Employee.all.where("shop_code='#{current_shop.shop_code}' and is_active = true").order("name asc")
|
||||
@roles = Employee.where("shop_code='#{current_shop.shop_code}'").distinct.pluck(:role)
|
||||
|
||||
# byebug
|
||||
# @roles = Lookup.collection_of("employee_roles")
|
||||
@login_form = LoginForm.new()
|
||||
@@ -36,7 +37,7 @@ class HomeController < ApplicationController
|
||||
@login_form = LoginForm.new()
|
||||
@login_form.emp_id = params[:emp_id]
|
||||
@login_form.password = params[:login_form][:password]
|
||||
@employee = Employee.login(@shop,@login_form.emp_id, @login_form.password)
|
||||
@employee = Employee.login(current_shop,@login_form.emp_id, @login_form.password)
|
||||
|
||||
if @employee != nil
|
||||
session[:session_token] = @employee.token_session
|
||||
@@ -51,7 +52,7 @@ class HomeController < ApplicationController
|
||||
@login_form = LoginForm.new()
|
||||
@login_form.emp_id = params[:login_form][:emp_id]
|
||||
@login_form.password = params[:login_form][:password]
|
||||
@employee = Employee.login(@shop,@login_form.emp_id, @login_form.password)
|
||||
@employee = Employee.login(current_shop,@login_form.emp_id, @login_form.password)
|
||||
|
||||
if @employee != nil
|
||||
if @employee.is_active
|
||||
@@ -94,21 +95,21 @@ class HomeController < ApplicationController
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@orders = @shop.sales::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@orders = @shop.sales::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@orders = @shop.sales::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@sales = @shop.sales::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@sales = @shop.sales::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@sales = @shop.sales::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top",@shop).sum('i.qty')
|
||||
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom",@shop).sum('i.qty')
|
||||
@@ -195,7 +196,7 @@ class HomeController < ApplicationController
|
||||
def route_by_role(employee)
|
||||
if employee.role == "administrator"
|
||||
# redirect_to dashboard_path
|
||||
shift = ShiftSale.current_open_shift(employee.id,@shop)
|
||||
shift = ShiftSale.current_open_shift(employee)
|
||||
if !shift.nil?
|
||||
redirect_to origami_root_path
|
||||
else
|
||||
@@ -203,7 +204,7 @@ class HomeController < ApplicationController
|
||||
end
|
||||
elsif employee.role == "cashier"
|
||||
#check if cashier has existing open cashier
|
||||
shift = ShiftSale.current_open_shift(employee.id,@shop)
|
||||
shift = ShiftSale.current_open_shift(employee)
|
||||
if !shift.nil?
|
||||
redirect_to origami_dashboard_path
|
||||
# redirect_to origami_root_path
|
||||
|
||||
@@ -3,16 +3,14 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(filter)
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(@shop,filter)
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||
|
||||
@stock_journals = StockJournal.where(item_code: inventory.item_code).order("id DESC")
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(inventory_definition_id,@shop.shop_code)
|
||||
@stock_journals = StockJournal.where("item_code=? and shop_code='#{@shop.shop_code}'",inventory.item_code).order("id DESC")
|
||||
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
|
||||
|
||||
respond_to do |format|
|
||||
@@ -20,12 +18,4 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# GET /inventory_definitions
|
||||
# GET /inventory_definitions.json
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.all
|
||||
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
# GET /inventory_definitions/1
|
||||
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
|
||||
# GET /inventory_definitions/new
|
||||
def new
|
||||
@menus = Menu.all
|
||||
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
end
|
||||
@@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code)
|
||||
if inventory.nil?
|
||||
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
@@ -39,6 +39,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
@inventory_definition.min_order_level = params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.shop_code = @shop.shop_code
|
||||
@inventory_definition.created_by = current_user.id
|
||||
if @inventory_definition.save
|
||||
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
|
||||
@@ -83,16 +84,16 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# DELETE /inventory_definitions/1
|
||||
# DELETE /inventory_definitions/1.json
|
||||
def destroy
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
@inventory_definition.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
|
||||
inventory = InventoryDefinition.find(params[:id])
|
||||
StockJournal.delete_stock_journal(inventory.item_code)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code)
|
||||
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
StockJournal.delete_stock_journal(inventory.item_code,@shop)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code,@shop)
|
||||
if !inventory.nil?
|
||||
inventory.destroy
|
||||
flash[:message] = 'Inventory was successfully destroyed.'
|
||||
@@ -103,16 +104,10 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_inventory_definition
|
||||
@inventory_definition = InventoryDefinition.find(params[:id])
|
||||
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
@@ -25,7 +25,6 @@ class Inventory::StockCheckItemsController < BaseInventoryController
|
||||
# POST /stock_check_items.json
|
||||
def create
|
||||
@stock_check_item = StockCheckItem.new(stock_check_item_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_check_item.save
|
||||
format.html { redirect_to inventory_stock_checks_path, notice: 'Stock check item was successfully created.' }
|
||||
@@ -61,12 +60,6 @@ class Inventory::StockCheckItemsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_check_item
|
||||
|
||||
@@ -8,19 +8,23 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
.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_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.where("inventory_definitions.shop_code='#{@shop.shop_code}'")
|
||||
.group("mi.menu_category_id")
|
||||
.order("mi.menu_category_id desc")
|
||||
unless !@category.nil?
|
||||
@category_id =@category[0].id
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
item_list = JSON.parse(params[:stock_item])
|
||||
reason = params[:reason]
|
||||
check = StockCheck.new
|
||||
@check = check.create(current_user, reason, item_list)
|
||||
@check = check.create(current_user, reason, item_list,@shop)
|
||||
end
|
||||
|
||||
def show
|
||||
@check = StockCheck.find(params[:id])
|
||||
@check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
|
||||
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])
|
||||
|
||||
@@ -28,31 +32,31 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
|
||||
def save_to_journal
|
||||
check = params[:data]
|
||||
stockCheck = StockCheck.find(check)
|
||||
stockCheck = StockCheck.find_by_id_and_shop_code(check,@shop.shop_code)
|
||||
stockCheck.stock_check_items.each do |item|
|
||||
StockJournal.from_stock_check(item)
|
||||
StockJournal.from_stock_check(item,@shop)
|
||||
end
|
||||
end
|
||||
|
||||
def print_stock_check
|
||||
stock_id = params[:stock_check_id] # sale_id
|
||||
stockcheck = StockCheck.find(stock_id)
|
||||
stockcheck = StockCheck.find_by_id_and_shop_code(stock_id,@shop.shop_code)
|
||||
stockcheck_items = stockcheck.stock_check_items
|
||||
member_info = nil
|
||||
unique_code = 'StockCheckPdf'
|
||||
|
||||
shop_details = current_shop
|
||||
checker = Employee.find(stockcheck.check_by)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
checker = Employee.find_by_id_and_shop_code(stockcheck.check_by,@shop.shop_code)
|
||||
print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
if !print_settings.nil?
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
|
||||
|
||||
#Pull this menu
|
||||
@menu_category = InventoryDefinition.search_by_category(params[:id])
|
||||
puts @menu_category.to_json
|
||||
|
||||
@@ -25,7 +25,7 @@ class StockJournalsController < ApplicationController
|
||||
# POST /stock_journals.json
|
||||
def create
|
||||
@stock_journal = StockJournal.new(stock_journal_params)
|
||||
|
||||
@stock_journal.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @stock_journal.save
|
||||
format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' }
|
||||
@@ -61,12 +61,6 @@ class StockJournalsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_journal
|
||||
|
||||
@@ -81,10 +81,4 @@ class Oqs::EditController < BaseOqsController
|
||||
render :json => {:status=> false, :message => "Not allowed over quantity!" }
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,13 +6,13 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
# @tables = DiningFacility.all.active.order('status desc')
|
||||
@tables = DiningFacility.where(:type => 'Table').order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@tables = DiningFacility.all.active.where("type = 'Table' and shop_code='#{@shop.shop_code}' ").order('status desc')
|
||||
@rooms = DiningFacility.all.active.where("type = 'Room' and shop_code='#{@shop.shop_code}' ").order('status desc')
|
||||
|
||||
@filter = params[:filter]
|
||||
|
||||
@queue_stations = OrderQueueStation.active
|
||||
|
||||
|
||||
# @queue_completed_item = completed_order(@filter)
|
||||
@queue_completed_item = all_order(@filter)
|
||||
if !@queue_completed_item.empty?
|
||||
@@ -49,7 +49,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
# zone_id = qid.zone_id
|
||||
# i=i+1
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
# end
|
||||
@@ -157,8 +157,8 @@ puts items.to_json
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status,oqs_id=nil,filter,table_id,delivery_status)
|
||||
if oqs_id != "0"
|
||||
def queue_items_query(status,oqs_id=nil,filter,table_id,delivery_status)
|
||||
if oqs_id != "0"
|
||||
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
else
|
||||
oqs = ''
|
||||
@@ -169,7 +169,7 @@ puts items.to_json
|
||||
elsif delivery_status == "Processed"
|
||||
queue_status = "and assigned_order_items.delivery_status = true "
|
||||
else
|
||||
queue_status = "and assigned_order_items.delivery_status = false "
|
||||
queue_status = "and assigned_order_items.delivery_status = false "
|
||||
end
|
||||
if !table_id.empty?
|
||||
tableId = table_id.to_a.map{|h| h}.join(",")
|
||||
@@ -178,12 +178,12 @@ puts items.to_json
|
||||
table = ''
|
||||
end
|
||||
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items,
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items,
|
||||
cus.name as customer_name, odt.created_at,
|
||||
assigned_order_items.delivery_status")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
@@ -234,7 +234,7 @@ puts items.to_json
|
||||
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")
|
||||
.where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
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}%",)
|
||||
.group("odt.order_items_id")
|
||||
.order("assigned_order_items.created_at desc")
|
||||
|
||||
@@ -242,7 +242,7 @@ puts items.to_json
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
# def queue_items_count_query(status,filter)
|
||||
# def queue_items_count_query(status,filter)
|
||||
# query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
|
||||
# .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
# left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -257,7 +257,7 @@ puts items.to_json
|
||||
|
||||
# end
|
||||
|
||||
def queue_items_count_query(status,filter)
|
||||
def queue_items_count_query(status,filter)
|
||||
# query = OrderQueueStation.all
|
||||
query = OrderQueueStation.select("order_queue_stations.id as station_id,
|
||||
(case when (count(odt.item_code)>0) then count(odt.item_code) else 0 end) as total")
|
||||
|
||||
@@ -7,10 +7,10 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.active.order('status desc')
|
||||
@all_room = Room.all.active.order('status desc')
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
||||
@all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
||||
end
|
||||
|
||||
def detail
|
||||
@@ -19,7 +19,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -28,10 +28,6 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@@ -140,7 +136,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@order.shop_code =@shop.shop_code
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
@@ -237,7 +233,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
|
||||
#Send to background job for processing
|
||||
order = Order.find(order_id)
|
||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
@@ -311,10 +307,4 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
return from
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# def set_dining
|
||||
# @dining = DiningFacility.find(params[:id])
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Origami::AlipayController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@alipaycount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_alipay = 0
|
||||
@member_discount = 0
|
||||
@@ -64,7 +64,7 @@ class Origami::AlipayController < BaseOrigamiController
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
@@ -86,8 +86,8 @@ class Origami::AlipayController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -10,33 +10,32 @@ class Origami::CashInsController < BaseOrigamiController
|
||||
payment_method_reference = params[:payment_method_reference]
|
||||
type = params[:type]
|
||||
p_jour = PaymentJournal.new
|
||||
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
|
||||
current_shift = ShiftSale.current_shift
|
||||
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
if shift
|
||||
shift = ShiftSale.current_open_shift(shift.id)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift.id)
|
||||
end
|
||||
else
|
||||
shift = Employee.find(current_shift.employee_id).name
|
||||
|
||||
end
|
||||
emp = Employee.find_by_id(shift.employee_id)
|
||||
shift = ShiftSale.current_open_shift(emp)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift)
|
||||
end
|
||||
else
|
||||
# shift = Employee.find(current_shift.employee_id).name
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
|
||||
puts shift.to_json
|
||||
shift.cash_in = shift.cash_in + amount.to_f
|
||||
shift.save
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -7,28 +7,29 @@ class Origami::CashOutsController < BaseOrigamiController
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
p_jour = PaymentJournal.new
|
||||
p_jour.cash_out(reference, remark, amount, current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
|
||||
current_shift = ShiftSale.current_shift
|
||||
p_jour.cash_out(reference, remark, amount, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
if shift
|
||||
shift = ShiftSale.current_open_shift(shift.id)
|
||||
emp = Employee.find_by_id(shift.employee_id)
|
||||
shift = ShiftSale.current_open_shift(emp)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift.id)
|
||||
shift = ShiftSale.current_open_shift(current_shift)
|
||||
end
|
||||
else
|
||||
shift = Employee.find(current_shift.employee_id).name
|
||||
|
||||
# shift = Employee.find(current_shift.employee_id).name
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
shift.cash_out = shift.cash_out + amount.to_i
|
||||
|
||||
@@ -9,7 +9,6 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
@creditcount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
@@ -32,7 +31,6 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
@@ -50,7 +48,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
|
||||
def create_credit_payment
|
||||
arr_sale = JSON.parse(params[:data])
|
||||
if !ShiftSale.current_shift.nil?
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil?
|
||||
if !arr_sale.nil?
|
||||
arr_sale.each do |arr_sale|
|
||||
arr_sale.each do |sale|
|
||||
|
||||
@@ -92,12 +92,12 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
@membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type")
|
||||
#get paypar accountno
|
||||
@paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no")
|
||||
#for create customer on/off
|
||||
@create_flag = true
|
||||
lookup_customer = Lookup.collection_of('customer_settings')
|
||||
lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
class Origami::DashboardController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@shop = Shop.first
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user)
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale('card', today, current_user)
|
||||
pay = Sale.payment_sale(@shop,'card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today, current_user)
|
||||
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
else
|
||||
@sale_data = nil
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user)
|
||||
@total_accounts = Sale.total_account(today,current_user)
|
||||
@total_order = Sale.total_order(@shop,today,current_user)
|
||||
@total_accounts = Sale.total_account(@shop,today,current_user)
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today,current_user)
|
||||
acc = Sale.account_data(@shop,account.account_id, today,current_user)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
@@ -39,28 +38,28 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
@account_data = nil
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today,current_user)
|
||||
@total_foc_items = Sale.total_foc_items(today,current_user)
|
||||
@top_items = Sale.top_items(@shop,today,current_user)
|
||||
@total_foc_items = Sale.total_foc_items(@shop,today,current_user)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@current_user = current_user
|
||||
#dine-in cashier
|
||||
dinein_cashier = Lookup.collection_of('dinein_cashier')
|
||||
dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
@dinein_cashier = 0
|
||||
if !dinein_cashier[0].nil?
|
||||
@dinein_cashier = dinein_cashier[0][1]
|
||||
end
|
||||
|
||||
#quick service
|
||||
quick_service = Lookup.collection_of('quick_service')
|
||||
quick_service = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service')
|
||||
@quick_service = 0
|
||||
if !quick_service[0].nil?
|
||||
@quick_service = quick_service[0][1]
|
||||
end
|
||||
|
||||
#fourt court
|
||||
food_court = Lookup.collection_of('food_court')
|
||||
food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court')
|
||||
@food_court = 0
|
||||
@food_court_name = nil
|
||||
if !food_court[0].nil?
|
||||
@@ -69,7 +68,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#order reservation
|
||||
order_reservation = Lookup.collection_of('order_reservation')
|
||||
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
|
||||
@order_reservation = 0
|
||||
if !order_reservation.empty?
|
||||
order_reservation.each do |order_reserve|
|
||||
@@ -80,7 +79,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#dashboard settings on/off for supervisor and cashier
|
||||
dashboard_settings = Lookup.collection_of('dashboard_settings')
|
||||
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings')
|
||||
@setting_flag = true
|
||||
if !dashboard_settings.empty?
|
||||
dashboard_settings.each do |setting|
|
||||
@@ -91,7 +90,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#reservation
|
||||
reservation = Lookup.collection_of('reservation')
|
||||
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation')
|
||||
@reservation = 0
|
||||
if !reservation.empty?
|
||||
reservation.each do |reserve|
|
||||
@@ -103,13 +102,13 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_all_menu
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'")
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params)
|
||||
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
|
||||
@@ -6,14 +6,14 @@ class Origami::DingaController < BaseOrigamiController
|
||||
@membership_rebate_balance=0
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = @sale_data.receipt_no
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
else
|
||||
new_total = @sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-@sale_data.grand_total
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
@rounding_adj = new_total-@sale_data.grand_total
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
@@ -77,12 +77,12 @@ def create
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
# shop_details = Shop.first
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
|
||||
@@ -21,8 +21,8 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@accounts = Account.all
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
@@ -87,7 +87,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class Origami::GiftVoucherController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = 0
|
||||
@gift_vouchercount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_gift_voucher = 0
|
||||
@member_discount = 0
|
||||
@@ -15,16 +15,16 @@ class Origami::GiftVoucherController < BaseOrigamiController
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
|
||||
others = 0
|
||||
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "gift_voucher"
|
||||
@gift_vouchercount = @gift_vouchercount + sale_payment.payment_amount
|
||||
@@ -48,13 +48,13 @@ class Origami::GiftVoucherController < BaseOrigamiController
|
||||
ref_no = params[:reference_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
@@ -64,8 +64,8 @@ class Origami::GiftVoucherController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -4,15 +4,14 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@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')
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@shop = shop_detail
|
||||
@occupied_table = DiningFacility.where("status='occupied'").count
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
end
|
||||
|
||||
# origami table detail
|
||||
@@ -21,20 +20,19 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@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')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
|
||||
@shop = shop_detail
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
@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}'")
|
||||
@order_items = Array.new
|
||||
@@ -106,16 +104,16 @@ class Origami::HomeController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#for bank integration
|
||||
@checkout_time = Lookup.collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
|
||||
|
||||
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
|
||||
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@tax_arr.push(acc.name)
|
||||
end
|
||||
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
@@ -123,7 +121,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
#for edit order on/off
|
||||
@edit_order_origami = true
|
||||
lookup_edit_order = Lookup.collection_of('edit_order')
|
||||
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
|
||||
if !lookup_edit_order.empty?
|
||||
lookup_edit_order.each do |edit_order|
|
||||
if edit_order[0].downcase == "editorderorigami"
|
||||
@@ -136,7 +134,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
|
||||
@@ -12,7 +12,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@jcbcount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_jcb = 0
|
||||
@member_discount= 0
|
||||
@@ -21,15 +21,15 @@ class Origami::JcbController < BaseOrigamiController
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
|
||||
others = 0
|
||||
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
@@ -66,13 +66,13 @@ class Origami::JcbController < BaseOrigamiController
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
@@ -87,8 +87,8 @@ class Origami::JcbController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -11,14 +11,14 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
@cashier_id = current_user.emp_id
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "JunctionPay"
|
||||
@junction_pay_count = @junction_pay_count + sale_payment.payment_amount
|
||||
@@ -32,7 +32,7 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -52,13 +52,13 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
|
||||
@@ -12,7 +12,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@mastercount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_master = 0
|
||||
@member_discount = 0
|
||||
@@ -21,15 +21,15 @@ class Origami::MasterController < BaseOrigamiController
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
|
||||
others = 0
|
||||
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
@@ -63,13 +63,13 @@ class Origami::MasterController < BaseOrigamiController
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
@@ -85,8 +85,8 @@ class Origami::MasterController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Origami::MpuController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@mpucount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_mpu = 0
|
||||
@member_discount = 0
|
||||
@@ -20,15 +20,15 @@ class Origami::MpuController < BaseOrigamiController
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
|
||||
others = 0
|
||||
|
||||
|
||||
if @shop.is_rounding_adj && (!path.include? ("credit_payment"))
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
@@ -64,13 +64,13 @@ class Origami::MpuController < BaseOrigamiController
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
@@ -85,8 +85,8 @@ class Origami::MpuController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,6 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
@order = OrderReservation.latest_order #.active
|
||||
@count_on_order = OrderReservation.get_count_on_order
|
||||
@count_on_completed = OrderReservation.get_count_on_completed
|
||||
@shop = Shop.find_by_id(1)
|
||||
@receipt_bill = check_receipt_bill
|
||||
end
|
||||
|
||||
@@ -23,7 +22,7 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
|
||||
order_reserve = OrderReservation.find_by_transaction_ref(params[:ref_no])
|
||||
if !order_reserve.nil?
|
||||
if !ShiftSale.current_shift.nil?
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil?
|
||||
if @status == "processed"
|
||||
if order_reserve.status == "accepted"
|
||||
result = OrderReservation.create_doemal_order(order_reserve,current_user)
|
||||
@@ -87,7 +86,7 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
def send_status
|
||||
order_reservation = OrderReservation.find_by_transaction_ref(params[:ref_no])
|
||||
if !order_reservation.nil?
|
||||
if !ShiftSale.current_shift.nil? || params[:status] == 'accepted' || (order_reservation.status == 'new' && params[:status] == 'rejected')
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil? || params[:status] == 'accepted' || (order_reservation.status == 'new' && params[:status] == 'rejected')
|
||||
response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],params[:status],params[:waiting_time],params[:min_type],params[:reason])
|
||||
else
|
||||
response = { status: false, message: 'No current shift open for this employee!'}
|
||||
@@ -99,12 +98,12 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_order_info
|
||||
order_reservation = OrderReservation.where("status = 'new'").count()
|
||||
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{@shop.shop_code}'").count()
|
||||
render :json => order_reservation
|
||||
end
|
||||
|
||||
def check_receipt_bill
|
||||
receipt_bill = Lookup.collection_of("order_reservation")
|
||||
receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation")
|
||||
|
||||
status = 0
|
||||
if !receipt_bill.nil?
|
||||
|
||||
@@ -6,14 +6,14 @@ class Origami::PaymalController < BaseOrigamiController
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = sale_data.receipt_no
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
# @rounding_adj = sale_data.rounding_adjustment
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
# @rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
@@ -72,16 +72,16 @@ def create
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
puts params.to_json
|
||||
puts params.to_json
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
|
||||
@@ -17,7 +17,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
@@ -32,7 +32,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
@@ -63,7 +63,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer = Customer.find(sale_data.customer_id)
|
||||
# rounding adjustment
|
||||
if shop_detail.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = new_total - sale_data.grand_total
|
||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
@@ -76,14 +76,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
|
||||
# find order id by sale id
|
||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
@@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
@@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_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 = {
|
||||
:filepath => filename,
|
||||
@@ -144,7 +144,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#shop_detail = Shop.first
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if shop_detail.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
@@ -178,7 +178,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
bookings = Booking.find_by_sale_id(sale_id)
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
@@ -198,7 +198,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Print
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
@@ -226,7 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
@@ -281,14 +281,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_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
|
||||
@@ -313,7 +313,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def show
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -333,7 +333,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@membership_rebate_balance=0
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -358,17 +358,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
@@ -379,7 +379,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
@shop = shop_detail #show shop info
|
||||
# @shop = shop_detail #show shop info
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
|
||||
@@ -436,7 +436,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@@ -450,7 +450,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
@@ -546,7 +546,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
@@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -664,7 +664,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
@@ -687,7 +687,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
printer = PrintSetting.all
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -702,7 +702,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
@@ -711,7 +711,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -745,7 +745,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
def rounding_adj
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
@shop = shop_detail
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -770,9 +769,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if cashier_type.strip.downcase == "doemal_order"
|
||||
unique_code = "ReceiptBillOrderPdf"
|
||||
else
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
@@ -795,7 +794,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
payment_method = "paypar"
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
end
|
||||
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
status,msg =sale_payment.process_payment(saleObj, current_user, redeem_amount,payment_method)
|
||||
if status == true
|
||||
@@ -28,5 +28,5 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@sale = Sale.pending_sale(@cashier_type)
|
||||
@order = Sale.pending_order(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type,@shop.shop_code)
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
|
||||
@occupied_table = @sale.count.length + @order.count.length
|
||||
@@ -36,7 +36,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@sales = Sale.pending_sale(@cashier_type)
|
||||
@orders = Sale.pending_order(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type,@shop.shop_code)
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
|
||||
@occupied_table = @sales.count.length + @orders.count.length
|
||||
@@ -46,7 +46,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@sales = Sale.pending_sale(@cashier_type)
|
||||
@orders = Sale.pending_order(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type,@shop.shop_code)
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
|
||||
@occupied_table = @sales.count.length + @orders.count.length
|
||||
@@ -81,7 +81,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@sales = Sale.pending_sale(@cashier_type)
|
||||
@orders = Sale.pending_order(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type)
|
||||
@completed = Sale.completed_sale(@cashier_type,@shop.shop_code)
|
||||
|
||||
@occupied_table = @sales.count.length + @orders.count.length
|
||||
|
||||
|
||||
@@ -13,16 +13,12 @@ class Origami::QuickServiceController < ApplicationController
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all
|
||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}'")
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@cashier_type = "quick_service"
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -31,9 +27,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
|
||||
#checked quick_service only
|
||||
@quick_service_only = false
|
||||
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
||||
puts 'lookup_dine_in!!!!'
|
||||
puts lookup_dine_in
|
||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quickservice_add_order')
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "quickserviceaddorder"
|
||||
@@ -121,7 +115,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
order.waiters = current_login_employee.name
|
||||
order.employee_name = current_login_employee.name
|
||||
|
||||
|
||||
order.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
# @rounding_adj = sale_data.rounding_adjustment
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
# @rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
@@ -68,5 +68,5 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
end
|
||||
# Print Request Bill and add to sale tables
|
||||
def print
|
||||
if !ShiftSale.current_shift.nil?
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil?
|
||||
order_id = params[:id] # order_id
|
||||
order = Order.find(order_id)
|
||||
booking = order.booking
|
||||
@@ -45,7 +45,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(sale_data)
|
||||
Promotion.promo_activate(sale_data,@shop.shop_code)
|
||||
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
@@ -62,14 +62,14 @@ class Origami::RequestBillsController < ApplicationController
|
||||
render :json => result.to_json
|
||||
else
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
if !booking.dining_facility_id.nil?
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
@@ -2,37 +2,35 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
def index
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@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')
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@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")
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code)
|
||||
|
||||
@shop = Shop.first
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@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}' ")
|
||||
@order_items = Array.new
|
||||
@dining_room.each do |booking|
|
||||
@@ -91,7 +89,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@sale_taxes = []
|
||||
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
@@ -105,7 +103,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
# @room.bookings.each do |booking|
|
||||
# if booking.sale_id.nil?
|
||||
# @order_items = Array.new
|
||||
|
||||
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# @obj = order
|
||||
@@ -148,7 +146,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
lookup_edit_order = Lookup.collection_of('edit_order')
|
||||
if !lookup_edit_order.empty?
|
||||
lookup_edit_order.each do |edit_order|
|
||||
if edit_order[0].downcase == "editorderorigami"
|
||||
if edit_order[0].downcase == "editorderorigami"
|
||||
if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter')
|
||||
@edit_order_origami = false
|
||||
end
|
||||
@@ -161,8 +159,8 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -163,9 +163,9 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
sale.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
|
||||
end
|
||||
|
||||
# make cancel void item
|
||||
@@ -195,7 +195,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
end
|
||||
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" )
|
||||
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@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")
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
|
||||
@@ -4,7 +4,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
def show
|
||||
@cashier_type = params[:type]
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
#for bank integration
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
@@ -56,7 +56,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
cashier_terminal.save
|
||||
|
||||
#add shift_sale_id to card_settle_trans
|
||||
bank_integration = Lookup.find_by_lookup_type('bank_integration')
|
||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
|
||||
if !bank_integration.nil?
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
@@ -74,7 +74,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
@@ -92,7 +92,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
if @lookup.to_i == 1
|
||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||
other_charges = Sale.get_other_charges()
|
||||
@@ -129,7 +129,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
Employee.logout(session[:session_token])
|
||||
Employee.logout(@shop,session[:session_token])
|
||||
session[:session_token] = nil
|
||||
end
|
||||
|
||||
@@ -137,7 +137,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def sale_summary
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
# @shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
|
||||
@@ -100,7 +100,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
|
||||
status = false
|
||||
if !ShiftSale.current_shift.nil?
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if !params[:booking_id].empty?
|
||||
@@ -133,7 +133,8 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
|
||||
:booking_status => "assign" })
|
||||
:booking_status => "assign",
|
||||
:shop_code =>@shop.shop_code})
|
||||
|
||||
if !orders.nil?
|
||||
orders.each do |order|
|
||||
@@ -333,7 +334,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale_data)
|
||||
Promotion.promo_activate(sale_data,@shop.shop_code)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
@@ -358,6 +359,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
order.waiters = current_user.name
|
||||
order.employee_name = current_user.name
|
||||
order.guest_info = nil
|
||||
order.shop_code = @shop.shop_code
|
||||
order.save!
|
||||
|
||||
return order
|
||||
@@ -410,10 +412,4 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
render :json => { status: true }
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,9 +2,9 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
def new
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
|
||||
|
||||
@survey = Survey.new
|
||||
@id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
@@ -18,8 +18,8 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
if @booking.dining_facility_id.to_i>0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
|
||||
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
@@ -27,14 +27,14 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@dining_facility = nil
|
||||
@table_type = nil
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
@dining_facility = DiningFacility.find(@id)
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
|
||||
end
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -43,38 +43,40 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
if params[:table_id].to_i>0
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
if params[:sale_id].to_i > 0
|
||||
# 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)
|
||||
# set cashier
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
if open_cashier.count>0
|
||||
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
else
|
||||
shift_by_terminal = ShiftSale.current_open_shift(current_shift.employee_id)
|
||||
end
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
# 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)
|
||||
# set cashier
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
current_shift_user =Employee.find_by_id(current_user.employee_id)
|
||||
if open_cashier.count>0
|
||||
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0])
|
||||
else
|
||||
shift_by_terminal = ShiftSale.current_open_shift(current_shift_user)
|
||||
end
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
|
||||
|
||||
if @type == "quick_service" || @type == "food_court"
|
||||
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
|
||||
else
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
end
|
||||
|
||||
|
||||
|
||||
if params[:survey_id].nil? || params[:survey_id] == ""
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.shift_id = shift_by_terminal.id
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
@survey.shop_code = @shop.shop_code
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
redirect_to @url
|
||||
@@ -106,5 +108,5 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
def survey_params
|
||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
shop = Shop.first
|
||||
# shop = Shop.first
|
||||
puts "table bookig lenght"
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
@@ -11,7 +11,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
# rounding adjustment
|
||||
if shop.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -32,16 +32,17 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def show
|
||||
# puts 'Catch me if you can.......................'
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
shop = Shop.first
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
# shop = Shop.first
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
# rounding adjustment
|
||||
if shop.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -49,7 +50,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale.grand_total)
|
||||
sale.rounding_adjustment = new_total-sale.grand_total
|
||||
sale.update_attributes(grand_total: new_total,old_grand_total: sale.grand_total,rounding_adjustment:sale.rounding_adjustment)
|
||||
sale.update_attributes(grand_total: new_total,old_grand_total: sale.grand_total,rounding_adjustment:sale.rounding_adjustment)
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
@@ -64,7 +65,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
@status_sale = 'sale'
|
||||
@customer = @sale.customer
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
|
||||
@@ -11,7 +11,7 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@unionpaycount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_unionpay = 0
|
||||
@member_discount = 0
|
||||
@@ -21,13 +21,13 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
@@ -61,15 +61,15 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
path = request.fullpath
|
||||
@@ -83,8 +83,8 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@visacount = 0
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_visa = 0
|
||||
@member_discount = 0
|
||||
@@ -19,7 +19,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
@@ -27,7 +27,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
@@ -61,15 +61,15 @@ class Origami::VisaController < BaseOrigamiController
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
path = request.fullpath
|
||||
@@ -83,8 +83,8 @@ class Origami::VisaController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
end
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
@@ -115,10 +115,8 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
@@ -126,7 +124,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.all
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -141,13 +139,13 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -8,14 +8,14 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
@vouchercount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "voucher"
|
||||
@vouchercount = @vouchercount + sale_payment.payment_amount
|
||||
|
||||
@@ -55,7 +55,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
end
|
||||
# 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 )
|
||||
@@ -88,10 +88,8 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
@@ -99,7 +97,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.all
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -115,13 +113,13 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController
|
||||
# GET /print_settings/1
|
||||
# GET /print_settings/1.json
|
||||
def show
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
end
|
||||
|
||||
# GET /print_settings/new
|
||||
@@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# GET /print_settings/1/edit
|
||||
def edit
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
@server_mode = ENV["SERVER_MODE"]
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ class PrintSettingsController < ApplicationController
|
||||
# POST /print_settings.json
|
||||
def create
|
||||
@print_setting = PrintSetting.new(print_setting_params)
|
||||
|
||||
@print_setting.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @print_setting.save
|
||||
format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' }
|
||||
@@ -48,7 +48,7 @@ class PrintSettingsController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @print_setting.update(print_setting_params)
|
||||
if @print_setting.unique_code == 'CloseCashierPdf'
|
||||
Lookup.save_shift_sale_items_settings(params[:shift_sale_items])
|
||||
Lookup.save_shift_sale_items_settings(params[:shift_sale_items],@shop.shop_code)
|
||||
end
|
||||
|
||||
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }
|
||||
@@ -68,8 +68,8 @@ class PrintSettingsController < ApplicationController
|
||||
render :json => {:status=> "Success", :url => print_settings_url }.to_json
|
||||
end
|
||||
|
||||
def get_printer_options
|
||||
printer_name = params[:printer_name]
|
||||
def get_printer_options
|
||||
printer_name = params[:printer_name]
|
||||
printer_options = Printer::PrinterWorker.printer_options(printer_name)
|
||||
options = {
|
||||
:url => printer_options['device-uri'],
|
||||
|
||||
@@ -24,9 +24,9 @@ authorize_resource :class => false
|
||||
end
|
||||
end
|
||||
|
||||
@lookup = Lookup.find_by_lookup_type('reprint_receipt')
|
||||
@lookup = Lookup.find_by_lookup_type_and_shop_code('reprint_receipt',@shop.shop_code)
|
||||
if @lookup.nil?
|
||||
@lookup = Lookup.create_reprint_receipt_lookup
|
||||
@lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code)
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
@@ -152,7 +152,7 @@ authorize_resource :class => false
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
|
||||
@@ -5,7 +5,7 @@ class Settings::AccountsController < ApplicationController
|
||||
# GET /settings/accounts
|
||||
# GET /settings/accounts.json
|
||||
def index
|
||||
@settings_accounts = Account.all
|
||||
@settings_accounts = Account.all.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
# GET /settings/accounts/1
|
||||
@@ -26,6 +26,7 @@ class Settings::AccountsController < ApplicationController
|
||||
# POST /settings/accounts.json
|
||||
def create
|
||||
@settings_account = Account.new(account_params)
|
||||
@settings_account.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_account.save
|
||||
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully created.' }
|
||||
|
||||
@@ -28,7 +28,7 @@ class Settings::CashierTerminalsController < ApplicationController
|
||||
# POST /settings/cashier_terminals.json
|
||||
def create
|
||||
@settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params)
|
||||
|
||||
@settings_cashier_terminal.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_cashier_terminal.save
|
||||
format.html { redirect_to settings_cashier_terminals_path, notice: 'Cashier terminal was successfully created.' }
|
||||
|
||||
@@ -18,7 +18,7 @@ class Settings::CommissionersController < ApplicationController
|
||||
def new
|
||||
@commissioner = Commissioner.new
|
||||
@employee = Employee.all.order('name asc')
|
||||
|
||||
|
||||
end
|
||||
|
||||
# GET /commissioners/1/edit
|
||||
@@ -30,6 +30,7 @@ class Settings::CommissionersController < ApplicationController
|
||||
def create
|
||||
@commissioner = Commissioner.new(commissioner_params)
|
||||
@commissioner.created_by = current_user.id
|
||||
@commissioner.shop_code = @shop.shop_code
|
||||
unless @commissioner.joined_date.nil?
|
||||
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
|
||||
@@ -31,6 +31,7 @@ class Settings::CommissionsController < ApplicationController
|
||||
@commission = Commission.new(commission_params)
|
||||
@commission.product_type = 'menu_item'
|
||||
@commission.product_code = "[]"
|
||||
@commission.shop_code = @shop.shop_code
|
||||
|
||||
respond_to do |format|
|
||||
if @commission.save
|
||||
@@ -74,7 +75,7 @@ class Settings::CommissionsController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commission
|
||||
|
||||
@@ -31,7 +31,7 @@ class Settings::EmployeesController < ApplicationController
|
||||
# POST /employees.json
|
||||
def create
|
||||
@employee = Employee.new(employee_params)
|
||||
|
||||
@employee.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @employee.save
|
||||
format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' }
|
||||
|
||||
@@ -25,7 +25,7 @@ class Settings::LookupsController < ApplicationController
|
||||
# POST /settings/lookups.json
|
||||
def create
|
||||
@settings_lookup = Lookup.new(settings_lookup_params)
|
||||
|
||||
@settings_lookup.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_lookup.save
|
||||
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' }
|
||||
|
||||
@@ -26,7 +26,7 @@ class Settings::MembershipActionsController < ApplicationController
|
||||
# POST /settings/membership_actions.json
|
||||
def create
|
||||
@settings_membership_action = MembershipAction.new(settings_membership_action_params)
|
||||
|
||||
@settings_membership_action.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_membership_action.save
|
||||
format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' }
|
||||
|
||||
@@ -26,7 +26,7 @@ class Settings::MembershipSettingsController < ApplicationController
|
||||
# POST /settings/membership_settings.json
|
||||
def create
|
||||
@settings_membership_setting = MembershipSetting.new(settings_membership_setting_params)
|
||||
|
||||
@settings_membership_setting.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_membership_setting.save
|
||||
format.html { redirect_to settings_membership_settings_path, notice: 'Membership setting was successfully created.' }
|
||||
|
||||
@@ -5,7 +5,7 @@ class Settings::MenusController < ApplicationController
|
||||
# GET /settings/menus
|
||||
# GET /settings/menus.json
|
||||
def index
|
||||
@settings_menus = Menu.all.page(params[:page]).per(10)
|
||||
@settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xlsx
|
||||
@@ -32,6 +32,7 @@ class Settings::MenusController < ApplicationController
|
||||
def create
|
||||
@settings_menu = Menu.new(settings_menu_params)
|
||||
@settings_menu.created_by = current_login_employee.name
|
||||
@settings_menu.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_menu.save
|
||||
format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' }
|
||||
@@ -73,7 +74,7 @@ class Settings::MenusController < ApplicationController
|
||||
end
|
||||
|
||||
def export
|
||||
@settings_menus = Menu.all.page(params[:page]).per(10)
|
||||
@settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10)
|
||||
menu = Menu.find(params[:id])
|
||||
|
||||
p = Axlsx::Package.new
|
||||
@@ -93,17 +94,17 @@ class Settings::MenusController < ApplicationController
|
||||
:alignment => { :horizontal => :left,
|
||||
:vertical => :center ,
|
||||
:header_text => true}
|
||||
|
||||
|
||||
# Menu Sheet
|
||||
wb.add_worksheet(name: menu.name,is_ordering: menu.is_ordering) do |sheet|
|
||||
sheet.add_row ["Name",menu.name,"is_ordering",menu.is_ordering], :style=>title
|
||||
sheet.add_row ["Name",menu.name,"is_ordering",menu.is_ordering], :style=>title
|
||||
sheet.add_row
|
||||
|
||||
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default", "Image Path"], :style=>header_text
|
||||
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default", "Image Path"], :style=>header_text
|
||||
menu.menu_categories.each do |mc|
|
||||
mc.menu_items.each do |mi|
|
||||
attributes = ""
|
||||
i=0
|
||||
mc.menu_items.each do |mi|
|
||||
attributes = ""
|
||||
i=0
|
||||
if mi.item_attributes.length > 0
|
||||
mi.item_attributes.each do |mia|
|
||||
attribute = MenuItemAttribute.find(mia)
|
||||
@@ -111,8 +112,8 @@ class Settings::MenusController < ApplicationController
|
||||
attributes = attributes + attribute.name
|
||||
else
|
||||
attributes = attributes + attribute.name + ","
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
image_path = ""
|
||||
@@ -128,8 +129,8 @@ class Settings::MenusController < ApplicationController
|
||||
options = options + option.name
|
||||
else
|
||||
options = options + option.name + ","
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -141,8 +142,8 @@ class Settings::MenusController < ApplicationController
|
||||
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default, image_path], :style=>wrap_text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
directory_name = "public/menus"
|
||||
@@ -154,9 +155,9 @@ class Settings::MenusController < ApplicationController
|
||||
|
||||
def import
|
||||
if params[:file]
|
||||
status = Menu.import(params[:file], current_user.name)
|
||||
status = Menu.import(params[:file], current_user.name,@shop)
|
||||
redirect_to settings_menus_path, notice: status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -32,6 +32,7 @@ class Settings::OrderQueueStationsController < ApplicationController
|
||||
@settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params)
|
||||
@settings_order_queue_station.created_by = current_login_employee.name
|
||||
@settings_order_queue_station.processing_items = "[]"
|
||||
@settings_order_queue_station.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_order_queue_station.save
|
||||
format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' }
|
||||
@@ -77,7 +78,7 @@ class Settings::OrderQueueStationsController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_order_queue_station
|
||||
|
||||
@@ -26,7 +26,7 @@ class Settings::PaymentMethodSettingsController < ApplicationController
|
||||
# POST /settings/payment_method_settings.json
|
||||
def create
|
||||
@settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params)
|
||||
|
||||
@settings_payment_method_settings.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_payment_method_setting.save
|
||||
format.html { redirect_to settings_payment_method_settings_path, notice: 'Payment method setting was successfully created.' }
|
||||
|
||||
@@ -26,9 +26,10 @@ load_and_authorize_resource except: [:create]
|
||||
# POST /settings/products
|
||||
# POST /settings/products.json
|
||||
def create
|
||||
|
||||
|
||||
@settings_product = Product.new(settings_product_params)
|
||||
@settings_product.created_by = current_user.name
|
||||
@settings_product.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_product.save
|
||||
format.html { redirect_to settings_products_path, notice: 'Product was successfully created.' }
|
||||
@@ -71,7 +72,7 @@ load_and_authorize_resource except: [:create]
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_product
|
||||
|
||||
@@ -30,6 +30,7 @@ class Settings::PromotionsController < ApplicationController
|
||||
def create
|
||||
@promotion = Promotion.new(promotion_params)
|
||||
@promotion.created_by = current_login_employee.id
|
||||
@promotion.shop_code = @shop.shop_code
|
||||
if !@promotion.promo_start_hour.nil?
|
||||
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
end
|
||||
@@ -126,7 +127,7 @@ class Settings::PromotionsController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_promotion
|
||||
|
||||
@@ -29,6 +29,7 @@ class Settings::RoomsController < ApplicationController
|
||||
@settings_room.type = DiningFacility::ROOM_TYPE
|
||||
@settings_room.zone_id = params[:zone_id]
|
||||
@settings_room.created_by = current_login_employee.name
|
||||
@settings_room.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_room.save
|
||||
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' }
|
||||
|
||||
@@ -56,9 +56,9 @@ class Settings::ShopsController < ApplicationController
|
||||
audio_data = @settings_shop.display_images.find_by_name("order_audio").image
|
||||
delete_path = Rails.root.join("public/#{audio_data}")
|
||||
if File.exists?(delete_path)
|
||||
File.delete(delete_path)
|
||||
end
|
||||
end
|
||||
File.delete(delete_path)
|
||||
end
|
||||
end
|
||||
save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}")
|
||||
File.open(save_path, 'wb') do |f|
|
||||
f.write a.read
|
||||
|
||||
@@ -28,6 +28,7 @@ class Settings::TablesController < ApplicationController
|
||||
@settings_table = Table.new(settings_table_params)
|
||||
@settings_table.type = DiningFacility::TABLE_TYPE
|
||||
@settings_table.zone_id = params[:zone_id]
|
||||
@settings_table.shop_code = @shop.shop_code
|
||||
@settings_table.created_by = current_login_employee.name
|
||||
respond_to do |format|
|
||||
if @settings_table.save
|
||||
|
||||
@@ -47,7 +47,7 @@ class Settings::TaxProfilesController < ApplicationController
|
||||
def create
|
||||
@settings_tax_profile = TaxProfile.new(settings_tax_profile_params)
|
||||
@settings_tax_profile.created_by = current_login_employee.name
|
||||
|
||||
@settings_tax_profile.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_tax_profile.save
|
||||
format.html { redirect_to settings_tax_profiles_path, notice: 'Tax profile was successfully created.' }
|
||||
|
||||
@@ -5,7 +5,7 @@ class Settings::ZonesController < ApplicationController
|
||||
# GET /settings/zones
|
||||
# GET /settings/zones.json
|
||||
def index
|
||||
@settings_zones = Zone.all
|
||||
@settings_zones = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
||||
end
|
||||
|
||||
# GET /settings/zones/1
|
||||
@@ -28,6 +28,7 @@ class Settings::ZonesController < ApplicationController
|
||||
# POST /settings/zones.json
|
||||
def create
|
||||
@settings_zone = Zone.new(settings_zone_params)
|
||||
@settings_zone.shop_code =@shop.shop_code
|
||||
@settings_zone.created_by = current_login_employee.name
|
||||
respond_to do |format|
|
||||
if @settings_zone.save
|
||||
|
||||
@@ -9,16 +9,16 @@ class Transactions::BookingsController < ApplicationController
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@bookings = Booking.all.order("sale_id desc")
|
||||
@bookings = Booking.where("shop_code='#{@shop.shop_code}'").order("sale_id desc")
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
|
||||
else
|
||||
booking = Booking.search(filter,from,to)
|
||||
booking = Booking.search(filter,from,to).where("bookings.shop_code='#{@shop.shop_code}'")
|
||||
if booking.count > 0
|
||||
@bookings = booking
|
||||
@bookings = booking
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
|
||||
else
|
||||
@bookings = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
@receipt_no = filter
|
||||
@from = from
|
||||
@@ -33,7 +33,7 @@ class Transactions::BookingsController < ApplicationController
|
||||
# GET /transactions/bookings/1
|
||||
# GET /transactions/bookings/1.json
|
||||
def show
|
||||
|
||||
|
||||
@booking = Booking.find(params[:id])
|
||||
@order = nil
|
||||
@order_items = []
|
||||
@@ -45,7 +45,7 @@ class Transactions::BookingsController < ApplicationController
|
||||
end
|
||||
if @booking.sale_id.present?
|
||||
@sale = Sale.find(@booking.sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
|
||||
@@ -89,8 +89,8 @@ class Transactions::SalesController < ApplicationController
|
||||
# GET /transactions/sales/1
|
||||
# GET /transactions/sales/1.json
|
||||
def show
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'")
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}' and is_active='1'")
|
||||
@sale = Sale.find(params[:id])
|
||||
|
||||
@order_items = []
|
||||
|
||||
@@ -36,17 +36,18 @@ class AssignedOrderItem < ApplicationRecord
|
||||
assigned_order_item.order_queue_station = order_queue_station
|
||||
assigned_order_item.print_status = false
|
||||
assigned_order_item.delivery_status = false
|
||||
assigned_order_item.shop_code =order.shop_code
|
||||
assigned_order_item.save!
|
||||
end
|
||||
|
||||
def self.assigned_order_item_by_job(order_id)
|
||||
order_item = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
assigned_order_items.order_queue_station_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_instance_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
assigned_order_items.order_queue_station_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_instance_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
|
||||
@@ -127,4 +127,9 @@ class Booking < ApplicationRecord
|
||||
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
|
||||
end
|
||||
end
|
||||
def generate_custom_id
|
||||
if self.booking_id.nil?
|
||||
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,9 +32,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_current_booking
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
||||
# booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit(self.shop_code)
|
||||
booking = Booking.where("shop_code='#{self.shop_code}' and dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
@@ -43,8 +42,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_moved_booking
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit(self.shop_code)
|
||||
booking = Booking.where("shop_code='#{self.shop_code}' and dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
@@ -70,8 +69,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_current_checkout_booking
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit(self.shop_code)
|
||||
booking = Booking.where("shop_code='#{self.shop_code}' and dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
@@ -82,7 +81,7 @@ class DiningFacility < ApplicationRecord
|
||||
def get_checkout_booking
|
||||
booking = self.get_current_checkout_booking
|
||||
if booking
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
|
||||
free_time_min = 0
|
||||
if !lookup_checkout_time.empty?
|
||||
now = Time.now.utc
|
||||
@@ -118,11 +117,11 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_checkin_booking
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit(self.shop_code)
|
||||
bookings = Booking.where("shop_code='#{self.shop_code}' and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||
arr_booking = Array.new
|
||||
if bookings
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
|
||||
free_time_min = 0
|
||||
if !lookup_checkout_time.empty?
|
||||
now = Time.now.utc
|
||||
|
||||
@@ -3,7 +3,6 @@ class Employee < ApplicationRecord
|
||||
has_many :commissioners
|
||||
has_many :shit_sales
|
||||
belongs_to :order_queue_station
|
||||
belongs_to :shop
|
||||
validates_presence_of :name, :role
|
||||
validates_presence_of :password, :on => [:create]
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
@@ -21,7 +20,7 @@ class Employee < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.login(shop,emp_id, password)
|
||||
user = shop.employees.find_by_emp_id(emp_id)
|
||||
user = Employee.find_by_emp_id_and_shop_code(emp_id,shop.shop_code)
|
||||
expiry_time = login_expiry_time(shop)
|
||||
if (user)
|
||||
#user.authenticate(password)
|
||||
@@ -39,7 +38,7 @@ class Employee < ApplicationRecord
|
||||
|
||||
def self.authenticate_by_token(session_token,shop)
|
||||
if (session_token)
|
||||
user = shop.employees.find_by_token_session(session_token)
|
||||
user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
|
||||
expiry_time = login_expiry_time(shop)
|
||||
|
||||
if user && user.session_expiry.utc > DateTime.now.utc
|
||||
@@ -57,7 +56,7 @@ class Employee < ApplicationRecord
|
||||
|
||||
def self.logout(shop,session_token)
|
||||
if (session_token)
|
||||
user = shop.employees.find_by_token_session(session_token)
|
||||
user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
|
||||
|
||||
if user
|
||||
user.token_session = nil
|
||||
@@ -75,7 +74,7 @@ class Employee < ApplicationRecord
|
||||
|
||||
def self.login_expiry_time(shop)
|
||||
expiry_time = 30
|
||||
login_expiry = shop.lookups.collection_of('expiry_time')
|
||||
login_expiry = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('expiry_time')
|
||||
if !login_expiry.empty?
|
||||
login_expiry.each do |exp_time|
|
||||
if exp_time[0].downcase == "login"
|
||||
|
||||
@@ -8,7 +8,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
logger.debug saleObj.sale_items.to_json
|
||||
if !saleObj.nil?
|
||||
saleObj.sale_items.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
found, inventory_definition = find_product_in_inventory(item,saleObj.shop_code)
|
||||
if found
|
||||
check_balance(item,inventory_definition)
|
||||
end
|
||||
@@ -23,7 +23,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_product_in_inventory(item,instance_code)
|
||||
def self.find_product_in_inventory(item,shop_code=nil)
|
||||
# unless instance_code.empty?
|
||||
# instance_code = instance_code.to_s
|
||||
# instance_code[0] = ""
|
||||
@@ -36,16 +36,15 @@ class InventoryDefinition < ApplicationRecord
|
||||
# puts "found prodcut+++++++++++++++++++++++++++++++++++==="
|
||||
# puts prod.to_json
|
||||
# end
|
||||
|
||||
if product = InventoryDefinition.find_by_item_code(item.item_instance_code)
|
||||
if stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
|
||||
if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
||||
if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
|
||||
return true, product
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_balance(item, inventory_definition) # item => saleItemOBj
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
@@ -94,7 +93,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
.order("mi.menu_category_id desc")
|
||||
end
|
||||
|
||||
def self.get_by_category(filter)
|
||||
def self.get_by_category(shop,filter)
|
||||
# THEN (SELECT min(balance) FROM stock_journals
|
||||
# least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
|
||||
# THEN (SELECT balance FROM stock_journals
|
||||
@@ -123,9 +122,9 @@ class InventoryDefinition < ApplicationRecord
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
.where("inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ?
|
||||
.where("inventory_definitions.shop_code='#{shop.shop_code}' and (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 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}%")
|
||||
.group("mi.menu_category_id,inventory_definitions.item_code")
|
||||
.order("balance asc, mi.name asc,acc.title desc,mi.menu_category_id desc")
|
||||
|
||||
@@ -22,10 +22,10 @@ class Lookup < ApplicationRecord
|
||||
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
|
||||
# end
|
||||
|
||||
def self.get_checkin_time_limit
|
||||
def self.get_checkin_time_limit(shop_code)
|
||||
time_limit = 5
|
||||
|
||||
lookup = Lookup.find_by_lookup_type('checkin_time_limit')
|
||||
lookup = Lookup.find_by_lookup_type_and_shop_code('checkin_time_limit',shop_code)
|
||||
if !lookup.nil?
|
||||
time_limit = lookup.value.to_i
|
||||
end
|
||||
@@ -60,39 +60,41 @@ class Lookup < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.create_shift_sale_lookup
|
||||
def self.create_shift_sale_lookup(shop_code)
|
||||
@lookup = Lookup.new
|
||||
@lookup.lookup_type = 'shift_sale_items'
|
||||
@lookup.name = 'Shift Sale Items'
|
||||
@lookup.value = 0
|
||||
@lookup.shop_code = shop_code
|
||||
@lookup.save
|
||||
|
||||
return @lookup
|
||||
end
|
||||
|
||||
def self.create_reprint_receipt_lookup
|
||||
def self.create_reprint_receipt_lookup(shop_code)
|
||||
@lookup = Lookup.new
|
||||
@lookup.lookup_type = 'reprint_receipt'
|
||||
@lookup.name = 'Reprint Receipt in Report'
|
||||
@lookup.value = 0
|
||||
@lookup.shop_code = shop_code
|
||||
@lookup.save
|
||||
|
||||
return @lookup
|
||||
end
|
||||
|
||||
def self.save_shift_sale_items_settings(val)
|
||||
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
|
||||
def self.save_shift_sale_items_settings(val,shop_code)
|
||||
@lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last
|
||||
if @lookup.nil?
|
||||
@lookup = Lookup.create_shift_sale_lookup
|
||||
@lookup = Lookup.create_shift_sale_lookup(shop_code)
|
||||
end
|
||||
@lookup.value = val
|
||||
@lookup.save
|
||||
end
|
||||
|
||||
def self.shift_sale_items_lookup_value
|
||||
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
|
||||
def self.shift_sale_items_lookup_value(shop_code)
|
||||
@lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last
|
||||
if @lookup.nil?
|
||||
@lookup = Lookup.create_shift_sale_lookup
|
||||
@lookup = Lookup.create_shift_sale_lookup(shop_code)
|
||||
end
|
||||
return @lookup.value
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class MembershipSetting < ApplicationRecord
|
||||
scope :active, -> { where(is_active: true) }
|
||||
|
||||
MembershipSetting = MembershipSetting.find_by_id(1)
|
||||
# MembershipSetting = MembershipSetting.find_by_id(1)
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class Menu < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.import(file, created_by)
|
||||
def self.import(file, created_by,shop)
|
||||
status = ""
|
||||
spreadsheet = open_spreadsheet(file)
|
||||
if spreadsheet.sheets.count > 1
|
||||
@@ -61,9 +61,9 @@ class Menu < ApplicationRecord
|
||||
# Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||
account = Account.find_by_id(row["id"])
|
||||
if account
|
||||
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"],shop_code: shop.shop_code)
|
||||
else
|
||||
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"],shop_code: shop.shop_code)
|
||||
end
|
||||
elsif sheet_name == "Item Set"
|
||||
# ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||
@@ -92,9 +92,9 @@ class Menu < ApplicationRecord
|
||||
elsif sheet_name == "Menu"
|
||||
menu = Menu.find_by_id(row["id"])
|
||||
if menu
|
||||
Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
|
||||
Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"],shop_code: shop.shop_code)
|
||||
else
|
||||
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
|
||||
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"],shop_code: shop.shop_code)
|
||||
end
|
||||
elsif sheet_name == "Menu Category"
|
||||
# MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||
@@ -141,19 +141,13 @@ class Menu < ApplicationRecord
|
||||
end
|
||||
else
|
||||
# Menu by Menu Import
|
||||
@shop = Shop.first
|
||||
shop_code = ""
|
||||
if !@shop.nil?
|
||||
if @shop.shop_code
|
||||
shop_code = @shop.shop_code + "_"
|
||||
end
|
||||
end
|
||||
shop_code= shop.shop_code + "_"
|
||||
|
||||
sheet = spreadsheet.sheet(0)
|
||||
menu = sheet.row(1)[1]
|
||||
is_ordering = sheet.row(1)[3]?sheet.row(1)[3]:0
|
||||
|
||||
imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by})
|
||||
imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by,shop_code: shop.shop_code})
|
||||
|
||||
(4..sheet.last_row).each do |ii|
|
||||
row = Hash[[sheet.row(3),sheet.row(ii)].transpose]
|
||||
@@ -192,7 +186,7 @@ class Menu < ApplicationRecord
|
||||
if !menu_itm
|
||||
account = Account.find_by_title(row["Account"])
|
||||
if account.nil?
|
||||
account = Account.create({title: row["Account"], account_type: "0"})
|
||||
account = Account.create({title: row["Account"], account_type: "0",shop_code: shop.shop_code})
|
||||
end
|
||||
|
||||
image_path = ""
|
||||
|
||||
@@ -35,12 +35,14 @@ class Order < ApplicationRecord
|
||||
if self.is_extra_time && self.extra_time
|
||||
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc,:checkout_at => Time.now.utc + self.extra_time.to_i,
|
||||
:checkin_by => self.employee_name,
|
||||
:booking_status => "assign" })
|
||||
:checkin_by => self.employee_name,
|
||||
:booking_status => "assign",
|
||||
:shop_code=>self.shop_code})
|
||||
else
|
||||
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "assign" })
|
||||
:booking_status => "assign",
|
||||
:shop_code=>self.shop_code })
|
||||
end
|
||||
#end extra time
|
||||
|
||||
@@ -290,11 +292,11 @@ class Order < ApplicationRecord
|
||||
#Process order items and send to order queue
|
||||
def self.pay_process_order_queue(id,table_id)
|
||||
# if ENV["SERVER_MODE"] != 'cloud'
|
||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||
order = Order.find(id)
|
||||
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",order.shop_code)
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(id, table_id)
|
||||
else
|
||||
order = Order.find(id)
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id)
|
||||
|
||||
@@ -136,7 +136,7 @@ class OrderItem < ApplicationRecord
|
||||
print instance_code
|
||||
end
|
||||
if self.qty != self.qty_before_last_save
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,instance_code)
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,self.order.shop_code)
|
||||
if found
|
||||
InventoryDefinition.check_balance(self, inventory_definition)
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
|
||||
def process_order (order, table_id, order_source = nil, pdf_status = nil ,change_to=nil,current_user=nil)
|
||||
|
||||
oqs_stations = OrderQueueStation.active
|
||||
oqs_stations = OrderQueueStation.active.where("shop_code='#{order.shop_code}'")
|
||||
|
||||
|
||||
order_items = order.order_items
|
||||
@@ -213,7 +213,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
#Print order_items in 1 slip
|
||||
def print_slip(oqs, order, order_items ,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
||||
if pdf_status.nil?
|
||||
printer = PrintSetting.all.order("id ASC")
|
||||
printer = PrintSetting.where("shop_code='#{oqs.shop_code}'").order("id ASC")
|
||||
unique_code="OrderSummaryPdf"
|
||||
|
||||
if !printer.empty?
|
||||
@@ -234,7 +234,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,oqs.shop_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
|
||||
else
|
||||
@@ -249,7 +249,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
def print_slip_item(oqs, order, assigned_items,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
||||
|
||||
if pdf_status.nil?
|
||||
printer = PrintSetting.all.order("id ASC")
|
||||
printer = PrintSetting.where("shop_code='#{oqs.shop_code}'").order("id ASC")
|
||||
unique_code="OrderItemPdf"
|
||||
|
||||
if !printer.empty?
|
||||
@@ -274,7 +274,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
|
||||
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||
# print when complete click
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,oqs.shop_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
if !assigned_items.nil?
|
||||
assigned_items.each do |order_item|
|
||||
@@ -297,7 +297,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
@type = (DiningFacility.find(change_to)).type
|
||||
@moved_by = current_user
|
||||
@date = DateTime.now
|
||||
@shop = Shop.first
|
||||
@shop = Shop.find_by_shop_code(oqs.shop_code)
|
||||
unique_code = "MoveTablePdf"
|
||||
# pdf_no = PrintSetting.where(:unique_code => unique_code).count
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
@@ -40,8 +40,8 @@ class OrderReservation < ApplicationRecord
|
||||
# unless customer.valid?
|
||||
# render json: {
|
||||
# status: 422,
|
||||
# message: "Validation error",
|
||||
# errors: customer.errors
|
||||
# message: "Validation error",
|
||||
# errors: customer.errors
|
||||
# }.to_json
|
||||
# return
|
||||
# end
|
||||
@@ -53,7 +53,7 @@ class OrderReservation < ApplicationRecord
|
||||
Rails.logger.debug order_reserve.to_s
|
||||
check_order_reservation = OrderReservation.where("transaction_ref = ?",order_reserve[:reference])
|
||||
if check_order_reservation.empty?
|
||||
OrderReservation.transaction do
|
||||
OrderReservation.transaction do
|
||||
begin
|
||||
order_reservation = OrderReservation.new
|
||||
order_reservation.order_reservation_type = order_reserve[:order_type]
|
||||
@@ -84,7 +84,7 @@ class OrderReservation < ApplicationRecord
|
||||
end
|
||||
order_reservation.save!
|
||||
if order_reserve[:order_info][:items]
|
||||
order_reserve[:order_info][:items].each do |oritem|
|
||||
order_reserve[:order_info][:items].each do |oritem|
|
||||
OrderReservationItem.process_order_reservation_item(oritem[:product_code],oritem[:item_instance_code],oritem[:product_name],oritem[:product_alt_name],
|
||||
oritem[:account_id],oritem[:qty],oritem[:price],oritem[:unit_price],
|
||||
oritem[:options],nil,order_reservation.id)
|
||||
@@ -93,13 +93,13 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reserve[:delivery_info]
|
||||
Delivery.addDeliveryInfo(order_reserve[:delivery_info],order_reservation.id)
|
||||
end
|
||||
|
||||
|
||||
return order_reservation.id, true
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
raise ActiveRecord::Rollback
|
||||
|
||||
return nil, false
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
return check_order_reservation[0].id, false
|
||||
@@ -112,14 +112,14 @@ class OrderReservation < ApplicationRecord
|
||||
|
||||
items_arr = []
|
||||
count = 1
|
||||
order.order_reservation_items.each { |i|
|
||||
order.order_reservation_items.each { |i|
|
||||
i.item_instance_code = i.item_instance_code.downcase.to_s
|
||||
items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": i.options}
|
||||
count += 1
|
||||
items_arr.push(items)
|
||||
}
|
||||
customer_id = order.customer_id
|
||||
|
||||
|
||||
@order = Order.new
|
||||
@order.source = "doemal_order"
|
||||
@order.order_type = "delivery"
|
||||
@@ -138,7 +138,7 @@ class OrderReservation < ApplicationRecord
|
||||
|
||||
# Order.send_customer_view(@booking)
|
||||
if @status && @booking
|
||||
|
||||
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_user)
|
||||
|
||||
#order status send to doemal
|
||||
@@ -157,7 +157,7 @@ class OrderReservation < ApplicationRecord
|
||||
def self.update_doemal_payment(order,current_user,receipt_bill)
|
||||
if(Sale.exists?(order.sale_id))
|
||||
saleObj = Sale.find(order.sale_id)
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.find_by_shop_code(order.shop_code)
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -167,11 +167,11 @@ class OrderReservation < ApplicationRecord
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
if(order.payment_type == "cash_on_delivery")
|
||||
sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash")
|
||||
@@ -183,9 +183,9 @@ class OrderReservation < ApplicationRecord
|
||||
callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED)
|
||||
#order reservation status updated
|
||||
update_order_reservation(order.id, saleObj.sale_id, DELIVERED)
|
||||
Rails.logger.debug "@@@@ receipt_bill :: "
|
||||
Rails.logger.debug "@@@@ receipt_bill :: "
|
||||
Rails.logger.debug receipt_bill
|
||||
|
||||
|
||||
if receipt_bill == 1
|
||||
#receipt bill pdf setting
|
||||
# get printer info
|
||||
@@ -194,7 +194,7 @@ class OrderReservation < ApplicationRecord
|
||||
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
shop_detail = Shop.first
|
||||
# shop_detail = Shop.first
|
||||
order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id)
|
||||
if !cashier_terminal.nil?
|
||||
# Calculate Food and Beverage Total
|
||||
@@ -203,16 +203,16 @@ class OrderReservation < ApplicationRecord
|
||||
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_details, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
|
||||
#receipt bill pdf setting
|
||||
|
||||
result = {:status=> true,
|
||||
:filepath => filename,
|
||||
:sale_id => saleObj.sale_id,
|
||||
:receipt_no => sale_receipt_no,
|
||||
:printer_name => printer_name,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings ,
|
||||
result = {:status=> true,
|
||||
:filepath => filename,
|
||||
:sale_id => saleObj.sale_id,
|
||||
:receipt_no => sale_receipt_no,
|
||||
:printer_name => printer_name,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings ,
|
||||
:message => DELIVERED }
|
||||
else
|
||||
result = {:status=> true, :message => DELIVERED }
|
||||
@@ -223,7 +223,7 @@ class OrderReservation < ApplicationRecord
|
||||
result = {:status=> true, :message => DELIVERED }
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.send_status_to_ordering(url,ref_no,status,waiting_time=nil,min_type=nil,reason=nil)
|
||||
@@ -349,12 +349,12 @@ class OrderReservation < ApplicationRecord
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
# For Sale Audit
|
||||
# For Sale Audit
|
||||
if !current_user.nil?
|
||||
action_by = current_user.name
|
||||
else
|
||||
@@ -363,7 +363,7 @@ class OrderReservation < ApplicationRecord
|
||||
|
||||
approved_name = nil
|
||||
approved_by = Employee.find_by_emp_id(access_code)
|
||||
|
||||
|
||||
if !approved_by.nil?
|
||||
approved_name = approved_by.name
|
||||
end
|
||||
@@ -372,7 +372,7 @@ class OrderReservation < ApplicationRecord
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,cashier_name, approved_name,remark,"SALEVOID" )
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
@@ -410,7 +410,7 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
@@ -428,7 +428,7 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
@@ -446,7 +446,7 @@ class OrderReservation < ApplicationRecord
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code,from:from
|
||||
|
||||
@@ -7,7 +7,8 @@ class PaymentJournal < ApplicationRecord
|
||||
self.payment_method = payment_method
|
||||
self.payment_status = 'paid'
|
||||
self.payment_method_references = payment_method_reference
|
||||
self.created_by = current_user
|
||||
self.created_by = current_user.id
|
||||
self.shop_code = current_user.shop_code
|
||||
self.save
|
||||
end
|
||||
|
||||
@@ -16,7 +17,8 @@ class PaymentJournal < ApplicationRecord
|
||||
self.remark = remark
|
||||
self.debit_amount = amount
|
||||
self.payment_status = 'paid'
|
||||
self.created_by = current_user
|
||||
self.created_by = current_user.id
|
||||
self.shop_code = current_user.shop_code
|
||||
self.save
|
||||
end
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# end
|
||||
|
||||
shop = Shop.first
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
# shop = Shop.first
|
||||
directory_name = 'public/orders_'+oqs.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
@@ -80,8 +80,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
print_setting = PrintSetting.all.order("id ASC")
|
||||
order=print_query('order_summary', order_id)
|
||||
|
||||
shop = Shop.first
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
# shop = Shop.first
|
||||
directory_name = 'public/orders_'+oqs.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
# For Print Per Item
|
||||
@@ -192,8 +192,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
order=print_query('booking_summary', booking_id)
|
||||
|
||||
shop = Shop.first
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
# shop = Shop.first
|
||||
directory_name = 'public/orders_'+oqs.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
# For Print Per Item
|
||||
|
||||
@@ -195,7 +195,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
if !printer_settings.nil?
|
||||
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
settings = PrintSetting.all
|
||||
settings = PrintSetting.where("shop_code='#{shop_details.shop_code}'")
|
||||
if !settings.nil?
|
||||
settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
@@ -206,7 +206,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{shop_details.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||
|
||||
@@ -33,9 +33,9 @@ class ProductCommission < ApplicationRecord
|
||||
product_commission.save
|
||||
end
|
||||
|
||||
def self.edit_product_commission(saleItemObj)
|
||||
def self.edit_product_commission(saleItemObj,shop_code)
|
||||
menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
|
||||
commission = Commission.where('product_code = ? AND is_active = ?', menu_item.id, true).take
|
||||
commission = Commission.where("shop_code='#{shop_code}' and product_code = ? AND is_active = ?", menu_item.id, true).take
|
||||
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take
|
||||
|
||||
if !product_commission.nil?
|
||||
|
||||
@@ -15,11 +15,11 @@ class Promotion < ApplicationRecord
|
||||
promo_day.include? Date.today.wday.to_s
|
||||
end
|
||||
|
||||
def self.promo_activate(saleObj)
|
||||
def self.promo_activate(saleObj,shop_code)
|
||||
current_day = Time.now.strftime("%Y-%m-%d")
|
||||
current_time = Time.now.strftime('%H:%M:%S')
|
||||
day = Date.today.wday
|
||||
promoList = is_between_promo_datetime(current_day,current_time)
|
||||
promoList = is_between_promo_datetime(current_day,current_time,shop_code)
|
||||
|
||||
promoList.each do |promo|
|
||||
if promo.is_promo_day
|
||||
@@ -30,8 +30,8 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
def self.is_between_promo_datetime(current_day,current_time,shop_code) #database is not local time
|
||||
promoList = Promotion.where("shop_code='#{shop_code}' and (Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
return promoList
|
||||
end
|
||||
|
||||
@@ -157,7 +157,7 @@ class Promotion < ApplicationRecord
|
||||
sale_item.is_taxable = 1
|
||||
sale_item.sale = saleObj
|
||||
sale_item.save
|
||||
|
||||
|
||||
saleObj.sale_items << sale_item
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, source)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,6 @@ class Sale < ApplicationRecord
|
||||
belongs_to :cashier, foreign_key: "cashier_id", class_name: "Employee"
|
||||
belongs_to :customer, :optional => true
|
||||
belongs_to :shift_sale
|
||||
belongs_to :shop
|
||||
has_many :sale_items
|
||||
has_many :sale_discount_items
|
||||
has_many :sale_discounts
|
||||
@@ -30,7 +29,6 @@ class Sale < ApplicationRecord
|
||||
scope :date_between, -> (from, to) { where("DATE(CONVERT_TZ(receipt_date, '+00:00', ?)) BETWEEN ? AND ?", Time.zone.formatted_offset, from, to) }
|
||||
scope :time_between, -> (from, to) { where("TIME(CONVERT_TZ(receipt_date, '+00:00', ?)) BETWEEN ? AND ?", Time.zone.formatted_offset, from, to) }
|
||||
scope :along_with_sale_payments_except_void, -> { joins("LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND DATE(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30')) = DATE(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'))") }
|
||||
|
||||
def qty_of(item_instance_code)
|
||||
order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first
|
||||
end
|
||||
@@ -137,8 +135,8 @@ class Sale < ApplicationRecord
|
||||
order = Order.find(order_id)
|
||||
|
||||
# current cashier login
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
open_cashier = Employee.where("shop_code='#{order.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift(order.shop_code)
|
||||
# shift with terminal zone
|
||||
|
||||
# set cashier
|
||||
@@ -146,12 +144,12 @@ class Sale < ApplicationRecord
|
||||
if !booking.dining_facility_id.nil?
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||
shift = ShiftSale.where("shop_code='#{order.shop_code}' and shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||
#for multiple zone with terminal
|
||||
if shift.nil?
|
||||
multiple_zone = CashierTerminalByZone.where("zone_id = #{table.zone_id}")
|
||||
multiple_zone.each do |zone|
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first
|
||||
shift = ShiftSale.where("shop_code='#{order.shop_code}' and shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first
|
||||
if !shift.nil? then
|
||||
break
|
||||
end
|
||||
@@ -159,7 +157,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(cashier.id)
|
||||
shift = ShiftSale.current_open_shift(cashier)
|
||||
end
|
||||
# set cashier
|
||||
if shift != nil #if current login employee open shift
|
||||
@@ -171,7 +169,7 @@ class Sale < ApplicationRecord
|
||||
# table and terminal in multiple shift
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0])
|
||||
if shift_id
|
||||
self.shift_sale_id = shift_id.id
|
||||
else
|
||||
@@ -189,7 +187,7 @@ class Sale < ApplicationRecord
|
||||
self.requested_by = requested_by.name
|
||||
|
||||
self.requested_at = DateTime.now.utc.getlocal
|
||||
|
||||
self.shop_code = order.shop_code
|
||||
Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}"
|
||||
if order
|
||||
self.customer_id = order.customer_id
|
||||
@@ -235,15 +233,13 @@ class Sale < ApplicationRecord
|
||||
|
||||
#fOR Quick Service pay and create
|
||||
def self.request_bill(order,current_user,current_login_employee)
|
||||
if !ShiftSale.current_shift.nil?
|
||||
if !ShiftSale.current_shift(order.shop_code).nil?
|
||||
order_id = order.order_id # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
if @sale_data = check_booking.sale
|
||||
# Create Sale if it doesn't exist
|
||||
# puts "current_login_employee"
|
||||
# puts current_login_employee.name
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(check_booking,current_login_employee,current_user,order.source)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
@@ -254,7 +250,7 @@ class Sale < ApplicationRecord
|
||||
# @sale_data.save
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale_data)
|
||||
Promotion.promo_activate(@sale_data,order.shop_code)
|
||||
@status = true
|
||||
return @status, @sale_data
|
||||
else
|
||||
@@ -439,7 +435,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil)
|
||||
shop = Shop.first
|
||||
# shop = Shop.first
|
||||
|
||||
#Computation Fields
|
||||
subtotal_price = 0
|
||||
@@ -506,7 +502,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Re-Calculte
|
||||
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
||||
shop = Shop.first
|
||||
shop = Shop.find_by_shop_code(self.shop_code)
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
|
||||
@@ -560,7 +556,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable, order_source = nil, tax_type = nil)
|
||||
shop = Shop.first
|
||||
shop = Shop.find_by_shop_code(self.shop_code)
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||
@@ -640,7 +636,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.find_by_shop_code(self.shop_code)
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(self.grand_total)
|
||||
@@ -656,7 +652,7 @@ class Sale < ApplicationRecord
|
||||
#Generate new Receipt No when it is not assigned
|
||||
def generate_receipt_no
|
||||
#shop_code and client_code
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.find_by_shop_code(self.shop_code)
|
||||
#Date-Shift-
|
||||
if self.receipt_no.nil?
|
||||
prefix = DateTime.now().utc
|
||||
@@ -1526,7 +1522,7 @@ end
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
query = Sale.top_bottom(shop,today,shift,from,to,from_time,to_time)
|
||||
if type == "top"
|
||||
@@ -1557,7 +1553,7 @@ end
|
||||
query = query.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
query = Sale.top_bottom(shop,today,shift).group('i.product_name')
|
||||
if type == "top"
|
||||
@@ -1579,7 +1575,7 @@ end
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
query = Sale.hourly_sale_data(shop,today,nil,from,to,from_time,to_time)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
query = Sale.hourly_sale_data(shop,today,shift,from,to,from_time,to_time)
|
||||
end
|
||||
@@ -1592,7 +1588,7 @@ end
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
query = Sale.hourly_sale_data(shop,today)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
query = Sale.hourly_sale_data(shop,today,shift)
|
||||
end
|
||||
@@ -1603,7 +1599,7 @@ end
|
||||
|
||||
def self.employee_sales(today,current_user,from,to,from_time,to_time,shop)
|
||||
shift = if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
ShiftSale.current_open_shift(current_user.id,shop)
|
||||
ShiftSale.current_open_shift(current_user)
|
||||
end
|
||||
|
||||
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
|
||||
@@ -1616,8 +1612,8 @@ end
|
||||
end
|
||||
|
||||
def self.total_trans(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil,shop)
|
||||
query = shop.sales.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count")
|
||||
.where('sale_status = "completed"')
|
||||
query = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count")
|
||||
.where("sale_status = 'completed' AND shop_code='#{shop.shop_code}'")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
|
||||
query = query.date_between(from, to)
|
||||
@@ -1628,7 +1624,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1636,8 +1632,8 @@ end
|
||||
end
|
||||
|
||||
def self.total_card_sale(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil,shop)
|
||||
query = shop.sales.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.where('sales.sale_status = "completed" and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")')
|
||||
query = Sale.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and (sp.payment_method = 'mpu' or sp.payment_method = 'visa' or sp.payment_method = 'master' or sp.payment_method = 'jcb' or sp.payment_method = 'unionpay' or sp.payment_method = 'alipay' or sp.payment_method = 'paymal' or sp.payment_method = 'dinga' or sp.payment_method = 'JunctionPay')")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1647,7 +1643,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1671,7 +1667,7 @@ end
|
||||
query = query.merge(Sale.date_on(today))
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1680,8 +1676,8 @@ end
|
||||
end
|
||||
|
||||
def self.summary_sale_receipt(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||
.where('sale_status = "completed"')
|
||||
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||
.where("shop_code='#{shop.shop_code}' and sale_status = 'completed'")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1691,7 +1687,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1699,8 +1695,8 @@ end
|
||||
end
|
||||
|
||||
def self.total_payment_methods(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select("distinct sp.payment_method")
|
||||
.where('sales.sale_status = "completed"')
|
||||
query = Sale.select("distinct sp.payment_method")
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed'")
|
||||
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
@@ -1711,7 +1707,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1721,9 +1717,10 @@ end
|
||||
def self.payment_sale(shop,payment_method, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
|
||||
|
||||
query = shop.sales.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount")
|
||||
query = Sale.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount")
|
||||
.joins(:sale_payments)
|
||||
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
|
||||
.where("sales.shop_code='#{shop.shop_code}'")
|
||||
.completed
|
||||
|
||||
if payment_method == 'card'
|
||||
@@ -1742,7 +1739,7 @@ end
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1773,9 +1770,9 @@ end
|
||||
end
|
||||
|
||||
def self.total_dinein_takeaway(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and c.membership_id is null')
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and c.membership_id is null")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1785,7 +1782,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1793,9 +1790,9 @@ end
|
||||
end
|
||||
|
||||
def self.total_membership(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))')
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and ((c.customer_type = 'Dinein' and c.membership_id is not null) or (c.customer_type = 'Takeaway' and c.membership_id is not null))")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1805,7 +1802,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1859,8 +1856,9 @@ end
|
||||
# end
|
||||
|
||||
def self.total_order(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.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)
|
||||
.where("shop_code='#{shop.shop_code}'")
|
||||
.completed
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
@@ -1872,7 +1870,7 @@ end
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1881,10 +1879,10 @@ end
|
||||
end
|
||||
|
||||
def self.total_account(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select("distinct b.id as account_id, b.title as title")
|
||||
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||
.where('sales.sale_status = "completed"')
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed'")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1894,7 +1892,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1902,9 +1900,9 @@ end
|
||||
end
|
||||
|
||||
def self.account_data(shop,account_id, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}'")
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and a.account_id ='#{account_id}'")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1914,7 +1912,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1922,9 +1920,9 @@ end
|
||||
end
|
||||
|
||||
def self.top_items(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed'")
|
||||
.where("sales.shop_code='#{shop.shop_code}' and (a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed'")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1934,7 +1932,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id,shop)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1944,8 +1942,8 @@ end
|
||||
end
|
||||
|
||||
def self.total_foc_items(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%'")
|
||||
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%'")
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -1955,7 +1953,7 @@ end
|
||||
query = query.date_on(today)
|
||||
end
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -2017,13 +2015,13 @@ end
|
||||
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}")
|
||||
.group("bookings.booking_id")
|
||||
end
|
||||
def self.completed_sale(type)
|
||||
def self.completed_sale(type,shop_code)
|
||||
if type == "cashier"
|
||||
type = "and orders.source = 'emenu' or orders.source = 'cashier'"
|
||||
else
|
||||
type = "and orders.source = '#{type}'"
|
||||
end
|
||||
query = Sale.all
|
||||
query = Sale.where("sales.shop_code='#{shop_code}'")
|
||||
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
|
||||
.joins("join orders as orders on orders.order_id = sale_orders.order_id")
|
||||
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}")
|
||||
@@ -2086,8 +2084,7 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
|
||||
end
|
||||
|
||||
def unique_tax_profiles(order_source, customer_id)
|
||||
tax_data = TaxProfile
|
||||
.where(group_type: order_source)
|
||||
tax_data = TaxProfile.where(group_type: order_source,shop_code: self.shop_code)
|
||||
|
||||
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
||||
if customer_tax_profiles.present?
|
||||
@@ -2099,24 +2096,24 @@ end
|
||||
|
||||
def self.top_bottom(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
query = shop.sales.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,i.product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'")
|
||||
else
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
query = query.where("shop_code='#{shop.shop_code}' and (i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed'")
|
||||
end
|
||||
if !shift.nil?
|
||||
query = query.where("shift_sale_id='#{shift.id}'")
|
||||
end
|
||||
else
|
||||
query = shop.sales.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,i.product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
.where("shop_code='#{shop.shop_code}' and (i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
" and sale_status= 'completed'")
|
||||
if !shift.nil?
|
||||
query = query.where("shift_sale_id='#{shift.id}'")
|
||||
@@ -2127,7 +2124,7 @@ end
|
||||
|
||||
def self.hourly_sale_data(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
query = shop.sales.select("grand_total")
|
||||
query = Sale.select("grand_total")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time)
|
||||
else
|
||||
@@ -2136,11 +2133,11 @@ def self.hourly_sale_data(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_
|
||||
if !shift.nil?
|
||||
query = query.where("shift_sale_id='#{shift.id}'")
|
||||
end
|
||||
query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
|
||||
query = query.where("shop_code='#{shop.shop_code}'").group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
|
||||
.order('receipt_date')
|
||||
else
|
||||
query = shop.sales.select("grand_total")
|
||||
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||
query = Sale.select("grand_total")
|
||||
.where("shop_code='#{shop.shop_code}' and sale_status = 'completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = ?",today)
|
||||
if !shift.nil?
|
||||
query = query.where("shift_sale_id='#{shift.id}'")
|
||||
end
|
||||
@@ -2152,9 +2149,9 @@ def self.hourly_sale_data(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_
|
||||
end
|
||||
|
||||
def self.employee_sale(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = shop.sales.joins(:cashier)
|
||||
query = Sale.joins(:cashier)
|
||||
.joins(:sale_payments)
|
||||
.paid.completed
|
||||
.paid.completed.where("sales.shop_code='#{shop.shop_code}'")
|
||||
if !from.nil? && !to.nil?
|
||||
query = query.date_between(from, to)
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
@@ -2475,7 +2472,7 @@ private
|
||||
def update_stock_journal
|
||||
if self.sale_status == "void" && self.sale_status_before_last_save != "void"
|
||||
self.sale_items.each do |item|
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
@@ -2488,7 +2485,7 @@ private
|
||||
end
|
||||
elsif self.sale_status == "waste" || self.sale_status == "spoile" || (self.payment_status == "foc" && self.payment_status_was != "foc")
|
||||
self.bookings.first.order_items.each do |item|
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code)
|
||||
if found
|
||||
if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id)
|
||||
stock_journal.update(remark: self.sale_status)
|
||||
|
||||
@@ -311,11 +311,11 @@ class SaleItem < ApplicationRecord
|
||||
cancel_foc = self.status_before_last_save == "foc"
|
||||
|
||||
if is_void or cancel_void or is_edit or is_foc or cancel_foc
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,self.sale.shop_code)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
stock = StockJournal.where("shop_code='#{self.sale.shop_code}' and item_code=?", self.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
check_item = StockCheckItem.where("shop_code='#{self.sale.shop_code}' and item_code=?", self.item_instance_code).order("id DESC").first
|
||||
if is_void or cancel_void or is_edit
|
||||
if is_void
|
||||
qty = -self.qty
|
||||
|
||||
@@ -34,9 +34,9 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_kbz_pay_amount(sale_id, current_user)
|
||||
def self.get_kbz_pay_amount(sale_id, current_user,shop)
|
||||
amount = 0
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => shop.shop_code).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.payment_status == 'pending'
|
||||
@@ -136,11 +136,12 @@ class SalePayment < ApplicationRecord
|
||||
#record an payment in sale-audit
|
||||
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
|
||||
if payment_for
|
||||
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||
current_shift_user =Employee.find_by_id(self.sale.cashier_id)
|
||||
shift = ShiftSale.current_open_shift(current_shift_user)
|
||||
if !shift.nil?
|
||||
shift_sale_id = shift.id
|
||||
else
|
||||
shift = ShiftSale.current_shift
|
||||
shift = ShiftSale.current_shift(self.sale.shop_code)
|
||||
shift_sale_id = shift.id
|
||||
end
|
||||
|
||||
@@ -726,11 +727,12 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
# update for cashier shift
|
||||
def update_shift
|
||||
|
||||
shift = ShiftSale.current_open_shift(self.action_by.id)
|
||||
current_shift_user = Employee.find_by_id(self.action_by.id)
|
||||
shift = ShiftSale.current_open_shift(current_shift_user)
|
||||
|
||||
if shift.nil?
|
||||
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||
current_shift_user = Employee.find_by_id(self.sale.cashier_id)
|
||||
shift = ShiftSale.current_open_shift(current_shift_user)
|
||||
end
|
||||
|
||||
if !shift.nil?
|
||||
@@ -740,7 +742,7 @@ class SalePayment < ApplicationRecord
|
||||
self.sale.cashier_name = Employee.find(shift.employee_id).name
|
||||
self.sale.save
|
||||
else
|
||||
shift = ShiftSale.current_shift
|
||||
shift = ShiftSale.current_shift(self.sale.shop_code)
|
||||
shift.update(self.sale)
|
||||
self.sale.shift_sale_id = shift.id
|
||||
self.sale.cashier_id = shift.employee_id
|
||||
@@ -972,7 +974,7 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
#credit payment query
|
||||
def self.get_credit_sales(params)
|
||||
def self.get_credit_sales(params,shop_code)
|
||||
receipt_no = ""
|
||||
customer = ""
|
||||
if !params["receipt_no"].blank?
|
||||
@@ -1001,7 +1003,7 @@ class SalePayment < ApplicationRecord
|
||||
else
|
||||
query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}")
|
||||
end
|
||||
query = query.group("s.receipt_no")
|
||||
query = query.where("s.shop_code='#{shop_code}'").group("s.receipt_no")
|
||||
.order("s.receipt_date ASC, s.receipt_no ASC")
|
||||
return query
|
||||
end
|
||||
|
||||
@@ -18,18 +18,18 @@ class ShiftSale < ApplicationRecord
|
||||
has_many :sales
|
||||
belongs_to :shop
|
||||
|
||||
def self.current_shift
|
||||
def self.current_shift(shop_code)
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null").first
|
||||
shift = ShiftSale.where("shop_code='#{shop_code}' and shift_started_at is not null and shift_closed_at is null").first
|
||||
return shift
|
||||
end
|
||||
|
||||
def self.current_open_shift(current_user,shop)
|
||||
def self.current_open_shift(current_user)
|
||||
#if current_user
|
||||
#find open shift where is open today and is not closed and login by current cashier
|
||||
#DATE(shift_started_at)=? and
|
||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
shift = shop.shift_sales.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
||||
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
|
||||
return shift
|
||||
#end
|
||||
end
|
||||
|
||||
@@ -3,36 +3,7 @@ class Shop < ApplicationRecord
|
||||
|
||||
# Shop Image Uploader
|
||||
mount_uploader :logo, ShopImageUploader
|
||||
has_many :accounts
|
||||
has_many :bookings
|
||||
has_many :cashier_terminals
|
||||
has_many :commissioners
|
||||
has_many :commissions
|
||||
has_many :customers
|
||||
has_many :dining_facilities
|
||||
has_many :dining_queues
|
||||
has_many :employees
|
||||
has_many :inventory_definitions
|
||||
has_many :item_sets
|
||||
has_many :lookups
|
||||
has_many :membership_settings
|
||||
has_many :menus
|
||||
has_many :order_queue_stations
|
||||
has_many :orders
|
||||
has_many :payment_journals
|
||||
has_many :payment_method_settings
|
||||
has_many :print_settings
|
||||
has_many :sales
|
||||
has_many :products
|
||||
has_many :promotions
|
||||
has_many :seed_generators
|
||||
has_many :stock_checks
|
||||
has_many :stock_journals
|
||||
has_many :surveys
|
||||
has_many :tax_profiles
|
||||
has_many :zones
|
||||
has_many :display_images
|
||||
has_many :shift_sales
|
||||
accepts_nested_attributes_for :display_images
|
||||
|
||||
def file_data=(input_data)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
class StockCheck < ApplicationRecord
|
||||
has_many :stock_check_items
|
||||
|
||||
def create(user, reason, item_list)
|
||||
def create(user, reason, item_list,shop)
|
||||
self.reason = reason
|
||||
self.check_by = user.id
|
||||
self.check_start = Time.now
|
||||
self.check_end = Time.now
|
||||
self.shop_code = shop.shop_code
|
||||
save
|
||||
item_list.each do |item|
|
||||
stockItem = StockCheckItem.new
|
||||
|
||||
@@ -67,7 +67,7 @@ class StockCheckItem < ApplicationRecord
|
||||
return query
|
||||
end
|
||||
|
||||
def self.delete_stock_check_item(item_code)
|
||||
self.where("item_code=?", item_code).delete_all
|
||||
def self.delete_stock_check_item(item_code,shop)
|
||||
self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user