diff --git a/Dockerfile b/Dockerfile
index a3e46f4d..74c726d4 100644
--- a/Dockerfile
+++ b/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"]
\ No newline at end of file
+CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
diff --git a/Dockerfile.backup b/Dockerfile.backup
new file mode 100644
index 00000000..a72a1ae4
--- /dev/null
+++ b/Dockerfile.backup
@@ -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"]
diff --git a/Gemfile b/Gemfile
index 8c30c9a9..b423167a 100644
--- a/Gemfile
+++ b/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'
diff --git a/Gemfile.lock b/Gemfile.lock
index 3a70c5bd..730e1f37 100644
--- a/Gemfile.lock
+++ b/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
diff --git a/README.md b/README.md
index 77a25926..54474f5e 100755
--- a/README.md
+++ b/README.md
@@ -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 }
diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb
index bc06496d..7b9b0cf2 100755
--- a/app/controllers/api/api_controller.rb
+++ b/app/controllers/api/api_controller.rb
@@ -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.
diff --git a/app/controllers/api/authenticate_controller.rb b/app/controllers/api/authenticate_controller.rb
index 287730f6..ba2cf5a8 100755
--- a/app/controllers/api/authenticate_controller.rb
+++ b/app/controllers/api/authenticate_controller.rb
@@ -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
diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb
index 4c9d5a79..22f1ede8 100755
--- a/app/controllers/api/bill_controller.rb
+++ b/app/controllers/api/bill_controller.rb
@@ -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
diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb
index 08edc944..6548c103 100644
--- a/app/controllers/api/call_waiters_controller.rb
+++ b/app/controllers/api/call_waiters_controller.rb
@@ -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)
diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb
index 32c2192e..f2981601 100644
--- a/app/controllers/api/order_reserve/order_reservation_controller.rb
+++ b/app/controllers/api/order_reserve/order_reservation_controller.rb
@@ -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
diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb
index 33dc116b..2b9fbfbf 100755
--- a/app/controllers/api/orders_controller.rb
+++ b/app/controllers/api/orders_controller.rb
@@ -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"
diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb
index 1dd984c4..24461ae9 100644
--- a/app/controllers/api/payment/mobilepayment_controller.rb
+++ b/app/controllers/api/payment/mobilepayment_controller.rb
@@ -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
diff --git a/app/controllers/api/sound_effect_controller.rb b/app/controllers/api/sound_effect_controller.rb
index 97dc3db5..f3126ca2 100644
--- a/app/controllers/api/sound_effect_controller.rb
+++ b/app/controllers/api/sound_effect_controller.rb
@@ -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")
diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb
index 1c5e81a2..2f2da0e2 100644
--- a/app/controllers/api/survey_controller.rb
+++ b/app/controllers/api/survey_controller.rb
@@ -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])
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index c4023b49..636fdc8e 100755
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
#before_action :check_installation
protect_from_forgery with: :exception
diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb
index 1bf5b4d4..1bb0421e 100755
--- a/app/controllers/base_controller.rb
+++ b/app/controllers/base_controller.rb
@@ -1,5 +1,6 @@
class BaseController < ActionController::Base
+ include MultiTenancy
layout "installation"
protect_from_forgery with: :exception
-
+
end
diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb
index 00b5cf98..2cf47467 100755
--- a/app/controllers/base_crm_controller.rb
+++ b/app/controllers/base_crm_controller.rb
@@ -1,5 +1,5 @@
class BaseCrmController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
layout "CRM"
before_action :check_user
diff --git a/app/controllers/base_foodcourt_controller.rb b/app/controllers/base_foodcourt_controller.rb
index 5a37529b..3d28f342 100644
--- a/app/controllers/base_foodcourt_controller.rb
+++ b/app/controllers/base_foodcourt_controller.rb
@@ -1,5 +1,5 @@
class BaseFoodcourtController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
layout "foodcourt"
before_action :check_user
diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb
index 8ee82777..bd455c33 100755
--- a/app/controllers/base_inventory_controller.rb
+++ b/app/controllers/base_inventory_controller.rb
@@ -1,5 +1,5 @@
class BaseInventoryController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
layout "inventory"
before_action :check_user
diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb
index 9b337b69..6e6a9c0f 100755
--- a/app/controllers/base_oqs_controller.rb
+++ b/app/controllers/base_oqs_controller.rb
@@ -1,5 +1,5 @@
class BaseOqsController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
layout "OQS"
before_action :check_user
diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb
index 3c362207..3a609dab 100755
--- a/app/controllers/base_origami_controller.rb
+++ b/app/controllers/base_origami_controller.rb
@@ -1,5 +1,5 @@
class BaseOrigamiController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
layout "origami"
before_action :check_user
diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb
index 0875fda5..b3d1d23a 100755
--- a/app/controllers/base_report_controller.rb
+++ b/app/controllers/base_report_controller.rb
@@ -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
diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb
index 580de0f9..b1d2056c 100755
--- a/app/controllers/base_waiter_controller.rb
+++ b/app/controllers/base_waiter_controller.rb
@@ -1,5 +1,5 @@
class BaseWaiterController < ActionController::Base
- include LoginVerification
+ include LoginVerification, MultiTenancy
layout "waiter"
before_action :check_user
diff --git a/app/controllers/concerns/license_verification.rb b/app/controllers/concerns/license_verification.rb
index e28cc28a..a29eaff5 100644
--- a/app/controllers/concerns/license_verification.rb
+++ b/app/controllers/concerns/license_verification.rb
@@ -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
diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb
index 5ae86b18..3b714cc9 100755
--- a/app/controllers/concerns/login_verification.rb
+++ b/app/controllers/concerns/login_verification.rb
@@ -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?
diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb
new file mode 100644
index 00000000..5009e094
--- /dev/null
+++ b/app/controllers/concerns/multi_tenancy.rb
@@ -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
diff --git a/app/controllers/concerns/number_formattable.rb b/app/controllers/concerns/number_formattable.rb
new file mode 100644
index 00000000..bb022263
--- /dev/null
+++ b/app/controllers/concerns/number_formattable.rb
@@ -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
diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index 936ef7a2..6d7783fa 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -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)
diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb
index 28da784a..3eb6622e 100755
--- a/app/controllers/crm/dining_queues_controller.rb
+++ b/app/controllers/crm/dining_queues_controller.rb
@@ -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.
diff --git a/app/controllers/foodcourt/addorders_controller.rb b/app/controllers/foodcourt/addorders_controller.rb
index 7960c2f9..7abbdd90 100755
--- a/app/controllers/foodcourt/addorders_controller.rb
+++ b/app/controllers/foodcourt/addorders_controller.rb
@@ -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)
diff --git a/app/controllers/foodcourt/cash_ins_controller.rb b/app/controllers/foodcourt/cash_ins_controller.rb
index 9f96dffd..7245ffa7 100755
--- a/app/controllers/foodcourt/cash_ins_controller.rb
+++ b/app/controllers/foodcourt/cash_ins_controller.rb
@@ -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])
diff --git a/app/controllers/foodcourt/cash_outs_controller.rb b/app/controllers/foodcourt/cash_outs_controller.rb
index f890f51c..1dbf62d2 100755
--- a/app/controllers/foodcourt/cash_outs_controller.rb
+++ b/app/controllers/foodcourt/cash_outs_controller.rb
@@ -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])
diff --git a/app/controllers/foodcourt/customers_controller.rb b/app/controllers/foodcourt/customers_controller.rb
index 853d58c0..316b9837 100644
--- a/app/controllers/foodcourt/customers_controller.rb
+++ b/app/controllers/foodcourt/customers_controller.rb
@@ -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
diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb
index 9fd19ec7..23c905b7 100644
--- a/app/controllers/foodcourt/dashboard_controller.rb
+++ b/app/controllers/foodcourt/dashboard_controller.rb
@@ -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
diff --git a/app/controllers/foodcourt/discounts_controller.rb b/app/controllers/foodcourt/discounts_controller.rb
index 80d30cd9..e2ef8fcc 100755
--- a/app/controllers/foodcourt/discounts_controller.rb
+++ b/app/controllers/foodcourt/discounts_controller.rb
@@ -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
diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb
index ade02080..df04116f 100644
--- a/app/controllers/foodcourt/food_court_controller.rb
+++ b/app/controllers/foodcourt/food_court_controller.rb
@@ -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
diff --git a/app/controllers/foodcourt/home_controller.rb b/app/controllers/foodcourt/home_controller.rb
index 3d424f14..f894afc9 100755
--- a/app/controllers/foodcourt/home_controller.rb
+++ b/app/controllers/foodcourt/home_controller.rb
@@ -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)
diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb
index c313b972..5bfa1291 100755
--- a/app/controllers/foodcourt/payments_controller.rb
+++ b/app/controllers/foodcourt/payments_controller.rb
@@ -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)
diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb
index d0048dbf..8ecff4d2 100755
--- a/app/controllers/foodcourt/shifts_controller.rb
+++ b/app/controllers/foodcourt/shifts_controller.rb
@@ -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)
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index af100ec5..772710df 100755
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -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
diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb
index 137b733a..e06e2341 100755
--- a/app/controllers/inventory/inventory_controller.rb
+++ b/app/controllers/inventory/inventory_controller.rb
@@ -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
diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb
index 8497553e..dd21f7fc 100755
--- a/app/controllers/inventory/inventory_definitions_controller.rb
+++ b/app/controllers/inventory/inventory_definitions_controller.rb
@@ -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
diff --git a/app/controllers/inventory/stock_check_items_controller.rb b/app/controllers/inventory/stock_check_items_controller.rb
index e4563277..eda096d4 100755
--- a/app/controllers/inventory/stock_check_items_controller.rb
+++ b/app/controllers/inventory/stock_check_items_controller.rb
@@ -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
diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb
index c756c8bb..fea1ff0c 100755
--- a/app/controllers/inventory/stock_checks_controller.rb
+++ b/app/controllers/inventory/stock_checks_controller.rb
@@ -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]
diff --git a/app/controllers/inventory/stock_journals_controller.rb b/app/controllers/inventory/stock_journals_controller.rb
index cdba207e..7a99e5aa 100755
--- a/app/controllers/inventory/stock_journals_controller.rb
+++ b/app/controllers/inventory/stock_journals_controller.rb
@@ -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
diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb
index aeda9b40..e2499fbb 100644
--- a/app/controllers/oqs/edit_controller.rb
+++ b/app/controllers/oqs/edit_controller.rb
@@ -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
diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb
index f63e505e..c89f6e0a 100755
--- a/app/controllers/oqs/home_controller.rb
+++ b/app/controllers/oqs/home_controller.rb
@@ -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?
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index baa88e4d..9670ee23 100755
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -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"
diff --git a/app/controllers/origami/alipay_controller.rb b/app/controllers/origami/alipay_controller.rb
index 63ff5a6b..9b8014f2 100644
--- a/app/controllers/origami/alipay_controller.rb
+++ b/app/controllers/origami/alipay_controller.rb
@@ -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
diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb
index 7ebb698a..ac3c0648 100755
--- a/app/controllers/origami/cash_ins_controller.rb
+++ b/app/controllers/origami/cash_ins_controller.rb
@@ -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
diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb
index f5ac5740..564945f5 100755
--- a/app/controllers/origami/credit_payments_controller.rb
+++ b/app/controllers/origami/credit_payments_controller.rb
@@ -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)
diff --git a/app/controllers/origami/credit_sales_controller.rb b/app/controllers/origami/credit_sales_controller.rb
index 8f43edda..587b22dd 100644
--- a/app/controllers/origami/credit_sales_controller.rb
+++ b/app/controllers/origami/credit_sales_controller.rb
@@ -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
diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb
index 69b2d398..b812605b 100644
--- a/app/controllers/origami/customers_controller.rb
+++ b/app/controllers/origami/customers_controller.rb
@@ -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?
diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb
index 0a8e5c18..bc01dc27 100644
--- a/app/controllers/origami/dashboard_controller.rb
+++ b/app/controllers/origami/dashboard_controller.rb
@@ -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
diff --git a/app/controllers/origami/dinga_controller.rb b/app/controllers/origami/dinga_controller.rb
index 0472728a..eba83f26 100644
--- a/app/controllers/origami/dinga_controller.rb
+++ b/app/controllers/origami/dinga_controller.rb
@@ -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)
diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb
index 69826641..b44ac29b 100644
--- a/app/controllers/origami/food_court_controller.rb
+++ b/app/controllers/origami/food_court_controller.rb
@@ -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"
diff --git a/app/controllers/origami/gift_voucher_controller.rb b/app/controllers/origami/gift_voucher_controller.rb
index 7bd4cd77..a19bcfac 100644
--- a/app/controllers/origami/gift_voucher_controller.rb
+++ b/app/controllers/origami/gift_voucher_controller.rb
@@ -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
diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb
index 81986afa..349dd27f 100755
--- a/app/controllers/origami/home_controller.rb
+++ b/app/controllers/origami/home_controller.rb
@@ -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)
diff --git a/app/controllers/origami/in_duties_controller.rb b/app/controllers/origami/in_duties_controller.rb
index 5210851b..0c1b3723 100755
--- a/app/controllers/origami/in_duties_controller.rb
+++ b/app/controllers/origami/in_duties_controller.rb
@@ -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?
diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb
index 897d8bae..a26a427e 100644
--- a/app/controllers/origami/jcb_controller.rb
+++ b/app/controllers/origami/jcb_controller.rb
@@ -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
diff --git a/app/controllers/origami/junction_pay_controller.rb b/app/controllers/origami/junction_pay_controller.rb
index 67a9c748..4c97efcc 100644
--- a/app/controllers/origami/junction_pay_controller.rb
+++ b/app/controllers/origami/junction_pay_controller.rb
@@ -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)
diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb
index 26a31b71..d01db13b 100644
--- a/app/controllers/origami/master_controller.rb
+++ b/app/controllers/origami/master_controller.rb
@@ -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
diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb
index 41c58941..86680c6e 100755
--- a/app/controllers/origami/movetable_controller.rb
+++ b/app/controllers/origami/movetable_controller.rb
@@ -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)
diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb
index 2c8a1d29..17b4dd34 100644
--- a/app/controllers/origami/mpu_controller.rb
+++ b/app/controllers/origami/mpu_controller.rb
@@ -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
diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb
index 3bde49ec..3e26e07a 100644
--- a/app/controllers/origami/order_reservation_controller.rb
+++ b/app/controllers/origami/order_reservation_controller.rb
@@ -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
diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb
index 5f34d9a3..2a7c9aa3 100755
--- a/app/controllers/origami/orders_controller.rb
+++ b/app/controllers/origami/orders_controller.rb
@@ -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])
diff --git a/app/controllers/origami/paymal_controller.rb b/app/controllers/origami/paymal_controller.rb
index 91fa4790..0b418215 100644
--- a/app/controllers/origami/paymal_controller.rb
+++ b/app/controllers/origami/paymal_controller.rb
@@ -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
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 0b0613d7..271daf3b 100755
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -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)
diff --git a/app/controllers/origami/paypar_payments_controller.rb b/app/controllers/origami/paypar_payments_controller.rb
index 70a3aef5..d977f38b 100755
--- a/app/controllers/origami/paypar_payments_controller.rb
+++ b/app/controllers/origami/paypar_payments_controller.rb
@@ -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)
diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb
index f57189d0..3d7ef13b 100644
--- a/app/controllers/origami/quick_service_controller.rb
+++ b/app/controllers/origami/quick_service_controller.rb
@@ -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"
diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb
index 4a2d867a..49942e4b 100755
--- a/app/controllers/origami/redeem_payments_controller.rb
+++ b/app/controllers/origami/redeem_payments_controller.rb
@@ -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
diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb
index c23d4964..a3cdf679 100755
--- a/app/controllers/origami/request_bills_controller.rb
+++ b/app/controllers/origami/request_bills_controller.rb
@@ -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
diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb
index 8d805771..c73c153a 100755
--- a/app/controllers/origami/room_invoices_controller.rb
+++ b/app/controllers/origami/room_invoices_controller.rb
@@ -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
diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb
index c7c19930..6f219691 100755
--- a/app/controllers/origami/rooms_controller.rb
+++ b/app/controllers/origami/rooms_controller.rb
@@ -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|
diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb
index 7c9ec35e..57c1dc93 100755
--- a/app/controllers/origami/sale_edit_controller.rb
+++ b/app/controllers/origami/sale_edit_controller.rb
@@ -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
diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb
index 4e20e293..6aef2b0c 100755
--- a/app/controllers/origami/sales_controller.rb
+++ b/app/controllers/origami/sales_controller.rb
@@ -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])
diff --git a/app/controllers/origami/second_display_controller.rb b/app/controllers/origami/second_display_controller.rb
index 21c0674d..392b85e6 100644
--- a/app/controllers/origami/second_display_controller.rb
+++ b/app/controllers/origami/second_display_controller.rb
@@ -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
diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb
index a80a3a4d..b723af80 100755
--- a/app/controllers/origami/split_bill_controller.rb
+++ b/app/controllers/origami/split_bill_controller.rb
@@ -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
diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb
index a5d72b1e..3605d8e6 100755
--- a/app/controllers/origami/table_invoices_controller.rb
+++ b/app/controllers/origami/table_invoices_controller.rb
@@ -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?
diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb
index aaa05922..f132a49d 100644
--- a/app/controllers/origami/unionpay_controller.rb
+++ b/app/controllers/origami/unionpay_controller.rb
@@ -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
diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb
index 7463e271..91095f64 100644
--- a/app/controllers/origami/visa_controller.rb
+++ b/app/controllers/origami/visa_controller.rb
@@ -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
diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb
index 38ae404d..a4fd46d1 100755
--- a/app/controllers/origami/void_controller.rb
+++ b/app/controllers/origami/void_controller.rb
@@ -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
diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb
index 671eb9fc..4ecd784b 100755
--- a/app/controllers/origami/voucher_controller.rb
+++ b/app/controllers/origami/voucher_controller.rb
@@ -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
diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb
index ff86bbd2..18391443 100755
--- a/app/controllers/origami/waste_spoile_controller.rb
+++ b/app/controllers/origami/waste_spoile_controller.rb
@@ -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
diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb
index 0d8c5280..f1f6ed68 100755
--- a/app/controllers/print_settings_controller.rb
+++ b/app/controllers/print_settings_controller.rb
@@ -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.' }
diff --git a/app/controllers/reports/hourly_saleitem_controller.bk.rb b/app/controllers/reports/hourly_saleitem_controller.bk.rb
index 88a61335..ab4f81ea 100644
--- a/app/controllers/reports/hourly_saleitem_controller.bk.rb
+++ b/app/controllers/reports/hourly_saleitem_controller.bk.rb
@@ -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
diff --git a/app/controllers/reports/product_sale_controller.rb b/app/controllers/reports/product_sale_controller.rb
index 9791545e..61f17396 100644
--- a/app/controllers/reports/product_sale_controller.rb
+++ b/app/controllers/reports/product_sale_controller.rb
@@ -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
diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb
index 81704ace..3a5848d4 100755
--- a/app/controllers/reports/receipt_no_controller.rb
+++ b/app/controllers/reports/receipt_no_controller.rb
@@ -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
diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb
index d3b738c5..59bf70c5 100755
--- a/app/controllers/reports/receipt_no_detail_controller.rb
+++ b/app/controllers/reports/receipt_no_detail_controller.rb
@@ -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
diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb
index bb57eb64..987674d5 100755
--- a/app/controllers/settings/cashier_terminals_controller.rb
+++ b/app/controllers/settings/cashier_terminals_controller.rb
@@ -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
diff --git a/app/controllers/settings/commissioners_controller.rb b/app/controllers/settings/commissioners_controller.rb
index 0f93545d..54a9e926 100755
--- a/app/controllers/settings/commissioners_controller.rb
+++ b/app/controllers/settings/commissioners_controller.rb
@@ -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
diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb
index 5c9dae6f..140ff2c0 100755
--- a/app/controllers/settings/employees_controller.rb
+++ b/app/controllers/settings/employees_controller.rb
@@ -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.' }
diff --git a/app/controllers/settings/lookups_controller.rb b/app/controllers/settings/lookups_controller.rb
index 87c81842..4390dadd 100755
--- a/app/controllers/settings/lookups_controller.rb
+++ b/app/controllers/settings/lookups_controller.rb
@@ -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.' }
diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb
index 74b2a10b..e85e7a99 100755
--- a/app/controllers/settings/payment_method_settings_controller.rb
+++ b/app/controllers/settings/payment_method_settings_controller.rb
@@ -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.' }
diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb
index 9f3c8fcf..25b1b9d7 100755
--- a/app/controllers/settings/promotions_controller.rb
+++ b/app/controllers/settings/promotions_controller.rb
@@ -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
diff --git a/app/controllers/settings/rooms_controller.rb b/app/controllers/settings/rooms_controller.rb
index 35e4fcb5..5ba5c0ef 100755
--- a/app/controllers/settings/rooms_controller.rb
+++ b/app/controllers/settings/rooms_controller.rb
@@ -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
diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb
index ab492bdf..33d47d09 100644
--- a/app/controllers/settings/shops_controller.rb
+++ b/app/controllers/settings/shops_controller.rb
@@ -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
diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb
index bed00c2e..6556159c 100755
--- a/app/controllers/transactions/sales_controller.rb
+++ b/app/controllers/transactions/sales_controller.rb
@@ -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
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 27024d75..16e44953 100755
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 10a4cba8..590cdf8d 100755
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -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
diff --git a/app/models/dining_charge.rb b/app/models/dining_charge.rb
index 6f931bcf..3151e88f 100755
--- a/app/models/dining_charge.rb
+++ b/app/models/dining_charge.rb
@@ -22,7 +22,7 @@ class DiningCharge < ApplicationRecord
end
return block_count, price
else
- puts "<<<<<<<< NO"
+ Rails.logger.info "Params not enough"
end
end
diff --git a/app/models/employee.rb b/app/models/employee.rb
index 67aad0f6..f27adf29 100755
--- a/app/models/employee.rb
+++ b/app/models/employee.rb
@@ -3,6 +3,7 @@ class Employee < ApplicationRecord
has_many :commissioners
has_many :shit_sales
belongs_to :order_queue_station
+
validates_presence_of :name, :role
validates_presence_of :password, :on => [:create]
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
@@ -19,9 +20,9 @@ class Employee < ApplicationRecord
Employee.select("id, name").map { |e| [e.name, e.id] }
end
- def self.login(shop,emp_id, password)
- user = Employee.find_by_emp_id_and_shop_code(emp_id,shop.shop_code)
- expiry_time = login_expiry_time(shop)
+ def self.login(emp_id, password)
+ user = Employee.find_by_emp_id(emp_id)
+ expiry_time = login_expiry_time
if (user)
#user.authenticate(password)
if (user.authenticate(password))
@@ -36,10 +37,10 @@ class Employee < ApplicationRecord
end
- def self.authenticate_by_token(session_token,shop)
+ def self.authenticate_by_token(session_token)
if (session_token)
- user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
- expiry_time = login_expiry_time(shop)
+ user = Employee.find_by_token_session(session_token)
+ expiry_time = login_expiry_time
if user && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
@@ -54,9 +55,9 @@ class Employee < ApplicationRecord
return false
end
- def self.logout(shop,session_token)
+ def self.logout(session_token)
if (session_token)
- user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code)
+ user = Employee.find_by_token_session(session_token)
if user
user.token_session = nil
@@ -72,9 +73,9 @@ class Employee < ApplicationRecord
retry
end
- def self.login_expiry_time(shop)
+ def self.login_expiry_time
expiry_time = 30
- login_expiry = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('expiry_time')
+ login_expiry = Lookup.collection_of('expiry_time')
if !login_expiry.empty?
login_expiry.each do |exp_time|
if exp_time[0].downcase == "login"
diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb
index b7ef3e44..fb00113a 100755
--- a/app/models/inventory_definition.rb
+++ b/app/models/inventory_definition.rb
@@ -23,34 +23,23 @@ class InventoryDefinition < ApplicationRecord
end
end
- def self.find_product_in_inventory(item,shop_code=nil)
- # unless instance_code.empty?
- # instance_code = instance_code.to_s
- # instance_code[0] = ""
- # instance_code = instance_code.chomp("]")
- # else
- # instance_code = '"0"'
- # end
- #
- # if prod = InventoryDefinition.where("item_code IN(#{instance_code})")
- # puts "found prodcut+++++++++++++++++++++++++++++++++++==="
- # puts prod.to_json
- # end
- if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
- if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,shop_code)
+
+ def self.find_product_in_inventory(item)
+ if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code)
+ if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code)
return true, product
end
end
end
def self.check_balance(item, inventory_definition) # item => saleItemOBj
- stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first
- unless stock.nil?
- modify_balance(item, stock, inventory_definition)
- else
- puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUT OF STOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
- StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
- end
+
+ stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first
+ unless stock.nil?
+ modify_balance(item, stock, inventory_definition)
+ else
+ StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
+ end
end
def self.modify_balance(item, stock, inventory_definition) #saleitemObj
@@ -75,6 +64,7 @@ class InventoryDefinition < ApplicationRecord
elsif item.is_a? SaleItem
trans_type = StockJournal::SALES_TRANS
end
+ # StockJournal.add_to_journal(instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
StockJournal.add_to_journal(item.item_instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
check_item.different = check_item.different - qty
check_item.save
diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb
index 5893e048..523a7fc5 100644
--- a/app/models/kbz_pay.rb
+++ b/app/models/kbz_pay.rb
@@ -3,13 +3,13 @@ class KbzPay
KBZ_PAY = 'KBZPay'
def self.pay(amount, receipt_no, url, key, app_id, code)
- shop = Shop.first
+ shop = Shop.current_shop
prefix = shop.shop_code
receipt_no = "#{prefix}#{receipt_no}"
datetime = DateTime.now.strftime("%d%m%Y%H%M")
kbz_app_id = app_id
- kbz_merch_code = code
+ kbz_merch_code = code
kbz_api_key = key
kbz_provider_url = "#{url}/precreate"
@@ -58,17 +58,17 @@ class KbzPay
# Rails.logger.debug result['Response']
return false, result['Response']
end
-
+
end
def self.query(receipt_no, current_user, url, key, app_id, code)
- shop = Shop.first
+ shop = Shop.current_shop
prefix = shop.shop_code
receipt_no = "#{prefix}#{receipt_no}"
amount = 0
datetime = DateTime.now.strftime("%d%m%Y%H%M")
kbz_app_id = app_id
- kbz_merch_code = code
+ kbz_merch_code = code
kbz_api_key = key
kbz_provider_url = "#{url}/queryorder"
@@ -122,7 +122,7 @@ class KbzPay
# return true, "successfully paid by KBZ PAY"
elsif result['Response']['trade_status'] == "PAY_FAILED"
-
+
# return false, "pay failed by KBZ PAY"
elsif result['Response']['trade_status'] == "WAIT_PAY"
# return false , "Waiting to pay by KBZ PAY"
@@ -135,4 +135,4 @@ class KbzPay
return amount
end
-end
\ No newline at end of file
+end
diff --git a/app/models/license.rb b/app/models/license.rb
index 9ef7d956..2c550a1e 100755
--- a/app/models/license.rb
+++ b/app/models/license.rb
@@ -18,22 +18,22 @@ class License
if (server != "")
self.class.base_uri server
end
- end
+ end
# For Cloud
- def detail_with_local_cache(lookup)
+ def detail_with_local_cache(lookup)
aes = MyAesCrypt.new
- aes_key, aes_iv = aes.export_to_file(lookup)
-
+ aes_key, aes_iv = aes.export_to_file(lookup)
+
##Check from local redis - if available load local otherwise get from remote
- cache_key = "#{lookup}:license:#{aes_key}:hostname"
+ cache_key = "#{lookup}:license:#{aes_key}:hostname"
cache_license = nil
##Get redis connection from connection pool
redis = Redis.new
- cache_license = redis.get(cache_key)
-
+ cache_license = redis.get(cache_key)
+
Rails.logger.info "Cache key - " + cache_key.to_s
if cache_license.nil?
##change the d/e key
@@ -41,12 +41,13 @@ class License
@params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: aes_iv} }
response = self.class.get("/subdomain", @params)
@license = response.parsed_response
+ Rails.logger.info "License Response - " + response.parsed_response.to_s
if (@license["status"] == true)
assign(aes_key, aes_iv)
- # Rails.logger.info "License - " + response.parsed_response.to_s
-
+ #Rails.logger.info "License - " + response.parsed_response.to_s
+
redis = Redis.new
redis.set(cache_key, Marshal.dump(@license))
# redis.sadd("License:cache:keys", cache_key)
@@ -59,36 +60,36 @@ class License
return true
end
- else
+ else
@license = Marshal.load(cache_license)
assign(aes_key, aes_iv)
- # Rails.logger.info 'API License'
+ # Rails.logger.info 'API License'
return true
end
end
# For Local System
- def detail_with_local_file()
+ def detail_with_local_file()
renewal_date_str = read_license("renewable_date")
- if check_expiring(renewal_date_str)
- # return for all ok
+ if check_expiring(renewal_date_str)
+ # return for all ok
return 1
else
has_license = verify_license()
if has_license
- # return for expiring
+ # return for expiring
return 2
else
return 0
end
end
- # end
- end
+ # end
+ end
# License Activation
def license_activate (shop, license_key, db_host, db_schema, db_user, db_password)
- aes = MyAesCrypt.new
- aes_key, aes_iv = aes.export_key(license_key)
+ aes = MyAesCrypt.new
+ aes_key, aes_iv = aes.export_key(license_key)
@params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } }
response = self.class.get("/activate", @params)
@@ -96,21 +97,21 @@ class License
if (@activate["status"])
##Check from local redis - if available load local otherwise get from remote
- cache_key = "shop:#{@activate["shop_name"]}"
+ cache_key = "shop:#{@activate["shop_name"]}"
- cache_license = nil
+ cache_license = nil
##Get redis connection from connection pool
redis = Redis.new
- cache_license = redis.get(cache_key)
+ cache_license = redis.get(cache_key)
Rails.logger.info "Cache key - " + cache_key.to_s
- if cache_license.nil?
- cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
+ if cache_license.nil?
+ cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
redis = Redis.new
redis.set(cache_key, Marshal.dump(cache))
- end
+ end
Rails.logger.info "License - " + response.parsed_response.to_s
@@ -120,21 +121,21 @@ class License
sym_path = File.expand_path("~/symmetric/")
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
-
+
if(response[:status])
response = run_symmetric(sym_path)
end
end
else
response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"}
- end
+ end
return response
end
- def verify_license
- api_token = read_license_no_decrypt("api_token")
+ def verify_license
+ api_token = read_license_no_decrypt("api_token")
@params = { query: {lookup_type: "application", api_token: api_token} }
-
+
begin
response = self.class.get("/verify", @params)
@varified = response.parsed_response
@@ -145,7 +146,7 @@ class License
end
else
delete_license_file
- end
+ end
rescue SocketError => e
Rails.logger.debug "In SocketError No Internet connection ! "
@@ -159,21 +160,21 @@ class License
rescue OpenURI::HTTPError
Rails.logger.debug "Can't connect server"
return true
- end
- return false
+ end
+ return false
end
# Check Expired before 30 days
- def check_expiring(renewal_date_str)
+ def check_expiring(renewal_date_str)
if !renewal_date_str.empty?
- renewal_date = DateTime.parse(renewal_date_str)
+ renewal_date = DateTime.parse(renewal_date_str)
renewal_date > Date.today.advance(:days => 30)
end
end
# Check License expired date from PROVISION SERVER
- def check_expired(renewal_date_str)
+ def check_expired(renewal_date_str)
expired_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str)
if(renewal_date_str != expired_date_str)
@@ -186,32 +187,32 @@ class License
return false
end
end
-
+
# Check License File exists
def self.check_license_file
- return File.exist?("config/license.yml")
+ return File.exist?("config/license.yml")
end
# read line by key for license file
- def read_license(key_name)
- decrypted_line = ""
+ def read_license(key_name)
+ decrypted_line = ""
key, iv = get_redis_key()
- if File.exist?("config/license.yml")
+ if File.exist?("config/license.yml")
File.open("config/license.yml").each do |line|
- if line.include? (key_name)
- decrypted_line_array = line.split(": ")
+ if line.include? (key_name)
+ decrypted_line_array = line.split(": ")
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
end
- end
+ end
return decrypted_line
end
# read line by key for license file without decrypt
def read_license_no_decrypt(key)
decrypted_line = ""
- if File.exist?("config/license.yml")
+ if File.exist?("config/license.yml")
File.open("config/license.yml").each do |line|
if line.include? (key)
decrypted_line_array = line.split(": ")
@@ -226,18 +227,18 @@ class License
def update_license(content, new_content)
key, iv = get_redis_key()
- if !new_content.include? "=="
+ if !new_content.include? "=="
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
-
+
content_str = read_license_no_decrypt(content)
- if File.exist?("config/license.yml")
+ if File.exist?("config/license.yml")
file_str = File.read("config/license.yml")
new_file_str = file_str.gsub(content_str, encode_str(crypted_str))
# To write changes to the file, use:
File.open("config/license.yml", "w") {|file| file.puts new_file_str }
-
+
# File.open("config/license.yml").each do |line|
# new_file_str = line.gsub(content, crypted_str)
# f.put
@@ -247,33 +248,33 @@ class License
# Re-get keys
def get_key
- api_token = read_license_no_decrypt("api_token")
- shop_name = read_license_no_decrypt("shop_name")
+ api_token = read_license_no_decrypt("api_token")
+ shop_name = read_license_no_decrypt("shop_name")
@params = { query: {lookup_type: "application", api_token: api_token } }
response = self.class.get("/get_key", @params)
@data = response.parsed_response
-
+
if (@data["status"])
##Check from local redis - if available load local otherwise get from remote
- cache_key = "shop:#{shop_name.chomp}"
+ cache_key = "shop:#{shop_name.chomp}"
- cache_license = nil
+ cache_license = nil
##Get redis connection from connection pool
redis = Redis.new
- cache_license = redis.get(cache_key)
+ cache_license = redis.get(cache_key)
Rails.logger.info "Cache key - " + cache_key.to_s
- if cache_license.nil?
- cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] }
+ if cache_license.nil?
+ cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] }
redis = Redis.new
redis.set(cache_key, Marshal.dump(cache))
- end
+ end
return true
- end
+ end
return false
- end
+ end
private
def get_redis_key
@@ -281,18 +282,18 @@ class License
key = ""
shop = read_license_no_decrypt("shop_name")
##Check from local redis - if available load local otherwise get from remote
- cache_key = "shop:#{shop.chomp}"
+ cache_key = "shop:#{shop.chomp}"
- cache_shop = nil
+ cache_shop = nil
##Get redis connection from connection pool
redis = Redis.new
- cache_shop = redis.get(cache_key)
+ cache_shop = redis.get(cache_key)
- if !cache_shop.nil?
- @shop = Marshal.load(cache_shop)
- key = @shop["key"]
- iv = @shop["iv"]
+ if !cache_shop.nil?
+ @shop = Marshal.load(cache_shop)
+ key = @shop["key"]
+ iv = @shop["iv"]
end
return key, iv
end
@@ -307,13 +308,13 @@ class License
# License File Creation
def create_license_file(response_data)
- if File.exist?("config/license.yml")
+ if File.exist?("config/license.yml")
delete_license_file
end
begin
# Licese File Creation
- File.open("config/license.yml", "w") do |f|
+ File.open("config/license.yml", "w") do |f|
f.puts("iv_key: #{response_data['iv_key']}")
f.puts("shop_name: #{response_data['shop_name']}")
f.puts("email: #{response_data['email']}")
@@ -325,11 +326,11 @@ class License
f.puts("dbusername: #{response_data['dbusername']}")
f.puts("dbpassword: #{response_data['dbpassword']}")
f.puts("api_token: #{response_data['api_token']}")
- f.puts("app_token: #{response_data['app_token']}")
+ f.puts("app_token: #{response_data['app_token']}")
f.puts("plan_sku: #{response_data['plan_sku']}")
f.puts("renewable_date: #{response_data['renewable_date']}")
f.puts("plan_name: #{response_data['plan_name']}")
- end
+ end
rescue IOError
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
end
@@ -352,15 +353,15 @@ class License
f.write("group.id=sx\n")
f.write("external.id=000\n")
f.write("job.purge.period.time.ms=7200000\n")
- f.write("job.routing.period.time.ms=5000\n")
- f.write("job.push.period.time.ms=10000\n")
- f.write("job.pull.period.time.ms=10000\n")
- f.write("initial.load.create.first=true\n")
+ f.write("job.routing.period.time.ms=5000\n")
+ f.write("job.push.period.time.ms=10000\n")
+ f.write("job.pull.period.time.ms=10000\n")
+ f.write("initial.load.create.first=true\n")
f.write("initial.load.use.extract.job.enabled=true\n")
f.write("rest.api.enable=true\n")
- f.close
+ f.close
- # read from license file
+ # read from license file
# shop_name = read_license_no_decrypt("shop_name")
shop_name = "cloud"
dbhost = read_license("dbhost")
@@ -378,12 +379,12 @@ class License
f.write("registration.url=http://#{db_host}:31415/sync/sx\n")
f.write("group.id=cloud\n")
f.write("external.id=001\n")
- f.write("job.routing.period.time.ms=5000\n")
- f.write("job.push.period.time.ms=10000\n")
+ f.write("job.routing.period.time.ms=5000\n")
+ f.write("job.push.period.time.ms=10000\n")
f.write("job.pull.period.time.ms=10000\n")
f.write("rest.api.enable=true\n")
- # f.write("initial.load.create.first=true\n")
- # f.write("initial.load.use.extract.job.enabled=true\n")
+ # f.write("initial.load.create.first=true\n")
+ # f.write("initial.load.use.extract.job.enabled=true\n")
f.close
rescue IOError
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
@@ -392,12 +393,12 @@ class License
end
end
- # Run Symmetric
+ # Run Symmetric
def run_symmetric(sym_path)
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
# check_sym_proc_str = check_sym_proc_str.split("\n")
# sym_install_status = check_sym_proc_str[0].split(": ")
-
+
check_sym_proc_str = `#{"sudo service SymmetricDS status"}`
# Check Sym Installed
@@ -412,7 +413,7 @@ class License
check_sym_table = system("sudo " + sym_path + "/bin/symadmin --engine sx create-sym-tables")
if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql"
-
+
if File.exist? (sym_sql)
# Import Sym Sql to db and start sym
run_sym_sql = system("sudo " + sym_path + "/bin/dbimport --engine sx " + sym_sql.to_s)
@@ -427,7 +428,7 @@ class License
else
response = { "status": false, "message": "Activation is success but Cannot create Sym Tables. \n Please contact code2lab call center!"}
end
- else
+ else
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
end
end
@@ -435,7 +436,7 @@ class License
# Check Symmetric Running
def check_sym_running(status, sym_path)
# Run Sym Service
- # if status.include? "Server is already running"
+ # if status.include? "Server is already running"
# return true
# elsif status.include? "false"
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
@@ -443,9 +444,9 @@ class License
# return true
# else
# check_sym_running(sym_start_status[0])
- # end
+ # end
# else
- # return true
+ # return true
# end
if status.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
@@ -456,15 +457,15 @@ class License
# Delete License File
def delete_license_file
- File.delete("config/license.yml") if File.exist?("config/license.yml")
+ File.delete("config/license.yml") if File.exist?("config/license.yml")
end
# Assign db info for Cloud
- def assign(aes_key, aes_iv)
+ def assign(aes_key, aes_iv)
key = Base64.decode64(aes_key)
iv = Base64.decode64(aes_iv)
-
- if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
+
+ if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
host = Base64.decode64(@license["dbhost"])
dbschema = Base64.decode64(@license["dbschema"])
dbusername = Base64.decode64(@license["dbusername"])
@@ -473,8 +474,8 @@ class License
self.dbhost = AESCrypt.decrypt_data(host, key, iv, ENV['CIPHER_TYPE'])
self.dbschema = AESCrypt.decrypt_data(dbschema, key, iv, ENV['CIPHER_TYPE'])
self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE'])
- self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE'])
+ self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE'])
end
-
+
end
end
diff --git a/app/models/lookup.rb b/app/models/lookup.rb
index 5aaf3329..f71be27c 100755
--- a/app/models/lookup.rb
+++ b/app/models/lookup.rb
@@ -3,6 +3,8 @@ class Lookup < ApplicationRecord
has_many :accounts
belongs_to :shop
+ scope :number_formats, -> { where(lookup_type: 'number_format')}
+
def available_types
{'Employee Roles' => 'employee_roles',
'Dining Facilities Status' => 'dining_facilities_status',
diff --git a/app/models/menu.rb b/app/models/menu.rb
index de60ef66..a1b6d735 100755
--- a/app/models/menu.rb
+++ b/app/models/menu.rb
@@ -141,7 +141,14 @@ class Menu < ApplicationRecord
end
else
# Menu by Menu Import
- shop_code= shop.shop_code + "_"
+
+ @shop = Shop.current_shop
+ shop_code = ""
+ if !@shop.nil?
+ if @shop.shop_code
+ shop_code = @shop.shop_code + "_"
+ end
+ end
sheet = spreadsheet.sheet(0)
menu = sheet.row(1)[1]
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
index 3461c5ea..21608ecc 100755
--- a/app/models/order_item.rb
+++ b/app/models/order_item.rb
@@ -125,42 +125,14 @@ class OrderItem < ApplicationRecord
end
def update_stock_journal
- if self.set_menu_items.present?
- puts "set menu itemsssssssss???????????????????????????????"
- puts items = JSON.parse(self.set_menu_items)
- instance_code = Array.new
- count = 0
- items.each { |i|
- instance_code.push(i["item_instance_code"])
- }
- print instance_code
- end
- if self.qty != self.qty_before_last_save
- found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,self.order.shop_code)
- if found
- InventoryDefinition.check_balance(self, inventory_definition)
+
+ unless MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code)
+ if self.qty != self.qty_before_last_save
+ found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
+ if found
+ InventoryDefinition.check_balance(self, inventory_definition)
+ end
end
end
- # if self.qty > self.qty_was
- # credit = 0
- # debit = self.qty.to_i - self.qty_was.to_i
- # else
- # credit = self.qty_was.to_i - self.qty.to_i
- # debit = 0
- # end
- # if credit != debit
- # defination = InventoryDefinition.find_by_item_code(self.item_instance_code)
- # stock = StockJournal.where('item_code = ?', self.item_instance_code).order("id DESC").first
- # journal = StockJournal.create(
- # item_code: self.item_instance_code,
- # credit: credit,
- # debit: debit,
- # balance: stock.balance - debit + credit,
- # inventory_definition_id: defination.id,
- # remark: 'ok',
- # trans_ref: self.order.id,
- # trans_type: StockJournal::SALES_TRANS
- # )
- # end
end
end
diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb
index f7d8ab36..ff67c34b 100755
--- a/app/models/order_queue_station.rb
+++ b/app/models/order_queue_station.rb
@@ -297,8 +297,9 @@ class OrderQueueStation < ApplicationRecord
@type = (DiningFacility.find(change_to)).type
@moved_by = current_user
@date = DateTime.now
- @shop = Shop.find_by_shop_code(oqs.shop_code)
- unique_code = "MoveTablePdf"
+
+ @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)
# printer_array = []
diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb
index 4903c692..60c2a347 100644
--- a/app/models/order_reservation.rb
+++ b/app/models/order_reservation.rb
@@ -157,7 +157,8 @@ class OrderReservation < ApplicationRecord
def self.update_doemal_payment(order,current_user,receipt_bill)
if(Sale.exists?(order.sale_id))
saleObj = Sale.find(order.sale_id)
- shop_details = Shop.find_by_shop_code(order.shop_code)
+
+ shop_details = Shop.current_shop
# rounding adjustment
if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -194,7 +195,8 @@ class OrderReservation < ApplicationRecord
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
- # shop_detail = Shop.first
+
+ shop_detail = Shop.current_shop
order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id)
if !cashier_terminal.nil?
# Calculate Food and Beverage Total
@@ -400,7 +402,7 @@ class OrderReservation < ApplicationRecord
end
def self.check_new_order
- shop = Shop.find_by_id(1)
+ shop = Shop.current_shop
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
@@ -418,7 +420,7 @@ class OrderReservation < ApplicationRecord
end
def self.check_order_send_to_kitchen
- shop = Shop.find_by_id(1)
+ shop = Shop.current_shop
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
@@ -436,7 +438,7 @@ class OrderReservation < ApplicationRecord
end
def self.check_order_ready_to_delivery
- shop = Shop.find_by_id(1)
+ shop = Shop.current_shop
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb
index cadba8ce..32ef0081 100755
--- a/app/models/printer/order_queue_printer.rb
+++ b/app/models/printer/order_queue_printer.rb
@@ -38,8 +38,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# end
- # shop = Shop.first
- directory_name = 'public/orders_'+oqs.shop_code
+
+ shop = Shop.current_shop
+ directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
@@ -80,8 +81,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting = PrintSetting.all.order("id ASC")
order=print_query('order_summary', order_id)
- # shop = Shop.first
- directory_name = 'public/orders_'+oqs.shop_code
+
+ shop = Shop.current_shop
+ directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
# For Print Per Item
@@ -192,8 +194,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order=print_query('booking_summary', booking_id)
- # shop = Shop.first
- directory_name = 'public/orders_'+oqs.shop_code
+
+ shop = Shop.current_shop
+ directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
# For Print Per Item
diff --git a/app/models/room.rb b/app/models/room.rb
index 87f232e9..63c548ec 100755
--- a/app/models/room.rb
+++ b/app/models/room.rb
@@ -1,4 +1,3 @@
class Room < DiningFacility
-
has_many :bookings, :foreign_key => 'dining_facility_id'
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 535e32ce..66ed469a 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -1,4 +1,5 @@
class Sale < ApplicationRecord
+ include NumberFormattable
self.primary_key = "sale_id"
#primary key - need to be unique generated for multiple shops
@@ -7,12 +8,15 @@ class Sale < ApplicationRecord
belongs_to :cashier, foreign_key: "cashier_id", class_name: "Employee"
belongs_to :customer, :optional => true
belongs_to :shift_sale
+ has_one :survey, foreign_key: "receipt_no"
+ has_many :sale_audits
has_many :sale_items
has_many :sale_discount_items
has_many :sale_discounts
has_many :sale_taxes
has_many :sale_payments
has_many :sale_orders
+ has_many :sale_payments_for_credits, through: :sale_audits
has_many :orders, through: :sale_orders
has_many :order_items, through: :sale_orders
has_many :bookings
@@ -25,10 +29,11 @@ class Sale < ApplicationRecord
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
scope :paid, -> { where(payment_status: 'paid')}
scope :completed, -> { where(sale_status: 'completed') }
- scope :date_on, -> (date) { where("DATE(CONVERT_TZ(receipt_date, '+00:00', ?)) = ?", Time.zone.formatted_offset, date) }
- scope :date_between, -> (from, to) { where("DATE(CONVERT_TZ(receipt_date, '+00:00', ?)) BETWEEN ? AND ?", Time.zone.formatted_offset, from, to) }
- scope :time_between, -> (from, to) { where("TIME(CONVERT_TZ(receipt_date, '+00:00', ?)) BETWEEN ? AND ?", Time.zone.formatted_offset, from, to) }
- scope :along_with_sale_payments_except_void, -> { joins("LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND DATE(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30')) = DATE(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'))") }
+
+ scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) }
+ scope :along_with_sale_payments_except_void_between, -> (from, to) { joins(sanitize_sql_array(["LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to])) }
+
+
def qty_of(item_instance_code)
order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first
end
@@ -435,7 +440,8 @@ class Sale < ApplicationRecord
#compute - invoice total
def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil)
- # shop = Shop.first
+
+ shop = Shop.current_shop
#Computation Fields
subtotal_price = 0
@@ -502,7 +508,8 @@ class Sale < ApplicationRecord
# Tax Re-Calculte
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
- shop = Shop.find_by_shop_code(self.shop_code)
+
+ shop = Shop.current_shop
#if tax is not apply create new record
# SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
@@ -524,7 +531,7 @@ class Sale < ApplicationRecord
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
# #Creat new tax records
- if self.payment_status != 'foc'
+ if self.payment_status != 'foc' && tax_type.to_s == "all"
tax_profiles.each do |tax|
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
@@ -539,16 +546,82 @@ class Sale < ApplicationRecord
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
- sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ end
+
+ sale_tax.inclusive = tax.inclusive
+ sale_tax.save
+
+ if !tax.inclusive
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
+
#new taxable amount is standard rule for step by step
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
+ end
+ elsif tax_type.to_s == "no_tax"
+ tax_profiles.each do |tax|
+ sale_tax = SaleTax.new(:sale => self)
+ sale_tax.tax_name = tax.name
+ sale_tax.tax_rate = 0
+ sale_tax.tax_payable_amount = 0
sale_tax.inclusive = tax.inclusive
sale_tax.save
end
+ elsif tax_type.to_s == "Commercial Tax"
+ tax_profiles.each do |tax|
+ if tax.name == tax_type.to_s
+ sale_tax = SaleTax.new(:sale => self)
+ sale_tax.tax_name = tax.name
+ sale_tax.tax_rate = tax.rate
+ # substract , to give after discount
+ total_tax = total_taxable - total_discount
+ #include or execulive
+ if tax.inclusive
+ tax_incl_exec = "inclusive"
+ rate = tax.rate
+ divided_value = (100 + rate)/rate
+ sale_tax.tax_payable_amount = total_tax / divided_value
+ else
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
+ end
+ #new taxable amount is standard rule for step by step
+ if shop.calc_tax_order
+ total_taxable = total_taxable + sale_tax.tax_payable_amount
+ end
+ sale_tax.inclusive = tax.inclusive
+ sale_tax.save
+ end
+ end
+ elsif tax_type.to_s == "Service Charges"
+ tax_profiles.each do |tax|
+ if tax.name == tax_type.to_s
+ sale_tax = SaleTax.new(:sale => self)
+ sale_tax.tax_name = tax.name
+ sale_tax.tax_rate = tax.rate
+ # substract , to give after discount
+ total_tax = total_taxable - total_discount
+ #include or execulive
+ if tax.inclusive
+ tax_incl_exec = "inclusive"
+ rate = tax.rate
+ divided_value = (100 + rate)/rate
+ sale_tax.tax_payable_amount = total_tax / divided_value
+ else
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
+ end
+ #new taxable amount is standard rule for step by step
+ if shop.calc_tax_order
+ total_taxable = total_taxable + sale_tax.tax_payable_amount
+ end
+ sale_tax.inclusive = tax.inclusive
+ sale_tax.save
+ end
+ end
end
self.tax_type = tax_incl_exec
self.total_tax = total_tax_amount
@@ -556,7 +629,8 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable, order_source = nil, tax_type = nil)
- shop = Shop.find_by_shop_code(self.shop_code)
+
+ shop = Shop.current_shop
#if tax is not apply create new record
# SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
@@ -574,7 +648,7 @@ class Sale < ApplicationRecord
order_source = "cashier"
end
- # tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id)
+ # tax_data = TaxProfile.unscope(:order).where("group_type=?",order_source).pluck(:id)
# customer = Customer.find(self.customer_id).tax_profiles
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
@@ -595,6 +669,12 @@ class Sale < ApplicationRecord
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ end
+
+ sale_tax.inclusive = tax.inclusive
+ sale_tax.save
+
+ if !tax.inclusive
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
@@ -602,9 +682,6 @@ class Sale < ApplicationRecord
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
-
- sale_tax.inclusive = tax.inclusive
- sale_tax.save
end
self.tax_type = tax_incl_exec
self.total_tax = total_tax_amount
@@ -636,7 +713,8 @@ class Sale < ApplicationRecord
end
def adjust_rounding
- shop_details = Shop.find_by_shop_code(self.shop_code)
+
+ shop_details = Shop.current_shop
# rounding adjustment
if shop_details.is_rounding_adj
new_total = Sale.get_rounding_adjustment(self.grand_total)
@@ -652,7 +730,8 @@ class Sale < ApplicationRecord
#Generate new Receipt No when it is not assigned
def generate_receipt_no
#shop_code and client_code
- shop_details = Shop.find_by_shop_code(self.shop_code)
+
+ shop_details = Shop.current_shop
#Date-Shift-
if self.receipt_no.nil?
prefix = DateTime.now().utc
@@ -773,8 +852,8 @@ def self.daily_sales_list(from,to,shop_code)
ELSE 0 END as credit_amount,
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
- .along_with_sale_payments_except_void
- .where("shop_code='#{shop_code}' and (sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
+ .along_with_sale_payments_except_void_between(from, to)
+ .where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
.group("sale_id").to_sql
daily_total = connection.select_all("SELECT
@@ -1165,7 +1244,7 @@ end
#product sale report query
def self.get_menu_item_query(order_by)
- query = MenuItem.unscoped.select("acc.id as account_id,
+ query = MenuItem.unscope(:order).select("acc.id as account_id,
acc.title as account_name,
mii.item_instance_code as item_code, " +
"(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," +
@@ -1194,7 +1273,7 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
payment_type = " and sale_payments.payment_method = '#{payment_type}'"
end
- query = Sale.all.select("sales.*,sale_payments.*,df.name,df.type")
+ query = Sale.includes(:sale_items).select("sales.*,sale_payments.*,df.name,df.type")
.where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
@@ -1212,17 +1291,16 @@ end
def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type)
## => left join -> show all sales although no orders
- if payment_type.blank?
- payment_type = ''
- else
- payment_type = " and sale_payments.payment_method = '#{payment_type}'"
- end
- query = Sale.select("sales.*,bookings.dining_facility_id as table_id")
- .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}")
- .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
- .joins("join bookings on bookings.sale_id = sales.sale_id")
- .group("sales.sale_id")
+ query = Sale.includes([:customer, :survey, :sale_payments])
+ .includes(:bookings => :dining_facility)
+ .select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount")
+ .joins(:bookings)
+ .left_joins(:sale_payments_for_credits)
+ .completed
+ .where.not(total_amount: 0)
+ .group(:sale_id)
+ .order(:receipt_date)
if shift.present?
query = query.where("sales.shift_sale_id in (?)", shift.to_a)
elsif shift_sale_range.present?
@@ -1230,6 +1308,9 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
else
query = query.where("sales.receipt_date between ? and ?",from,to)
end
+
+ ActiveRecord::Associations::Preloader.new.preload(query, :sale_items, SaleItem.where.not(price: 0))
+
return query
end
@@ -1502,173 +1583,130 @@ end
return tax
end
- def self.top_bottom_products(today,current_user,from,to,from_time,to_time,type,shop)
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- if current_user.nil?
- query = Sale.top_bottom(shop,today,nil,from,to,from_time,to_time)
- if type == "top"
- query = query.group('i.product_name')
- .order("SUM(i.qty) DESC").limit(20)
- elsif type == "bottom"
- query = query.group('i.product_name')
- .order("SUM(i.qty) ASC").limit(20)
- end
- else
- if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
- query = Sale.top_bottom(shop,today,nil,from,to,from_time,to_time)
- if type == "top"
- query = query.group('i.product_name')
- .order("SUM(i.qty) DESC").limit(20)
- elsif type == "bottom"
- query = query.group('i.product_name')
- .order("SUM(i.qty) ASC").limit(20)
- end
- else
- shift = ShiftSale.current_open_shift(current_user)
- if !shift.nil?
- query = Sale.top_bottom(shop,today,shift,from,to,from_time,to_time)
- if type == "top"
- query = query.group('i.product_name')
- .order("SUM(i.qty) DESC").limit(20)
- elsif type == "bottom"
- query = query.group('i.product_name')
- .order("SUM(i.qty) ASC").limit(20)
- end
- end
- end
- end
+ def self.top_bottom_products(current_user,from,to,type,current_shop)
+ query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
+ .completed
+ .where("qty > 0 AND price > 0 AND shop_code='#{current_shop.shop_code}'")
+ .group("SUBSTRING_INDEX(product_name, ' - ', 1)")
+
+ if !from.nil? && !to.nil?
+ query = query.receipt_date_between(from, to)
else
- if current_user.nil?
- query = Sale.top_bottom(shop,today).group('i.product_name')
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
+ end
+
+ if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
+ if shift = ShiftSale.current_open_shift(current_user.id)
+ query = query.where("shift_sale_id='#{shift.id}'")
- if type == "top"
- query = query.order("SUM(i.qty) DESC").limit(20)
- elsif type == "bottom"
- query = query.order("SUM(i.qty) ASC").limit(20)
- end
- else
- if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
- query = Sale.top_bottom(shop,today).group('i.product_name')
- if type == "top"
- query = query.order("SUM(i.qty) DESC").limit(20)
- elsif type == "bottom"
- query = query.order("SUM(i.qty) ASC").limit(20)
- end
- else
- shift = ShiftSale.current_open_shift(current_user)
- if !shift.nil?
- query = Sale.top_bottom(shop,today,shift).group('i.product_name')
- if type == "top"
- query = query.order("SUM(i.qty) DESC").limit(20)
- elsif type == "bottom"
- query = query.order("SUM(i.qty) ASC").limit(20)
- end
- end
- end
end
end
+
+ if type == "top"
+ query = query.order("SUM(qty) DESC")
+ else
+ query = query.order("SUM(qty) ASC")
+ end
+
+ query.limit(20).sum('qty')
end
- def self.hourly_sales(today,current_user,from,to,from_time,to_time,shop)
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- if current_user.nil?
- query = Sale.hourly_sale_data(shop,today,nil,from,to,from_time,to_time)
- else
- if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
- query = Sale.hourly_sale_data(shop,today,nil,from,to,from_time,to_time)
- else
- shift = ShiftSale.current_open_shift(current_user)
- if !shift.nil?
- query = Sale.hourly_sale_data(shop,today,shift,from,to,from_time,to_time)
- end
- end
- end
+
+ def self.hourly_sales(current_user,from,to, current_shop)
+ query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '#{Time.zone.formatted_offset}'), '%I %p')")
+ .order('receipt_date').completed
+
+ if !from.nil? && !to.nil?
+ query = query.receipt_date_between(from, to)
else
- if current_user.nil?
- query = Sale.hourly_sale_data(shop,today)
- else
- if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
- query = Sale.hourly_sale_data(shop,today)
- else
- shift = ShiftSale.current_open_shift(current_user)
- if !shift.nil?
- query = Sale.hourly_sale_data(shop,today,shift)
- end
- end
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
+ end
+
+ if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
+ if shift = ShiftSale.current_open_shift(current_user.id)
+ query = query.where("shift_sale_id='#{shift.id}'")
end
end
+
+ query.sum(:grand_total)
end
- def self.employee_sales(today,current_user,from,to,from_time,to_time,shop)
+
+ def self.employee_sales(current_user,from,to, current_shop)
+
shift = if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
ShiftSale.current_open_shift(current_user)
end
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
- query = employee_sale(shop,today, shift, from, to, from_time, to_time)
+
+ query = employee_sale(shift, from, to, current_shop)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount,
CASE WHEN sale_payments.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card'
ELSE sale_payments.payment_method END AS payment_method, employees.name AS e_name")
end
- def self.total_trans(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil,shop)
- query = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count")
- .where("sale_status = 'completed' AND shop_code='#{shop.shop_code}'")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ def self.total_trans(current_user=nil,from=nil,to=nil)
+ query = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count")
+ .where('sale_status = "completed"')
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
return query
end
- def self.total_card_sale(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil,shop)
+
+ def self.total_card_sale(current_user=nil,from=nil,to=nil)
query = Sale.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and (sp.payment_method = 'mpu' or sp.payment_method = 'visa' or sp.payment_method = 'master' or sp.payment_method = 'jcb' or sp.payment_method = 'unionpay' or sp.payment_method = 'alipay' or sp.payment_method = 'paymal' or sp.payment_method = 'dinga' or sp.payment_method = 'JunctionPay')")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where('sales.sale_status = "completed" and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")')
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.sum("sp.payment_amount")
end
- def self.credit_payment(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil,shop)
+
+ def self.credit_payment(current_user=nil,from=nil,to=nil, current_shop)
+
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
query = SalePayment.credits
.joins(:sale)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sale_payments.sale_id")
- .where("sale_payments.payment_method= ? AND sales.sale_status = ? AND sales.shop_code=?", 'creditnote', 'completed',shop.shop_code)
+ .where("sale_payments.payment_method= ? AND sales.sale_status = ? AND sales.shop_code=?", 'creditnote', 'completed',current_shop.shop_code)
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.merge(Sale.date_between(from, to))
- if !from_time.nil? && !to_time.nil?
- query = query.merge(Sale.time_between(from_time, to_time))
- end
+ if (!from.nil? && !to.nil?)
+ query = query.merge(Sale.receipt_date_between(from, to))
else
- query = query.merge(Sale.date_on(today))
+ query = query.merge(Sale.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day))
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
@@ -1678,52 +1716,57 @@ end
return query.sum("sale_payments.payment_amount - IFNULL(payments_for_credits.payment_amount, 0)")
end
- def self.summary_sale_receipt(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.summary_sale_receipt(current_user=nil,from=nil,to=nil)
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
- .where("shop_code='#{shop.shop_code}' and sale_status = 'completed'")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where('sale_status = "completed"')
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.first()
end
- def self.total_payment_methods(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
- query = Sale.select("distinct sp.payment_method")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed'")
+
+ def self.total_payment_methods(current_user=nil,from=nil,to=nil)
+ query = Sale.select("CASE WHEN sp.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' ELSE sp.payment_method END as payment_method")
+ .where("sales.sale_status = 'completed'")
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .group("CASE WHEN sp.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' ELSE sp.payment_method END")
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
return query
end
- def self.payment_sale(shop,payment_method, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.payment_sale(payment_method, current_user=nil,from=nil,to=nil)
+
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
query = Sale.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount")
.joins(:sale_payments)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
- .where("sales.shop_code='#{shop.shop_code}'")
.completed
if payment_method == 'card'
@@ -1732,13 +1775,10 @@ end
query = query.where("sale_payments.payment_method = ?", payment_method)
end
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time,to_time)
- end
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1746,25 +1786,35 @@ end
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query.first
end
- def self.total_customer(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
- total_dinein_takeaway = self.total_dinein_takeaway(shop,today,current_user,from,to,from_time,to_time)
+
+ def self.total_customer(current_user=nil,from=nil,to=nil)
+ total_dinein_takeaway = self.total_dinein_takeaway(current_user,from,to)
+
dinein_cnt = 0
takeaway_cnt = 0
+
if !total_dinein_takeaway.nil?
if total_dinein_takeaway[0]
dinein_cnt = total_dinein_takeaway[0].total_dinein_cus
takeaway_cnt = total_dinein_takeaway[0].total_take_cus
end
end
- membership_cnt = self.total_membership(shop,today,current_user,from,to,from_time,to_time)
+
+
+ membership_cnt = self.total_membership(current_user,from,to)
+
member_cnt = 0
+
if !membership_cnt.nil?
member_cnt = membership_cnt.total_memb_cus
end
+
total_cus = 0
+
if dinein_cnt > dinein_cnt || takeaway_cnt > 0 || !membership_cnt.nil?
total_cus = dinein_cnt.to_int + takeaway_cnt.to_int + member_cnt.to_int
end
@@ -1772,43 +1822,47 @@ end
return total_cus, dinein_cnt, takeaway_cnt, member_cnt
end
- def self.total_dinein_takeaway(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.total_dinein_takeaway(current_user=nil,from=nil,to=nil)
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and c.membership_id is null")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where('sales.sale_status = "completed" and c.membership_id is null')
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.first()
end
- def self.total_membership(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.total_membership(current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and ((c.customer_type = 'Dinein' and c.membership_id is not null) or (c.customer_type = 'Takeaway' and c.membership_id is not null))")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where('sales.sale_status = "completed" and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))')
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.first()
end
@@ -1858,18 +1912,18 @@ end
# query = query.first()
# end
- def self.total_order(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.total_order(current_user=nil,from=nil,to=nil, current_shop)
+
query = Sale.select("count(distinct sale_orders.order_id) as total_order")
.joins(:sale_orders)
- .where("shop_code='#{shop.shop_code}'")
+ .where("shop_code='#{current_shop.shop_code}'")
.completed
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1881,85 +1935,70 @@ end
query = query.first
end
- def self.total_account(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
- query = Sale.select("distinct b.id as account_id, b.title as title")
- .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
- .joins("JOIN accounts as b ON b.id = a.account_id")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed'")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
- else
- query = query.date_on(today)
- end
- if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
- if shift = ShiftSale.current_open_shift(current_user)
- query = query.where("sales.shift_sale_id = ?", shift.id)
- end
- end
- return query
- end
- def self.account_data(shop,account_id, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+ def self.account_data(account_id, current_user=nil,from=nil,to=nil)
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and a.account_id ='#{account_id}'")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}'")
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.first
end
- def self.top_items(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.top_items(current_user=nil,from=nil,to=nil)
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
- .where("sales.shop_code='#{shop.shop_code}' and (a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed'")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed'")
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.group("a.product_code")
.order("SUM(a.qty) DESC")
.first()
end
- def self.total_foc_items(shop,today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
+
+ def self.total_foc_items(current_user=nil,from=nil,to=nil)
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
- .where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%'")
- if (!from.nil? && !to.nil?) && (from != "" && to!="")
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ .where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%'")
+
+ if (!from.nil? && !to.nil?)
+ query = query.receipt_date_between(from, to)
+
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
+
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
+
query = query.count()
end
@@ -2096,71 +2135,16 @@ def unique_tax_profiles(order_source, customer_id)
return tax_data
end
-def self.top_bottom(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
- if !from.nil? && !to.nil?
- query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
- " i.price as unit_price,i.product_name")
- .joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
- if !from_time.nil? && !to_time.nil?
- query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
- " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'")
- else
- query = query.where("shop_code='#{shop.shop_code}' and (i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
- " and sale_status= 'completed'")
- end
- if !shift.nil?
- query = query.where("shift_sale_id='#{shift.id}'")
- end
- else
- query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
- " i.price as unit_price,i.product_name")
- .joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
- .where("shop_code='#{shop.shop_code}' and (i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
- " and sale_status= 'completed'")
- if !shift.nil?
- query = query.where("shift_sale_id='#{shift.id}'")
- end
- end
- return query
-end
-def self.hourly_sale_data(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
- if !from.nil? && !to.nil?
- query = Sale.select("grand_total")
- if !from_time.nil? && !to_time.nil?
- query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time)
- else
- query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
- end
- if !shift.nil?
- query = query.where("shift_sale_id='#{shift.id}'")
- end
- query = query.where("shop_code='#{shop.shop_code}'").group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
- .order('receipt_date')
- else
- query = Sale.select("grand_total")
- .where("shop_code='#{shop.shop_code}' and sale_status = 'completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = ?",today)
- if !shift.nil?
- query = query.where("shift_sale_id='#{shift.id}'")
- end
- query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
- .order('receipt_date')
- end
+def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, current_shop)
- return query
-end
-
-def self.employee_sale(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
query = Sale.joins(:cashier)
.joins(:sale_payments)
- .paid.completed.where("sales.shop_code='#{shop.shop_code}'")
+ .paid.completed.where("sales.shop_code='#{current_shop.shop_code}'")
if !from.nil? && !to.nil?
- query = query.date_between(from, to)
- if !from_time.nil? && !to_time.nil?
- query = query.time_between(from_time, to_time)
- end
+ query = query.receipt_date_between(from, to)
else
- query = query.date_on(today)
+ query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if !shift.nil?
@@ -2313,7 +2297,7 @@ end
def grand_total_round
print_settings = PrintSetting.get_precision_delimiter()
if !print_settings.nil?
- self.grand_total =self.grand_total.round(print_settings.precision.to_i)
+ self.grand_total =self.grand_total.round(precision)
end
end
@@ -2460,8 +2444,6 @@ private
def round_to_precision
if (self.total_amount != self.total_amount_was || self.total_discount != self.total_discount_was || self.total_tax != self.total_tax_was)
if (self.total_amount % 1 > 0 || self.total_discount % 1 > 0 || self.total_tax % 1 > 0)
- precision = PrintSetting.get_precision_delimiter().precision.to_i
-
self.total_amount = self.total_amount.round(precision)
self.total_discount = self.total_discount.round(precision)
self.total_tax = self.total_tax.round(precision)
@@ -2490,7 +2472,11 @@ private
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code)
if found
if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id)
- stock_journal.update(remark: self.sale_status)
+ if self.payment_status == "foc" && self.payment_status_was != "foc"
+ stock_journal.update(remark: self.payment_status)
+ else
+ stock_journal.update(remark: self.sale_status)
+ end
end
end
end
diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb
index 7b5c52e5..d77d59e3 100755
--- a/app/models/sale_audit.rb
+++ b/app/models/sale_audit.rb
@@ -6,7 +6,7 @@ class SaleAudit < ApplicationRecord
belongs_to :sale
- belongs_to :credit_payment, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment"
+ belongs_to :sale_payments_for_credit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment"
def self.sync_sale_audit_records(sale_audits)
if !sale_audits.nil?
diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb
index c6b19926..177ce1f6 100755
--- a/app/models/sale_item.rb
+++ b/app/models/sale_item.rb
@@ -1,4 +1,5 @@
class SaleItem < ApplicationRecord
+ include NumberFormattable
self.primary_key = "sale_item_id"
#primary key - need to be unique generated for multiple shops
@@ -13,6 +14,7 @@ class SaleItem < ApplicationRecord
before_validation :round_to_precision
after_update :update_stock_journal
+ after_save :update_stock_journal_set_item
# Add Sale Items
def self.add_sale_items(sale_items)
@@ -293,8 +295,6 @@ class SaleItem < ApplicationRecord
if self.unit_price != self.unit_price_was || self.price != self.price_was
if unit_price_fraction > 0 || price_fraction > 0
if ['Discount', 'promotion'].include?(self.status)
- precision = PrintSetting.get_precision_delimiter().precision.to_i
-
self.unit_price = self.unit_price.round(precision)
self.price = (self.unit_price * self.qty).round(precision)
self.taxable_price = self.price
@@ -304,40 +304,42 @@ class SaleItem < ApplicationRecord
end
def update_stock_journal
- is_void = self.status == "void" && self.status_before_last_save != "void"
- cancel_void = self.status_before_last_save == "void" && self.status.nil?
- is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
- is_foc = self.status == "foc" && self.status_before_last_save != "foc"
- cancel_foc = self.status_before_last_save == "foc"
+ unless MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code)
+ is_void = self.status == "void" && self.status_before_last_save != "void"
+ cancel_void = self.status_before_last_save == "void" && self.status.nil?
+ is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
+ is_foc = self.status == "foc" && self.status_before_last_save != "foc"
+ cancel_foc = self.status_before_last_save == "foc"
- if is_void or cancel_void or is_edit or is_foc or cancel_foc
- found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,self.sale.shop_code)
- if found
- stock = StockJournal.where("shop_code='#{self.sale.shop_code}' and item_code=?", self.item_instance_code).order("id DESC").first
- unless stock.nil?
- check_item = StockCheckItem.where("shop_code='#{self.sale.shop_code}' and item_code=?", self.item_instance_code).order("id DESC").first
- if is_void or cancel_void or is_edit
- if is_void
- qty = -self.qty
- remark = "void"
- elsif cancel_void
- qty = self.qty
- remark = "cancel void"
- elsif is_edit
- qty = self.qty - self.qty_before_last_save
- remark = "edit"
- end
- StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
- check_item.different = check_item.different + qty
- check_item.save
- else is_foc or cancel_foc
- qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
- if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id
- if stock_journal = StockJournal.find_by_trans_ref(order_item_id)
- if is_foc
- stock_journal.update(remark: "foc")
- elsif cancel_foc
- stock_journal.update(remark: "cancel_foc")
+ if is_void or cancel_void or is_edit or is_foc or cancel_foc
+ found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
+ if found
+ stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
+ unless stock.nil?
+ check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
+ if is_void or cancel_void or is_edit
+ if is_void
+ qty = -self.qty
+ remark = "void"
+ elsif cancel_void
+ qty = self.qty
+ remark = "cancel void"
+ elsif is_edit
+ qty = self.qty - self.qty_before_last_save
+ remark = "edit"
+ end
+ StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
+ check_item.different = check_item.different + qty
+ check_item.save
+ else is_foc or cancel_foc
+ qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
+ if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id
+ if stock_journal = StockJournal.find_by_trans_ref(order_item_id)
+ if is_foc
+ stock_journal.update(remark: "foc")
+ elsif cancel_foc
+ stock_journal.update(remark: "cancel_foc")
+ end
end
end
end
@@ -346,4 +348,80 @@ class SaleItem < ApplicationRecord
end
end
end
+
+ def update_stock_journal_set_item
+ is_void = self.status == "void" && self.status_before_last_save != "void" && self.qty > 0
+ cancel_void = self.status_before_last_save == "void" && self.status.nil?
+ is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
+ is_foc = self.status == "foc" && self.status_before_last_save != "foc"
+ cancel_foc = self.status_before_last_save == "foc"
+
+ is_waste = self.status == "waste"
+ is_spoile = self.status == "spoile"
+
+ if MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code)
+ if self.qty == 1 && self.qty != self.qty_before_last_save
+ found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
+ if found
+ stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
+ unless stock.nil?
+ check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
+ if self.qty.to_i >= 0
+ qty = self.qty - self.qty_was
+ if stock.balance.to_i >= qty
+ Rails.logger.info ">> stock is greater than order qty"
+ remark = "ok"
+ else
+ Rails.logger.info " << stock is less than order qty"
+ remark = "out of stock"
+ end
+ end
+ StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
+ check_item.different = check_item.different - qty
+ check_item.save
+ else
+ StockJournal.add_to_journal(self.item_instance_code, self.qty, 0, "out of stock", inventory_definition, self.id, StockJournal::SALES_TRANS)
+ end
+ end
+ elsif is_void or cancel_void or is_edit
+ if is_void
+ qty = -self.qty
+ remark = "void"
+ elsif cancel_void
+ qty = self.qty
+ remark = "cancel void"
+ elsif is_edit
+ qty = self.qty - self.qty_before_last_save
+ remark = "edit"
+ end
+ found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
+ if found
+ stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
+ unless stock.nil?
+ check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
+
+ StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
+ check_item.different = check_item.different + qty
+ check_item.save
+ end
+ end
+ elsif is_foc or cancel_foc
+ qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
+ if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code).order(id: :desc).first
+ if is_foc
+ stock_journal.update(remark: "foc")
+ elsif cancel_foc
+ stock_journal.update(remark: "cancel_foc")
+ end
+ end
+ elsif is_waste or is_spoile
+ found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
+ if found
+ if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code)
+ stock_journal.update(remark: self.status)
+ end
+ end
+ end
+ end
+ end
end
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 9041484f..7e8cbe1c 100755
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -70,8 +70,6 @@ class SalePayment < ApplicationRecord
self.sale = invoice
self.received_amount = cash_amount
self.payment_reference = remark
- # puts action_by
- # puts "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
self.action_by = action_by
#get all payment for this invoices
if payment_for
@@ -242,10 +240,7 @@ class SalePayment < ApplicationRecord
end
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
- # membership_actions_data = MembershipAction.find_by_membership_type("redeem");
membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
- puts "This is membership_actions_data"
- puts membership_actions_data.to_json
if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
@@ -334,8 +329,7 @@ class SalePayment < ApplicationRecord
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json
end
-
- puts params
+
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb
index 6baa3f47..e84aa434 100755
--- a/app/models/sale_tax.rb
+++ b/app/models/sale_tax.rb
@@ -1,4 +1,5 @@
class SaleTax < ApplicationRecord
+ include NumberFormattable
self.primary_key = "sale_tax_id"
#primary key - need to be unique generated for multiple shops
@@ -44,7 +45,6 @@ class SaleTax < ApplicationRecord
def round_to_precision
if self.tax_payable_amount != self.tax_payable_amount_was
if self.tax_payable_amount % 1 > 0
- precision = PrintSetting.get_precision_delimiter().precision.to_i
self.tax_payable_amount = self.tax_payable_amount.round(precision)
end
end
diff --git a/app/models/shop.rb b/app/models/shop.rb
index d12986a1..a9b672b1 100755
--- a/app/models/shop.rb
+++ b/app/models/shop.rb
@@ -1,12 +1,18 @@
class Shop < ApplicationRecord
- #ShopDetail = Shop.find_by_id(1)
+ #ShopDetail = Shop.current_shop
# Shop Image Uploader
+
mount_uploader :logo, ShopImageUploader
has_many :display_images
+
accepts_nested_attributes_for :display_images
def file_data=(input_data)
self.data = input_data.read
end
+
+ def self.current_shop
+ ActsAsTenant.current_tenant
+ end
end
diff --git a/app/models/stock_journal.rb b/app/models/stock_journal.rb
index d70ca051..2250b23a 100755
--- a/app/models/stock_journal.rb
+++ b/app/models/stock_journal.rb
@@ -4,6 +4,8 @@ class StockJournal < ApplicationRecord
ORDER_TRANS = "order"
STOCK_CHECK_TRANS = "stock_check"
+ scope :created_at_between, -> (from, to) { where(created_at: from..to)}
+
def self.add_to_journal(item_instance_code, qty, old_balance, stock_message, inventory_definition, trans_ref, trans_type) # item => saleObj | balance => Stock journal
balance = calculate_balance(old_balance, qty)
@@ -56,23 +58,14 @@ class StockJournal < ApplicationRecord
journal.save
end
- def self.inventory_balances(today,from,to,from_time,to_time,shop)
+
+ def self.inventory_balances(from,to, current_shop)
+ query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
+ .joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
+ .group("mii.item_instance_name")
+ .order("mii.item_instance_name ASC")
if !from.nil? && !to.nil?
- query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
- .joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
- if !from_time.nil? && !to_time.nil?
- query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'")
- else
- query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'")
- end
- query = query.where("shop_code='#{shop.shop_code}'").group("mii.item_instance_name")
- .order("mii.item_instance_name ASC")
- else
- query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
- .joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
- .where("shop_code='#{shop.shop_code}' and DATE_FORMAT(stock_journals.created_at,'%Y-%m-%d') = '#{today}'")
- .group("mii.item_instance_name")
- .order("mii.item_instance_name ASC")
+ query = query.created_at_between(from, to)
end
end
diff --git a/app/models/verify_number.rb b/app/models/verify_number.rb
index 26c57057..6cb885b1 100644
--- a/app/models/verify_number.rb
+++ b/app/models/verify_number.rb
@@ -4,7 +4,6 @@ class VerifyNumber < ApplicationRecord
url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Doemal,+Pin+Code:+"+pin.to_s+"&recipients="+ phone.to_s
- puts url
begin
@result = HTTParty.get(url.to_str)
@@ -18,7 +17,6 @@ class VerifyNumber < ApplicationRecord
response = { status: false, message: "Can't open membership server "}
end
puts @result
- puts "<><><><><><<><>><><"
end
end
diff --git a/app/pdf/check_in_out_pdf.rb b/app/pdf/check_in_out_pdf.rb
index 08b9eba8..dfc40c2c 100644
--- a/app/pdf/check_in_out_pdf.rb
+++ b/app/pdf/check_in_out_pdf.rb
@@ -1,5 +1,5 @@
class CheckInOutPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size, :item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,booking, table)
self.page_width = print_settings.page_width
diff --git a/app/pdf/close_cashier_customise_pdf.rb b/app/pdf/close_cashier_customise_pdf.rb
index 2b05394d..34c4288d 100644
--- a/app/pdf/close_cashier_customise_pdf.rb
+++ b/app/pdf/close_cashier_customise_pdf.rb
@@ -1,5 +1,5 @@
class CloseCashierCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
@@ -39,22 +39,11 @@ class CloseCashierCustomisePdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
- #check delimiter
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header( shop_details)
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
end
def header (shop_details)
@@ -103,13 +92,13 @@ class CloseCashierCustomisePdf < Prawn::Document
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
+ text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
@@ -117,8 +106,8 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Closing Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
- # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
+ text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
+ # text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
end
@@ -135,7 +124,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Received Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
@@ -144,7 +133,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Cash In :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -152,7 +141,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Cash Out :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
@@ -165,7 +154,7 @@ class CloseCashierCustomisePdf < Prawn::Document
total_discount_account = total_discount_account.to_f + amount.total_price.to_f
end
- #end total amount by Account
+ #end total amount by Account
#start total FOC amount
@total_foc = 0
@@ -173,7 +162,7 @@ class CloseCashierCustomisePdf < Prawn::Document
@total_foc = other.foc_amount.round(2)
end
- #end total FOC amount
+ #end total FOC amount
total_grand_total = shift_sale.grand_total + @total_foc.to_f + shift_sale.total_void.to_f - total_discount_account.to_f
# @total_grand_total = @shift_sale.grand_total + @overall + @total_foc + @shift_sale.total_void
y_position = cursor
@@ -181,21 +170,21 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Grand Total :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
- #end total amount by Account
+ #end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -205,8 +194,8 @@ class CloseCashierCustomisePdf < Prawn::Document
@total_foc = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
- end
+ text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -218,7 +207,7 @@ class CloseCashierCustomisePdf < Prawn::Document
move_down -5
stroke_horizontal_rule
- move_down 7
+ move_down 7
@total_foc = 0
y_position = cursor
@@ -226,7 +215,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Cash Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -234,9 +223,9 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
- #start other payment details
+ #start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
@@ -246,7 +235,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -256,7 +245,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -266,7 +255,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -276,7 +265,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -286,7 +275,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -296,7 +285,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Alipay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -306,7 +295,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -316,7 +305,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Dinga Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -326,7 +315,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Redeem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -336,7 +325,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Paymal Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -346,7 +335,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
end
@@ -356,7 +345,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Other Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -365,8 +354,8 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
-
+ text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+
end
y_position = cursor
@@ -374,14 +363,14 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Gross Sale :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
+ text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
- # end other payment details
+ # end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
-
+
# start Dinein and Takeaway
y_position = cursor
@@ -392,7 +381,7 @@ class CloseCashierCustomisePdf < Prawn::Document
total_dinein = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -401,11 +390,11 @@ class CloseCashierCustomisePdf < Prawn::Document
end
if total_takeway.nil?
total_takeway = 0
- end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
-
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{ number_format(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ end
+
# stop Dinein and Takeaway
move_down -5
@@ -419,7 +408,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -428,7 +417,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Total Taxes :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -436,7 +425,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
+ text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
end
if total_credit_payments && total_credit_payments.to_f > 0
@@ -445,7 +434,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
#end for service charges and commercial tax
@@ -463,16 +452,16 @@ class CloseCashierCustomisePdf < Prawn::Document
move_down 7
#start total amount by Account Like Food / Beverage /..
# total_discount_by_account.each do |amount|
-
+
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- # text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ # text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
# end
# end
- #end total amount by Account
+ #end total amount by Account
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -481,19 +470,19 @@ class CloseCashierCustomisePdf < Prawn::Document
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
# end
-
+
#start total amount by Account Like Food / Beverage /..
- total_amount_by_account.each do |amount|
+ total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
- #end total amount by Account
+ #end total amount by Account
#start total other charges amount
if total_other_charges.present?
@@ -502,9 +491,9 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Total Other Charges :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
- end
+ end
#end total other charges amount
move_down -5
@@ -513,32 +502,32 @@ class CloseCashierCustomisePdf < Prawn::Document
#start total over all discount
if total_member_discount[0].member_discount.present?
- @member_discount = total_member_discount[0].member_discount rescue 0.0
+ @member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
- else
- @overall = shift_sale.total_discounts
+ else
+ @overall = shift_sale.total_discounts
end
-
+
if @overall > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
+ text "-#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ end
move_down -5
stroke_horizontal_rule
move_down 7
- end
+ end
#end total over all discount
if total_waste.to_f > 0
@@ -547,7 +536,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Total Waste :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
end
@@ -557,7 +546,7 @@ class CloseCashierCustomisePdf < Prawn::Document
text "Total Spoile :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
end
@@ -591,4 +580,3 @@ class CloseCashierCustomisePdf < Prawn::Document
move_down 5
end
end
-
diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb
index d4564291..976c3d93 100755
--- a/app/pdf/close_cashier_pdf.rb
+++ b/app/pdf/close_cashier_pdf.rb
@@ -1,5 +1,5 @@
class CloseCashierPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
@@ -39,25 +39,14 @@ class CloseCashierPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
- #check delimiter
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header( shop_details)
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
if !sale_items.nil? or !sale_items.blank?
- sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
+ sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
end
end
@@ -107,13 +96,13 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
+ text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
@@ -121,8 +110,8 @@ class CloseCashierPdf < Prawn::Document
text "Closing Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
- # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
+ text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
+ # text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
end
@@ -139,7 +128,7 @@ class CloseCashierPdf < Prawn::Document
text "Received Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
@@ -148,7 +137,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash In:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -156,7 +145,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash Out:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
@@ -169,7 +158,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -177,10 +166,10 @@ class CloseCashierPdf < Prawn::Document
text "Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
- #start other payment details
+ #start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
@@ -190,7 +179,7 @@ class CloseCashierPdf < Prawn::Document
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -200,7 +189,7 @@ class CloseCashierPdf < Prawn::Document
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -210,7 +199,7 @@ class CloseCashierPdf < Prawn::Document
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -220,7 +209,7 @@ class CloseCashierPdf < Prawn::Document
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -230,7 +219,7 @@ class CloseCashierPdf < Prawn::Document
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -240,7 +229,7 @@ class CloseCashierPdf < Prawn::Document
text "Alipay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -250,7 +239,7 @@ class CloseCashierPdf < Prawn::Document
text "KBZ Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -260,7 +249,7 @@ class CloseCashierPdf < Prawn::Document
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -270,7 +259,7 @@ class CloseCashierPdf < Prawn::Document
text "Dinga Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -280,7 +269,7 @@ class CloseCashierPdf < Prawn::Document
text "Redeem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -290,7 +279,7 @@ class CloseCashierPdf < Prawn::Document
text "Paymal Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -300,7 +289,7 @@ class CloseCashierPdf < Prawn::Document
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
end
@@ -310,7 +299,7 @@ class CloseCashierPdf < Prawn::Document
text "Other Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -319,7 +308,7 @@ class CloseCashierPdf < Prawn::Document
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -327,10 +316,10 @@ class CloseCashierPdf < Prawn::Document
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
+ text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
- # end other payment details
+ # end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
@@ -342,7 +331,7 @@ class CloseCashierPdf < Prawn::Document
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -351,7 +340,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Taxes :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -359,7 +348,7 @@ class CloseCashierPdf < Prawn::Document
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
+ text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
end
if total_credit_payments && total_credit_payments.to_f > 0
@@ -368,7 +357,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
#end for service charges and commercial tax
@@ -386,30 +375,30 @@ class CloseCashierPdf < Prawn::Document
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
- #end total amount by Account
+ #end total amount by Account
if total_member_discount[0].member_discount.present?
- @member_discount = total_member_discount[0].member_discount rescue 0.0
+ @member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
- else
- @overall = shift_sale.total_discounts
+ else
+ @overall = shift_sale.total_discounts
end
y_position = cursor
@@ -417,18 +406,18 @@ class CloseCashierPdf < Prawn::Document
text "Total Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
+ text "#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total FOC :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
- end
+ text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ end
- y_position = cursor
+ y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void :", :size => self.item_font_size, :align => :right
end
@@ -441,7 +430,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Waste :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -449,7 +438,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Spoile :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
# y_position = cursor
@@ -459,19 +448,19 @@ class CloseCashierPdf < Prawn::Document
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
# end
-
+
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
- total_amount_by_account.each do |amount|
+ total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
@@ -482,7 +471,7 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
end
- #end total amount by Account
+ #end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -532,7 +521,7 @@ class CloseCashierPdf < Prawn::Document
sale_items.each do |item|
if !arr.include?(item['menu_category_id'])
-
+
if flag == true
move_down 5
stroke_horizontal_rule
@@ -567,7 +556,7 @@ class CloseCashierPdf < Prawn::Document
# text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
# }
add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i)
-
+
if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void'
total_qty += item['total_item'].to_i
total_items += item['total_item'].to_i
@@ -657,4 +646,4 @@ class CloseCashierPdf < Prawn::Document
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
end
-end
\ No newline at end of file
+end
diff --git a/app/pdf/close_cashier_pdf_v1.rb b/app/pdf/close_cashier_pdf_v1.rb
index 687f0aa8..c241c047 100644
--- a/app/pdf/close_cashier_pdf_v1.rb
+++ b/app/pdf/close_cashier_pdf_v1.rb
@@ -1,5 +1,5 @@
class CloseCashierPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
@@ -39,22 +39,11 @@ class CloseCashierPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
- #check delimiter
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header( shop_details)
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
end
@@ -104,13 +93,13 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
+ text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
@@ -118,8 +107,8 @@ class CloseCashierPdf < Prawn::Document
text "Closing Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
- # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
+ text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
+ # text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
end
@@ -136,7 +125,7 @@ class CloseCashierPdf < Prawn::Document
text "Received Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
@@ -145,7 +134,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash In:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -153,7 +142,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash Out:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
@@ -166,7 +155,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -174,10 +163,10 @@ class CloseCashierPdf < Prawn::Document
text "Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
+ text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
- #start other payment details
+ #start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
@@ -187,7 +176,7 @@ class CloseCashierPdf < Prawn::Document
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -197,7 +186,7 @@ class CloseCashierPdf < Prawn::Document
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -207,7 +196,7 @@ class CloseCashierPdf < Prawn::Document
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -217,7 +206,7 @@ class CloseCashierPdf < Prawn::Document
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -227,7 +216,7 @@ class CloseCashierPdf < Prawn::Document
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -237,7 +226,7 @@ class CloseCashierPdf < Prawn::Document
text "Alipay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -247,7 +236,7 @@ class CloseCashierPdf < Prawn::Document
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -257,7 +246,7 @@ class CloseCashierPdf < Prawn::Document
text "Dinga Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -267,7 +256,7 @@ class CloseCashierPdf < Prawn::Document
text "Redeem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -277,7 +266,7 @@ class CloseCashierPdf < Prawn::Document
text "Paymal Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -287,7 +276,7 @@ class CloseCashierPdf < Prawn::Document
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
end
@@ -297,7 +286,7 @@ class CloseCashierPdf < Prawn::Document
text "Other Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -306,7 +295,7 @@ class CloseCashierPdf < Prawn::Document
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -314,10 +303,10 @@ class CloseCashierPdf < Prawn::Document
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
+ text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
- # end other payment details
+ # end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
@@ -329,7 +318,7 @@ class CloseCashierPdf < Prawn::Document
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -338,7 +327,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Taxes :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -346,7 +335,7 @@ class CloseCashierPdf < Prawn::Document
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
+ text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
end
if total_credit_payments && total_credit_payments.to_f > 0
@@ -355,7 +344,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
#end for service charges and commercial tax
@@ -373,30 +362,30 @@ class CloseCashierPdf < Prawn::Document
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
- #end total amount by Account
+ #end total amount by Account
if total_member_discount[0].member_discount.present?
- @member_discount = total_member_discount[0].member_discount rescue 0.0
+ @member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
-
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
- else
- @overall = shift_sale.total_discounts
+ else
+ @overall = shift_sale.total_discounts
end
y_position = cursor
@@ -404,18 +393,18 @@ class CloseCashierPdf < Prawn::Document
text "Total Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
- end
+ text "#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
+ end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total FOC :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
- end
+ text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ end
- y_position = cursor
+ y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void :", :size => self.item_font_size, :align => :right
end
@@ -428,7 +417,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Waste :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -436,7 +425,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Spoile :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
# y_position = cursor
@@ -446,19 +435,19 @@ class CloseCashierPdf < Prawn::Document
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
# end
-
+
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
- total_amount_by_account.each do |amount|
+ total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
+ text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
@@ -469,7 +458,7 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
end
- #end total amount by Account
+ #end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -502,4 +491,4 @@ class CloseCashierPdf < Prawn::Document
end
-end
\ No newline at end of file
+end
diff --git a/app/pdf/move_table_pdf.rb b/app/pdf/move_table_pdf.rb
index 5d44b393..dc55eedc 100644
--- a/app/pdf/move_table_pdf.rb
+++ b/app/pdf/move_table_pdf.rb
@@ -1,5 +1,5 @@
class MoveTablePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
self.page_width = printer_settings.page_width
@@ -39,7 +39,7 @@ class MoveTablePdf < Prawn::Document
stroke_horizontal_rule
move_down 5
- add_lining_item(order_items, printer_settings.precision)
+ add_lining_item(order_items, precision)
move_down 5
stroke_horizontal_rule
@@ -98,7 +98,7 @@ class MoveTablePdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
+ text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
diff --git a/app/pdf/move_table_star_pdf.rb b/app/pdf/move_table_star_pdf.rb
index 0467cbab..88ea4ef1 100644
--- a/app/pdf/move_table_star_pdf.rb
+++ b/app/pdf/move_table_star_pdf.rb
@@ -1,5 +1,5 @@
class MoveTableStarPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
self.page_width = printer_settings.page_width
@@ -38,7 +38,7 @@ class MoveTableStarPdf < Prawn::Document
stroke_horizontal_rule
move_down 5
- add_lining_item(order_items, printer_settings.precision)
+ add_lining_item(order_items, precision)
move_down 5
stroke_horizontal_rule
@@ -97,7 +97,7 @@ class MoveTableStarPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
+ text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
diff --git a/app/pdf/order_item_customise_pdf.rb b/app/pdf/order_item_customise_pdf.rb
index b509a01a..32be1928 100644
--- a/app/pdf/order_item_customise_pdf.rb
+++ b/app/pdf/order_item_customise_pdf.rb
@@ -1,5 +1,5 @@
class OrderItemCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
@@ -47,7 +47,7 @@ class OrderItemCustomisePdf < Prawn::Document
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
- order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
+ order_items(order_item, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -107,7 +107,7 @@ class OrderItemCustomisePdf < Prawn::Document
end
bounding_box([self.item_width - 10,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
+ text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -146,7 +146,7 @@ class OrderItemCustomisePdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.page_width) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb
index ed079aeb..d4a05aa2 100755
--- a/app/pdf/order_item_pdf.rb
+++ b/app/pdf/order_item_pdf.rb
@@ -1,5 +1,5 @@
class OrderItemPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
@@ -48,7 +48,7 @@ class OrderItemPdf < Prawn::Document
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
- order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
+ order_items(order_item, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -108,7 +108,7 @@ class OrderItemPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -147,7 +147,7 @@ class OrderItemPdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_item_slim_customise_pdf.rb b/app/pdf/order_item_slim_customise_pdf.rb
index c4b1e5c5..f759cbec 100644
--- a/app/pdf/order_item_slim_customise_pdf.rb
+++ b/app/pdf/order_item_slim_customise_pdf.rb
@@ -1,5 +1,5 @@
class OrderItemSlimCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :item_slim_font_size
def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
@@ -11,9 +11,9 @@ class OrderItemSlimCustomisePdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
self.item_slim_font_size=8
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -29,17 +29,17 @@ class OrderItemSlimCustomisePdf < Prawn::Document
})
font "#{print_settings.font}"
- fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
+ fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
- # font "public/fonts/padauk.ttf"
- #font "public/fonts/Chinese.ttf"
+ # font "public/fonts/padauk.ttf"
+ #font "public/fonts/Chinese.ttf"
if !order_item_slim.dining.nil?
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 1
@@ -47,35 +47,35 @@ class OrderItemSlimCustomisePdf < Prawn::Document
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
# order items slim
- order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty)
+ order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
end
stroke_horizontal_rule
@@ -88,7 +88,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document
def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
y_position = cursor
- #Add Order Item
+ #Add Order Item
add_order_items_slim(order_item_slim, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
@@ -108,7 +108,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document
end
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
+ text "[#{number_format(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -146,7 +146,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.page_width) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb
index 3e39644f..a32c1a26 100755
--- a/app/pdf/order_item_slim_pdf.rb
+++ b/app/pdf/order_item_slim_pdf.rb
@@ -1,7 +1,7 @@
class OrderItemSlimPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
-
+
def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
@@ -12,9 +12,9 @@ class OrderItemSlimPdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
@@ -29,17 +29,17 @@ class OrderItemSlimPdf < Prawn::Document
})
font "#{print_settings.font}"
- fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
+ fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
- # font "public/fonts/padauk.ttf"
- #font "public/fonts/Chinese.ttf"
+ # font "public/fonts/padauk.ttf"
+ #font "public/fonts/Chinese.ttf"
if !order_item_slim.dining.nil?
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 1
@@ -47,35 +47,35 @@ class OrderItemSlimPdf < Prawn::Document
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
# order items slim
- order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty)
+ order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -87,7 +87,7 @@ class OrderItemSlimPdf < Prawn::Document
def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
y_position = cursor
- #Add Order Item
+ #Add Order Item
add_order_items_slim(order_item_slim, options, alt_name, precision)
puts options
puts '............PDF OPTIONS...............'
@@ -108,7 +108,7 @@ class OrderItemSlimPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "[#{number_format(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -146,7 +146,7 @@ class OrderItemSlimPdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_item_star_pdf.rb b/app/pdf/order_item_star_pdf.rb
index 2686efd7..0703c8a2 100644
--- a/app/pdf/order_item_star_pdf.rb
+++ b/app/pdf/order_item_star_pdf.rb
@@ -1,5 +1,5 @@
class OrderItemStarPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
@@ -48,7 +48,7 @@ class OrderItemStarPdf < Prawn::Document
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
- order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
+ order_items(order_item, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -108,7 +108,7 @@ class OrderItemStarPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -147,7 +147,7 @@ class OrderItemStarPdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_set_item_customise_pdf.rb b/app/pdf/order_set_item_customise_pdf.rb
index 2e1d0a2c..f684e275 100644
--- a/app/pdf/order_set_item_customise_pdf.rb
+++ b/app/pdf/order_set_item_customise_pdf.rb
@@ -1,5 +1,5 @@
class OrderSetItemCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
@@ -12,9 +12,9 @@ class OrderSetItemCustomisePdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
@@ -29,11 +29,11 @@ class OrderSetItemCustomisePdf < Prawn::Document
})
font "#{print_settings.font}"
- fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
+ fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
- # font "public/fonts/padauk.ttf"
- #font "public/fonts/Chinese.ttf"
+ # font "public/fonts/padauk.ttf"
+ #font "public/fonts/Chinese.ttf"
if !order_set_item.dining.nil?
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
@@ -46,35 +46,35 @@ class OrderSetItemCustomisePdf < Prawn::Document
order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at)
# order items
- order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty)
+ order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
end
stroke_horizontal_rule
@@ -86,7 +86,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
y_position = cursor
- #Add Order Item
+ #Add Order Item
add_order_set_items(order_set_item, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
@@ -106,7 +106,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
end
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
+ text "[#{number_format(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -161,7 +161,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.page_width) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb
index 09cdc6db..cb57c870 100755
--- a/app/pdf/order_set_item_pdf.rb
+++ b/app/pdf/order_set_item_pdf.rb
@@ -1,5 +1,5 @@
class OrderSetItemPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
@@ -11,9 +11,9 @@ class OrderSetItemPdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
@@ -28,11 +28,11 @@ class OrderSetItemPdf < Prawn::Document
})
font "#{print_settings.font}"
- fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
+ fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
- # font "public/fonts/padauk.ttf"
- #font "public/fonts/Chinese.ttf"
+ # font "public/fonts/padauk.ttf"
+ #font "public/fonts/Chinese.ttf"
if !order_set_item.dining.nil?
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
@@ -45,35 +45,35 @@ class OrderSetItemPdf < Prawn::Document
order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at)
# order items
- order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty)
+ order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -85,7 +85,7 @@ class OrderSetItemPdf < Prawn::Document
def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
y_position = cursor
- #Add Order Item
+ #Add Order Item
add_order_set_items(order_set_item, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
@@ -105,7 +105,7 @@ class OrderSetItemPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "[#{number_format(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
@@ -160,7 +160,7 @@ class OrderSetItemPdf < Prawn::Document
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
diff --git a/app/pdf/order_summary_customise_pdf.rb b/app/pdf/order_summary_customise_pdf.rb
index 8ffedca0..bce29877 100644
--- a/app/pdf/order_summary_customise_pdf.rb
+++ b/app/pdf/order_summary_customise_pdf.rb
@@ -1,5 +1,5 @@
class OrderSummaryCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
self.page_width = print_settings.page_width
@@ -48,9 +48,9 @@ class OrderSummaryCustomisePdf < Prawn::Document
# order items
if order_items == nil
- order_items(order, alt_name, print_settings.precision)
+ order_items(order, alt_name, precision)
else
- order_items(order_items, alt_name, print_settings.precision)
+ order_items(order_items, alt_name, precision)
end
end
@@ -113,7 +113,7 @@ class OrderSummaryCustomisePdf < Prawn::Document
end
bounding_box([self.item_width - 10,y_position], :width => self.qty_width) do
- text " [#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text " [#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb
index fd446131..f3d25ff1 100755
--- a/app/pdf/order_summary_pdf.rb
+++ b/app/pdf/order_summary_pdf.rb
@@ -1,5 +1,5 @@
class OrderSummaryPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
self.page_width = print_settings.page_width
@@ -11,9 +11,9 @@ class OrderSummaryPdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -27,18 +27,18 @@ class OrderSummaryPdf < Prawn::Document
})
font "#{print_settings.font}"
- fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
+ fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
-
+
if !order[0].dining.nil?
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 5
@@ -47,38 +47,38 @@ class OrderSummaryPdf < Prawn::Document
# order items
if order_items == nil
- order_items(order, alt_name, print_settings.precision)
+ order_items(order, alt_name, precision)
else
- order_items(order_items, alt_name, print_settings.precision)
+ order_items(order_items, alt_name, precision)
end
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
- end
-
- move_down 5
- y_position = cursor
- bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ end
+
+ move_down 5
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -103,7 +103,7 @@ class OrderSummaryPdf < Prawn::Document
#Add Order Item
add_order_items(order_item, alt_name, precision)
-
+
end
# Add order items under order info
@@ -113,7 +113,7 @@ class OrderSummaryPdf < Prawn::Document
move_down 5
order_item.each do|odi|
- # check for item not to show
+ # check for item not to show
# if odi.price != 0
y_position = cursor
@@ -123,14 +123,14 @@ class OrderSummaryPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
+ text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
-
+
if alt_name
if !(odi.alt_name).empty?
move_down 4
@@ -138,15 +138,15 @@ class OrderSummaryPdf < Prawn::Document
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
-
+
end
# add option
options = odi.options == "[]"? "" : odi.options
-
+
if options != ""
move_down 5
-
+
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left
@@ -161,7 +161,7 @@ class OrderSummaryPdf < Prawn::Document
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 5
# end
- end
+ end
end
def get_booking_id(order_no)
diff --git a/app/pdf/order_summary_set_customise_pdf.rb b/app/pdf/order_summary_set_customise_pdf.rb
index 0e33d314..70c116fc 100644
--- a/app/pdf/order_summary_set_customise_pdf.rb
+++ b/app/pdf/order_summary_set_customise_pdf.rb
@@ -1,5 +1,5 @@
class OrderSummarySetCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
self.page_width = print_settings.page_width
@@ -12,9 +12,9 @@ class OrderSummarySetCustomisePdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -38,7 +38,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 5
@@ -47,38 +47,38 @@ class OrderSummarySetCustomisePdf < Prawn::Document
# order items
if order_items == nil
- order_items(order, alt_name, print_settings.precision)
+ order_items(order, alt_name, precision)
else
- order_items(order_items, alt_name, print_settings.precision)
+ order_items(order_items, alt_name, precision)
end
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
end
stroke_horizontal_rule
@@ -92,7 +92,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
#Add Order Item
add_order_items(order_item, alt_name, precision)
-
+
end
# Add order items under order info
@@ -102,7 +102,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
move_down 5
order_item.each do|odi|
- # check for item not to show
+ # check for item not to show
# if odi.price != 0
y_position = cursor
@@ -112,14 +112,14 @@ class OrderSummarySetCustomisePdf < Prawn::Document
end
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "[#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
-
+
if alt_name
if !(odi.alt_name).empty?
move_down 4
@@ -127,7 +127,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
-
+
end
#add set menu items
@@ -148,10 +148,10 @@ class OrderSummarySetCustomisePdf < Prawn::Document
# add option
options = odi.options == "[]"? "" : odi.options
-
+
if options != ""
move_down 5
-
+
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left
@@ -166,7 +166,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 5
# end
- end
+ end
end
def get_booking_id(order_no)
diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb
index 5e27f82b..dd65f0d2 100755
--- a/app/pdf/order_summary_set_pdf.rb
+++ b/app/pdf/order_summary_set_pdf.rb
@@ -1,5 +1,5 @@
class OrderSummarySetPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
self.page_width = print_settings.page_width
@@ -11,9 +11,9 @@ class OrderSummarySetPdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -37,7 +37,7 @@ class OrderSummarySetPdf < Prawn::Document
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 5
@@ -46,38 +46,38 @@ class OrderSummarySetPdf < Prawn::Document
# order items
if order_items == nil
- order_items(order, alt_name, print_settings.precision)
+ order_items(order, alt_name, precision)
else
- order_items(order_items, alt_name, print_settings.precision)
+ order_items(order_items, alt_name, precision)
end
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
- end
-
- move_down 5
- y_position = cursor
- bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ end
+
+ move_down 5
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -102,7 +102,7 @@ class OrderSummarySetPdf < Prawn::Document
#Add Order Item
add_order_items(order_item, alt_name, precision)
-
+
end
# Add order items under order info
@@ -112,7 +112,7 @@ class OrderSummarySetPdf < Prawn::Document
move_down 5
order_item.each do|odi|
- # check for item not to show
+ # check for item not to show
# if odi.price != 0
y_position = cursor
@@ -122,14 +122,14 @@ class OrderSummarySetPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
+ text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
-
+
if alt_name
if !(odi.alt_name).empty?
move_down 4
@@ -137,7 +137,7 @@ class OrderSummarySetPdf < Prawn::Document
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
-
+
end
#add set menu items
@@ -158,10 +158,10 @@ class OrderSummarySetPdf < Prawn::Document
# add option
options = odi.options == "[]"? "" : odi.options
-
+
if options != ""
move_down 5
-
+
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left
@@ -176,7 +176,7 @@ class OrderSummarySetPdf < Prawn::Document
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 5
# end
- end
+ end
end
def get_booking_id(order_no)
diff --git a/app/pdf/order_summary_slim_customise_pdf.rb b/app/pdf/order_summary_slim_customise_pdf.rb
index c641b0c8..e8bd21f2 100644
--- a/app/pdf/order_summary_slim_customise_pdf.rb
+++ b/app/pdf/order_summary_slim_customise_pdf.rb
@@ -1,5 +1,5 @@
class OrderSummarySlimCustomisePdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:item_slim_font_size
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
self.page_width = print_settings.page_width
@@ -11,10 +11,10 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
- self.item_slim_font_size=8
+ self.label_width=90
+ self.item_slim_font_size=8
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -38,7 +38,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 1
@@ -47,38 +47,38 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
# order items
if order_items == nil
- order_items(order, alt_name, print_settings.precision)
+ order_items(order, alt_name, precision)
else
- order_items(order_items, alt_name, print_settings.precision)
+ order_items(order_items, alt_name, precision)
end
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
- end
-
- move_down 1
- y_position = cursor
- bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
+ end
+
+ move_down 1
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
end
stroke_horizontal_rule
@@ -95,7 +95,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
#Add Order Item
add_order_items(order_item, alt_name, precision)
-
+
end
# Add order items under order info
@@ -105,7 +105,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
move_down 1
order_item.each do|odi|
- # check for item not to show
+ # check for item not to show
# if odi.price != 0
y_position = cursor
@@ -115,14 +115,14 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
end
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
- text "[#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ text "[#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
-
+
if alt_name
if !(odi.alt_name).empty?
move_down 1
@@ -134,7 +134,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
# add option
options = odi.options == "[]"? "" : odi.options
-
+
if options != ""
move_down 1
@@ -152,7 +152,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 1
# end
- end
+ end
end
def get_booking_id(order_no)
diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb
index 1b78cf23..2cbe14d8 100755
--- a/app/pdf/order_summary_slim_pdf.rb
+++ b/app/pdf/order_summary_slim_pdf.rb
@@ -1,5 +1,5 @@
class OrderSummarySlimPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
self.page_width = print_settings.page_width
@@ -11,9 +11,9 @@ class OrderSummarySlimPdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
- self.item_height = 15
+ self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.label_width=90
+ self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -37,7 +37,7 @@ class OrderSummarySlimPdf < Prawn::Document
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
-
+
stroke_horizontal_rule
move_down 1
@@ -46,38 +46,38 @@ class OrderSummarySlimPdf < Prawn::Document
# order items
if order_items == nil
- order_items(order, alt_name, print_settings.precision)
+ order_items(order, alt_name, precision)
else
- order_items(order_items, alt_name, print_settings.precision)
+ order_items(order_items, alt_name, precision)
end
end
# Write Order Information to PDF
- def order_info(order_no, order_by, order_at)
+ def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
- end
-
- move_down 1
- y_position = cursor
- bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
+ text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
+ end
+
+ move_down 1
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -102,7 +102,7 @@ class OrderSummarySlimPdf < Prawn::Document
#Add Order Item
add_order_items(order_item, alt_name, precision)
-
+
end
# Add order items under order info
@@ -112,7 +112,7 @@ class OrderSummarySlimPdf < Prawn::Document
move_down 1
order_item.each do|odi|
- # check for item not to show
+ # check for item not to show
# if odi.price != 0
y_position = cursor
@@ -122,14 +122,14 @@ class OrderSummarySlimPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
+ text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
-
+
if alt_name
if !(odi.alt_name).empty?
move_down 1
@@ -141,7 +141,7 @@ class OrderSummarySlimPdf < Prawn::Document
# add option
options = odi.options == "[]"? "" : odi.options
-
+
if options != ""
move_down 1
@@ -159,7 +159,7 @@ class OrderSummarySlimPdf < Prawn::Document
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 1
# end
- end
+ end
end
def get_booking_id(order_no)
diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb
index 8a844c40..7f2e47e9 100644
--- a/app/pdf/receipt_bill_a5_pdf.rb
+++ b/app/pdf/receipt_bill_a5_pdf.rb
@@ -1,5 +1,5 @@
class ReceiptBillA5Pdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref)
@@ -26,11 +26,6 @@ class ReceiptBillA5Pdf < Prawn::Document
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
-
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -46,23 +41,17 @@ class ReceiptBillA5Pdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name, latest_order_no)
- line_items(sale_items,printer_settings.precision,delimiter)
- all_total(sale_data,printer_settings.precision,delimiter)
+ line_items(sale_items,precision,delimiter)
+ all_total(sale_data,precision,delimiter)
if member_info != nil
- member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
+ member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
end
customer(customer_name)
@@ -80,19 +69,19 @@ class ReceiptBillA5Pdf < Prawn::Document
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
- discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
+ discount_account(discount_price_by_accounts,precision,delimiter)
end
if shop_details.show_account_info
- items_account(item_price_by_accounts,printer_settings.precision,delimiter)
+ items_account(item_price_by_accounts,precision,delimiter)
if other_charges_amount
- show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
+ show_other_charges_amount(other_charges_amount,precision,delimiter)
end
end
#start for individual payment
if !sale_data.equal_persons.nil?
- individual_payment(sale_data, printer_settings.precision, delimiter)
+ individual_payment(sale_data, precision, delimiter)
end
#end for individual payment
@@ -266,13 +255,14 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Sub Total", :size => self.item_font_size,:align => :left
end
# bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
- # text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
+ # text "#{number_format(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
# end
# bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
- # text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ # text "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
# end
- text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+
+ text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
end
@@ -299,9 +289,11 @@ class ReceiptBillA5Pdf < Prawn::Document
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
- text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+
+ text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+
if show_alt_name
if !(item.product_alt_name).empty?
@@ -329,7 +321,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "#{ dis_type }", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
+ text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end
if sale_data.sale_taxes.length > 0
@@ -345,7 +337,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
else
@@ -381,7 +373,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
+ text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
end
move_down line_move
@@ -422,7 +414,7 @@ class ReceiptBillA5Pdf < Prawn::Document
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -433,7 +425,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
#move_down line_move
end
@@ -468,7 +460,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -481,7 +473,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
#end Total rebate if birthday
@@ -493,7 +485,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if current_balance != nil
@@ -503,7 +495,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
@@ -525,7 +517,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -555,7 +547,8 @@ class ReceiptBillA5Pdf < Prawn::Document
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
- text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
+
+ text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -571,7 +564,9 @@ class ReceiptBillA5Pdf < Prawn::Document
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.description_width) do
- text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+
+ text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+
end
move_down line_move
end
@@ -583,7 +578,7 @@ class ReceiptBillA5Pdf < Prawn::Document
text "Other Charges", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
- text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -605,7 +600,7 @@ class ReceiptBillA5Pdf < Prawn::Document
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
- text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
diff --git a/app/pdf/receipt_bill_order_pdf.rb b/app/pdf/receipt_bill_order_pdf.rb
index c08aff35..7adbcd66 100644
--- a/app/pdf/receipt_bill_order_pdf.rb
+++ b/app/pdf/receipt_bill_order_pdf.rb
@@ -1,5 +1,5 @@
class ReceiptBillOrderPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
@@ -27,11 +27,6 @@ class ReceiptBillOrderPdf < Prawn::Document
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
-
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -47,19 +42,13 @@ class ReceiptBillOrderPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name, latest_order_no,order_reservation)
- line_items(sale_items,printer_settings.precision,delimiter,order_reservation)
- all_total(sale_data,printer_settings.precision,delimiter,order_reservation)
+ line_items(sale_items,precision,delimiter,order_reservation)
+ all_total(sale_data,precision,delimiter,order_reservation)
footer(printed_status)
end
@@ -209,8 +198,8 @@ class ReceiptBillOrderPdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
- text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(order_reservation.total_amount, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(order_reservation.total_amount, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
if !order_reservation.delivery_type.nil? && order_reservation.delivery_fee.to_f > 0
y_position = cursor
@@ -219,7 +208,9 @@ class ReceiptBillOrderPdf < Prawn::Document
end
bounding_box([self.description_width - 48,y_position], :width =>self.label_width, :height => self.item_height) do
- text "#{number_with_precision(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+
+ text "#{number_format(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+
end
end
@@ -230,7 +221,9 @@ class ReceiptBillOrderPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
- text "#{number_with_precision(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+
+ text "#{number_format(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+
end
end
@@ -239,7 +232,7 @@ class ReceiptBillOrderPdf < Prawn::Document
text "Convenience Charges " , :size => self.item_font_size, :align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
- text "#{number_with_precision(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if order_reservation.discount_amount > 0
@@ -249,7 +242,9 @@ class ReceiptBillOrderPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
- text "#{number_with_precision(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+
+ text "#{number_format(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+
end
end
end
@@ -278,9 +273,11 @@ class ReceiptBillOrderPdf < Prawn::Document
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
- text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+
+ text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+
if show_alt_name
if !(item.product_alt_name).empty?
@@ -309,7 +306,9 @@ class ReceiptBillOrderPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
+
+ text "#{number_format(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
+
end
move_down line_move
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index 9462533c..feb127d8 100755
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -1,7 +1,7 @@
# require 'prawn/qrcode'
require 'prawn/measurement_extensions'
class ReceiptBillPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
@@ -29,11 +29,6 @@ class ReceiptBillPdf < Prawn::Document
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
-
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -49,23 +44,17 @@ class ReceiptBillPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name, latest_order_no)
- line_items(sale_items,printer_settings.precision,delimiter)
- all_total(sale_data,printer_settings.precision,delimiter)
+ line_items(sale_items,precision,delimiter)
+ all_total(sale_data,precision,delimiter)
if member_info != nil
- member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
+ member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
end
customer(customer_name)
@@ -83,19 +72,19 @@ class ReceiptBillPdf < Prawn::Document
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
- discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
+ discount_account(discount_price_by_accounts,precision,delimiter)
end
if shop_details.show_account_info
- items_account(item_price_by_accounts,printer_settings.precision,delimiter)
+ items_account(item_price_by_accounts,precision,delimiter)
if other_charges_amount
- show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
+ show_other_charges_amount(other_charges_amount,precision,delimiter)
end
end
#start for individual payment
if !sale_data.equal_persons.nil?
- individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
+ individual_payment(sale_data,sale_data.equal_persons, precision, delimiter)
end
#end for individual payment
@@ -274,8 +263,8 @@ class ReceiptBillPdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
- text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
end
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
@@ -299,9 +288,9 @@ class ReceiptBillPdf < Prawn::Document
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
- text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
if show_alt_name
if !(item.product_alt_name).empty?
@@ -331,7 +320,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ dis_type }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
+ text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end
service_tax_desc = ""
@@ -356,14 +345,14 @@ class ReceiptBillPdf < Prawn::Document
sale_data.sale_taxes.each do |st|
if (st.tax_name.include? "Service")
service_tax_desc = st.tax_name
- service_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
+ service_tax_amount = st.tax_payable_amount
if incl_tax
service_tax_rate = st.tax_rate.to_i
end
end
if (st.tax_name.include? "Commercial")
com_tax_desc = st.tax_name
- com_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
+ com_tax_amount = st.tax_payable_amount
if incl_tax
com_tax_rate = st.tax_rate.to_i
end
@@ -375,7 +364,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ service_tax_desc } (#{incl_tax} #{ service_tax_rate }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
y_position = cursor
@@ -392,7 +381,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ com_tax_desc } (#{incl_tax} #{ com_tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
else
sale_data.sale_taxes.each do |st|
@@ -403,7 +392,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
@@ -440,7 +429,7 @@ class ReceiptBillPdf < Prawn::Document
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
+ text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
end
move_down line_move
@@ -481,7 +470,7 @@ class ReceiptBillPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -492,7 +481,7 @@ class ReceiptBillPdf < Prawn::Document
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
# move_down line_move
end
@@ -527,7 +516,7 @@ class ReceiptBillPdf < Prawn::Document
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -540,7 +529,7 @@ class ReceiptBillPdf < Prawn::Document
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
#end Total rebate if birthday
@@ -552,7 +541,7 @@ class ReceiptBillPdf < Prawn::Document
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if current_balance != nil
@@ -562,7 +551,7 @@ class ReceiptBillPdf < Prawn::Document
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
@@ -584,7 +573,7 @@ class ReceiptBillPdf < Prawn::Document
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -616,7 +605,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
+ text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -632,7 +621,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
- text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -644,7 +633,7 @@ class ReceiptBillPdf < Prawn::Document
text "Other Charges", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
- text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -667,7 +656,7 @@ class ReceiptBillPdf < Prawn::Document
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
- text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb
index 26d0a944..8a9f9c9c 100644
--- a/app/pdf/receipt_bill_star_pdf.rb
+++ b/app/pdf/receipt_bill_star_pdf.rb
@@ -1,5 +1,5 @@
class ReceiptBillStarPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
@@ -28,11 +28,6 @@ class ReceiptBillStarPdf < Prawn::Document
#setting page margin and width
super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
-
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -48,23 +43,17 @@ class ReceiptBillStarPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name, latest_order_no)
- line_items(sale_items,printer_settings.precision,delimiter)
- all_total(sale_data,printer_settings.precision,delimiter)
+ line_items(sale_items,precision,delimiter)
+ all_total(sale_data,precision,delimiter)
if member_info != nil
- member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
+ member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
end
customer(customer_name)
@@ -82,19 +71,19 @@ class ReceiptBillStarPdf < Prawn::Document
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
- discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
+ discount_account(discount_price_by_accounts,precision,delimiter)
end
if shop_details.show_account_info
- items_account(item_price_by_accounts,printer_settings.precision,delimiter)
+ items_account(item_price_by_accounts,precision,delimiter)
if other_charges_amount
- show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
+ show_other_charges_amount(other_charges_amount,precision,delimiter)
end
end
#start for individual payment
if !sale_data.equal_persons.nil?
- individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
+ individual_payment(sale_data,sale_data.equal_persons, precision, delimiter)
end
#end for individual payment
@@ -269,8 +258,8 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
- text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
end
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
@@ -294,9 +283,9 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
- text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
- text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
+ text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
if show_alt_name
if !(item.product_alt_name).empty?
@@ -326,7 +315,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{ dis_type }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
+ text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end
if sale_data.sale_taxes.length > 0
@@ -343,7 +332,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
else
@@ -379,7 +368,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
+ text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
end
move_down line_move
@@ -420,7 +409,7 @@ class ReceiptBillStarPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -431,7 +420,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
# move_down line_move
end
@@ -466,7 +455,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -479,7 +468,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
#end Total rebate if birthday
@@ -491,7 +480,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if current_balance != nil
@@ -501,7 +490,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
@@ -523,7 +512,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -555,7 +544,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
+ text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -571,7 +560,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
- text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -583,7 +572,7 @@ class ReceiptBillStarPdf < Prawn::Document
text "Other Charges", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
- text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
+ text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
@@ -606,7 +595,7 @@ class ReceiptBillStarPdf < Prawn::Document
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
- text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
diff --git a/app/pdf/sale_items_pdf.rb b/app/pdf/sale_items_pdf.rb
index 657b7fe1..af76c427 100644
--- a/app/pdf/sale_items_pdf.rb
+++ b/app/pdf/sale_items_pdf.rb
@@ -1,5 +1,5 @@
class SaleItemsPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges)
@@ -41,17 +41,6 @@ class SaleItemsPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
- #check delimiter
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header( shop_details)
stroke_horizontal_rule
diff --git a/app/pdf/sale_items_star_pdf.rb b/app/pdf/sale_items_star_pdf.rb
index 6860b341..a1181e13 100644
--- a/app/pdf/sale_items_star_pdf.rb
+++ b/app/pdf/sale_items_star_pdf.rb
@@ -1,5 +1,5 @@
class SaleItemsStarPdf < Prawn::Document
- include ActionView::Helpers::NumberHelper
+ include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges)
@@ -41,17 +41,6 @@ class SaleItemsStarPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- #precision checked
- if printer_settings.precision.to_i > 2
- printer_settings.precision = 2
- end
- #check delimiter
- if printer_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
-
header( shop_details)
stroke_horizontal_rule
diff --git a/app/uploaders/commissioner_image_uploader.rb b/app/uploaders/commissioner_image_uploader.rb
index 9b65e4a8..42e90a16 100644
--- a/app/uploaders/commissioner_image_uploader.rb
+++ b/app/uploaders/commissioner_image_uploader.rb
@@ -20,11 +20,11 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base
end
def filename
- if Shop.first.shop_code.nil?
- "#{original_filename}" if original_filename.present?
+ if Shop.current_shop.shop_code.nil?
+ "#{original_filename}" if original_filename.present?
else
- "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
- end
+ "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
+ end
end
# def cache_dir
@@ -62,6 +62,6 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
- # end
+ # end
-end
\ No newline at end of file
+end
diff --git a/app/uploaders/customer_image_uploader.rb b/app/uploaders/customer_image_uploader.rb
index be1326d6..77a133af 100644
--- a/app/uploaders/customer_image_uploader.rb
+++ b/app/uploaders/customer_image_uploader.rb
@@ -20,11 +20,11 @@ class CustomerImageUploader < CarrierWave::Uploader::Base
end
def filename
- if Shop.first.shop_code.nil?
- "#{original_filename}" if original_filename.present?
+ if Shop.current_shop.shop_code.nil?
+ "#{original_filename}" if original_filename.present?
else
- "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
- end
+ "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
+ end
end
# def cache_dir
@@ -62,6 +62,6 @@ class CustomerImageUploader < CarrierWave::Uploader::Base
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
- # end
+ # end
-end
\ No newline at end of file
+end
diff --git a/app/uploaders/employee_image_uploader.rb b/app/uploaders/employee_image_uploader.rb
index 17c9d120..eed8c04f 100644
--- a/app/uploaders/employee_image_uploader.rb
+++ b/app/uploaders/employee_image_uploader.rb
@@ -20,11 +20,11 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
end
def filename
- if Shop.first.shop_code.nil?
- "#{original_filename}" if original_filename.present?
- else
- "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
- end
+ # if Shop.current_shop.shop_code.nil?
+ "#{original_filename}" if original_filename.present?
+ # else
+ "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
+ # end
end
# def cache_dir
@@ -62,6 +62,6 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
- # end
+ # end
-end
\ No newline at end of file
+end
diff --git a/app/uploaders/menu_item_image_uploader.rb b/app/uploaders/menu_item_image_uploader.rb
index 7a4b2039..5f23cafc 100755
--- a/app/uploaders/menu_item_image_uploader.rb
+++ b/app/uploaders/menu_item_image_uploader.rb
@@ -15,16 +15,16 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
- "image/menu_images/#{Shop.first.shop_code}"
+ "image/menu_images/#{Shop.current_shop.shop_code}"
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def filename
- if Shop.first.shop_code.nil?
- "#{original_filename}" if original_filename.present?
+ if Shop.current_shop.shop_code.nil?
+ "#{original_filename}" if original_filename.present?
else
- "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
- end
+ "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
+ end
end
# def cache_dir
@@ -42,7 +42,7 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base
# Process files as they are uploaded:
# process scale: [200, 300]
process :resize_to_fit => [400, 250]#[200, 150]
-
+
#
# def scale(width, height)
# # do something
diff --git a/app/uploaders/product_image_uploader.rb b/app/uploaders/product_image_uploader.rb
index c39d867d..35fde675 100755
--- a/app/uploaders/product_image_uploader.rb
+++ b/app/uploaders/product_image_uploader.rb
@@ -20,11 +20,11 @@ class ProductImageUploader < CarrierWave::Uploader::Base
end
def filename
- if Shop.first.shop_code.nil?
- "#{original_filename}" if original_filename.present?
+ if Shop.current_shop.shop_code.nil?
+ "#{original_filename}" if original_filename.present?
else
- "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
- end
+ "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
+ end
end
# def cache_dir
diff --git a/app/uploaders/shop_image_uploader.rb b/app/uploaders/shop_image_uploader.rb
index 394704c3..c27fb65c 100644
--- a/app/uploaders/shop_image_uploader.rb
+++ b/app/uploaders/shop_image_uploader.rb
@@ -20,11 +20,11 @@ class ShopImageUploader < CarrierWave::Uploader::Base
end
def filename
- if Shop.first.shop_code.nil?
- "#{original_filename}" if original_filename.present?
+ if Shop.current_shop.shop_code.nil?
+ "#{original_filename}" if original_filename.present?
else
- "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
- end
+ "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
+ end
end
# def cache_dir
@@ -62,6 +62,6 @@ class ShopImageUploader < CarrierWave::Uploader::Base
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
- # end
+ # end
-end
\ No newline at end of file
+end
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index d8a5a9c8..71f7398a 100755
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -67,24 +67,16 @@
<%
if !@from.nil? && @from != ""
- from_date = DateTime.parse(@from).utc.getlocal.strftime("%d-%m-%Y")
+ from_date = @from.strftime("%d-%m-%Y")
+ from_time = @from.strftime("%H:%M") if @from.strftime("%H:%M") != "00:00"
else
- from_date = Time.now.utc.getlocal.strftime('%d-%m-%Y')
+ from_date = Time.now.strftime('%d-%m-%Y')
end
if !@to.nil? && @to != ""
- to_date = DateTime.parse(@to).utc.getlocal.strftime("%d-%m-%Y")
+ to_date = @to.strftime("%d-%m-%Y")
+ to_time = @to.strftime("%H:%M") if @to.strftime("%H:%M") != "23:59"
else
- to_date = Time.now.utc.getlocal.strftime('%d-%m-%Y')
- end
- if !@from_time.nil?
- from_time = @from_time
- else
- from_time = ''
- end
- if !@to_time.nil?
- to_time = @to_time
- else
- to_time = ''
+ to_date = Time.now.strftime('%d-%m-%Y')
end
%>
@@ -199,49 +191,48 @@
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
| <%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : |
- <%= number_with_precision( revenue, precision: @precision.to_i ,delimiter: @delimiter) %> |
+
+ <%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %> |
| <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : |
- <%= number_with_precision( @summ_sale.total_discount, precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %> |
+ <%= number_format( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> |
| <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : |
- <%= number_with_precision( @summ_sale.total_tax , precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %> |
+ <%= number_format( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> |
| <%= t("views.right_panel.detail.total_sale") %> : |
- <%= number_with_precision( @summ_sale.grand_total , precision: @precision.to_i ,delimiter: @delimiter)%> |
+ <%= number_format( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> |
<% if !(@total_payment_methods.nil?) %>
<% @total_payment_methods.each do |payment| %>
- <% if !@sale_data[0].empty? %>
- <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' && payment.payment_method != 'unionpay' %>
-
- <% if payment.payment_method == 'paypar' %>
- | Redeem Sale : |
- <% else %>
- <%= payment.payment_method.to_s.capitalize %> Sale : |
- <% end %>
-
- <% @sale_data.each do |data| %>
- <% pay_mth = payment.payment_method %>
- <%= number_with_precision(data[""+pay_mth+""], precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %>
- <% end %>
- |
-
- <% end %>
+
+ <% if payment.payment_method != 'card' %>
+
+ <% if payment.payment_method == 'paypar' %>
+ | Redeem Sale : |
+ <% else %>
+ <%= payment.payment_method.to_s.capitalize %> Sale : |
+ <% end %>
+
+ <%= number_format(@sale_data.find {|x| x.key?(payment.payment_method) }[payment.payment_method], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
+ |
+
<% end %>
<% end %>
- <% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %>
+ <% total_card = @sale_data.find {|x| x.key?("card") } %>
<% if !total_card.nil? %>
| <%= t("views.right_panel.detail.other_payment") %> : |
- <%= number_with_precision(total_card["card"], precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %>
+
+ <%= number_format(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
+
|
<% end %>
diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb
index 407b5952..9edc81bc 100755
--- a/app/views/layouts/login_dashboard.html.erb
+++ b/app/views/layouts/login_dashboard.html.erb
@@ -68,7 +68,7 @@
- <%= shop_detail.name %>
+ <%= Shop.current_shop.name rescue "" %>
diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder
index 9c9f1963..372d521c 100644
--- a/app/views/origami/dashboard/_menu.json.jbuilder
+++ b/app/views/origami/dashboard/_menu.json.jbuilder
@@ -8,22 +8,17 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (menu.menu_categories)
order_by = Lookup.find_by_lookup_type("order_by")
# if !order_by.nil? && order_by.value == "name"
- # categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc")
+ # categories = MenuCategory.unscope(:order).where("menu_id ='#{menu.id}'").order("name asc")
# else
# categories = menu.menu_categories
# end
categories = menu.menu_categories
json.categories categories do |category|
if category.is_available
- parent_category = category.parent
- if !parent_category.nil?
- json.sub_category "true"
- else
- json.sub_category "false"
- end
+ json.sub_category category.children.present?
+
valid_time = category.valid_time
json.valid_time valid_time
-
json.id category.id
json.code category.code
json.order_by category.order_by
@@ -80,7 +75,7 @@ if (menu.menu_categories)
alt_name: its.alt_name,
min_selectable_qty: its.min_selectable_qty,
max_selectable_qty: its.max_selectable_qty,
- instances: its.menu_item_instances.pluck(:id).map { |id| {id: id}}
+ instances: its.menu_item_instances.map { |i| {id: i.id} }
}
}
diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb
index 204ac3d4..713ba6a5 100644
--- a/app/views/origami/dashboard/index.html.erb
+++ b/app/views/origami/dashboard/index.html.erb
@@ -6,18 +6,6 @@
<%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %>
- <% if @print_settings.precision.to_i > 0
- precision = @print_settings.precision
- else
- precision = 0
- end
- #check delimiter
- if @print_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
- %>
@@ -91,19 +79,19 @@
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
| <%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : |
- <%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %> |
+ <%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %> |
| <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : |
- <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %> |
+ <%= number_format( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %> |
| <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : |
- <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%> |
+ <%= number_format( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%> |
| <%= t("views.right_panel.detail.total") %> <%= t :sale %> : |
- <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> |
+ <%= number_format( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> |
diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb
index abeeb442..5d24c9d1 100755
--- a/app/views/origami/discounts/index.html.erb
+++ b/app/views/origami/discounts/index.html.erb
@@ -2,20 +2,6 @@
- <% if !@print_settings.nil? %>
- <% if @print_settings.precision.to_i > 0
- precision = @print_settings.precision
- else
- precision = 0
- end
- #check delimiter
- if @print_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
- %>
- <% end %>
@@ -96,7 +82,7 @@
| Sub Total: |
- <%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> |
+ <%= number_format(sub_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %> |
@@ -364,7 +350,7 @@
| Sub Total: |
- <%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> |
+ <%= number_format(sub_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %> |
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
@@ -373,7 +359,7 @@
| Discount: |
<%end%>
- (<%= number_with_precision(@obj_sale.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>) |
+ (<%= number_format(@obj_sale.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>) |
<% if @status_sale == "sale" %>
@@ -396,15 +382,15 @@
<% end %>
- | <%= number_with_precision(@obj_sale.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> |
+ <%= number_format(@obj_sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> |
| Rounding Adj: |
- <%= number_with_precision(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> |
+ <%= number_format(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> |
| Grand Total: |
- <%= number_with_precision(@obj_sale.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> |
+ <%= number_format(@obj_sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %> |
<% end %>
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index a40f7f58..a7737724 100755
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -2,20 +2,6 @@
- <% if !@print_settings.nil? %>
- <% if @print_settings.precision.to_i > 0
- precision = @print_settings.precision
- else
- precision = 0
- end
- #check delimiter
- if @print_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
- %>
- <% end %>
@@ -78,9 +64,9 @@
<% sub_total += sale_item.price%>
| <%= count %> |
- <%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%> |
+ <%=sale_item.product_name%>@<%=number_format( sale_item.unit_price, precision: precision.to_i )%> |
<%=sale_item.qty%> |
- <%=(number_with_precision(sale_item.price, precision: precision.to_i ))%> |
+ <%=(number_format(sale_item.price, precision: precision.to_i ))%> |
<%end %>
@@ -93,7 +79,7 @@
| Sub Total |
- <%=number_with_precision(sub_total, precision: precision.to_i)%> |
+ <%=number_format(sub_total, precision: precision.to_i)%> |
<%if @sale_data.discount_type == 'member_discount'%>
@@ -101,7 +87,7 @@
<%else%>
| (Discount) |
<%end%>
- (<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>) |
+ (<%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>) |
|
@@ -122,20 +108,20 @@
<% end %>
|
- <%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> |
+ <%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> |
| Rounding Adj: |
- <%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> |
+ <%= number_format(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> |
| Grand Total |
- <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> |
+ <%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> |
<%if @balance > 0%>
| <%= @accountable_type %> |
- <%=number_with_precision(@balance, precision: precision.to_i )%> |
+ <%=number_format(@balance, precision: precision.to_i )%> |
<% end %>
<% if !@individual_total[0].nil? %>
@@ -149,7 +135,7 @@
Amount Due (per person)
|
- <%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%> |
+ <%= number_format(@individual_total[0]['per_person_amount'], precision: precision.to_i )%> |
<% end %>
@@ -171,16 +157,16 @@
<% if @sale_payment.nil? %>
- <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
+ <%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<% else %>
- <%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
+ <%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<% end %>
<% if @sale_payment.nil? %>
- <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
+ <%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
<% end %>
@@ -190,13 +176,13 @@
Cash
- <%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
Credit
-
<%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
0
@@ -205,21 +191,21 @@
Other Payments (KBZ Pay)
- <%= number_with_precision(@kbz_pay_amount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
+ <%= number_format(@kbz_pay_amount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
<% elsif @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
Other Payments
- <%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
+ <%= number_format(@other, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
<% else %>
Other Payments
- <%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
+ <%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
<% end %>
@@ -231,9 +217,9 @@
MPU
<% if @other != 0.0 %>
-
<%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@other, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
-
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -242,9 +228,9 @@
Redeem
<% if @ppamount != 0.0 %>
-
<%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@ppamount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
-
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -253,9 +239,9 @@
VISA
<% if @visacount != 0.0 %>
- <%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@visacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -264,9 +250,9 @@
JCB
<% if @jcbcount != 0.0 %>
- <%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@jcbcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -275,9 +261,9 @@
MASTER
<% if @mastercount != 0.0 %>
- <%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@mastercount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -287,9 +273,9 @@
UNIONPAY
<% if @unionpaycount != 0.0 %>
- <%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@unionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -298,9 +284,9 @@
Alipay
<% if @alipaycount != 0.0 %>
- <%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@alipaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -309,9 +295,9 @@
PAYMAL
<% if @paymalcount != 0.0 %>
- <%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@paymalcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -319,9 +305,9 @@
DINGA
<% if @dingacount != 0.0 %>
- <%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@dingacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -330,9 +316,9 @@
JUNCTION PAY
<% if @junctionpaycount != 0.0 %>
- <%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@junctionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -341,15 +327,15 @@
GIFT VOUCHER
<% if @giftvouchercount != 0.0 %>
- <%= number_with_precision(@giftvouchercount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(@giftvouchercount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %>
- <%= number_with_precision(0, precision: precision.to_i ) %>
+ <%= number_format(0, precision: precision.to_i ) %>
<% end %>
Balance
-
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb
index a4d8a666..b7ec4ca1 100755
--- a/app/views/origami/surveys/_form.html.erb
+++ b/app/views/origami/surveys/_form.html.erb
@@ -99,7 +99,7 @@
@@ -189,16 +178,16 @@
$('#sel_period').change(function(){
search_by_period();
});
-
+
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
- show_shift_name(period,period_type,from,to,'shift_item');
- }
-
+ show_shift_name(period,period_type,from,to,'shift_item');
+ }
+
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
@@ -213,50 +202,50 @@
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
- });
-
+ });
+
function search_by_date(){
-
+
from = $("#from").val();
to = $("#to").val();
var period = 0;
- var period_type = 1;
+ var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
-
+
if(check_arr.length == 1){
- show_shift_name(period,period_type,from,to,'shift_item');
+ show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
-
+
}
-
+
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
-
+
shift.empty();
-
+
var str = '';
- var param_shift = '';
+ var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
url = '<%= reports_get_shift_by_order_reservation_path %>';
-
+
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
str = '
';
- $(data.message).each(function(index){
-
+ $(data.message).each(function(index){
+
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
var shift_id = data.message[index].shift_id ;
@@ -265,18 +254,18 @@
selected = 'selected = "selected"';
}
else{
- selected = '';
- }
+ selected = '';
+ }
}else{
- selected = '';
- }
+ selected = '';
+ }
str += '
';
-
+
// console.log(sh_date)
- })
+ })
shift.append(str);
});
}
});
-
\ No newline at end of file
+
diff --git a/app/views/reports/payment_method/index.html.erb b/app/views/reports/payment_method/index.html.erb
index 8dd47a94..ed0ffec3 100755
--- a/app/views/reports/payment_method/index.html.erb
+++ b/app/views/reports/payment_method/index.html.erb
@@ -57,37 +57,25 @@
<%= t("views.right_panel.detail.giftvoucher_sales") %> |
- <% if @print_settings.precision.to_i > 0
- precision = @print_settings.precision
- else
- precision = 0
- end
- #check delimiter
- if @print_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
- %>
<% unless @sale_data.empty? %>
<% @sale_data.each do |sale| %>
- | <%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
-
- <%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+
+ <%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<% end %>
@@ -135,11 +123,11 @@
<%= payment.payment_method rescue '-' %> |
<%= payment.sale.customer.name rescue '-' %> |
<% if payment.payment_method === 'cash' %>
- <%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%else%>
- <%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%end%>
- <%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
@@ -147,7 +135,7 @@
<%if total>0%>
| Total |
- <%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%=number_format(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%end%>
diff --git a/app/views/reports/payment_method/index.xls.erb b/app/views/reports/payment_method/index.xls.erb
index 723a9ffd..a6fcf35d 100755
--- a/app/views/reports/payment_method/index.xls.erb
+++ b/app/views/reports/payment_method/index.xls.erb
@@ -8,9 +8,9 @@
-
+
- |
+ |
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
@@ -18,9 +18,9 @@
|
<% if @shift_from %>
- <% if @shift_data.employee %>
+ <% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
- <% end %>
+ <% end %>
|
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
|
@@ -44,40 +44,28 @@
<%= t("views.right_panel.detail.giftvoucher_sales") %> |
- <% if @print_settings.precision.to_i > 0
- precision = @print_settings.precision
- else
- precision = 0
- end
- #check delimiter
- if @print_settings.delimiter
- delimiter = ","
- else
- delimiter = ""
- end
- %>
<% unless @sale_data.empty? %>
<% @sale_data.each do |sale| %>
- | <%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
-
- <%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
- <%= number_with_precision(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+
+ <%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<% end %>
-
+
<% end %>
@@ -92,7 +80,7 @@
All Payment Details |
<%end%>
-
+
| <%= t("views.right_panel.detail.shift_name") %> |
<%= t("views.right_panel.detail.receipt_no") %> |
@@ -109,9 +97,9 @@
<% if payment.payment_method === 'cash'
total += payment.payment_amount - payment.change_amount
else
- total += payment.payment_amount
- end%>
-
+ total += payment.payment_amount
+ end%>
+
<% if @shift_from.nil? && @shift_to.nil? %>
| <%= payment.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%> |
<% else %>
@@ -122,19 +110,19 @@
<%= payment.payment_method rescue '-' %> |
<%= payment.sale.customer.name rescue '-' %> |
<% if payment.payment_method === 'cash' %>
- <%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%else%>
- <%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%= number_format(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%end%>
- <%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
-
+ <%= number_format(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+
-
+
<% end %>
<%if total>0%>
| Total |
- <%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
+ <%=number_format(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> |
<%end%>
@@ -142,4 +130,4 @@