update number_formattable
This commit is contained in:
@@ -2,37 +2,43 @@ module NumberFormattable
|
|||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def precision
|
def precision
|
||||||
@precision ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == '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?
|
if @precision.nil?
|
||||||
@print_settings ||= PrintSetting.get_precision_delimiter
|
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||||
if @print_settings
|
if @print_settings
|
||||||
@precision = OpenStruct.new(value: @print_settings.precision.to_i)
|
@precision = @print_settings.precision.to_i
|
||||||
else
|
else
|
||||||
@precision = OpenStruct.new(value: 2)
|
@precision = 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@precison_value ||= @precision.value.to_i
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delimiter
|
def delimiter
|
||||||
@delimiter ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == '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?
|
if @delimiter.nil?
|
||||||
@print_settings ||= PrintSetting.get_precision_delimiter
|
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||||
if @print_settings && @print_settings.delimiter
|
if @print_settings && @print_settings.delimiter
|
||||||
@delimiter = OpenStruct.new(value: ",")
|
@delimiter = ","
|
||||||
else
|
else
|
||||||
@delimiter = OpenStruct.new(value: "")
|
@delimiter = ","
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@delimiter_value ||= @delimiter.value.to_s.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def strip_insignificant_zeros
|
def strip_insignificant_zeros
|
||||||
@strip_insignificant_zeros ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}
|
return @strip_insignificant_zeros if defined? @strip_insignificant_zeros
|
||||||
if @strip_insignificant_zeros.nil?
|
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||||
@strip_insignificant_zeros = OpenStruct.new(value: false)
|
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
|
||||||
@strip_insignificant_zeros_value ||= ['1', 't', 'true', 'on', 'y', 'yes'].include? @strip_insignificant_zeros.value.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def number_format(number, options = {})
|
def number_format(number, options = {})
|
||||||
|
|||||||
@@ -2,21 +2,20 @@ class Origami::DashboardController < BaseOrigamiController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
|
|
||||||
today = DateTime.now.strftime('%Y-%m-%d')
|
|
||||||
|
|
||||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||||
|
|
||||||
@sale_data = Array.new
|
@sale_data = Array.new
|
||||||
@total_payment_methods = Sale.total_payment_methods(current_user)
|
@total_payment_methods = Sale.total_payment_methods(current_user)
|
||||||
|
|
||||||
if !@total_payment_methods.nil?
|
if !@total_payment_methods.nil?
|
||||||
@total_payment_methods.each do |payment|
|
@total_payment_methods.each do |payment|
|
||||||
pay = Sale.payment_sale(payment.payment_method, current_user)
|
pay = Sale.payment_sale(payment.payment_method, current_user)
|
||||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@sale_data = nil
|
@sale_data = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@summ_sale = Sale.summary_sale_receipt(current_user)
|
@summ_sale = Sale.summary_sale_receipt(current_user)
|
||||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(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_other_customer = Sale.total_other_customer(today,current_user)
|
||||||
@@ -25,13 +24,13 @@ class Origami::DashboardController < BaseOrigamiController
|
|||||||
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
||||||
@account_data = Array.new
|
@account_data = Array.new
|
||||||
if !@total_accounts.nil?
|
if !@total_accounts.nil?
|
||||||
@total_accounts.each do |account|
|
@total_accounts.each do |account|
|
||||||
acc = Sale.account_data(account.account_id, current_user)
|
acc = Sale.account_data(account.account_id, current_user)
|
||||||
if !acc.nil?
|
if !acc.nil?
|
||||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
end
|
||||||
|
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
||||||
else
|
else
|
||||||
@account_data = nil
|
@account_data = nil
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user