Merge branch 'foodcourt' of gitlab.com:code2lab/SXRestaurant into foodcourt
This commit is contained in:
21
Dockerfile
21
Dockerfile
@@ -1,15 +1,20 @@
|
||||
FROM ruby:2.4.1
|
||||
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
|
||||
FROM ruby:2.5
|
||||
RUN apt-get update -qq && apt-get install -y build-essential libmariadb-dev libcups2-dev libpq-dev nodejs tzdata
|
||||
RUN mkdir /sxrestaurant
|
||||
RUN mkdir -p /sxrestaurant/tmp/puma
|
||||
ENV RAILS_ENV staging
|
||||
ENV RACK_ENV staging
|
||||
ENV RAILS_ENV production
|
||||
ENV RACK_ENV production
|
||||
WORKDIR /sxrestaurant
|
||||
COPY Gemfile /sxrestaurant/Gemfile
|
||||
COPY Gemfile.lock /sxrestaurant/Gemfile.lock
|
||||
RUN bundle install --without development test
|
||||
#RUN gem install bundler
|
||||
#COPY Gemfile /sxrestaurant/Gemfile
|
||||
#COPY Gemfile.lock /sxrestaurant/Gemfile.lock
|
||||
#RUN bundle install --without development test
|
||||
RUN echo "Asia/Rangoon" > /etc/timezone
|
||||
RUN dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN date
|
||||
COPY . /sxrestaurant
|
||||
RUN gem install bundler
|
||||
#RUN bundle update --bundler
|
||||
RUN bundle install --without development test
|
||||
RUN bundle exec rake assets:precompile
|
||||
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
||||
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
||||
|
||||
19
Dockerfile.backup
Normal file
19
Dockerfile.backup
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM ruby:2.5
|
||||
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
|
||||
RUN mkdir /sxrestaurant
|
||||
RUN mkdir -p /sxrestaurant/tmp/puma
|
||||
ENV RAILS_ENV production
|
||||
ENV RACK_ENV production
|
||||
WORKDIR /sxrestaurant
|
||||
#RUN gem install bundler
|
||||
#COPY Gemfile /sxrestaurant/Gemfile
|
||||
#COPY Gemfile.lock /sxrestaurant/Gemfile.lock
|
||||
#RUN bundle install --without development test
|
||||
RUN echo "Asia/Rangoon" > /etc/timezone
|
||||
RUN dpkg-reconfigure -f noninteractive tzdata
|
||||
COPY . /sxrestaurant
|
||||
RUN gem install bundler
|
||||
#RUN bundle update --bundler
|
||||
RUN bundle install --without development test
|
||||
RUN bundle exec rake assets:precompile
|
||||
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
||||
8
Gemfile
8
Gemfile
@@ -1,6 +1,9 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# ruby '2.4.1'
|
||||
|
||||
#ruby '2.5.0'
|
||||
#ruby '2.5.7'
|
||||
|
||||
|
||||
git_source(:github) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
||||
@@ -40,6 +43,9 @@ gem 'material_icons'
|
||||
gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2'
|
||||
gem 'rack-cors'
|
||||
|
||||
# Multi-tenancy for shops
|
||||
gem 'acts_as_tenant'
|
||||
|
||||
# image upload
|
||||
gem 'carrierwave', '~> 1.0'
|
||||
gem 'mini_magick'
|
||||
|
||||
12
Gemfile.lock
12
Gemfile.lock
@@ -46,6 +46,9 @@ GEM
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
acts_as_tenant (0.4.4)
|
||||
rails (>= 4.0)
|
||||
request_store (>= 1.0.5)
|
||||
aescrypt (1.0.0)
|
||||
airbrussh (1.4.0)
|
||||
sshkit (>= 1.6.1, != 1.7.0)
|
||||
@@ -219,6 +222,8 @@ GEM
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
redis (3.3.5)
|
||||
request_store (1.4.1)
|
||||
rack (>= 1.4)
|
||||
roo (1.13.2)
|
||||
nokogiri
|
||||
rubyzip
|
||||
@@ -271,8 +276,7 @@ GEM
|
||||
activemodel (>= 5.0)
|
||||
spreadsheet (1.2.5)
|
||||
ruby-ole (>= 1.0)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
spring (2.1.0)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
@@ -316,6 +320,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
acts_as_tenant
|
||||
aescrypt
|
||||
axlsx (= 2.0.1)
|
||||
axlsx_rails
|
||||
@@ -375,5 +380,8 @@ DEPENDENCIES
|
||||
web-console (>= 3.3.0)
|
||||
whenever
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
|
||||
@@ -279,6 +279,15 @@ For Food Court Settings On/Off
|
||||
** '0' means can not use food court and '1' means can use food court **
|
||||
=> settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' }
|
||||
|
||||
For Number Formats
|
||||
Precision
|
||||
=> settings/lookups => { lookup_type: number_format, name: precision, value: {0..2} }
|
||||
Delimiter
|
||||
=> settings/lookups => { lookup_type: number_format, name: delimiter, value: { ',', '\u0020', '', ... }
|
||||
Strip insignificant zeros
|
||||
=> settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros,
|
||||
value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] }
|
||||
|
||||
/* Customer Types in lookups */
|
||||
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
|
||||
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
include TokenVerification, MultiTenancy
|
||||
include ActionController::MimeResponds
|
||||
|
||||
# before_action :lookup_domain
|
||||
before_action :core_allow
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
before_action :core_allow
|
||||
|
||||
def core_allow
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
|
||||
headers['Access-Control-Request-Method'] = '*'
|
||||
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class Api::AuthenticateController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
before_action :find_shop
|
||||
# before_action :find_shop
|
||||
|
||||
def create
|
||||
emp_id = params[:emp_id]
|
||||
password = params[:password]
|
||||
|
||||
if emp_id && password
|
||||
@employee = Employee.login(@shop, emp_id, password)
|
||||
@employee = Employee.login(emp_id, password)
|
||||
if @employee && @employee.role == "waiter"
|
||||
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
|
||||
else
|
||||
|
||||
@@ -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(@shop.shop_code).nil?
|
||||
if !ShiftSale.current_shift(Shop.current_shop.shop_code).nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if (params[:booking_id])
|
||||
@@ -106,7 +106,7 @@ class Api::BillController < Api::ApiController
|
||||
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
# shop_details = Shop.find(1)
|
||||
# shop_details = Shop.current_shop
|
||||
|
||||
# customer= Customer.find(@sale_data.customer_id)
|
||||
# # get member information
|
||||
|
||||
@@ -23,8 +23,9 @@ class Api::CallWaitersController < ActionController::API
|
||||
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.current_shop
|
||||
unique_code = "CallWaiterPdf"
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||
|
||||
@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
|
||||
|
||||
if !order_reservation_id.nil? && flag
|
||||
shop = Shop.find_by_id(1)
|
||||
shop = Shop.current_shop
|
||||
if !shop.nil?
|
||||
shop_code = shop.shop_code
|
||||
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||
@@ -96,9 +96,6 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
|
||||
end
|
||||
end
|
||||
|
||||
# puts "!!! send doemal ::"
|
||||
# puts result
|
||||
|
||||
Rails.logger.debug "send status to doemal"
|
||||
Rails.logger.debug result
|
||||
|
||||
@@ -46,9 +46,7 @@ class Api::OrdersController < Api::ApiController
|
||||
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||
# end
|
||||
|
||||
# @shop = Shop.first
|
||||
puts "Hello world"
|
||||
puts @shop.to_json
|
||||
@shop = Shop.current_shop
|
||||
return @shop.to_json
|
||||
end
|
||||
|
||||
@@ -162,7 +160,6 @@ class Api::OrdersController < Api::ApiController
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
|
||||
@@ -14,11 +14,12 @@ 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.current_shop
|
||||
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if @shop.is_rounding_adj
|
||||
if shop_detail.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
|
||||
|
||||
@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
|
||||
|
||||
#sound effect / alarm api for doemal side calling
|
||||
def sound_effect
|
||||
shop = Shop.find_by_id(1)
|
||||
shop = Shop.current_shop
|
||||
if !shop.nil?
|
||||
shop_code = shop.shop_code
|
||||
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||
|
||||
@@ -15,12 +15,8 @@ class Api::SurveyController < Api::ApiController
|
||||
|
||||
def create
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
# cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# puts params.to_json
|
||||
# set cashier
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift(Shop.current_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])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class BaseController < ActionController::Base
|
||||
include MultiTenancy
|
||||
layout "installation"
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class BaseCrmController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "CRM"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class BaseFoodcourtController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "foodcourt"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class BaseInventoryController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "inventory"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class BaseOqsController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "OQS"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class BaseOrigamiController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "origami"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "application"
|
||||
|
||||
before_action :check_user
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
@@ -26,61 +26,51 @@ class BaseReportController < ActionController::Base
|
||||
}
|
||||
|
||||
def get_date_range_from_params
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
day_ref = Time.now.utc.getlocal
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
|
||||
if from.present? && to.present?
|
||||
if params[:from].present? && params[:to].present?
|
||||
from = Time.parse(params[:from])
|
||||
to = Time.parse(params[:to])
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
from = Time.now
|
||||
to = Time.now
|
||||
when PERIOD["yesterday"]
|
||||
from = 1.day.ago
|
||||
to = 1.day.ago
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week
|
||||
to = Time.now
|
||||
when PERIOD["last_week"]
|
||||
from = 1.week.ago.beginning_of_week
|
||||
to = 1.week.ago.end_of_week
|
||||
when PERIOD["last_7"]
|
||||
from = 7.day.ago
|
||||
to = Time.now
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month
|
||||
to = Time.now
|
||||
when PERIOD["last_month"]
|
||||
from = 1.month.ago.beginning_of_month
|
||||
to = 1.month.ago.end_of_month
|
||||
when PERIOD["last_30"]
|
||||
from = 30.day.ago
|
||||
to = Time.now
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year
|
||||
to = Time.now
|
||||
when PERIOD["last_year"]
|
||||
from = 1.year.ago.beginning_of_year
|
||||
to = 1.year.ago.end_of_year
|
||||
end
|
||||
end
|
||||
|
||||
f_date = DateTime.parse(from)
|
||||
t_date = DateTime.parse(to)
|
||||
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
from = f_time.beginning_of_day.utc.getlocal
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
from = from.beginning_of_day
|
||||
to = to.end_of_day
|
||||
|
||||
else
|
||||
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
from = (day_ref - 1.day).beginning_of_day.utc
|
||||
to = (day_ref - 1.day).end_of_day.utc
|
||||
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_week"]
|
||||
from = (day_ref - 7.day).beginning_of_week.utc
|
||||
to = (day_ref - 7.day).end_of_week.utc
|
||||
when PERIOD["last_7"]
|
||||
from = (day_ref - 7.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_month"]
|
||||
from = (day_ref - 1.month).beginning_of_month.utc
|
||||
to = (day_ref - 1.month).end_of_month.utc
|
||||
when PERIOD["last_30"]
|
||||
from = (day_ref - 30.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_year"]
|
||||
from = (day_ref - 1.year).beginning_of_year.utc
|
||||
to = (day_ref - 1.year).end_of_year.utc
|
||||
end
|
||||
end
|
||||
|
||||
return from, to
|
||||
return from, to
|
||||
end
|
||||
|
||||
def check_user
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class BaseWaiterController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification, MultiTenancy
|
||||
layout "waiter"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -56,7 +56,7 @@ module LicenseVerification
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
puts "RUN SAY BYAR"
|
||||
Rails.logger.info "License successed"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module LoginVerification
|
||||
extend ActiveSupport::Concern
|
||||
included do
|
||||
before_action :authenticate_session_token
|
||||
helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
|
||||
helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
|
||||
end
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
@@ -18,38 +18,34 @@ module LoginVerification
|
||||
|
||||
def current_shop
|
||||
begin
|
||||
shop_code ='263'
|
||||
@shop =Shop.find_by_shop_code(shop_code)
|
||||
return @shop
|
||||
return Shop.current_shop
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session_and_shop_code(session[:session_token],@shop.shop_code)
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session_and_shop_code(session[:session_token],@shop.shop_code) if session[:session_token]
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashiers
|
||||
def get_cashier
|
||||
@cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
shop_code ='263'
|
||||
@shop = Shop.find_by_shop_code(shop_code)
|
||||
return @shop
|
||||
@shop = current_shop
|
||||
end
|
||||
|
||||
#check order reservation used
|
||||
def order_reservation
|
||||
order_reserve = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
|
||||
order_reserve = Lookup.collection_of('order_reservation')
|
||||
status = false
|
||||
if !order_reserve.empty?
|
||||
order_reserve.each do |order|
|
||||
@@ -65,7 +61,7 @@ module LoginVerification
|
||||
|
||||
#check bank integration used
|
||||
def bank_integration
|
||||
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
status = false
|
||||
if !bank_integration.empty?
|
||||
bank_integration.each do |bank|
|
||||
@@ -90,8 +86,7 @@ module LoginVerification
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
#Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user =Employee.authenticate_by_token(token,current_shop)
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
|
||||
20
app/controllers/concerns/multi_tenancy.rb
Normal file
20
app/controllers/concerns/multi_tenancy.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module MultiTenancy
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
||||
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
||||
helper_method :current_shop if respond_to? :helper_method
|
||||
end
|
||||
|
||||
private
|
||||
def find_shop_by_subdomain_or_frist
|
||||
if request.subdomain.present?
|
||||
shop_code = request.subdomain.partition('-').last
|
||||
shop = Shop.find_by(shop_code: shop_code)
|
||||
else
|
||||
shop = Shop.first
|
||||
end
|
||||
set_current_tenant(shop)
|
||||
end
|
||||
end
|
||||
68
app/controllers/concerns/number_formattable.rb
Normal file
68
app/controllers/concerns/number_formattable.rb
Normal file
@@ -0,0 +1,68 @@
|
||||
module NumberFormattable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def precision
|
||||
return @precision if defined? @precision
|
||||
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||
if @number_formats
|
||||
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
|
||||
end
|
||||
if @precision.nil?
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||
if @print_settings
|
||||
@precision = @print_settings.precision.to_i
|
||||
else
|
||||
@precision = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def delimiter
|
||||
return @delimiter if defined? @delimiter
|
||||
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||
if @number_formats
|
||||
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
|
||||
end
|
||||
if @delimiter.nil?
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||
if @print_settings && @print_settings.delimiter
|
||||
@delimiter = ","
|
||||
else
|
||||
@delimiter = ","
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def strip_insignificant_zeros
|
||||
return @strip_insignificant_zeros if defined? @strip_insignificant_zeros
|
||||
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||
if @number_formats
|
||||
@strip_insignificant_zeros = @number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}.value.in? ['1', 't', 'true', 'on', 'y', 'yes'] rescue false
|
||||
end
|
||||
end
|
||||
|
||||
def number_format(number, options = {})
|
||||
options[:precision] = options[:precision] || precision
|
||||
# options[:delimiter] = options[:delimiter] || delimiter
|
||||
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
|
||||
|
||||
number = number.to_f.round(options[:precision])
|
||||
|
||||
if options[:precision] > 0
|
||||
if options[:strip_insignificant_zeros]
|
||||
formatted = "%.12g" % number
|
||||
else
|
||||
formatted = "%.#{options[:precision]}f" % number
|
||||
end
|
||||
else
|
||||
formatted = number.to_i.to_s
|
||||
end
|
||||
|
||||
if options[:delimiter] && !options[:delimiter].empty?
|
||||
formatted = formatted.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, "\\1#{options[:delimiter]}")
|
||||
end
|
||||
|
||||
return formatted
|
||||
end
|
||||
|
||||
end
|
||||
@@ -38,7 +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.shop_code = Shop.current_shop.shop_code
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
flash[:member_notice]='Customer was successfully created.'
|
||||
@@ -83,7 +83,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
@taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
|
||||
@filter = filter
|
||||
@@ -103,11 +103,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
# puts @crm_customers.to_json
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @crm_customers }
|
||||
@@ -135,7 +130,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
params[:type] = nil
|
||||
params[:customer_id] = params[:id]
|
||||
@credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
@credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code)
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(params[:id])
|
||||
@@ -260,7 +255,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
if @checked_contact.nil?
|
||||
respond_to do |format|
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
@crm_customers.shop_code = @shop.shop_code
|
||||
@crm_customers.shop_code = Shop.current_shop.shop_code
|
||||
if @crm_customers.save
|
||||
# update tax profile
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
|
||||
@@ -6,8 +6,8 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
# GET /crm/dining_queues.json
|
||||
def index
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@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")
|
||||
@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")
|
||||
|
||||
if params[:term]
|
||||
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
|
||||
@@ -39,9 +39,8 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
# POST /crm/dining_queues
|
||||
# POST /crm/dining_queues.json
|
||||
def create
|
||||
puts dining_queue_params
|
||||
@dining_queue = DiningQueue.new(dining_queue_params)
|
||||
@dining_queue.shop_code = @shop.shop_code
|
||||
@dining_queue.shop_code = Shop.current_shop.shop_code
|
||||
respond_to do |format|
|
||||
if @dining_queue.save
|
||||
|
||||
@@ -88,7 +87,7 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
|
||||
def assign
|
||||
@queue = DiningQueue.find(params[:id])
|
||||
@tables = DiningFacility.where("status = 'available' and shop_code='#{@shop.shop_code}' and type!='HotelRoom'")
|
||||
@tables = DiningFacility.where("status = 'available' and type!='HotelRoom'")
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
@@ -109,8 +108,7 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
:type => type,
|
||||
:checkin_at => Time.now.utc,
|
||||
:customer_id => queue.customer_id,
|
||||
:booking_status => "assign",
|
||||
:shop_code => @shop.shop_code})
|
||||
:booking_status => "assign"})
|
||||
booking.save!
|
||||
|
||||
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
|
||||
@@ -139,7 +137,7 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_queue
|
||||
@dining_queue = DiningQueue.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
@dining_queue = DiningQueue.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
@@ -7,10 +7,10 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@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')
|
||||
@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')
|
||||
end
|
||||
|
||||
def detail
|
||||
@@ -19,7 +19,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -136,7 +136,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code =@shop.shop_code
|
||||
@order.shop_code = Shop.current_shop.shop_code
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
@@ -233,7 +233,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
|
||||
#Send to background job for processing
|
||||
order = Order.find(order_id)
|
||||
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)
|
||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
|
||||
@@ -15,13 +15,13 @@ class Foodcourt::CashInsController < BaseFoodcourtController
|
||||
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)
|
||||
current_shift = ShiftSale.current_shift(Shop.current_shopshop_code)
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ class Foodcourt::CashOutsController < BaseFoodcourtController
|
||||
p_jour.cash_out(reference, remark, amount, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
current_shift = ShiftSale.current_shift(Shop.current_shop.shop_code)
|
||||
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
@@ -92,12 +92,12 @@ class Foodcourt::CustomersController < BaseFoodcourtController
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type")
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
#get paypar accountno
|
||||
@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.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings')
|
||||
lookup_customer = Lookup.collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
@@ -168,9 +168,9 @@ class Foodcourt::CustomersController < BaseFoodcourtController
|
||||
sale = Sale.find_by_receipt_no(receipt_no)
|
||||
@out = []
|
||||
action_by = current_user.name
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
|
||||
@@ -3,9 +3,10 @@ class Foodcourt::DashboardController < BaseFoodcourtController
|
||||
def index
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
|
||||
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type")
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@shop = Shop.current_shop
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
@@ -102,7 +103,7 @@ class Foodcourt::DashboardController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
def get_all_menu
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'")
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
@@ -21,8 +21,8 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@accounts = Account.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||
end
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
|
||||
@@ -17,14 +17,15 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
||||
shop = Shop.current_shop
|
||||
@zone = Zone.all.where("is_active= true")
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@cashier_type = "food_court"
|
||||
#checked quick_service only
|
||||
@quick_service_only = true
|
||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
@@ -161,7 +162,7 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product..where("shop_code='#{@shop.shop_code}'")
|
||||
@product = Product.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
|
||||
@@ -4,6 +4,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
@shop = Shop.current_shop
|
||||
@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)
|
||||
@@ -19,7 +20,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@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)
|
||||
|
||||
@@ -19,7 +19,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
#shop_detail = Shop.first
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
@@ -63,7 +63,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
# For Print
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
@@ -91,7 +91,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
@@ -146,14 +146,14 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
#end
|
||||
end
|
||||
@@ -170,7 +170,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
def show
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -190,7 +190,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@membership_rebate_balance=0
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -215,17 +215,17 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,Shop.current_shop)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
@@ -267,7 +267,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
#end rounding adjustment
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -293,7 +293,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@@ -307,7 +307,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
@@ -469,7 +469,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -544,7 +544,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
printer = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -559,7 +559,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
@@ -568,7 +568,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -603,7 +603,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -626,9 +626,9 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
if cashier_type.strip.downcase == "doemal_order"
|
||||
unique_code = "ReceiptBillOrderPdf"
|
||||
else
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
@@ -651,7 +651,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
@cashier_type = params[:type]
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
#for bank integration
|
||||
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
|
||||
bank_integration = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
@@ -16,7 +16,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
|
||||
@terminal = CashierTerminal.available.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
cashier_terminal.save
|
||||
|
||||
#add shift_sale_id to card_settle_trans
|
||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
|
||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',Shop.current_shop.shop_code)
|
||||
if !bank_integration.nil?
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
@@ -74,7 +74,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
@@ -92,13 +92,13 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code)
|
||||
if @lookup.to_i == 1
|
||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{Shop.current_shop.shop_code}'")
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@@ -129,7 +129,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
end
|
||||
Employee.logout(@shop,session[:session_token])
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = nil
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{Shop.current_shop.shop_code}'")
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ class HomeController < ApplicationController
|
||||
|
||||
def index
|
||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
@employees = Employee.all.where("shop_code='#{current_shop.shop_code}' and is_active = true").order("name asc")
|
||||
@roles = Employee.where("shop_code='#{current_shop.shop_code}'").distinct.pluck(:role)
|
||||
shop = Shop.current_shop
|
||||
@employees = Employee.all.where("shop_code='#{shop.shop_code}' and is_active = true").order("name asc")
|
||||
@roles = Employee.where("shop_code='#{shop.shop_code}'").distinct.pluck(:role)
|
||||
|
||||
# byebug
|
||||
# @roles = Lookup.collection_of("employee_roles")
|
||||
@@ -52,7 +53,7 @@ class HomeController < ApplicationController
|
||||
@login_form = LoginForm.new()
|
||||
@login_form.emp_id = params[:login_form][:emp_id]
|
||||
@login_form.password = params[:login_form][:password]
|
||||
@employee = Employee.login(current_shop,@login_form.emp_id, @login_form.password)
|
||||
@employee = Employee.login(@login_form.emp_id, @login_form.password)
|
||||
|
||||
if @employee != nil
|
||||
if @employee.is_active
|
||||
@@ -94,31 +95,26 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def dashboard
|
||||
@from, @to, @from_time, @to_time = get_date_range_from_params
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@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 = 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 = 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 = 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 = 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 = 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')
|
||||
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time,@shop).sum(:grand_total)
|
||||
@from, @to = get_date_range_from_params
|
||||
|
||||
@shop = Shop.current_shop
|
||||
|
||||
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
|
||||
@sales = Sale.receipt_date_between(@from, @to).completed
|
||||
|
||||
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)
|
||||
@orders = @orders.where(shift_sale_id: shift.id)
|
||||
@sales = @sales.where(shift_sale_id: shift.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top",current_shop)
|
||||
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom",current_shop)
|
||||
@hourly_sales = Sale.hourly_sales(current_user,@from,@to,current_shop)
|
||||
employee_sales = Sale.employee_sales(current_user,@from,@to,current_shop)
|
||||
|
||||
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time,@shop)
|
||||
@employee_sales = []
|
||||
if !employee_sales.nil?
|
||||
employee_sales.each do |emp|
|
||||
@@ -130,43 +126,43 @@ class HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time,@shop).sum(:balance)
|
||||
|
||||
@total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time,@shop)
|
||||
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time,@shop)
|
||||
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time,@shop)
|
||||
@inventories = StockJournal.inventory_balances(@from,@to, current_shop).sum(:balance)
|
||||
|
||||
@total_trans = Sale.total_trans(current_user,@from,@to)
|
||||
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
||||
@total_credit = Sale.credit_payment(current_user,@from,@to, current_shop)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
|
||||
|
||||
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(@shop,'card', today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
pay = Sale.payment_sale(payment.payment_method, current_user,@from,@to)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@total_order = Sale.total_order(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_accounts = Sale.total_account(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@summ_sale = Sale.summary_sale_receipt(current_user,@from,@to)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(current_user,@from,@to, current_shop)
|
||||
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(@shop,account.account_id, today,current_user,@from,@to,@from_time,@to_time)
|
||||
if !acc.nil?
|
||||
|
||||
acc = Sale.account_data(account.account_id,current_user,@from,@to)
|
||||
if !acc.nil? && acc.cnt_acc > 0
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_foc_items = Sale.total_foc_items(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@top_items = Sale.top_items(current_user,@from,@to)
|
||||
@total_foc_items = Sale.total_foc_items(current_user,@from,@to)
|
||||
|
||||
# get printer info
|
||||
# @print_settings = get_precision_delimiter
|
||||
@@ -174,7 +170,7 @@ class HomeController < ApplicationController
|
||||
|
||||
def destroy
|
||||
# clear in employee session
|
||||
Employee.logout(@shop,session[:session_token])
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = nil
|
||||
# redirect_to root_path
|
||||
render :json => {:status=> "Success", :url => root_path }.to_json
|
||||
@@ -236,23 +232,18 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def get_date_range_from_params
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
from_time = params[:from_time]
|
||||
to_time = params[:to_time]
|
||||
|
||||
if from.present? && to.present?
|
||||
# f_date = DateTime.parse(from)
|
||||
# t_date = DateTime.parse(to)
|
||||
# f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
# t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
# from = f_time.beginning_of_day.utc.getlocal
|
||||
# to = t_time.end_of_day.utc.getlocal
|
||||
|
||||
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
|
||||
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
|
||||
if params[:from].present? && params[:to].present?
|
||||
if params[:from_time].present? && params[:to_time].present?
|
||||
from = Time.parse("#{params[:from]} #{params[:from_time]}")
|
||||
to = Time.parse("#{params[:to]} #{params[:to_time]}")
|
||||
else
|
||||
from = Time.parse(params[:from])
|
||||
to = Time.parse(params[:to]).end_of_day
|
||||
end
|
||||
|
||||
return from, to, from_time, to_time
|
||||
else
|
||||
from = Time.now.beginning_of_day
|
||||
to = Time.now.end_of_day
|
||||
end
|
||||
return from, to
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,4 +18,12 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
|
||||
def shop_detail
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -104,6 +104,12 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_inventory_definition
|
||||
|
||||
@@ -60,6 +60,12 @@ class Inventory::StockCheckItemsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_check_item
|
||||
|
||||
@@ -32,22 +32,23 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
|
||||
def save_to_journal
|
||||
check = params[:data]
|
||||
stockCheck = StockCheck.find_by_id_and_shop_code(check,@shop.shop_code)
|
||||
stockCheck = StockCheck.find_by_id(check)
|
||||
stockCheck.stock_check_items.each do |item|
|
||||
StockJournal.from_stock_check(item,@shop)
|
||||
StockJournal.from_stock_check(item,Shop.current_shop)
|
||||
end
|
||||
end
|
||||
|
||||
def print_stock_check
|
||||
stock_id = params[:stock_check_id] # sale_id
|
||||
stockcheck = StockCheck.find_by_id_and_shop_code(stock_id,@shop.shop_code)
|
||||
stockcheck = StockCheck.find_by_id(stock_id)
|
||||
stockcheck_items = stockcheck.stock_check_items
|
||||
member_info = nil
|
||||
unique_code = 'StockCheckPdf'
|
||||
|
||||
shop_details = current_shop
|
||||
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)
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
checker = Employee.find(stockcheck.check_by)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
if !print_settings.nil?
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
|
||||
@@ -59,8 +60,6 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
|
||||
#Pull this menu
|
||||
@menu_category = InventoryDefinition.search_by_category(params[:id])
|
||||
puts @menu_category.to_json
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu_category
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
@@ -70,7 +69,7 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = current_shop
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
|
||||
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
@@ -61,6 +61,12 @@ class StockJournalsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_journal
|
||||
|
||||
@@ -81,4 +81,10 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -118,8 +118,6 @@ class Oqs::HomeController < BaseOqsController
|
||||
status = params[:status]
|
||||
|
||||
items = queue_items_query(false,oqs_id,filter,table_id,status)
|
||||
puts "items0"
|
||||
puts items.to_json
|
||||
if !items.empty?
|
||||
items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
|
||||
@@ -46,8 +46,6 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
@@ -63,7 +61,6 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
#Pull this menu
|
||||
@menu = Menu.find_by_id(params[:id])
|
||||
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
Menu.current_menu
|
||||
@@ -77,8 +74,6 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
@@ -136,7 +131,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code =@shop.shop_code
|
||||
@order.shop_code = Shop.current_shop.shop_code
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
@@ -199,7 +194,6 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
|
||||
@@ -11,7 +11,8 @@ class Origami::AlipayController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@alipaycount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_alipay = 0
|
||||
@member_discount = 0
|
||||
@@ -64,7 +65,8 @@ 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.current_shop
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
@@ -86,8 +88,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,6 @@ class Origami::CashInsController < BaseOrigamiController
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
puts shift.to_json
|
||||
shift.cash_in = shift.cash_in + amount.to_f
|
||||
shift.save
|
||||
end
|
||||
|
||||
@@ -9,6 +9,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
@creditcount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop.current_shop
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
@@ -32,6 +33,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
|
||||
@@ -3,11 +3,11 @@ class Origami::CreditSalesController < BaseOrigamiController
|
||||
@cashier_type = 'cashier'
|
||||
@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')
|
||||
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@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")
|
||||
@@ -15,7 +15,7 @@ class Origami::CreditSalesController < BaseOrigamiController
|
||||
@sale = Sale.find_by_sale_id(params[:sale_id])
|
||||
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
||||
.where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote")
|
||||
|
||||
|
||||
@sale_taxes = []
|
||||
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
@@ -24,5 +24,5 @@ class Origami::CreditSalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -87,7 +87,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
@taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
|
||||
@@ -1,65 +1,69 @@
|
||||
class Origami::DashboardController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
|
||||
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type")
|
||||
@shop = Shop.current_shop
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
|
||||
|
||||
@total_payment_methods = Sale.total_payment_methods(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(@shop,'card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
|
||||
@total_payment_methods.each do |payment|
|
||||
pay = Sale.payment_sale(payment.payment_method, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
else
|
||||
@sale_data = nil
|
||||
end
|
||||
@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)
|
||||
|
||||
@summ_sale = Sale.summary_sale_receipt(current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(@shop,today,current_user)
|
||||
@total_accounts = Sale.total_account(@shop,today,current_user)
|
||||
@total_order = Sale.total_order(current_user)
|
||||
|
||||
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
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
|
||||
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, current_user)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
||||
else
|
||||
@account_data = nil
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(@shop,today,current_user)
|
||||
@total_foc_items = Sale.total_foc_items(@shop,today,current_user)
|
||||
|
||||
@top_items = Sale.top_items(current_user)
|
||||
@total_foc_items = Sale.total_foc_items(current_user)
|
||||
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@current_user = current_user
|
||||
#dine-in cashier
|
||||
dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
dinein_cashier = Lookup.where("shop_code='#{current_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.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service')
|
||||
quick_service = Lookup.where("shop_code='#{current_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.where("shop_code='#{@shop.shop_code}'").collection_of('food_court')
|
||||
food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court')
|
||||
@food_court = 0
|
||||
@food_court_name = nil
|
||||
if !food_court[0].nil?
|
||||
@@ -68,7 +72,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#order reservation
|
||||
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
|
||||
order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation')
|
||||
@order_reservation = 0
|
||||
if !order_reservation.empty?
|
||||
order_reservation.each do |order_reserve|
|
||||
@@ -79,7 +83,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#dashboard settings on/off for supervisor and cashier
|
||||
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings')
|
||||
dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings')
|
||||
@setting_flag = true
|
||||
if !dashboard_settings.empty?
|
||||
dashboard_settings.each do |setting|
|
||||
@@ -90,7 +94,7 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#reservation
|
||||
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation')
|
||||
reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation')
|
||||
@reservation = 0
|
||||
if !reservation.empty?
|
||||
reservation.each do |reserve|
|
||||
@@ -102,13 +106,15 @@ 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.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all
|
||||
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
credit_sales = SalePayment.get_credit_sales(params,current_shop.shop_code)
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
|
||||
@@ -6,7 +6,8 @@ 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.current_shop
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
else
|
||||
@@ -77,7 +78,8 @@ def create
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# shop_details = Shop.first
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
|
||||
@@ -17,14 +17,15 @@ class Origami::FoodCourtController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
||||
shop = Shop.current_shop
|
||||
@zone = Zone.all.where("shop_code='#{shop.shop_code}' and is_active= true")
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@tables = Table.all.active.where("shop_code='#{shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.all.active.where("shop_code='#{shop.shop_code}'").order('status desc')
|
||||
@cashier_type = "food_court"
|
||||
#checked quick_service only
|
||||
@quick_service_only = true
|
||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
lookup_dine_in = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('dinein_cashier')
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
@@ -134,10 +135,8 @@ class Origami::FoodCourtController < ApplicationController
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
@@ -150,7 +149,6 @@ class Origami::FoodCourtController < ApplicationController
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
@@ -171,7 +169,6 @@ class Origami::FoodCourtController < ApplicationController
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
|
||||
@@ -6,7 +6,8 @@ class Origami::GiftVoucherController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = 0
|
||||
@gift_vouchercount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_gift_voucher = 0
|
||||
@member_discount = 0
|
||||
@@ -48,8 +49,8 @@ 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.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@@ -64,8 +65,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,10 +4,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
@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')
|
||||
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).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')
|
||||
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
|
||||
@@ -20,10 +22,11 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
@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')
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).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')
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
|
||||
@@ -47,12 +47,6 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
def create_for_in_duty
|
||||
# this one use for create and update
|
||||
in_duty = in_duty_params
|
||||
# in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
# in_time = in_time.change(offset: '+06:30')
|
||||
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
# out_time = out_time.change(offset: '+06:30')
|
||||
# puts in_duty.to_json
|
||||
# puts "sssssssssssssssssss"
|
||||
@in_duty = InDuty.new
|
||||
in_duty_id = in_duty[:id]
|
||||
unless in_duty_id.empty?
|
||||
|
||||
@@ -12,7 +12,8 @@ class Origami::JcbController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@jcbcount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_jcb = 0
|
||||
@member_discount= 0
|
||||
@@ -66,8 +67,7 @@ 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.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@@ -87,8 +87,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
@cashier_id = current_user.emp_id
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
# @shop = Shop.first
|
||||
@shop = Shop.current_shop
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
@@ -52,8 +52,8 @@ class Origami::JunctionPayController < BaseOrigamiController
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# shop_details = Shop.first
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
|
||||
@@ -12,7 +12,8 @@ class Origami::MasterController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@mastercount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_master = 0
|
||||
@member_discount = 0
|
||||
@@ -63,8 +64,8 @@ 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.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@@ -85,8 +86,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,7 +105,7 @@ class Origami::MovetableController < BaseOrigamiController
|
||||
# @type = (DiningFacility.find(change_to)).type
|
||||
# @moved_by = @current_user.name
|
||||
# @date = DateTime.now
|
||||
# @shop = Shop.first
|
||||
# @shop = Shop.current_shop
|
||||
# unique_code = "MoveTablePdf"
|
||||
# pdf_no = PrintSetting.where(:unique_code => unique_code).count
|
||||
# #print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
@@ -11,7 +11,8 @@ class Origami::MpuController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@mpucount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_mpu = 0
|
||||
@member_discount = 0
|
||||
@@ -64,8 +65,8 @@ 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.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@@ -85,8 +86,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,8 @@ 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.current_shop
|
||||
@receipt_bill = check_receipt_bill
|
||||
end
|
||||
|
||||
@@ -98,7 +100,7 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_order_info
|
||||
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{@shop.shop_code}'").count()
|
||||
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{current_shop.shop_code}'").count()
|
||||
render :json => order_reservation
|
||||
end
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@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')
|
||||
@order = Order.find(params[:order_id])
|
||||
|
||||
@@ -6,7 +6,8 @@ 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.current_shop
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
@@ -74,7 +75,8 @@ def create
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# shop_details = Shop.first
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
|
||||
@@ -32,7 +32,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
@@ -59,11 +59,11 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#shop detail
|
||||
## shop_detail = Shop.first
|
||||
## shop_detail = Shop.current_shop
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer = Customer.find(sale_data.customer_id)
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = new_total - sale_data.grand_total
|
||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
@@ -76,14 +76,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
|
||||
|
||||
# find order id by sale id
|
||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
@@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => Shop.current_shop.shop_code).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
@@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, Shop.current_shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
@@ -141,10 +141,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
#shop_detail = Shop.first
|
||||
#shop_detail = Shop.current_shop
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
@@ -198,7 +198,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Print
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
@@ -226,7 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
@@ -281,14 +281,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
#end
|
||||
end
|
||||
@@ -313,7 +313,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def show
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",Shop.current_shop.shop_code)
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@@ -333,7 +333,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,Shop.current_shop.shop_code)
|
||||
@membership_rebate_balance=0
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -358,17 +358,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",Shop.current_shop.shop_code)
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,Shop.current_shop)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
@@ -410,7 +410,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#end rounding adjustment
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -436,7 +436,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{Shop.current_shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@@ -450,7 +450,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
@@ -577,7 +577,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
#shop_detail = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
@@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -686,8 +686,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
#shop_detail = Shop.current_shop
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
@@ -702,7 +703,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
@@ -711,7 +712,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -746,7 +747,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if Shop.current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
@@ -769,9 +770,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if cashier_type.strip.downcase == "doemal_order"
|
||||
unique_code = "ReceiptBillOrderPdf"
|
||||
else
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'")
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
@@ -794,7 +795,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
payment_method = "paypar"
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# shop_details = Shop.first
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
|
||||
@@ -137,10 +137,8 @@ class Origami::QuickServiceController < ApplicationController
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
@@ -153,7 +151,6 @@ class Origami::QuickServiceController < ApplicationController
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
@@ -174,7 +171,6 @@ class Origami::QuickServiceController < ApplicationController
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
|
||||
@@ -6,7 +6,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
# @shop = Shop.first
|
||||
@shop = Shop.current_shop
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
|
||||
@@ -90,7 +90,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
# Not Use for these printed bill cannot give customer
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
# shop_details = Shop.find(1)
|
||||
# shop_details = Shop.current_shop
|
||||
# # customer= Customer.where('customer_id=' +.customer_id)
|
||||
# customer= Customer.find(@sale_data.customer_id)
|
||||
# # get member information
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
class Origami::RoomInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
puts "room bookig lenght"
|
||||
@sale_array = Array.new
|
||||
@room.bookings.each do |booking|
|
||||
puts booking.sale_id
|
||||
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
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",@shop.shop_code)
|
||||
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).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')
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
@webview = false
|
||||
@@ -17,9 +18,10 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).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')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
@@ -31,6 +33,10 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code)
|
||||
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@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|
|
||||
|
||||
@@ -163,8 +163,6 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
|
||||
end
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@ class Origami::SalesController < BaseOrigamiController
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
|
||||
@tables = Table.unscope(:order).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).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')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
|
||||
@@ -27,7 +27,7 @@ class Origami::SecondDisplayController < BaseOrigamiController
|
||||
#Shop Name in Navbor
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# @shop = Shop.current_shop
|
||||
# end
|
||||
|
||||
|
||||
|
||||
@@ -158,15 +158,8 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
# puts order_id
|
||||
# puts order_ids.count
|
||||
# puts order_id_count
|
||||
# puts order_items.count
|
||||
# puts order_item_count
|
||||
|
||||
if !order_id.nil?
|
||||
if order_id_count > 1
|
||||
puts "order_id_count > 1"
|
||||
|
||||
updated_order_id = Array.new
|
||||
arr_order_ids.each do |order|
|
||||
@@ -178,9 +171,6 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
# puts "updated_order_id"
|
||||
# puts updated_order_id
|
||||
|
||||
if !updated_order_id.empty?
|
||||
order_ids.each do |odr_id|
|
||||
unless updated_order_id.include?(odr_id)
|
||||
@@ -208,8 +198,6 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
# puts new_order_status
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
@@ -236,7 +224,6 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
else
|
||||
# puts "order_id_count < 1"
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
@@ -249,8 +236,6 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
# puts new_order_status
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(order_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
@@ -412,4 +397,9 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
render :json => { status: true }
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
# shop = Shop.first
|
||||
puts "table bookig lenght"
|
||||
|
||||
shop = Shop.current_shop
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
puts booking.sale_id
|
||||
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
@@ -30,12 +29,11 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def show
|
||||
# puts 'Catch me if you can.......................'
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
# shop = Shop.first
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
shop = Shop.current_shop
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
|
||||
@@ -11,7 +11,8 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@unionpaycount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_unionpay = 0
|
||||
@member_discount = 0
|
||||
@@ -61,8 +62,8 @@ 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.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@@ -83,8 +84,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,8 @@ class Origami::VisaController < BaseOrigamiController
|
||||
end
|
||||
total = 0
|
||||
@visacount = 0
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
@rounding_adj = 0
|
||||
@can_visa = 0
|
||||
@member_discount = 0
|
||||
@@ -61,8 +62,8 @@ 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.current_shop
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@@ -83,8 +84,9 @@ 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.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,6 +115,8 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
|
||||
@@ -8,7 +8,8 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
@vouchercount = 0
|
||||
others = 0
|
||||
|
||||
# @shop = Shop.first
|
||||
|
||||
@shop = Shop.current_shop
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
|
||||
@@ -88,6 +88,8 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
|
||||
@@ -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(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(Shop.current_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(@shop.shop_code)
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(Shop.current_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
|
||||
@print_setting.shop_code = Shop.current_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],@shop.shop_code)
|
||||
Lookup.save_shift_sale_items_settings(params[:shift_sale_items],Shop.current_shop.shop_code)
|
||||
end
|
||||
|
||||
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }
|
||||
|
||||
@@ -27,9 +27,7 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
account_type = params[:account_type]
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
logger.debug 'product>>>>>>>>>>>>>>>>>>>>>>>>>>'
|
||||
# logger.debug @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"Date" =>key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
|
||||
|
||||
@hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
logger.debug @hourly_total_qty
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@ class Reports::ProductSaleController < BaseReportController
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
@shop = Shop.current_shop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -112,7 +112,6 @@ authorize_resource :class => false
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
rescue OpenURI::HTTPError
|
||||
puts "Fire in here"
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't open server "}
|
||||
@@ -121,9 +120,6 @@ authorize_resource :class => false
|
||||
rescue Errno::ECONNREFUSED, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
||||
response = { status: false, message: "Can't open membership server"}
|
||||
end
|
||||
|
||||
puts url
|
||||
puts response
|
||||
@message = @result.parsed_response['message']
|
||||
end
|
||||
|
||||
@@ -183,7 +179,7 @@ authorize_resource :class => false
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
#shop_detail = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
|
||||
@@ -10,11 +10,11 @@ authorize_resource :class => false
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
|
||||
else
|
||||
if @shift_sale.shift_closed_at.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
|
||||
@@ -25,8 +25,10 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
|
||||
@@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController
|
||||
# GET /settings/cashier_terminals
|
||||
# GET /settings/cashier_terminals.json
|
||||
def index
|
||||
@settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code)
|
||||
@settings_cashier_terminals = CashierTerminal.where("shop_code=?",Shop.current_shop.shop_code)
|
||||
end
|
||||
|
||||
# GET /settings/cashier_terminals/1
|
||||
|
||||
@@ -37,7 +37,6 @@ class Settings::CommissionersController < ApplicationController
|
||||
unless @commissioner.resigned_date.nil?
|
||||
@commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
# puts params[:from_induty].length
|
||||
if (params[:from_induty] != "true")
|
||||
respond_to do |format|
|
||||
if @commissioner.save
|
||||
|
||||
@@ -31,7 +31,7 @@ class Settings::EmployeesController < ApplicationController
|
||||
# POST /employees.json
|
||||
def create
|
||||
@employee = Employee.new(employee_params)
|
||||
@employee.shop_code = @shop.shop_code
|
||||
@employee.shop_code =current_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
|
||||
@settings_lookup.shop_code = current_shop.shop_code
|
||||
respond_to do |format|
|
||||
if @settings_lookup.save
|
||||
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' }
|
||||
|
||||
@@ -41,7 +41,6 @@ class Settings::PaymentMethodSettingsController < ApplicationController
|
||||
# PATCH/PUT /settings/payment_method_settings/1
|
||||
# PATCH/PUT /settings/payment_method_settings/1.json
|
||||
def update
|
||||
puts settings_payment_method_setting_params
|
||||
respond_to do |format|
|
||||
if @settings_payment_method_setting.update(settings_payment_method_setting_params)
|
||||
format.html { redirect_to settings_payment_method_setting_path(@settings_payment_method_setting), notice: 'Payment method setting was successfully updated.' }
|
||||
|
||||
@@ -117,8 +117,6 @@ class Settings::PromotionsController < ApplicationController
|
||||
end
|
||||
res.push({item_inst.menu_item.item_code => arr_inst})
|
||||
end
|
||||
puts "res"
|
||||
p res
|
||||
render json: res
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ class Settings::RoomsController < ApplicationController
|
||||
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_room }
|
||||
else
|
||||
puts "abc"
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
||||
@@ -56,14 +56,15 @@ 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
|
||||
save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}")
|
||||
|
||||
File.delete(delete_path)
|
||||
end
|
||||
end
|
||||
save_path = Rails.root.join("public/#{Shop.current_shop.shop_code}_#{a.original_filename}")
|
||||
File.open(save_path, 'wb') do |f|
|
||||
f.write a.read
|
||||
end
|
||||
audio_name = "#{current_shop.shop_code}_#{a.original_filename}"
|
||||
audio_name = "#{Shop.current_shop.shop_code}_#{a.original_filename}"
|
||||
@settings_shop.display_images.where(:name => "order_audio").destroy_all
|
||||
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name)
|
||||
else
|
||||
|
||||
@@ -346,7 +346,7 @@ class Transactions::SalesController < ApplicationController
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find_by_id(1)
|
||||
shop_details = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module ApplicationHelper
|
||||
include NumberFormattable
|
||||
|
||||
def flash_class(level)
|
||||
case level
|
||||
when :notice then "alert alert-info fade-in"
|
||||
@@ -6,5 +8,6 @@ module ApplicationHelper
|
||||
when :error then "alert alert-error fade-in"
|
||||
when :alert then "alert alert-error fade-in"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
|
||||
def self.inherited(subclass)
|
||||
super
|
||||
|
||||
return unless subclass.superclass == self
|
||||
return unless subclass.column_names.include? 'shop_id'
|
||||
|
||||
subclass.class_eval do
|
||||
acts_as_tenant(:shop)
|
||||
end
|
||||
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