dashboard hourly sale and license code clean

This commit is contained in:
Yan
2017-12-12 17:41:35 +06:30
parent e55948a7b2
commit bbf30ed26f
3 changed files with 10 additions and 27 deletions

View File

@@ -18,39 +18,21 @@ class License
if (server != "") if (server != "")
self.class.base_uri server self.class.base_uri server
end end
# @secret = ENV["aes_key"]
# @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } }
end end
# For Cloud
def detail_with_local_cache(lookup) def detail_with_local_cache(lookup)
aes = MyAesCrypt.new aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_to_file(lookup) aes_key, aes_iv = aes.export_to_file(lookup)
# flag = ENV["AES_IV"]
# # Check Exists IV
# if flag == "<%= ENV['AES_IV'] %>"
# # Export for Key
# aes = MyAesCrypt.new
# aes_key, aes_iv = aes.export_key(lookup)
# else
# aes_key = ENV["AES_KEY"]
# aes_iv = ENV["AES_IV"]
# end
##Check from local redis - if available load local otherwise get from remote ##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"
# No Needs for current
# @secret = key
cache_license = nil cache_license = nil
##Get redis connection from connection pool ##Get redis connection from connection pool
redis = Redis.new redis = Redis.new
cache_license = redis.get(cache_key) cache_license = redis.get(cache_key)
# Redis.current do |conn|
# cache_license = conn.get(cache_key)
# end
Rails.logger.info "Cache key - " + cache_key.to_s Rails.logger.info "Cache key - " + cache_key.to_s
if cache_license.nil? if cache_license.nil?
@@ -85,7 +67,7 @@ class License
end end
end end
# For Local System
def detail_with_local_file() def detail_with_local_file()
has_license = true # verify_license() has_license = true # verify_license()
@@ -118,7 +100,6 @@ class License
def verify_license def verify_license
api_token = read_license_no_decrypt("api_token") api_token = read_license_no_decrypt("api_token")
puts api_token
@params = { query: {lookup_type: "application", api_token: api_token} } @params = { query: {lookup_type: "application", api_token: api_token} }
response = self.class.get("/verify", @params) response = self.class.get("/verify", @params)
@varified = response.parsed_response @varified = response.parsed_response

View File

@@ -979,7 +979,8 @@ end
def self.hourly_sales(today) def self.hourly_sales(today)
query= Sale.select("grand_total") query= Sale.select("grand_total")
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.group("date_format(receipt_date, '%I %p')") .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
.order('receipt_date')
end end
def self.employee_sales(today) def self.employee_sales(today)

View File

@@ -390,6 +390,7 @@
$(this).off("click"); $(this).off("click");
var sale_id = $('#sale_id').text(); var sale_id = $('#sale_id').text();
var item_row = $('.is_card'); var item_row = $('.is_card');
if (item_row.length < 1) { if (item_row.length < 1) {
calculate_member_discount(sale_id); calculate_member_discount(sale_id);
} }